1 #include <msp/gl/extensions/arb_enhanced_layouts.h>
2 #include <msp/gl/extensions/arb_explicit_attrib_location.h>
3 #include <msp/gl/extensions/arb_explicit_uniform_location.h>
4 #include <msp/gl/extensions/arb_gpu_shader5.h>
5 #include <msp/gl/extensions/arb_separate_shader_objects.h>
6 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
7 #include <msp/gl/extensions/arb_vertex_shader.h>
8 #include <msp/gl/extensions/ext_framebuffer_multisample.h>
9 #include <msp/gl/extensions/ext_framebuffer_object.h>
10 #include <msp/gl/extensions/ext_gpu_shader4.h>
11 #include <msp/gl/extensions/ext_texture_array.h>
12 #include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
13 #include <msp/gl/extensions/msp_clipping.h>
14 #include <msp/gl/extensions/nv_fbo_color_attachments.h>
16 #include "device_backend.h"
24 OpenGLDevice::OpenGLDevice(Graphics::Window &wnd, const Graphics::GLOptions &opts):
28 void OpenGLDevice::fill_info()
30 DeviceInfo &info = static_cast<Device *>(this)->info;
32 if(const char *gl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_VERSION)))
34 string gl_ver = gl_ver_ptr;
35 if(!gl_ver.compare(0, 10, "OpenGL ES "))
38 Version ver(gl_ver.substr(0, gl_ver.find(' ')));
40 if(const char *force_ver_ptr = getenv("MSPGL_FORCE_VERSION"))
42 Version force_ver(force_ver_ptr);
47 info.api_version = ver;
50 DeviceLimits &lim = info.limits;
51 glGetIntegerv(GL_MAX_CLIP_PLANES, reinterpret_cast<int *>(&lim.max_clip_planes));
54 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast<int *>(&lim.max_vertex_attributes));
55 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast<int *>(&lim.max_texture_bindings));
57 if(EXT_framebuffer_object)
58 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast<int *>(&lim.max_color_attachments));
59 if(EXT_framebuffer_multisample)
60 glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast<int *>(&lim.max_samples));
61 if(ARB_uniform_buffer_object)
63 glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast<int *>(&lim.max_uniform_bindings));
64 glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<int *>(&lim.uniform_buffer_alignment));
66 if(EXT_texture_filter_anisotropic)
67 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &lim.max_anisotropy);
69 SL::Features &feat = info.glsl_features;
70 feat.target_api = get_backend_api();
71 feat.glsl_version = get_glsl_version();
72 feat.arb_enhanced_layouts = ARB_enhanced_layouts;
73 feat.arb_explicit_attrib_location = ARB_explicit_attrib_location;
74 feat.arb_explicit_uniform_location = ARB_explicit_uniform_location;
75 feat.arb_gpu_shader5 = ARB_gpu_shader5;
76 feat.arb_separate_shader_objects = ARB_separate_shader_objects;
77 feat.arb_uniform_buffer_object = ARB_uniform_buffer_object;
78 feat.ext_gpu_shader4 = EXT_gpu_shader4;
79 feat.ext_texture_array = EXT_texture_array;
80 feat.uniform_binding_range = lim.max_uniform_bindings;
81 feat.texture_binding_range = lim.max_texture_bindings;