]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/features.cpp
Convert Lighting to use shared actions
[libs/gl.git] / source / glsl / features.cpp
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/ext_gpu_shader4.h>
8 #include <msp/gl/extensions/ext_texture_array.h>
9 #include <msp/gl/misc.h>
10 #include "features.h"
11
12 namespace Msp {
13 namespace GL {
14 namespace SL {
15
16 Features::Features():
17         gl_api(OPENGL),
18         arb_enhanced_layouts(false),
19         arb_explicit_attrib_location(false),
20         arb_explicit_uniform_location(false),
21         arb_gpu_shader5(false),
22         arb_separate_shader_objects(false),
23         arb_uniform_buffer_object(false),
24         ext_gpu_shader4(false),
25         ext_texture_array(false),
26         constant_id_range(0x80000000U),
27         uniform_binding_range(84),
28         texture_binding_range(96)
29 { }
30
31 Features Features::from_context()
32 {
33         Features features;
34         features.gl_api = get_gl_api();
35         features.glsl_version = get_glsl_version();
36         features.arb_enhanced_layouts = ARB_enhanced_layouts;
37         features.arb_explicit_attrib_location = ARB_explicit_attrib_location;
38         features.arb_explicit_uniform_location = ARB_explicit_uniform_location;
39         features.arb_gpu_shader5 = ARB_gpu_shader5;
40         features.arb_separate_shader_objects = ARB_separate_shader_objects;
41         features.arb_uniform_buffer_object = ARB_uniform_buffer_object;
42         features.ext_gpu_shader4 = EXT_gpu_shader4;
43         features.ext_texture_array = EXT_texture_array;
44         features.uniform_binding_range = get_i(GL_MAX_UNIFORM_BUFFER_BINDINGS);
45         features.texture_binding_range = get_i(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
46         return features;
47 }
48
49 Features Features::from_version(const Version &ver)
50 {
51         Features features;
52         features.gl_api = OPENGL;
53         features.glsl_version = ver;
54         features.arb_enhanced_layouts = (ver>=Version(4, 40));
55         features.arb_explicit_attrib_location = (ver>=Version(1, 30));
56         features.arb_explicit_uniform_location = (ver>=Version(4, 30));
57         features.arb_gpu_shader5 = (ver>=Version(4, 0));
58         features.arb_separate_shader_objects = (ver>=Version(4, 10));
59         features.arb_uniform_buffer_object = (ver>=Version(1, 50));
60         features.ext_gpu_shader4 = (ver>=Version(1, 20));
61         features.ext_texture_array = (ver>=Version(1, 30));
62         features.uniform_binding_range = (ver>=Version(4, 30) ? 84 : ver>=Version(4, 0) ? 60 :
63                 ver>=Version(3, 30) ? 36 : 24);
64         features.texture_binding_range = (ver>=Version(4, 30) ? 96 : ver>=Version(4, 0) ? 80 :
65                 ver>=Version(1, 50) ? 48 : ver>=Version(1, 40) ? 32 : 16);
66         return features;
67 }
68
69 Features Features::latest()
70 {
71         return from_version(Version(4, 60));
72 }
73
74 } // namespace SL
75 } // namespace GL
76 } // namespace Msp