From: Mikko Rasa Date: Sat, 30 Oct 2021 20:29:48 +0000 (+0300) Subject: Make the Limits struct more robust X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0a359a7508a0117b055b72bcb7dc42ddcb2ed5f9;p=libs%2Fgl.git Make the Limits struct more robust --- diff --git a/source/backends/opengl/deviceinfo_backend.cpp b/source/backends/opengl/deviceinfo_backend.cpp index 7e1f3f48..30eeb032 100644 --- a/source/backends/opengl/deviceinfo_backend.cpp +++ b/source/backends/opengl/deviceinfo_backend.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -18,13 +19,21 @@ namespace GL { Limits::Limits() { - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast(&max_vertex_attributes)); - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast(&max_texture_bindings)); - glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast(&max_uniform_bindings)); glGetIntegerv(GL_MAX_CLIP_PLANES, reinterpret_cast(&max_clip_planes)); - glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast(&max_samples)); - glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast(&uniform_buffer_alignment)); - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast(&max_color_attachments)); + if(ARB_vertex_shader) + { + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, reinterpret_cast(&max_vertex_attributes)); + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, reinterpret_cast(&max_texture_bindings)); + } + if(EXT_framebuffer_object) + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, reinterpret_cast(&max_color_attachments)); + if(EXT_framebuffer_multisample) + glGetIntegerv(GL_MAX_SAMPLES, reinterpret_cast(&max_samples)); + if(ARB_uniform_buffer_object) + { + glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, reinterpret_cast(&max_uniform_bindings)); + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast(&uniform_buffer_alignment)); + } } diff --git a/source/core/deviceinfo.h b/source/core/deviceinfo.h index e121a8ca..6ac75ca1 100644 --- a/source/core/deviceinfo.h +++ b/source/core/deviceinfo.h @@ -11,13 +11,13 @@ Contains information about various limits imposed by the graphics device. */ struct Limits { - unsigned max_vertex_attributes; - unsigned max_texture_bindings; - unsigned max_uniform_bindings; - unsigned max_clip_planes; - unsigned max_samples; - unsigned uniform_buffer_alignment; - unsigned max_color_attachments; + unsigned max_clip_planes = 6; + unsigned max_vertex_attributes = 16; + unsigned max_texture_bindings = 16; + unsigned max_color_attachments = 8; + unsigned max_samples = 4; + unsigned max_uniform_bindings = 24; + unsigned uniform_buffer_alignment = 256; Limits(); };