author | Ryan C. Gordon <icculus@icculus.org> |
Thu, 07 Jun 2012 04:31:01 -0400 | |
changeset 1110 | 91a6af79b5e4 |
parent 1105 | 57e255c3b243 |
child 1111 | 7530b37979b8 |
permissions | -rw-r--r-- |
243
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
1 |
/** |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
2 |
* MojoShader; generate shader programs from bytecode of compiled |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
3 |
* Direct3D shaders. |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
4 |
* |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
5 |
* Please see the file LICENSE.txt in the source's root directory. |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
6 |
* |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
7 |
* This file written by Ryan C. Gordon. |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
8 |
*/ |
a0825a0d504a
Added comment header to mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
9 |
|
1043
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
10 |
// !!! FIXME: preshaders shouldn't be handled in here at all. This should |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
11 |
// !!! FIXME: be in the Effects API, once that's actually written. |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
12 |
|
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
#include <stdio.h> |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
#include <string.h> |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
#include <stdlib.h> |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
#include <stdarg.h> |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
#include <assert.h> |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
|
609 | 19 |
// !!! FIXME: most of these _MSC_VER should probably be _WINDOWS? |
254 | 20 |
#ifdef _MSC_VER |
21 |
#define WIN32_LEAN_AND_MEAN 1 |
|
22 |
#include <windows.h> // GL headers need this for WINGDIAPI definition. |
|
23 |
#endif |
|
24 |
||
457
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
25 |
#if (defined(__APPLE__) && defined(__MACH__)) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
26 |
#define PLATFORM_MACOSX 1 |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
27 |
#endif |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
28 |
|
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
29 |
#if PLATFORM_MACOSX |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
30 |
#include <Carbon/Carbon.h> |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
31 |
#endif |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
32 |
|
464
eba4cf79437f
Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
463
diff
changeset
|
33 |
#define __MOJOSHADER_INTERNAL__ 1 |
eba4cf79437f
Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
463
diff
changeset
|
34 |
#include "mojoshader_internal.h" |
eba4cf79437f
Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
463
diff
changeset
|
35 |
|
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
36 |
#define GL_GLEXT_LEGACY 1 |
246
897868fdd958
Moved gl*.h into GL directory.
Ryan C. Gordon <icculus@icculus.org>
parents:
245
diff
changeset
|
37 |
#include "GL/gl.h" |
897868fdd958
Moved gl*.h into GL directory.
Ryan C. Gordon <icculus@icculus.org>
parents:
245
diff
changeset
|
38 |
#include "GL/glext.h" |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
|
1073
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
40 |
#ifndef GL_HALF_FLOAT_NV |
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
41 |
#define GL_HALF_FLOAT_NV 0x140B |
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
42 |
#endif |
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
43 |
|
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
44 |
#ifndef GL_HALF_FLOAT_ARB |
6eccf031c7e6
Cleaned up half-float stuff.
Ryan C. Gordon <icculus@icculus.org>
parents:
1072
diff
changeset
|
45 |
#define GL_HALF_FLOAT_ARB 0x140B |
449
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
46 |
#endif |
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
47 |
|
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
48 |
#ifndef GL_HALF_FLOAT_OES |
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
49 |
#define GL_HALF_FLOAT_OES 0x8D61 |
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
50 |
#endif |
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
51 |
|
1056
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
52 |
// this happens to be the same value for ARB1 and GLSL. |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
53 |
#ifndef GL_PROGRAM_POINT_SIZE |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
54 |
#define GL_PROGRAM_POINT_SIZE 0x8642 |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
55 |
#endif |
449
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
56 |
|
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
struct MOJOSHADER_glShader |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
{ |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
const MOJOSHADER_parseData *parseData; |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
60 |
GLuint handle; |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
uint32 refcount; |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
}; |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
|
205
8583f89985df
Cache uniform locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
204
diff
changeset
|
64 |
typedef struct |
8583f89985df
Cache uniform locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
204
diff
changeset
|
65 |
{ |
206
7027d889acdd
Implemented MOJOSHADER_glProgramReady().
Ryan C. Gordon <icculus@icculus.org>
parents:
205
diff
changeset
|
66 |
MOJOSHADER_shaderType shader_type; |
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
67 |
const MOJOSHADER_uniform *uniform; |
798
5dd67cc04cf9
Bunch of small tweaks to make this compile as C++ code without errors/warnings.
Ryan C. Gordon <icculus@icculus.org>
parents:
797
diff
changeset
|
68 |
GLint location; |
205
8583f89985df
Cache uniform locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
204
diff
changeset
|
69 |
} UniformMap; |
8583f89985df
Cache uniform locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
204
diff
changeset
|
70 |
|
213
73935330a973
Cache attribute locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
71 |
typedef struct |
73935330a973
Cache attribute locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
72 |
{ |
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
73 |
const MOJOSHADER_attribute *attribute; |
798
5dd67cc04cf9
Bunch of small tweaks to make this compile as C++ code without errors/warnings.
Ryan C. Gordon <icculus@icculus.org>
parents:
797
diff
changeset
|
74 |
GLint location; |
213
73935330a973
Cache attribute locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
75 |
} AttributeMap; |
73935330a973
Cache attribute locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
76 |
|
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 |
struct MOJOSHADER_glProgram |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 |
{ |
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
79 |
MOJOSHADER_glShader *vertex; |
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
80 |
MOJOSHADER_glShader *fragment; |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
81 |
GLuint handle; |
774
9ac0e5ad0205
Don't push uniforms if they've definitely not changed.
Ryan C. Gordon <icculus@icculus.org>
parents:
773
diff
changeset
|
82 |
uint32 generation; |
205
8583f89985df
Cache uniform locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
204
diff
changeset
|
83 |
uint32 uniform_count; |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
84 |
uint32 texbem_count; |
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
85 |
UniformMap *uniforms; |
213
73935330a973
Cache attribute locations for GLSL programs at link time.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
86 |
uint32 attribute_count; |
226
4a2b3d0b535f
Patched mojoshader_opengl.c to compile, mostly.
Ryan C. Gordon <icculus@icculus.org>
parents:
223
diff
changeset
|
87 |
AttributeMap *attributes; |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
88 |
size_t vs_uniforms_float4_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
89 |
GLfloat *vs_uniforms_float4; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
90 |
size_t vs_uniforms_int4_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
91 |
GLint *vs_uniforms_int4; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
92 |
size_t vs_uniforms_bool_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
93 |
GLint *vs_uniforms_bool; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
94 |
size_t ps_uniforms_float4_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
95 |
GLfloat *ps_uniforms_float4; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
96 |
size_t ps_uniforms_int4_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
97 |
GLint *ps_uniforms_int4; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
98 |
size_t ps_uniforms_bool_count; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
99 |
GLint *ps_uniforms_bool; |
1043
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
100 |
|
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
101 |
size_t vs_preshader_reg_count; |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
102 |
GLfloat *vs_preshader_regs; |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
103 |
size_t ps_preshader_reg_count; |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
104 |
GLfloat *ps_preshader_regs; |
6227066350b4
Preshader input registers are separate from the actual shader constant file!
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
105 |
|
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 |
uint32 refcount; |
1056
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
107 |
|
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
108 |
int uses_pointsize; |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
109 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
110 |
// GLSL uses these...location of uniform arrays. |
797
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
111 |
GLint vs_float4_loc; |
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
112 |
GLint vs_int4_loc; |
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
113 |
GLint vs_bool_loc; |
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
114 |
GLint ps_float4_loc; |
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
115 |
GLint ps_int4_loc; |
58d15db2881e
GLSL Uniform locations are signed ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
791
diff
changeset
|
116 |
GLint ps_bool_loc; |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 |
}; |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 |
|
277
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
119 |
#ifndef WINGDIAPI |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
120 |
#define WINGDIAPI |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
121 |
#endif |
49a6571cac6d
Patched to compile on older (?) GL headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
122 |
|
242
c3c5693ba179
Fixed vertex attribute aliasing in OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
241
diff
changeset
|
123 |
// Entry points in base OpenGL that lack function pointer prototypes... |
276
1d7437469c94
Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents:
262
diff
changeset
|
124 |
typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); |
1d7437469c94
Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents:
262
diff
changeset
|
125 |
typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
126 |
typedef WINGDIAPI GLenum (APIENTRYP PFNGLGETERRORPROC) (void); |
358
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
127 |
typedef WINGDIAPI void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
128 |
typedef WINGDIAPI void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
129 |
|
773
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
130 |
// Max entries for each register file type... |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
131 |
#define MAX_REG_FILE_F 8192 |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
132 |
#define MAX_REG_FILE_I 2047 |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
133 |
#define MAX_REG_FILE_B 2047 |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
134 |
#define MAX_TEXBEMS 3 // ps_1_1 allows 4 texture stages, texbem can't use t0. |
773
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
135 |
|
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
136 |
struct MOJOSHADER_glContext |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
137 |
{ |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
138 |
// Allocators... |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
139 |
MOJOSHADER_malloc malloc_fn; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
140 |
MOJOSHADER_free free_fn; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
141 |
void *malloc_data; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
142 |
|
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
143 |
// The constant register files... |
806 | 144 |
// !!! FIXME: Man, it kills me how much memory this takes... |
145 |
// !!! FIXME: ... make this dynamically allocated on demand. |
|
773
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
146 |
GLfloat vs_reg_file_f[MAX_REG_FILE_F * 4]; |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
147 |
GLint vs_reg_file_i[MAX_REG_FILE_I * 4]; |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
148 |
uint8 vs_reg_file_b[MAX_REG_FILE_B]; |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
149 |
GLfloat ps_reg_file_f[MAX_REG_FILE_F * 4]; |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
150 |
GLint ps_reg_file_i[MAX_REG_FILE_I * 4]; |
3e3638be6e2b
Replaced some constants with #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
772
diff
changeset
|
151 |
uint8 ps_reg_file_b[MAX_REG_FILE_B]; |
284
ea52f9707795
Sampler loading support in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
281
diff
changeset
|
152 |
GLuint sampler_reg_file[16]; |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
153 |
GLfloat texbem_state[MAX_TEXBEMS * 6]; |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
154 |
|
774
9ac0e5ad0205
Don't push uniforms if they've definitely not changed.
Ryan C. Gordon <icculus@icculus.org>
parents:
773
diff
changeset
|
155 |
// This increments every time we change the register files. |
9ac0e5ad0205
Don't push uniforms if they've definitely not changed.
Ryan C. Gordon <icculus@icculus.org>
parents:
773
diff
changeset
|
156 |
uint32 generation; |
9ac0e5ad0205
Don't push uniforms if they've definitely not changed.
Ryan C. Gordon <icculus@icculus.org>
parents:
773
diff
changeset
|
157 |
|
1066
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
158 |
// This keeps track of implicitly linked programs. |
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
159 |
HashTable *linker_cache; |
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
160 |
|
775
2c93dcb14687
Only enable/disable vertex arrays when forced to.
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
161 |
// This tells us which vertex attribute arrays we have enabled. |
798
5dd67cc04cf9
Bunch of small tweaks to make this compile as C++ code without errors/warnings.
Ryan C. Gordon <icculus@icculus.org>
parents:
797
diff
changeset
|
162 |
GLint max_attrs; |
775
2c93dcb14687
Only enable/disable vertex arrays when forced to.
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
163 |
uint8 want_attr[32]; |
2c93dcb14687
Only enable/disable vertex arrays when forced to.
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
164 |
uint8 have_attr[32]; |
2c93dcb14687
Only enable/disable vertex arrays when forced to.
Ryan C. Gordon <icculus@icculus.org>
parents:
774
diff
changeset
|
165 |
|
1056
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
166 |
// rarely used, so we don't touch when we don't have to. |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
167 |
int pointsize_enabled; |
73c697a7e950
Toggle pointsize support as necessary in the OpenGL bindings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
168 |
|
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
169 |
// GL stuff... |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
170 |
int opengl_major; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
171 |
int opengl_minor; |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
172 |
int glsl_major; |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
173 |
int glsl_minor; |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
174 |
MOJOSHADER_glProgram *bound_program; |
262
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
175 |
char profile[16]; |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
176 |
|
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
177 |
// Extensions... |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
178 |
int have_core_opengl; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
179 |
int have_opengl_2; // different entry points than ARB extensions. |
463
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
180 |
int have_GL_ARB_vertex_program; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
181 |
int have_GL_ARB_fragment_program; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
182 |
int have_GL_NV_vertex_program2_option; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
183 |
int have_GL_NV_fragment_program2; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
184 |
int have_GL_NV_vertex_program3; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
185 |
int have_GL_NV_gpu_program4; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
186 |
int have_GL_ARB_shader_objects; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
187 |
int have_GL_ARB_vertex_shader; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
188 |
int have_GL_ARB_fragment_shader; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
189 |
int have_GL_ARB_shading_language_100; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
190 |
int have_GL_NV_half_float; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
191 |
int have_GL_ARB_half_float_vertex; |
6f3a82d7e3d2
Removed bitfields for full ints.
Ryan C. Gordon <icculus@icculus.org>
parents:
460
diff
changeset
|
192 |
int have_GL_OES_vertex_half_float; |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
193 |
|
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
194 |
// Entry points... |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
195 |
PFNGLGETSTRINGPROC glGetString; |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
196 |
PFNGLGETERRORPROC glGetError; |
276
1d7437469c94
Added MOJOSHADER_glMaxUniforms().
Ryan C. Gordon <icculus@icculus.org>
parents:
262
diff
changeset
|
197 |
PFNGLGETINTEGERVPROC glGetIntegerv; |
358
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
198 |
PFNGLENABLEPROC glEnable; |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
199 |
PFNGLDISABLEPROC glDisable; |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
200 |
PFNGLDELETESHADERPROC glDeleteShader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
201 |
PFNGLDELETEPROGRAMPROC glDeleteProgram; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
202 |
PFNGLATTACHSHADERPROC glAttachShader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
203 |
PFNGLCOMPILESHADERPROC glCompileShader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
204 |
PFNGLCREATESHADERPROC glCreateShader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
205 |
PFNGLCREATEPROGRAMPROC glCreateProgram; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
206 |
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
207 |
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
208 |
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
209 |
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
210 |
PFNGLGETSHADERIVPROC glGetShaderiv; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
211 |
PFNGLGETPROGRAMIVPROC glGetProgramiv; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
212 |
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
213 |
PFNGLLINKPROGRAMPROC glLinkProgram; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
214 |
PFNGLSHADERSOURCEPROC glShaderSource; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
215 |
PFNGLUNIFORM1IPROC glUniform1i; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
216 |
PFNGLUNIFORM1IVPROC glUniform1iv; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
217 |
PFNGLUNIFORM4FVPROC glUniform4fv; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
218 |
PFNGLUNIFORM4IVPROC glUniform4iv; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
219 |
PFNGLUSEPROGRAMPROC glUseProgram; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
220 |
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
221 |
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
222 |
PFNGLATTACHOBJECTARBPROC glAttachObjectARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
223 |
PFNGLCOMPILESHADERARBPROC glCompileShaderARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
224 |
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
225 |
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
226 |
PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
227 |
PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
228 |
PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
229 |
PFNGLGETINFOLOGARBPROC glGetInfoLogARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
230 |
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
231 |
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
232 |
PFNGLLINKPROGRAMARBPROC glLinkProgramARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
233 |
PFNGLSHADERSOURCEARBPROC glShaderSourceARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
234 |
PFNGLUNIFORM1IARBPROC glUniform1iARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
235 |
PFNGLUNIFORM1IVARBPROC glUniform1ivARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
236 |
PFNGLUNIFORM4FVARBPROC glUniform4fvARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
237 |
PFNGLUNIFORM4IVARBPROC glUniform4ivARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
238 |
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
239 |
PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB; |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
240 |
PFNGLGETPROGRAMIVARBPROC glGetProgramivARB; |
395
d2307cc5d6e7
Use local parameters, not environment params, in the arb1/nv2 profiles.
Ryan C. Gordon <icculus@icculus.org>
parents:
394
diff
changeset
|
241 |
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB; |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
242 |
PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC glProgramLocalParameterI4ivNV; |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
243 |
PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB; |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
244 |
PFNGLGENPROGRAMSARBPROC glGenProgramsARB; |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
245 |
PFNGLBINDPROGRAMARBPROC glBindProgramARB; |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
246 |
PFNGLPROGRAMSTRINGARBPROC glProgramStringARB; |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
247 |
|
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
248 |
// interface for profile-specific things. |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
249 |
int (*profileMaxUniforms)(MOJOSHADER_shaderType shader_type); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
250 |
int (*profileCompileShader)(const MOJOSHADER_parseData *pd, GLuint *s); |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
251 |
void (*profileDeleteShader)(const GLuint shader); |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
252 |
void (*profileDeleteProgram)(const GLuint program); |
347
f8d9d0ae6ba8
Bunch more work (ARB1 profile, OpenGL glue, and general fixes).
Ryan C. Gordon <icculus@icculus.org>
parents:
340
diff
changeset
|
253 |
GLint (*profileGetAttribLocation)(MOJOSHADER_glProgram *program, int idx); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
254 |
GLint (*profileGetUniformLocation)(MOJOSHADER_glProgram *program, MOJOSHADER_glShader *shader, int idx); |
347
f8d9d0ae6ba8
Bunch more work (ARB1 profile, OpenGL glue, and general fixes).
Ryan C. Gordon <icculus@icculus.org>
parents:
340
diff
changeset
|
255 |
GLint (*profileGetSamplerLocation)(MOJOSHADER_glProgram *, MOJOSHADER_glShader *, int); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
256 |
GLuint (*profileLinkProgram)(MOJOSHADER_glShader *, MOJOSHADER_glShader *); |
765
076f3bd42329
Moved profileInitProgram to profileFinalInitProgram.
Ryan C. Gordon <icculus@icculus.org>
parents:
764
diff
changeset
|
257 |
void (*profileFinalInitProgram)(MOJOSHADER_glProgram *program); |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
258 |
void (*profileUseProgram)(MOJOSHADER_glProgram *program); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
259 |
void (*profilePushConstantArray)(MOJOSHADER_glProgram *, const MOJOSHADER_uniform *, const GLfloat *); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
260 |
void (*profilePushUniforms)(void); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
261 |
void (*profilePushSampler)(GLint loc, GLuint sampler); |
760
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
262 |
int (*profileMustPushConstantArrays)(void); |
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
263 |
int (*profileMustPushSamplers)(void); |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
264 |
}; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
265 |
|
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
266 |
|
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
267 |
static MOJOSHADER_glContext *ctx = NULL; |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
268 |
|
219
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
269 |
// Error state... |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
270 |
static char error_buffer[1024] = { '\0' }; |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
271 |
|
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
272 |
static void set_error(const char *str) |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
273 |
{ |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
274 |
snprintf(error_buffer, sizeof (error_buffer), "%s", str); |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
275 |
} // set_error |
61167fc96790
Added MOJOSHADER_glGetError() function, filled in error state.
Ryan C. Gordon <icculus@icculus.org>
parents:
216
diff
changeset
|
276 |
|
457
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
277 |
#if PLATFORM_MACOSX |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
278 |
static inline int macosx_version_atleast(int x, int y, int z) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
279 |
{ |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
280 |
static int checked = 0; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
281 |
static int combined = 0; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
282 |
|
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
283 |
if (!checked) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
284 |
{ |
807
138d76f766d1
Fixed compiler warnings on 64-bit Mac OS X.
Ryan C. Gordon <icculus@icculus.org>
parents:
806
diff
changeset
|
285 |
SInt32 ver, major, minor, patch; |
457
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
286 |
int convert = 0; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
287 |
|
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
288 |
if (Gestalt(gestaltSystemVersion, &ver) != noErr) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
289 |
ver = 0x1000; // oh well. |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
290 |
else if (ver < 0x1030) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
291 |
convert = 1; // split (ver) into (major),(minor),(patch). |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
292 |
else |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
293 |
{ |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
294 |
// presumably this won't fail. But if it does, we'll just use the |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
295 |
// original version value. This might cut the value--10.12.11 will |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
296 |
// come out to 10.9.9, for example--but it's better than nothing. |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
297 |
if (Gestalt(gestaltSystemVersionMajor, &major) != noErr) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
298 |
convert = 1; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
299 |
else if (Gestalt(gestaltSystemVersionMinor, &minor) != noErr) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
300 |
convert = 1; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
301 |
else if (Gestalt(gestaltSystemVersionBugFix, &patch) != noErr) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
302 |
convert = 1; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
303 |
} // else |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
304 |
|
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
305 |
if (convert) |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
306 |
{ |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
307 |
major = ((ver & 0xFF00) >> 8); |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
308 |
major = (((major / 16) * 10) + (major % 16)); |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
309 |
minor = ((ver & 0xF0) >> 4); |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
310 |
patch = (ver & 0xF); |
533 | 311 |
} // if |
457
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
312 |
|
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
313 |
combined = (major << 16) | (minor << 8) | patch; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
314 |
checked = 1; |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
315 |
} // if |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
316 |
|
460
54c614f0fcb0
Fixed OS X detection code.
Ryan C. Gordon <icculus@icculus.org>
parents:
459
diff
changeset
|
317 |
return (combined >= ((x << 16) | (y << 8) | z)); |
457
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
318 |
} // macosx_version_atleast |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
319 |
#endif |
96552d8041bf
Forbid GLSL on Mac OS X Tiger systems.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
320 |
|
1066
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
321 |
static inline void out_of_memory(void) |
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
322 |
{ |
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
323 |
set_error("out of memory"); |
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
324 |
} // out_of_memory |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 |
|
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 |
static inline void *Malloc(const size_t len) |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 |
{ |
307
42f6a7ba69e2
Fixes for Visual Studio level 4 compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents:
291
diff
changeset
|
328 |
void *retval = ctx->malloc_fn((int) len, ctx->malloc_data); |
220
df5ea69833d5
Fixes to Malloc() and Free() in mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
219
diff
changeset
|
329 |
if (retval == NULL) |
1066
ff14db741834
Added MOJOSHADER_glBindShaders().
Ryan C. Gordon <icculus@icculus.org>
parents:
1063
diff
changeset
|
330 |
out_of_memory(); |
220
df5ea69833d5
Fixes to Malloc() and Free() in mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
219
diff
changeset
|
331 |
return retval; |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 |
} // Malloc |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 |
|
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
334 |
static inline void Free(void *ptr) |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 |
{ |
220
df5ea69833d5
Fixes to Malloc() and Free() in mojoshader_opengl.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
219
diff
changeset
|
336 |
if (ptr != NULL) |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
337 |
ctx->free_fn(ptr, ctx->malloc_data); |
202
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
338 |
} // Free |
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
339 |
|
20bdf2d7036e
Initial add of mojoshader_opengl.c
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
340 |
|
358
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
341 |
static inline void toggle_gl_state(GLenum state, int val) |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
342 |
{ |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
343 |
if (val) |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
344 |
ctx->glEnable(state); |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
345 |
else |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
346 |
ctx->glDisable(state); |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
347 |
} // toggle_gl_state |
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
348 |
|
f63e18cf642f
Fixed MOJOSHADER_glBindProgram() for arb1 profile (thanks, Nicholas!).
Ryan C. Gordon <icculus@icculus.org>
parents:
355
diff
changeset
|
349 |
|
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
350 |
// profile-specific implementations... |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
351 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
352 |
#if SUPPORT_PROFILE_GLSL |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
353 |
static inline GLenum glsl_shader_type(const MOJOSHADER_shaderType t) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
354 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
355 |
// these enums match between core 2.0 and the ARB extensions. |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
356 |
if (t == MOJOSHADER_TYPE_VERTEX) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
357 |
return GL_VERTEX_SHADER; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
358 |
else if (t == MOJOSHADER_TYPE_PIXEL) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
359 |
return GL_FRAGMENT_SHADER; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
360 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
361 |
// !!! FIXME: geometry shaders? |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
362 |
return GL_NONE; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
363 |
} // glsl_shader_type |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
364 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
365 |
|
760
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
366 |
static int impl_GLSL_MustPushConstantArrays(void) { return 1; } |
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
367 |
static int impl_GLSL_MustPushSamplers(void) { return 1; } |
438
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
436
diff
changeset
|
368 |
|
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
369 |
static int impl_GLSL_MaxUniforms(MOJOSHADER_shaderType shader_type) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
370 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
371 |
// these enums match between core 2.0 and the ARB extensions. |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
372 |
GLenum pname = GL_NONE; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
373 |
GLint val = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
374 |
if (shader_type == MOJOSHADER_TYPE_VERTEX) |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
375 |
pname = GL_MAX_VERTEX_UNIFORM_COMPONENTS; |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
376 |
else if (shader_type == MOJOSHADER_TYPE_PIXEL) |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
377 |
pname = GL_MAX_FRAGMENT_UNIFORM_COMPONENTS; |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
378 |
else |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
379 |
return -1; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
380 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
381 |
ctx->glGetIntegerv(pname, &val); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
382 |
return (int) val; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
383 |
} // impl_GLSL_MaxUniforms |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
384 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
385 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
386 |
static int impl_GLSL_CompileShader(const MOJOSHADER_parseData *pd, GLuint *s) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
387 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
388 |
GLint ok = 0; |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
389 |
const GLint codelen = (GLint) pd->output_len; |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
390 |
const GLenum shader_type = glsl_shader_type(pd->shader_type); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
391 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
392 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
393 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
394 |
const GLuint shader = ctx->glCreateShader(shader_type); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
395 |
ctx->glShaderSource(shader, 1, (const GLchar**) &pd->output, &codelen); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
396 |
ctx->glCompileShader(shader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
397 |
ctx->glGetShaderiv(shader, GL_COMPILE_STATUS, &ok); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
398 |
if (!ok) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
399 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
400 |
GLsizei len = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
401 |
ctx->glGetInfoLogARB(shader, sizeof (error_buffer), &len, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
402 |
(GLchar *) error_buffer); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
403 |
*s = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
404 |
return 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
405 |
} // if |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
406 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
407 |
*s = shader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
408 |
} // if |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
409 |
else |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
410 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
411 |
const GLhandleARB shader = ctx->glCreateShaderObjectARB(shader_type); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
412 |
assert(sizeof (shader) == sizeof (*s)); // not always true on OS X! |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
413 |
ctx->glShaderSourceARB(shader, 1, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
414 |
(const GLcharARB **) &pd->output, &codelen); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
415 |
ctx->glCompileShaderARB(shader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
416 |
ctx->glGetObjectParameterivARB(shader,GL_OBJECT_COMPILE_STATUS_ARB,&ok); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
417 |
if (!ok) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
418 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
419 |
GLsizei len = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
420 |
ctx->glGetInfoLogARB(shader, sizeof (error_buffer), &len, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
421 |
(GLcharARB *) error_buffer); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
422 |
*s = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
423 |
return 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
424 |
} // if |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
425 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
426 |
*s = (GLuint) shader; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
427 |
} // else |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
428 |
|
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
429 |
return 1; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
430 |
} // impl_GLSL_CompileShader |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
431 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
432 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
433 |
static void impl_GLSL_DeleteShader(const GLuint shader) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
434 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
435 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
436 |
ctx->glDeleteShader(shader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
437 |
else |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
438 |
ctx->glDeleteObjectARB((GLhandleARB) shader); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
439 |
} // impl_GLSL_DeleteShader |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
440 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
441 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
442 |
static void impl_GLSL_DeleteProgram(const GLuint program) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
443 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
444 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
445 |
ctx->glDeleteProgram(program); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
446 |
else |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
447 |
ctx->glDeleteObjectARB((GLhandleARB) program); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
448 |
} // impl_GLSL_DeleteProgram |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
449 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
450 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
451 |
static GLint impl_GLSL_GetUniformLocation(MOJOSHADER_glProgram *program, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
452 |
MOJOSHADER_glShader *shader, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
453 |
{ |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
454 |
return 0; // no-op, we push this as one big-ass array now. |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
455 |
} // impl_GLSL_GetUniformLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
456 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
457 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
458 |
static inline GLint glsl_uniform_loc(MOJOSHADER_glProgram *program, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
459 |
const char *name) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
460 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
461 |
return ctx->have_opengl_2 ? |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
462 |
ctx->glGetUniformLocation(program->handle, name) : |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
463 |
ctx->glGetUniformLocationARB((GLhandleARB) program->handle, name); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
464 |
} // glsl_uniform_loc |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
465 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
466 |
|
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
467 |
static GLint impl_GLSL_GetSamplerLocation(MOJOSHADER_glProgram *program, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
468 |
MOJOSHADER_glShader *shader, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
469 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
470 |
return glsl_uniform_loc(program, shader->parseData->samplers[idx].name); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
471 |
} // impl_GLSL_GetSamplerLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
472 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
473 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
474 |
static GLint impl_GLSL_GetAttribLocation(MOJOSHADER_glProgram *program, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
475 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
476 |
const MOJOSHADER_parseData *pd = program->vertex->parseData; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
477 |
const MOJOSHADER_attribute *a = pd->attributes; |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
478 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
479 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
480 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
481 |
return ctx->glGetAttribLocation(program->handle, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
482 |
(const GLchar *) a[idx].name); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
483 |
} // if |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
484 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
485 |
return ctx->glGetAttribLocationARB((GLhandleARB) program->handle, |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
486 |
(const GLcharARB *) a[idx].name); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
487 |
} // impl_GLSL_GetAttribLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
488 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
489 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
490 |
static GLuint impl_GLSL_LinkProgram(MOJOSHADER_glShader *vshader, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
491 |
MOJOSHADER_glShader *pshader) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
492 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
493 |
GLint ok = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
494 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
495 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
496 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
497 |
const GLuint program = ctx->glCreateProgram(); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
498 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
499 |
if (vshader != NULL) ctx->glAttachShader(program, vshader->handle); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
500 |
if (pshader != NULL) ctx->glAttachShader(program, pshader->handle); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
501 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
502 |
ctx->glLinkProgram(program); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
503 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
504 |
ctx->glGetProgramiv(program, GL_LINK_STATUS, &ok); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
505 |
if (!ok) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
506 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
507 |
GLsizei len = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
508 |
ctx->glGetProgramInfoLog(program, sizeof (error_buffer), |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
509 |
&len, (GLchar *) error_buffer); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
510 |
ctx->glDeleteProgram(program); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
511 |
return 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
512 |
} // if |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
513 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
514 |
return program; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
515 |
} // if |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
516 |
else |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
517 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
518 |
const GLhandleARB program = ctx->glCreateProgramObjectARB(); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
519 |
assert(sizeof(program) == sizeof(GLuint)); // not always true on OS X! |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
520 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
521 |
if (vshader != NULL) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
522 |
ctx->glAttachObjectARB(program, (GLhandleARB) vshader->handle); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
523 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
524 |
if (pshader != NULL) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
525 |
ctx->glAttachObjectARB(program, (GLhandleARB) pshader->handle); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
526 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
527 |
ctx->glLinkProgramARB(program); |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
528 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
529 |
ctx->glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &ok); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
530 |
if (!ok) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
531 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
532 |
GLsizei len = 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
533 |
ctx->glGetInfoLogARB(program, sizeof (error_buffer), |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
534 |
&len, (GLcharARB *) error_buffer); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
535 |
ctx->glDeleteObjectARB(program); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
536 |
return 0; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
537 |
} // if |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
538 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
539 |
return (GLuint) program; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
540 |
} // else |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
541 |
} // impl_GLSL_LinkProgram |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
542 |
|
765
076f3bd42329
Moved profileInitProgram to profileFinalInitProgram.
Ryan C. Gordon <icculus@icculus.org>
parents:
764
diff
changeset
|
543 |
static void impl_GLSL_FinalInitProgram(MOJOSHADER_glProgram *program) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
544 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
545 |
|
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
546 |
program->vs_float4_loc = glsl_uniform_loc(program, "vs_uniforms_vec4"); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
547 |
program->vs_int4_loc = glsl_uniform_loc(program, "vs_uniforms_ivec4"); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
548 |
program->vs_bool_loc = glsl_uniform_loc(program, "vs_uniforms_bool"); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
549 |
program->ps_float4_loc = glsl_uniform_loc(program, "ps_uniforms_vec4"); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
550 |
program->ps_int4_loc = glsl_uniform_loc(program, "ps_uniforms_ivec4"); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
551 |
program->ps_bool_loc = glsl_uniform_loc(program, "ps_uniforms_bool"); |
765
076f3bd42329
Moved profileInitProgram to profileFinalInitProgram.
Ryan C. Gordon <icculus@icculus.org>
parents:
764
diff
changeset
|
552 |
} // impl_GLSL_FinalInitProgram |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
553 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
554 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
555 |
static void impl_GLSL_UseProgram(MOJOSHADER_glProgram *program) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
556 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
557 |
if (ctx->have_opengl_2) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
558 |
ctx->glUseProgram(program ? program->handle : 0); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
559 |
else |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
560 |
ctx->glUseProgramObjectARB((GLhandleARB) (program ? program->handle : 0)); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
561 |
} // impl_GLSL_UseProgram |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
562 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
563 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
564 |
static void impl_GLSL_PushConstantArray(MOJOSHADER_glProgram *program, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
565 |
const MOJOSHADER_uniform *u, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
566 |
const GLfloat *f) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
567 |
{ |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
568 |
const GLint loc = glsl_uniform_loc(program, u->name); |
798
5dd67cc04cf9
Bunch of small tweaks to make this compile as C++ code without errors/warnings.
Ryan C. Gordon <icculus@icculus.org>
parents:
797
diff
changeset
|
569 |
if (loc >= 0) // not optimized out? |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
570 |
ctx->glUniform4fv(loc, u->array_count, f); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
571 |
} // impl_GLSL_PushConstantArray |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
572 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
573 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
574 |
static void impl_GLSL_PushUniforms(void) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
575 |
{ |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
576 |
const MOJOSHADER_glProgram *program = ctx->bound_program; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
577 |
|
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
578 |
assert(program->uniform_count > 0); // don't call with nothing to do! |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
579 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
580 |
if (program->vs_float4_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
581 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
582 |
ctx->glUniform4fv(program->vs_float4_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
583 |
program->vs_uniforms_float4_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
584 |
program->vs_uniforms_float4); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
585 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
586 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
587 |
if (program->vs_int4_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
588 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
589 |
ctx->glUniform4iv(program->vs_int4_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
590 |
program->vs_uniforms_int4_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
591 |
program->vs_uniforms_int4); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
592 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
593 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
594 |
if (program->vs_bool_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
595 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
596 |
ctx->glUniform1iv(program->vs_bool_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
597 |
program->vs_uniforms_bool_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
598 |
program->vs_uniforms_bool); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
599 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
600 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
601 |
if (program->ps_float4_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
602 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
603 |
ctx->glUniform4fv(program->ps_float4_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
604 |
program->ps_uniforms_float4_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
605 |
program->ps_uniforms_float4); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
606 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
607 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
608 |
if (program->ps_int4_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
609 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
610 |
ctx->glUniform4iv(program->ps_int4_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
611 |
program->ps_uniforms_int4_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
612 |
program->ps_uniforms_int4); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
613 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
614 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
615 |
if (program->ps_bool_loc != -1) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
616 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
617 |
ctx->glUniform1iv(program->ps_bool_loc, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
618 |
program->ps_uniforms_bool_count, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
619 |
program->ps_uniforms_bool); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
620 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
621 |
} // impl_GLSL_PushUniforms |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
622 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
623 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
624 |
static void impl_GLSL_PushSampler(GLint loc, GLuint sampler) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
625 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
626 |
ctx->glUniform1i(loc, sampler); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
627 |
} // impl_GLSL_PushSampler |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
628 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
629 |
#endif // SUPPORT_PROFILE_GLSL |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
630 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
631 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
632 |
#if SUPPORT_PROFILE_ARB1 |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
633 |
static inline GLenum arb1_shader_type(const MOJOSHADER_shaderType t) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
634 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
635 |
if (t == MOJOSHADER_TYPE_VERTEX) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
636 |
return GL_VERTEX_PROGRAM_ARB; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
637 |
else if (t == MOJOSHADER_TYPE_PIXEL) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
638 |
return GL_FRAGMENT_PROGRAM_ARB; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
639 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
640 |
// !!! FIXME: geometry shaders? |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
641 |
return GL_NONE; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
642 |
} // arb1_shader_type |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
643 |
|
760
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
644 |
static int impl_ARB1_MustPushConstantArrays(void) { return 0; } |
6dc8d2cafc58
"Must Push" seemed more correct than "Must Load".
Ryan C. Gordon <icculus@icculus.org>
parents:
759
diff
changeset
|
645 |
static int impl_ARB1_MustPushSamplers(void) { return 0; } |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
646 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
647 |
static int impl_ARB1_MaxUniforms(MOJOSHADER_shaderType shader_type) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
648 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
649 |
GLint retval = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
650 |
const GLenum program_type = arb1_shader_type(shader_type); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
651 |
if (program_type == GL_NONE) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
652 |
return -1; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
653 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
654 |
ctx->glGetProgramivARB(program_type, GL_MAX_PROGRAM_PARAMETERS_ARB, &retval); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
655 |
return (int) retval; // !!! FIXME: times four? |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
656 |
} // impl_ARB1_MaxUniforms |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
657 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
658 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
659 |
static int impl_ARB1_CompileShader(const MOJOSHADER_parseData *pd, GLuint *s) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
660 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
661 |
GLint shaderlen = (GLint) pd->output_len; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
662 |
const GLenum shader_type = arb1_shader_type(pd->shader_type); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
663 |
GLuint shader = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
664 |
ctx->glGenProgramsARB(1, &shader); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
665 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
666 |
ctx->glGetError(); // flush any existing error state. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
667 |
ctx->glBindProgramARB(shader_type, shader); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
668 |
ctx->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
669 |
shaderlen, pd->output); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
670 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
671 |
if (ctx->glGetError() == GL_INVALID_OPERATION) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
672 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
673 |
GLint pos = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
674 |
ctx->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
675 |
const GLubyte *errstr = ctx->glGetString(GL_PROGRAM_ERROR_STRING_ARB); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
676 |
snprintf(error_buffer, sizeof (error_buffer), |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
677 |
"ARB1 compile error at position %d: %s", |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
678 |
(int) pos, (const char *) errstr); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
679 |
ctx->glBindProgramARB(shader_type, 0); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
680 |
ctx->glDeleteProgramsARB(1, &shader); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
681 |
*s = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
682 |
return 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
683 |
} // if |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
684 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
685 |
*s = shader; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
686 |
return 1; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
687 |
} // impl_ARB1_CompileShader |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
688 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
689 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
690 |
static void impl_ARB1_DeleteShader(const GLuint _shader) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
691 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
692 |
GLuint shader = _shader; // const removal. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
693 |
ctx->glDeleteProgramsARB(1, &shader); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
694 |
} // impl_ARB1_DeleteShader |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
695 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
696 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
697 |
static void impl_ARB1_DeleteProgram(const GLuint program) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
698 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
699 |
// no-op. ARB1 doesn't have real linked programs. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
700 |
} // impl_GLSL_DeleteProgram |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
701 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
702 |
static GLint impl_ARB1_GetUniformLocation(MOJOSHADER_glProgram *program, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
703 |
MOJOSHADER_glShader *shader, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
704 |
{ |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
705 |
return 0; // no-op, we push this as one big-ass array now. |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
706 |
} // impl_ARB1_GetUniformLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
707 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
708 |
static GLint impl_ARB1_GetSamplerLocation(MOJOSHADER_glProgram *program, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
709 |
MOJOSHADER_glShader *shader, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
710 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
711 |
return shader->parseData->samplers[idx].index; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
712 |
} // impl_ARB1_GetSamplerLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
713 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
714 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
715 |
static GLint impl_ARB1_GetAttribLocation(MOJOSHADER_glProgram *program, int idx) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
716 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
717 |
return idx; // map to vertex arrays in the same order as the parseData. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
718 |
} // impl_ARB1_GetAttribLocation |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
719 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
720 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
721 |
static GLuint impl_ARB1_LinkProgram(MOJOSHADER_glShader *vshader, |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
722 |
MOJOSHADER_glShader *pshader) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
723 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
724 |
// there is no formal linking in ARB1...just return a unique value. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
725 |
static GLuint retval = 1; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
726 |
return retval++; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
727 |
} // impl_ARB1_LinkProgram |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
728 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
729 |
|
765
076f3bd42329
Moved profileInitProgram to profileFinalInitProgram.
Ryan C. Gordon <icculus@icculus.org>
parents:
764
diff
changeset
|
730 |
static void impl_ARB1_FinalInitProgram(MOJOSHADER_glProgram *program) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
731 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
732 |
// no-op. |
765
076f3bd42329
Moved profileInitProgram to profileFinalInitProgram.
Ryan C. Gordon <icculus@icculus.org>
parents:
764
diff
changeset
|
733 |
} // impl_ARB1_FinalInitProgram |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
734 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
735 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
736 |
static void impl_ARB1_UseProgram(MOJOSHADER_glProgram *program) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
737 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
738 |
GLuint vhandle = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
739 |
GLuint phandle = 0; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
740 |
if (program != NULL) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
741 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
742 |
if (program->vertex != NULL) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
743 |
vhandle = program->vertex->handle; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
744 |
if (program->fragment != NULL) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
745 |
phandle = program->fragment->handle; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
746 |
} // if |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
747 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
748 |
toggle_gl_state(GL_VERTEX_PROGRAM_ARB, vhandle != 0); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
749 |
toggle_gl_state(GL_FRAGMENT_PROGRAM_ARB, phandle != 0); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
750 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
751 |
ctx->glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vhandle); |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
752 |
ctx->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, phandle); |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
753 |
} // impl_ARB1_UseProgram |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
754 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
755 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
756 |
static void impl_ARB1_PushConstantArray(MOJOSHADER_glProgram *program, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
757 |
const MOJOSHADER_uniform *u, |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
758 |
const GLfloat *f) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
759 |
{ |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
760 |
// no-op. Constant arrays are defined in source code for arb1. |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
761 |
} // impl_ARB1_PushConstantArray |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
762 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
763 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
764 |
static void impl_ARB1_PushUniforms(void) |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
765 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
766 |
// vertex shader uniforms come first in program->uniforms array. |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
767 |
MOJOSHADER_shaderType shader_type = MOJOSHADER_TYPE_VERTEX; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
768 |
GLenum arb_shader_type = arb1_shader_type(shader_type); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
769 |
const MOJOSHADER_glProgram *program = ctx->bound_program; |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
770 |
const uint32 count = program->uniform_count; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
771 |
const GLfloat *srcf = program->vs_uniforms_float4; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
772 |
const GLint *srci = program->vs_uniforms_int4; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
773 |
const GLint *srcb = program->vs_uniforms_bool; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
774 |
GLint loc = 0; |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
775 |
GLint texbem_loc = 0; |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
776 |
uint32 i; |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
777 |
|
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
778 |
assert(count > 0); // shouldn't call this with nothing to do! |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
779 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
780 |
for (i = 0; i < count; i++) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
781 |
{ |
767
806ba18f23aa
Cleanups and fixes in ARB1 uniform pushing.
Ryan C. Gordon <icculus@icculus.org>
parents:
766
diff
changeset
|
782 |
UniformMap *map = &program->uniforms[i]; |
770
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
783 |
const MOJOSHADER_shaderType uniform_shader_type = map->shader_type; |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
784 |
const MOJOSHADER_uniform *u = map->uniform; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
785 |
const MOJOSHADER_uniformType type = u->type; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
786 |
const int size = u->array_count ? u->array_count : 1; |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
787 |
|
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
788 |
assert(!u->constant); |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
789 |
|
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
790 |
// Did we switch from vertex to pixel (to geometry, etc)? |
770
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
791 |
if (shader_type != uniform_shader_type) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
792 |
{ |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
793 |
if (shader_type == MOJOSHADER_TYPE_PIXEL) |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
794 |
texbem_loc = loc; |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
795 |
|
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
796 |
// we start with vertex, move to pixel, then to geometry, etc. |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
797 |
// The array should always be sorted as such. |
770
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
798 |
if (uniform_shader_type == MOJOSHADER_TYPE_PIXEL) |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
799 |
{ |
770
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
800 |
assert(shader_type == MOJOSHADER_TYPE_VERTEX); |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
801 |
srcf = program->ps_uniforms_float4; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
802 |
srci = program->ps_uniforms_int4; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
803 |
srcb = program->ps_uniforms_bool; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
804 |
loc = 0; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
805 |
} // if |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
806 |
else |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
807 |
{ |
769
0627038d2032
Fixed wrong assert; triggered if there were no vertex shader uniforms.
Ryan C. Gordon <icculus@icculus.org>
parents:
768
diff
changeset
|
808 |
// These should be ordered vertex, then pixel, then geometry. |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
809 |
assert(0 && "Unexpected shader type"); |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
810 |
} // else |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
811 |
|
770
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
812 |
shader_type = uniform_shader_type; |
b5e545408b02
Fixed incorrect variable name.
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
813 |
arb_shader_type = arb1_shader_type(uniform_shader_type); |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
814 |
} // if |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
815 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
816 |
if (type == MOJOSHADER_UNIFORM_FLOAT) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
817 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
818 |
int i; |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
819 |
for (i = 0; i < size; i++, srcf += 4, loc++) |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
820 |
ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, srcf); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
821 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
822 |
else if (type == MOJOSHADER_UNIFORM_INT) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
823 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
824 |
int i; |
1024
dbff93345a84
Test for the GL extension, not whether the entry point is NULL.
Ryan C. Gordon <icculus@icculus.org>
parents:
1023
diff
changeset
|
825 |
if (ctx->have_GL_NV_gpu_program4) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
826 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
827 |
// GL_NV_gpu_program4 has integer uniform loading support. |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
828 |
for (i = 0; i < size; i++, srci += 4, loc++) |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
829 |
ctx->glProgramLocalParameterI4ivNV(arb_shader_type, loc, srci); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
830 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
831 |
else |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
832 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
833 |
for (i = 0; i < size; i++, srci += 4, loc++) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
834 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
835 |
const GLfloat fv[4] = { |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
836 |
(GLfloat) srci[0], (GLfloat) srci[1], |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
837 |
(GLfloat) srci[2], (GLfloat) srci[3] |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
838 |
}; |
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
839 |
ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, fv); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
840 |
} // for |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
841 |
} // else |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
842 |
} // else if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
843 |
else if (type == MOJOSHADER_UNIFORM_BOOL) |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
844 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
845 |
int i; |
1024
dbff93345a84
Test for the GL extension, not whether the entry point is NULL.
Ryan C. Gordon <icculus@icculus.org>
parents:
1023
diff
changeset
|
846 |
if (ctx->have_GL_NV_gpu_program4) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
847 |
{ |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
848 |
// GL_NV_gpu_program4 has integer uniform loading support. |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
849 |
for (i = 0; i < size; i++, srcb++, loc++) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
850 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
851 |
const GLint ib = (GLint) ((*srcb) ? 1 : 0); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
852 |
const GLint iv[4] = { ib, ib, ib, ib }; |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
853 |
ctx->glProgramLocalParameterI4ivNV(arb_shader_type, loc, iv); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
854 |
} // for |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
855 |
} // if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
856 |
else |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
857 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
858 |
for (i = 0; i < size; i++, srcb++, loc++) |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
859 |
{ |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
860 |
const GLfloat fb = (GLfloat) ((*srcb) ? 1.0f : 0.0f); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
861 |
const GLfloat fv[4] = { fb, fb, fb, fb }; |
768
9ba81386bd4d
Optimize/cleanup in uniform array iteration work.
Ryan C. Gordon <icculus@icculus.org>
parents:
767
diff
changeset
|
862 |
ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, fv); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
863 |
} // for |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
864 |
} // else |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
865 |
} // else if |
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
866 |
} // for |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
867 |
|
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
868 |
if (program->texbem_count) |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
869 |
{ |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
870 |
const GLenum target = GL_FRAGMENT_PROGRAM_ARB; |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
871 |
GLfloat *srcf = program->ps_uniforms_float4; |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
872 |
srcf += (program->ps_uniforms_float4_count * 4) - |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
873 |
(program->texbem_count * 8); |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
874 |
loc = texbem_loc; |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
875 |
for (i = 0; i < program->texbem_count; i++, srcf += 8) |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
876 |
{ |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
877 |
ctx->glProgramLocalParameter4fvARB(target, loc++, srcf); |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
878 |
ctx->glProgramLocalParameter4fvARB(target, loc++, srcf + 4); |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
879 |
} // for |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1073
diff
changeset
|
880 |
} // if |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
881 |
} // impl_ARB1_PushUniforms |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
882 |
|
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
883 |
static void impl_ARB1_PushSampler(GLint loc, GLuint sampler) |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
884 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
885 |
// no-op in this profile...arb1 uses the texture units as-is. |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
886 |
assert(loc == (GLint) sampler); |
763
ef6489e7e263
Serious OpenGL glue surgery to push uniforms as one big array.
Ryan C. Gordon <icculus@icculus.org>
parents:
761
diff
changeset
|
887 |
} // impl_ARB1_PushSampler |
411
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
888 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
889 |
#endif // SUPPORT_PROFILE_ARB1 |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
890 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
891 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
892 |
const char *MOJOSHADER_glGetError(void) |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
893 |
{ |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
894 |
return error_buffer; |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
895 |
} // MOJOSHADER_glGetError |
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
896 |
|
01bc1352c047
Rearranged profile-specific functions in OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
410
diff
changeset
|
897 |
|
904
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
898 |
static void *loadsym(MOJOSHADER_glGetProcAddress lookup, void *d, |
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
899 |
const char *fn, int *ext) |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
900 |
{ |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
901 |
void *retval = NULL; |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
902 |
if (lookup != NULL) |
904
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
903 |
retval = lookup(fn, d); |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
904 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
905 |
if (retval == NULL) |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
906 |
*ext = 0; |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
907 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
908 |
return retval; |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
909 |
} // loadsym |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
910 |
|
904
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
911 |
static void lookup_entry_points(MOJOSHADER_glGetProcAddress lookup, void *d) |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
912 |
{ |
363 | 913 |
#define DO_LOOKUP(ext, typ, fn) { \ |
1023
8f4d16a3b380
Cleaned up GL symbol lookup slightly.
Ryan C. Gordon <icculus@icculus.org>
parents:
906
diff
changeset
|
914 |
ctx->fn = (typ) loadsym(lookup, d, #fn, &ctx->have_##ext); \ |
363 | 915 |
} |
916 |
||
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
917 |
DO_LOOKUP(core_opengl, PFNGLGETSTRINGPROC, glGetString); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
918 |
DO_LOOKUP(core_opengl, PFNGLGETERRORPROC, glGetError); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
919 |
DO_LOOKUP(core_opengl, PFNGLGETINTEGERVPROC, glGetIntegerv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
920 |
DO_LOOKUP(core_opengl, PFNGLENABLEPROC, glEnable); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
921 |
DO_LOOKUP(core_opengl, PFNGLDISABLEPROC, glDisable); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
922 |
DO_LOOKUP(opengl_2, PFNGLDELETESHADERPROC, glDeleteShader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
923 |
DO_LOOKUP(opengl_2, PFNGLDELETEPROGRAMPROC, glDeleteProgram); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
924 |
DO_LOOKUP(opengl_2, PFNGLATTACHSHADERPROC, glAttachShader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
925 |
DO_LOOKUP(opengl_2, PFNGLCOMPILESHADERPROC, glCompileShader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
926 |
DO_LOOKUP(opengl_2, PFNGLCREATESHADERPROC, glCreateShader); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
927 |
DO_LOOKUP(opengl_2, PFNGLCREATEPROGRAMPROC, glCreateProgram); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
928 |
DO_LOOKUP(opengl_2, PFNGLDISABLEVERTEXATTRIBARRAYPROC, glDisableVertexAttribArray); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
929 |
DO_LOOKUP(opengl_2, PFNGLENABLEVERTEXATTRIBARRAYPROC, glEnableVertexAttribArray); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
930 |
DO_LOOKUP(opengl_2, PFNGLGETATTRIBLOCATIONPROC, glGetAttribLocation); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
931 |
DO_LOOKUP(opengl_2, PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
932 |
DO_LOOKUP(opengl_2, PFNGLGETSHADERIVPROC, glGetShaderiv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
933 |
DO_LOOKUP(opengl_2, PFNGLGETPROGRAMIVPROC, glGetProgramiv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
934 |
DO_LOOKUP(opengl_2, PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
935 |
DO_LOOKUP(opengl_2, PFNGLLINKPROGRAMPROC, glLinkProgram); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
936 |
DO_LOOKUP(opengl_2, PFNGLSHADERSOURCEPROC, glShaderSource); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
937 |
DO_LOOKUP(opengl_2, PFNGLUNIFORM1IPROC, glUniform1i); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
938 |
DO_LOOKUP(opengl_2, PFNGLUNIFORM1IVPROC, glUniform1iv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
939 |
DO_LOOKUP(opengl_2, PFNGLUNIFORM4FVPROC, glUniform4fv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
940 |
DO_LOOKUP(opengl_2, PFNGLUNIFORM4IVPROC, glUniform4iv); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
941 |
DO_LOOKUP(opengl_2, PFNGLUSEPROGRAMPROC, glUseProgram); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
942 |
DO_LOOKUP(opengl_2, PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
943 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLDELETEOBJECTARBPROC, glDeleteObjectARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
944 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLATTACHOBJECTARBPROC, glAttachObjectARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
945 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLCOMPILESHADERARBPROC, glCompileShaderARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
946 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
947 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
948 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETINFOLOGARBPROC, glGetInfoLogARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
949 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
950 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
951 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLLINKPROGRAMARBPROC, glLinkProgramARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
952 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLSHADERSOURCEARBPROC, glShaderSourceARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
953 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM1IARBPROC, glUniform1iARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
954 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM1IVARBPROC, glUniform1ivARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
955 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM4FVARBPROC, glUniform4fvARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
956 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM4IVARBPROC, glUniform4ivARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
957 |
DO_LOOKUP(GL_ARB_shader_objects, PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
958 |
DO_LOOKUP(GL_ARB_vertex_shader, PFNGLDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
959 |
DO_LOOKUP(GL_ARB_vertex_shader, PFNGLENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
960 |
DO_LOOKUP(GL_ARB_vertex_shader, PFNGLGETATTRIBLOCATIONARBPROC, glGetAttribLocationARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
961 |
DO_LOOKUP(GL_ARB_vertex_shader, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
962 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
963 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB); |
395
d2307cc5d6e7
Use local parameters, not environment params, in the arb1/nv2 profiles.
Ryan C. Gordon <icculus@icculus.org>
parents:
394
diff
changeset
|
964 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
965 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB); |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
966 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLGENPROGRAMSARBPROC, glGenProgramsARB); |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
967 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLBINDPROGRAMARBPROC, glBindProgramARB); |
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
968 |
DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMSTRINGARBPROC, glProgramStringARB); |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
969 |
DO_LOOKUP(GL_NV_gpu_program4, PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC, glProgramLocalParameterI4ivNV); |
333
2b36a1d72fa1
Wrote most of the arb1 OpenGL glue code.
Ryan C. Gordon <icculus@icculus.org>
parents:
323
diff
changeset
|
970 |
|
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
971 |
#undef DO_LOOKUP |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
972 |
} // lookup_entry_points |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
973 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
974 |
static inline int opengl_version_atleast(const int major, const int minor) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
975 |
{ |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
976 |
return ( ((ctx->opengl_major << 16) | (ctx->opengl_minor & 0xFFFF)) >= |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
977 |
((major << 16) | (minor & 0xFFFF)) ); |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
978 |
} // opengl_version_atleast |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
979 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
980 |
static int verify_extension(const char *ext, int have, const char *extlist, |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
981 |
int major, int minor) |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
982 |
{ |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
983 |
if (have == 0) |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
984 |
return 0; // don't bother checking, we're missing an entry point. |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
985 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
986 |
else if (!ctx->have_core_opengl) |
262
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
987 |
return 0; // don't bother checking, we're missing basic functionality. |
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
988 |
|
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
989 |
// See if it's in the spec for this GL implementation's version. |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
990 |
if ((major > 0) && (opengl_version_atleast(major, minor))) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
991 |
return 1; |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
992 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
993 |
// Not available in the GL version, check the extension list. |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
994 |
const char *ptr = strstr(extlist, ext); |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
995 |
if (ptr == NULL) |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
996 |
return 0; |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
997 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
998 |
const char endchar = ptr[strlen(ext)]; |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
999 |
if ((endchar == '\0') || (endchar == ' ')) |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1000 |
return 1; // extension is in the list. |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1001 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1002 |
return 0; // just not supported, fail. |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1003 |
} // verify_extension |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1004 |
|
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1005 |
|
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1006 |
static void parse_opengl_version_str(const char *verstr, int *maj, int *min) |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1007 |
{ |
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1008 |
if (verstr == NULL) |
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1009 |
*maj = *min = 0; |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1010 |
else |
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1011 |
sscanf(verstr, "%d.%d", maj, min); |
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1012 |
} // parse_opengl_version_str |
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1013 |
|
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1014 |
|
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1015 |
#if SUPPORT_PROFILE_GLSL |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1016 |
static inline int glsl_version_atleast(const int major, const int minor) |
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1017 |
{ |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1018 |
return ( ((ctx->glsl_major << 16) | (ctx->glsl_minor & 0xFFFF)) >= |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1019 |
((major << 16) | (minor & 0xFFFF)) ); |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1020 |
} // glsl_version_atleast |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1021 |
#endif |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1022 |
|
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1023 |
static void detect_glsl_version(void) |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1024 |
{ |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1025 |
ctx->glsl_major = ctx->glsl_minor = 0; |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1026 |
|
808
b7196cc07283
Allow compiler to strip disabled glsl120 and nvX profiles as dead code.
Ryan C. Gordon <icculus@icculus.org>
parents:
807
diff
changeset
|
1027 |
#if SUPPORT_PROFILE_GLSL |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1028 |
if (!ctx->have_core_opengl) |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1029 |
return; // everything's busted, give up. |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1030 |
|
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1031 |
#if PLATFORM_MACOSX |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1032 |
// If running on Mac OS X <= 10.4, don't ever use GLSL, even if |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1033 |
// the system claims it is available. |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1034 |
if (!macosx_version_atleast(10, 5, 0)) |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1035 |
return; |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1036 |
#endif |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1037 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1038 |
if ( ctx->have_opengl_2 || |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1039 |
( ctx->have_GL_ARB_shader_objects && |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1040 |
ctx->have_GL_ARB_vertex_shader && |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1041 |
ctx->have_GL_ARB_fragment_shader && |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1042 |
ctx->have_GL_ARB_shading_language_100 ) ) |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1043 |
{ |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1044 |
// the GL2.0 and ARB enum is the same value. |
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1045 |
const GLenum enumval = GL_SHADING_LANGUAGE_VERSION; |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1046 |
ctx->glGetError(); // flush any existing error state. |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1047 |
const char *str = (const char *) ctx->glGetString(enumval); |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1048 |
if (ctx->glGetError() == GL_INVALID_ENUM) |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1049 |
str = NULL; |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1050 |
parse_opengl_version_str(str, &ctx->glsl_major, &ctx->glsl_minor); |
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1051 |
} // if |
808
b7196cc07283
Allow compiler to strip disabled glsl120 and nvX profiles as dead code.
Ryan C. Gordon <icculus@icculus.org>
parents:
807
diff
changeset
|
1052 |
#endif |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
1069
diff
changeset
|
1053 |
} // detect_glsl_version |
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1054 |
|
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
396
diff
changeset
|
1055 |
|
904
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
1056 |
static void load_extensions(MOJOSHADER_glGetProcAddress lookup, void *d) |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1057 |
{ |
262
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
1058 |
const char *extlist = NULL; |
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
1059 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1060 |
ctx->have_core_opengl = 1; |
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1061 |
ctx->have_opengl_2 = 1; |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
1062 |
ctx->have_GL_ARB_vertex_program = 1; |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
321
diff
changeset
|
1063 |
ctx->have_GL_ARB_fragment_program = 1; |
388
5930c6cd840e
Fixed detection of OpenGL extensions needed by nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
363
diff
changeset
|
1064 |
ctx->have_GL_NV_vertex_program2_option = 1; |
5930c6cd840e
Fixed detection of OpenGL extensions needed by nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
363
diff
changeset
|
1065 |
ctx->have_GL_NV_fragment_program2 = 1; |
421
bfd3d95273ec
First piece of work on nv3 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
420
diff
changeset
|
1066 |
ctx->have_GL_NV_vertex_program3 = 1; |
432
6c59f6c0456a
Fixed uninitialized variable in OpenGL glue's nv4 profile detection.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
1067 |
ctx->have_GL_NV_gpu_program4 = 1; |
237
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
1068 |
ctx->have_GL_ARB_shader_objects = 1; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
1069 |
ctx->have_GL_ARB_vertex_shader = 1; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
1070 |
ctx->have_GL_ARB_fragment_shader = 1; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
1071 |
ctx->have_GL_ARB_shading_language_100 = 1; |
09f35dfc1d7e
OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents:
236
diff
changeset
|
1072 |
ctx->have_GL_NV_half_float = 1; |
449
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
1073 |
ctx->have_GL_ARB_half_float_vertex = 1; |
5a978f37e750
Added support for GL_ARB_half_float_vertex and GL_OES_vertex_half_float.
Ryan C. Gordon <icculus@icculus.org>
parents:
448
diff
changeset
|
1074 |
ctx->have_GL_OES_vertex_half_float = 1; |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1075 |
|
904
5989f0d4185a
Added data argument to GL entry point lookup callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
1076 |
lookup_entry_points(lookup, d); |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1077 |
|
1072
3400f252c4e0
Fixed up calling GL2 vs ARB extension entry points.
Ryan C. Gordon <icculus@icculus.org>
parents:
1071
diff
changeset
|
1078 |
if (!ctx->have_core_opengl) |
229
67a3d459d865
OpenGL extension lookup and entry point loading.
Ryan C. Gordon <icculus@icculus.org>
parents:
226
diff
changeset
|
1079 |
set_error("missing basic OpenGL entry points"); |
262
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
1080 |
else |
0f1531ac2578
Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents:
255
diff
changeset
|
1081 |
{ |
1070
32eb4fe78351
Reworked GLSL extension and version detection.
Ryan C. Gordon <icculus |