X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Fdevice_backend.cpp;h=0fcbe07212ccb93783af6e473a7177783d9b98b2;hb=HEAD;hp=5429c0c1ced0b452e6b49625a534ff9204e0bb5b;hpb=f0414f06fc2463e9765c9492dce60e0468dceb3c;p=libs%2Fgl.git diff --git a/source/backends/opengl/device_backend.cpp b/source/backends/opengl/device_backend.cpp index 5429c0c1..0fcbe072 100644 --- a/source/backends/opengl/device_backend.cpp +++ b/source/backends/opengl/device_backend.cpp @@ -1,4 +1,23 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "device.h" #include "device_backend.h" +#include "gl.h" + +using namespace std; namespace Msp { namespace GL { @@ -7,5 +26,76 @@ OpenGLDevice::OpenGLDevice(Graphics::Window &wnd, const Graphics::GLOptions &opt context(wnd, opts) { } +Graphics::GLOptions OpenGLDevice::create_default_options() +{ + Graphics::GLOptions opts; + opts.gl_version_major = Graphics::GLOptions::LATEST_VERSION; + opts.core_profile = true; + return opts; +} + +void OpenGLDevice::fill_info() +{ + DeviceInfo &info = static_cast(this)->info; + + if(const char *gl_ver_ptr = reinterpret_cast(glGetString(GL_VERSION))) + { + string gl_ver = gl_ver_ptr; + if(!gl_ver.compare(0, 10, "OpenGL ES ")) + gl_ver.erase(0, 10); + + Version ver(gl_ver.substr(0, gl_ver.find(' '))); + + if(const char *force_ver_ptr = getenv("MSPGL_FORCE_VERSION")) + { + Version force_ver(force_ver_ptr); + if(force_ver(&lim.max_clip_planes)); + if(ARB_vertex_shader) + { + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast(&lim.max_vertex_attributes)); + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast(&lim.max_texture_bindings)); + } + if(ARB_shader_image_load_store) + glGetIntegerv(GL_MAX_IMAGE_UNITS, reinterpret_cast(&lim.max_storage_texture_bindings)); + if(EXT_framebuffer_object) + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast(&lim.max_color_attachments)); + if(EXT_framebuffer_multisample) + glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast(&lim.max_samples)); + if(ARB_uniform_buffer_object) + { + glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast(&lim.max_uniform_bindings)); + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast(&lim.uniform_buffer_alignment)); + } + if(EXT_texture_filter_anisotropic) + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &lim.max_anisotropy); + + SL::Features &feat = info.glsl_features; + feat.target_api = get_backend_api(); + feat.glsl_version = get_glsl_version(); + feat.arb_enhanced_layouts = ARB_enhanced_layouts; + feat.arb_explicit_attrib_location = ARB_explicit_attrib_location; + feat.arb_explicit_uniform_location = ARB_explicit_uniform_location; + feat.arb_gpu_shader5 = ARB_gpu_shader5; + feat.arb_separate_shader_objects = ARB_separate_shader_objects; + feat.arb_uniform_buffer_object = ARB_uniform_buffer_object; + feat.ext_gpu_shader4 = EXT_gpu_shader4; + feat.ext_texture_array = EXT_texture_array; + feat.uniform_binding_range = lim.max_uniform_bindings; + feat.texture_binding_range = lim.max_texture_bindings; + feat.storage_texture_binding_range = lim.max_storage_texture_bindings; + + state.bound_tex_targets.resize(lim.max_texture_bindings); + state.bound_storage_textures.resize(lim.max_storage_texture_bindings); + state.bound_uniform_blocks.resize(lim.max_uniform_bindings); +} + } // namespace GL } // namespace Msp