]> git.tdb.fi Git - libs/gl.git/blob - source/arb_vertex_shader.cpp
Make it possible to customize texture sampling in standard shaders
[libs/gl.git] / source / arb_vertex_shader.cpp
1 #include "arb_vertex_shader.h"
2
3 namespace Msp {
4 namespace GL {
5
6 PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = 0;
7 PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = 0;
8 PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = 0;
9 PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib = 0;
10 PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation = 0;
11 PFNGLGETVERTEXATTRIBPOINTERVPROC glGetVertexAttribPointerv = 0;
12 PFNGLGETVERTEXATTRIBDVPROC glGetVertexAttribdv = 0;
13 PFNGLGETVERTEXATTRIBFVPROC glGetVertexAttribfv = 0;
14 PFNGLGETVERTEXATTRIBIVPROC glGetVertexAttribiv = 0;
15 PFNGLVERTEXATTRIB1DPROC glVertexAttrib1d = 0;
16 PFNGLVERTEXATTRIB1DVPROC glVertexAttrib1dv = 0;
17 PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f = 0;
18 PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv = 0;
19 PFNGLVERTEXATTRIB1SPROC glVertexAttrib1s = 0;
20 PFNGLVERTEXATTRIB1SVPROC glVertexAttrib1sv = 0;
21 PFNGLVERTEXATTRIB2DPROC glVertexAttrib2d = 0;
22 PFNGLVERTEXATTRIB2DVPROC glVertexAttrib2dv = 0;
23 PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f = 0;
24 PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv = 0;
25 PFNGLVERTEXATTRIB2SPROC glVertexAttrib2s = 0;
26 PFNGLVERTEXATTRIB2SVPROC glVertexAttrib2sv = 0;
27 PFNGLVERTEXATTRIB3DPROC glVertexAttrib3d = 0;
28 PFNGLVERTEXATTRIB3DVPROC glVertexAttrib3dv = 0;
29 PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f = 0;
30 PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv = 0;
31 PFNGLVERTEXATTRIB3SPROC glVertexAttrib3s = 0;
32 PFNGLVERTEXATTRIB3SVPROC glVertexAttrib3sv = 0;
33 PFNGLVERTEXATTRIB4NBVPROC glVertexAttrib4Nbv = 0;
34 PFNGLVERTEXATTRIB4NIVPROC glVertexAttrib4Niv = 0;
35 PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4Nsv = 0;
36 PFNGLVERTEXATTRIB4NUBPROC glVertexAttrib4Nub = 0;
37 PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4Nubv = 0;
38 PFNGLVERTEXATTRIB4NUIVPROC glVertexAttrib4Nuiv = 0;
39 PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4Nusv = 0;
40 PFNGLVERTEXATTRIB4BVPROC glVertexAttrib4bv = 0;
41 PFNGLVERTEXATTRIB4DPROC glVertexAttrib4d = 0;
42 PFNGLVERTEXATTRIB4DVPROC glVertexAttrib4dv = 0;
43 PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = 0;
44 PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv = 0;
45 PFNGLVERTEXATTRIB4IVPROC glVertexAttrib4iv = 0;
46 PFNGLVERTEXATTRIB4SPROC glVertexAttrib4s = 0;
47 PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv = 0;
48 PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv = 0;
49 PFNGLVERTEXATTRIB4UIVPROC glVertexAttrib4uiv = 0;
50 PFNGLVERTEXATTRIB4USVPROC glVertexAttrib4usv = 0;
51 PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = 0;
52
53 Extension::SupportLevel init_arb_vertex_shader()
54 {
55         if(is_version_at_least(2, 0))
56         {
57                 glBindAttribLocation = reinterpret_cast<PFNGLBINDATTRIBLOCATIONPROC>(get_proc_address("glBindAttribLocation"));
58                 glDisableVertexAttribArray = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glDisableVertexAttribArray"));
59                 glEnableVertexAttribArray = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glEnableVertexAttribArray"));
60                 glGetActiveAttrib = reinterpret_cast<PFNGLGETACTIVEATTRIBPROC>(get_proc_address("glGetActiveAttrib"));
61                 glGetAttribLocation = reinterpret_cast<PFNGLGETATTRIBLOCATIONPROC>(get_proc_address("glGetAttribLocation"));
62                 glGetVertexAttribPointerv = reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVPROC>(get_proc_address("glGetVertexAttribPointerv"));
63                 glGetVertexAttribdv = reinterpret_cast<PFNGLGETVERTEXATTRIBDVPROC>(get_proc_address("glGetVertexAttribdv"));
64                 glGetVertexAttribfv = reinterpret_cast<PFNGLGETVERTEXATTRIBFVPROC>(get_proc_address("glGetVertexAttribfv"));
65                 glGetVertexAttribiv = reinterpret_cast<PFNGLGETVERTEXATTRIBIVPROC>(get_proc_address("glGetVertexAttribiv"));
66                 glVertexAttrib1d = reinterpret_cast<PFNGLVERTEXATTRIB1DPROC>(get_proc_address("glVertexAttrib1d"));
67                 glVertexAttrib1dv = reinterpret_cast<PFNGLVERTEXATTRIB1DVPROC>(get_proc_address("glVertexAttrib1dv"));
68                 glVertexAttrib1f = reinterpret_cast<PFNGLVERTEXATTRIB1FPROC>(get_proc_address("glVertexAttrib1f"));
69                 glVertexAttrib1fv = reinterpret_cast<PFNGLVERTEXATTRIB1FVPROC>(get_proc_address("glVertexAttrib1fv"));
70                 glVertexAttrib1s = reinterpret_cast<PFNGLVERTEXATTRIB1SPROC>(get_proc_address("glVertexAttrib1s"));
71                 glVertexAttrib1sv = reinterpret_cast<PFNGLVERTEXATTRIB1SVPROC>(get_proc_address("glVertexAttrib1sv"));
72                 glVertexAttrib2d = reinterpret_cast<PFNGLVERTEXATTRIB2DPROC>(get_proc_address("glVertexAttrib2d"));
73                 glVertexAttrib2dv = reinterpret_cast<PFNGLVERTEXATTRIB2DVPROC>(get_proc_address("glVertexAttrib2dv"));
74                 glVertexAttrib2f = reinterpret_cast<PFNGLVERTEXATTRIB2FPROC>(get_proc_address("glVertexAttrib2f"));
75                 glVertexAttrib2fv = reinterpret_cast<PFNGLVERTEXATTRIB2FVPROC>(get_proc_address("glVertexAttrib2fv"));
76                 glVertexAttrib2s = reinterpret_cast<PFNGLVERTEXATTRIB2SPROC>(get_proc_address("glVertexAttrib2s"));
77                 glVertexAttrib2sv = reinterpret_cast<PFNGLVERTEXATTRIB2SVPROC>(get_proc_address("glVertexAttrib2sv"));
78                 glVertexAttrib3d = reinterpret_cast<PFNGLVERTEXATTRIB3DPROC>(get_proc_address("glVertexAttrib3d"));
79                 glVertexAttrib3dv = reinterpret_cast<PFNGLVERTEXATTRIB3DVPROC>(get_proc_address("glVertexAttrib3dv"));
80                 glVertexAttrib3f = reinterpret_cast<PFNGLVERTEXATTRIB3FPROC>(get_proc_address("glVertexAttrib3f"));
81                 glVertexAttrib3fv = reinterpret_cast<PFNGLVERTEXATTRIB3FVPROC>(get_proc_address("glVertexAttrib3fv"));
82                 glVertexAttrib3s = reinterpret_cast<PFNGLVERTEXATTRIB3SPROC>(get_proc_address("glVertexAttrib3s"));
83                 glVertexAttrib3sv = reinterpret_cast<PFNGLVERTEXATTRIB3SVPROC>(get_proc_address("glVertexAttrib3sv"));
84                 glVertexAttrib4Nbv = reinterpret_cast<PFNGLVERTEXATTRIB4NBVPROC>(get_proc_address("glVertexAttrib4Nbv"));
85                 glVertexAttrib4Niv = reinterpret_cast<PFNGLVERTEXATTRIB4NIVPROC>(get_proc_address("glVertexAttrib4Niv"));
86                 glVertexAttrib4Nsv = reinterpret_cast<PFNGLVERTEXATTRIB4NSVPROC>(get_proc_address("glVertexAttrib4Nsv"));
87                 glVertexAttrib4Nub = reinterpret_cast<PFNGLVERTEXATTRIB4NUBPROC>(get_proc_address("glVertexAttrib4Nub"));
88                 glVertexAttrib4Nubv = reinterpret_cast<PFNGLVERTEXATTRIB4NUBVPROC>(get_proc_address("glVertexAttrib4Nubv"));
89                 glVertexAttrib4Nuiv = reinterpret_cast<PFNGLVERTEXATTRIB4NUIVPROC>(get_proc_address("glVertexAttrib4Nuiv"));
90                 glVertexAttrib4Nusv = reinterpret_cast<PFNGLVERTEXATTRIB4NUSVPROC>(get_proc_address("glVertexAttrib4Nusv"));
91                 glVertexAttrib4bv = reinterpret_cast<PFNGLVERTEXATTRIB4BVPROC>(get_proc_address("glVertexAttrib4bv"));
92                 glVertexAttrib4d = reinterpret_cast<PFNGLVERTEXATTRIB4DPROC>(get_proc_address("glVertexAttrib4d"));
93                 glVertexAttrib4dv = reinterpret_cast<PFNGLVERTEXATTRIB4DVPROC>(get_proc_address("glVertexAttrib4dv"));
94                 glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(get_proc_address("glVertexAttrib4f"));
95                 glVertexAttrib4fv = reinterpret_cast<PFNGLVERTEXATTRIB4FVPROC>(get_proc_address("glVertexAttrib4fv"));
96                 glVertexAttrib4iv = reinterpret_cast<PFNGLVERTEXATTRIB4IVPROC>(get_proc_address("glVertexAttrib4iv"));
97                 glVertexAttrib4s = reinterpret_cast<PFNGLVERTEXATTRIB4SPROC>(get_proc_address("glVertexAttrib4s"));
98                 glVertexAttrib4sv = reinterpret_cast<PFNGLVERTEXATTRIB4SVPROC>(get_proc_address("glVertexAttrib4sv"));
99                 glVertexAttrib4ubv = reinterpret_cast<PFNGLVERTEXATTRIB4UBVPROC>(get_proc_address("glVertexAttrib4ubv"));
100                 glVertexAttrib4uiv = reinterpret_cast<PFNGLVERTEXATTRIB4UIVPROC>(get_proc_address("glVertexAttrib4uiv"));
101                 glVertexAttrib4usv = reinterpret_cast<PFNGLVERTEXATTRIB4USVPROC>(get_proc_address("glVertexAttrib4usv"));
102                 glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(get_proc_address("glVertexAttribPointer"));
103                 return Extension::CORE;
104         }
105         if(is_supported("GL_ARB_vertex_shader"))
106         {
107                 glBindAttribLocation = reinterpret_cast<PFNGLBINDATTRIBLOCATIONPROC>(get_proc_address("glBindAttribLocationARB"));
108                 glDisableVertexAttribArray = reinterpret_cast<PFNGLDISABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glDisableVertexAttribArrayARB"));
109                 glEnableVertexAttribArray = reinterpret_cast<PFNGLENABLEVERTEXATTRIBARRAYPROC>(get_proc_address("glEnableVertexAttribArrayARB"));
110                 glGetActiveAttrib = reinterpret_cast<PFNGLGETACTIVEATTRIBPROC>(get_proc_address("glGetActiveAttribARB"));
111                 glGetAttribLocation = reinterpret_cast<PFNGLGETATTRIBLOCATIONPROC>(get_proc_address("glGetAttribLocationARB"));
112                 glGetVertexAttribPointerv = reinterpret_cast<PFNGLGETVERTEXATTRIBPOINTERVPROC>(get_proc_address("glGetVertexAttribPointervARB"));
113                 glGetVertexAttribdv = reinterpret_cast<PFNGLGETVERTEXATTRIBDVPROC>(get_proc_address("glGetVertexAttribdvARB"));
114                 glGetVertexAttribfv = reinterpret_cast<PFNGLGETVERTEXATTRIBFVPROC>(get_proc_address("glGetVertexAttribfvARB"));
115                 glGetVertexAttribiv = reinterpret_cast<PFNGLGETVERTEXATTRIBIVPROC>(get_proc_address("glGetVertexAttribivARB"));
116                 glVertexAttrib1d = reinterpret_cast<PFNGLVERTEXATTRIB1DPROC>(get_proc_address("glVertexAttrib1dARB"));
117                 glVertexAttrib1dv = reinterpret_cast<PFNGLVERTEXATTRIB1DVPROC>(get_proc_address("glVertexAttrib1dvARB"));
118                 glVertexAttrib1f = reinterpret_cast<PFNGLVERTEXATTRIB1FPROC>(get_proc_address("glVertexAttrib1fARB"));
119                 glVertexAttrib1fv = reinterpret_cast<PFNGLVERTEXATTRIB1FVPROC>(get_proc_address("glVertexAttrib1fvARB"));
120                 glVertexAttrib1s = reinterpret_cast<PFNGLVERTEXATTRIB1SPROC>(get_proc_address("glVertexAttrib1sARB"));
121                 glVertexAttrib1sv = reinterpret_cast<PFNGLVERTEXATTRIB1SVPROC>(get_proc_address("glVertexAttrib1svARB"));
122                 glVertexAttrib2d = reinterpret_cast<PFNGLVERTEXATTRIB2DPROC>(get_proc_address("glVertexAttrib2dARB"));
123                 glVertexAttrib2dv = reinterpret_cast<PFNGLVERTEXATTRIB2DVPROC>(get_proc_address("glVertexAttrib2dvARB"));
124                 glVertexAttrib2f = reinterpret_cast<PFNGLVERTEXATTRIB2FPROC>(get_proc_address("glVertexAttrib2fARB"));
125                 glVertexAttrib2fv = reinterpret_cast<PFNGLVERTEXATTRIB2FVPROC>(get_proc_address("glVertexAttrib2fvARB"));
126                 glVertexAttrib2s = reinterpret_cast<PFNGLVERTEXATTRIB2SPROC>(get_proc_address("glVertexAttrib2sARB"));
127                 glVertexAttrib2sv = reinterpret_cast<PFNGLVERTEXATTRIB2SVPROC>(get_proc_address("glVertexAttrib2svARB"));
128                 glVertexAttrib3d = reinterpret_cast<PFNGLVERTEXATTRIB3DPROC>(get_proc_address("glVertexAttrib3dARB"));
129                 glVertexAttrib3dv = reinterpret_cast<PFNGLVERTEXATTRIB3DVPROC>(get_proc_address("glVertexAttrib3dvARB"));
130                 glVertexAttrib3f = reinterpret_cast<PFNGLVERTEXATTRIB3FPROC>(get_proc_address("glVertexAttrib3fARB"));
131                 glVertexAttrib3fv = reinterpret_cast<PFNGLVERTEXATTRIB3FVPROC>(get_proc_address("glVertexAttrib3fvARB"));
132                 glVertexAttrib3s = reinterpret_cast<PFNGLVERTEXATTRIB3SPROC>(get_proc_address("glVertexAttrib3sARB"));
133                 glVertexAttrib3sv = reinterpret_cast<PFNGLVERTEXATTRIB3SVPROC>(get_proc_address("glVertexAttrib3svARB"));
134                 glVertexAttrib4Nbv = reinterpret_cast<PFNGLVERTEXATTRIB4NBVPROC>(get_proc_address("glVertexAttrib4NbvARB"));
135                 glVertexAttrib4Niv = reinterpret_cast<PFNGLVERTEXATTRIB4NIVPROC>(get_proc_address("glVertexAttrib4NivARB"));
136                 glVertexAttrib4Nsv = reinterpret_cast<PFNGLVERTEXATTRIB4NSVPROC>(get_proc_address("glVertexAttrib4NsvARB"));
137                 glVertexAttrib4Nub = reinterpret_cast<PFNGLVERTEXATTRIB4NUBPROC>(get_proc_address("glVertexAttrib4NubARB"));
138                 glVertexAttrib4Nubv = reinterpret_cast<PFNGLVERTEXATTRIB4NUBVPROC>(get_proc_address("glVertexAttrib4NubvARB"));
139                 glVertexAttrib4Nuiv = reinterpret_cast<PFNGLVERTEXATTRIB4NUIVPROC>(get_proc_address("glVertexAttrib4NuivARB"));
140                 glVertexAttrib4Nusv = reinterpret_cast<PFNGLVERTEXATTRIB4NUSVPROC>(get_proc_address("glVertexAttrib4NusvARB"));
141                 glVertexAttrib4bv = reinterpret_cast<PFNGLVERTEXATTRIB4BVPROC>(get_proc_address("glVertexAttrib4bvARB"));
142                 glVertexAttrib4d = reinterpret_cast<PFNGLVERTEXATTRIB4DPROC>(get_proc_address("glVertexAttrib4dARB"));
143                 glVertexAttrib4dv = reinterpret_cast<PFNGLVERTEXATTRIB4DVPROC>(get_proc_address("glVertexAttrib4dvARB"));
144                 glVertexAttrib4f = reinterpret_cast<PFNGLVERTEXATTRIB4FPROC>(get_proc_address("glVertexAttrib4fARB"));
145                 glVertexAttrib4fv = reinterpret_cast<PFNGLVERTEXATTRIB4FVPROC>(get_proc_address("glVertexAttrib4fvARB"));
146                 glVertexAttrib4iv = reinterpret_cast<PFNGLVERTEXATTRIB4IVPROC>(get_proc_address("glVertexAttrib4ivARB"));
147                 glVertexAttrib4s = reinterpret_cast<PFNGLVERTEXATTRIB4SPROC>(get_proc_address("glVertexAttrib4sARB"));
148                 glVertexAttrib4sv = reinterpret_cast<PFNGLVERTEXATTRIB4SVPROC>(get_proc_address("glVertexAttrib4svARB"));
149                 glVertexAttrib4ubv = reinterpret_cast<PFNGLVERTEXATTRIB4UBVPROC>(get_proc_address("glVertexAttrib4ubvARB"));
150                 glVertexAttrib4uiv = reinterpret_cast<PFNGLVERTEXATTRIB4UIVPROC>(get_proc_address("glVertexAttrib4uivARB"));
151                 glVertexAttrib4usv = reinterpret_cast<PFNGLVERTEXATTRIB4USVPROC>(get_proc_address("glVertexAttrib4usvARB"));
152                 glVertexAttribPointer = reinterpret_cast<PFNGLVERTEXATTRIBPOINTERPROC>(get_proc_address("glVertexAttribPointerARB"));
153                 return Extension::EXTENSION;
154         }
155         return Extension::UNSUPPORTED;
156 }
157
158 Extension ARB_vertex_shader("GL_ARB_vertex_shader", init_arb_vertex_shader);
159
160 } // namespace GL
161 } // namespace Msp