1 #ifndef __GL_COMMON_H__
2 #define __GL_COMMON_H__
13 #include "w32_common.h"
17 #include "x11_common.h"
20 // workaround for some gl.h headers
23 #define APIENTRY GLAPIENTRY
24 #elif defined(GL_WIN32)
25 #define APIENTRY __stdcall
32 * \defgroup glextdefines OpenGL extension defines
34 * conditionally define all extension defines used.
35 * vendor specific extensions should be marked as such
36 * (e.g. _NV), _ARB is not used to ease readability.
39 #ifndef GL_REGISTER_COMBINERS_NV
40 #define GL_REGISTER_COMBINERS_NV 0x8522
42 #ifndef GL_MAX_GENERAL_COMBINERS_NV
43 #define GL_MAX_GENERAL_COMBINERS_NV 0x854D
45 #ifndef GL_NUM_GENERAL_COMBINERS_NV
46 #define GL_NUM_GENERAL_COMBINERS_NV 0x854E
48 #ifndef GL_CONSTANT_COLOR0_NV
49 #define GL_CONSTANT_COLOR0_NV 0x852A
51 #ifndef GL_CONSTANT_COLOR1_NV
52 #define GL_CONSTANT_COLOR1_NV 0x852B
54 #ifndef GL_COMBINER0_NV
55 #define GL_COMBINER0_NV 0x8550
57 #ifndef GL_COMBINER1_NV
58 #define GL_COMBINER1_NV 0x8551
60 #ifndef GL_VARIABLE_A_NV
61 #define GL_VARIABLE_A_NV 0x8523
63 #ifndef GL_VARIABLE_B_NV
64 #define GL_VARIABLE_B_NV 0x8524
66 #ifndef GL_VARIABLE_C_NV
67 #define GL_VARIABLE_C_NV 0x8525
69 #ifndef GL_VARIABLE_D_NV
70 #define GL_VARIABLE_D_NV 0x8526
72 #ifndef GL_UNSIGNED_INVERT_NV
73 #define GL_UNSIGNED_INVERT_NV 0x8537
75 #ifndef GL_HALF_BIAS_NORMAL_NV
76 #define GL_HALF_BIAS_NORMAL_NV 0x853A
78 #ifndef GL_SIGNED_IDENTITY_NV
79 #define GL_SIGNED_IDENTITY_NV 0x853C
81 #ifndef GL_SCALE_BY_FOUR_NV
82 #define GL_SCALE_BY_FOUR_NV 0x853F
85 #define GL_DISCARD_NV 0x8530
88 #define GL_SPARE0_NV 0x852E
90 #ifndef GL_FRAGMENT_SHADER_ATI
91 #define GL_FRAGMENT_SHADER_ATI 0x8920
93 #ifndef GL_NUM_FRAGMENT_REGISTERS_ATI
94 #define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
97 #define GL_REG_0_ATI 0x8921
100 #define GL_REG_1_ATI 0x8922
103 #define GL_REG_2_ATI 0x8923
106 #define GL_CON_0_ATI 0x8941
109 #define GL_CON_1_ATI 0x8942
112 #define GL_ADD_ATI 0x8963
115 #define GL_MUL_ATI 0x8964
118 #define GL_MAD_ATI 0x8968
120 #ifndef GL_SWIZZLE_STR_ATI
121 #define GL_SWIZZLE_STR_ATI 0x8976
123 #ifndef GL_4X_BIT_ATI
124 #define GL_4X_BIT_ATI 2
126 #ifndef GL_BIAS_BIT_ATI
127 #define GL_BIAS_BIT_ATI 8
129 #ifndef GL_MAX_TEXTURE_UNITS
130 #define GL_MAX_TEXTURE_UNITS 0x84E2
133 #define GL_TEXTURE0 0x84C0
136 #define GL_TEXTURE1 0x84C1
139 #define GL_TEXTURE2 0x84C2
142 #define GL_TEXTURE3 0x84C3
144 #ifndef GL_TEXTURE_RECTANGLE
145 #define GL_TEXTURE_RECTANGLE 0x84F5
147 #ifndef GL_PIXEL_UNPACK_BUFFER
148 #define GL_PIXEL_UNPACK_BUFFER 0x88EC
150 #ifndef GL_STREAM_DRAW
151 #define GL_STREAM_DRAW 0x88E0
153 #ifndef GL_DYNAMIC_DRAW
154 #define GL_DYNAMIC_DRAW 0x88E8
156 #ifndef GL_WRITE_ONLY
157 #define GL_WRITE_ONLY 0x88B9
160 #define GL_BGR 0x80E0
163 #define GL_BGRA 0x80E1
165 #ifndef GL_UNSIGNED_BYTE_3_3_2
166 #define GL_UNSIGNED_BYTE_3_3_2 0x8032
168 #ifndef GL_UNSIGNED_BYTE_2_3_3_REV
169 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
171 #ifndef GL_UNSIGNED_SHORT_5_6_5
172 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
174 #ifndef GL_UNSIGNED_SHORT_5_6_5_REV
175 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
177 #ifndef GL_UNSIGNED_SHORT_5_5_5_1
178 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
180 #ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV
181 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
183 #ifndef GL_FRAGMENT_PROGRAM
184 #define GL_FRAGMENT_PROGRAM 0x8804
186 #ifndef GL_PROGRAM_FORMAT_ASCII
187 #define GL_PROGRAM_FORMAT_ASCII 0x8875
189 #ifndef GL_PROGRAM_ERROR_POSITION
190 #define GL_PROGRAM_ERROR_POSITION 0x864B
192 /** \} */ // end of glextdefines group
194 void glAdjustAlignment(int stride
);
196 const char *glValName(GLint value
);
198 int glFindFormat(uint32_t format
, int *bpp
, GLint
*gl_texfmt
,
199 GLenum
*gl_format
, GLenum
*gl_type
);
200 int glFmt2bpp(GLenum format
, GLenum type
);
201 void glCreateClearTex(GLenum target
, GLenum fmt
, GLint filter
,
202 int w
, int h
, unsigned char val
);
203 int glCreatePPMTex(GLenum target
, GLenum fmt
, GLint filter
,
204 FILE *f
, int *width
, int *height
, int *maxval
);
205 void glUploadTex(GLenum target
, GLenum format
, GLenum type
,
206 const void *data
, int stride
,
207 int x
, int y
, int w
, int h
, int slice
);
208 void glDrawTex(GLfloat x
, GLfloat y
, GLfloat w
, GLfloat h
,
209 GLfloat tx
, GLfloat ty
, GLfloat tw
, GLfloat th
,
210 int sx
, int sy
, int rect_tex
, int is_yv12
, int flip
);
212 /** \addtogroup glconversion
214 //! do not use YUV conversion, this should always stay 0
215 #define YUV_CONVERSION_NONE 0
216 //! use nVidia specific register combiners for YUV conversion
217 #define YUV_CONVERSION_COMBINERS 1
218 //! use a fragment program for YUV conversion
219 #define YUV_CONVERSION_FRAGMENT 2
220 //! use a fragment program for YUV conversion with gamma using POW
221 #define YUV_CONVERSION_FRAGMENT_POW 3
222 //! use a fragment program with additional table lookup for YUV conversion
223 #define YUV_CONVERSION_FRAGMENT_LOOKUP 4
224 //! use ATI specific register combiners ("fragment program")
225 #define YUV_CONVERSION_COMBINERS_ATI 5
227 void glSetupYUVConversion(GLenum target
, int type
,
228 float brightness
, float contrast
,
229 float hue
, float saturation
,
230 float rgamma
, float ggamma
, float bgamma
);
231 void inline glEnableYUVConversion(GLenum target
, int type
);
232 void inline glDisableYUVConversion(GLenum target
, int type
);
234 /** \addtogroup glcontext
236 //! could not set new window, will continue drawing into the old one.
237 #define SET_WINDOW_FAILED -1
238 //! new window is set, could even transfer the OpenGL context.
239 #define SET_WINDOW_OK 0
240 //! new window is set, but the OpenGL context needs to be reinitialized.
241 #define SET_WINDOW_REINIT 1
245 #define vo_check_events() vo_w32_check_events()
246 #define vo_fullscreen() vo_w32_fullscreen()
247 #define vo_ontop() vo_w32_ontop()
248 #define vo_uninit() vo_w32_uninit()
249 int setGlWindow(int *vinfo
, HGLRC
*context
, HWND win
);
250 void releaseGlContext(int *vinfo
, HGLRC
*context
);
252 #define vo_check_events() vo_x11_check_events(mDisplay)
253 #define vo_fullscreen() vo_x11_fullscreen()
254 #define vo_ontop() vo_x11_ontop()
255 #define vo_uninit() vo_x11_uninit()
256 int setGlWindow(XVisualInfo
**vinfo
, GLXContext
*context
, Window win
);
257 void releaseGlContext(XVisualInfo
**vinfo
, GLXContext
*context
);
259 void swapGlBuffers(void);
261 extern void (APIENTRY
*GenBuffers
)(GLsizei
, GLuint
*);
262 extern void (APIENTRY
*DeleteBuffers
)(GLsizei
, const GLuint
*);
263 extern void (APIENTRY
*BindBuffer
)(GLenum
, GLuint
);
264 extern GLvoid
* (APIENTRY
*MapBuffer
)(GLenum
, GLenum
);
265 extern GLboolean (APIENTRY
*UnmapBuffer
)(GLenum
);
266 extern void (APIENTRY
*BufferData
)(GLenum
, intptr_t, const GLvoid
*, GLenum
);
267 extern void (APIENTRY
*CombinerParameterfv
)(GLenum
, const GLfloat
*);
268 extern void (APIENTRY
*CombinerParameteri
)(GLenum
, GLint
);
269 extern void (APIENTRY
*CombinerInput
)(GLenum
, GLenum
, GLenum
, GLenum
, GLenum
,
271 extern void (APIENTRY
*CombinerOutput
)(GLenum
, GLenum
, GLenum
, GLenum
, GLenum
,
272 GLenum
, GLenum
, GLboolean
, GLboolean
,
274 extern void (APIENTRY
*BeginFragmentShader
)(void);
275 extern void (APIENTRY
*EndFragmentShader
)(void);
276 extern void (APIENTRY
*SampleMap
)(GLuint
, GLuint
, GLenum
);
277 extern void (APIENTRY
*ColorFragmentOp2
)(GLenum
, GLuint
, GLuint
, GLuint
, GLuint
,
278 GLuint
, GLuint
, GLuint
, GLuint
, GLuint
);
279 extern void (APIENTRY
*ColorFragmentOp3
)(GLenum
, GLuint
, GLuint
, GLuint
, GLuint
,
280 GLuint
, GLuint
, GLuint
, GLuint
, GLuint
,
281 GLuint
, GLuint
, GLuint
);
282 extern void (APIENTRY
*SetFragmentShaderConstant
)(GLuint
, const GLfloat
*);
283 extern void (APIENTRY
*ActiveTexture
)(GLenum
);
284 extern void (APIENTRY
*BindTexture
)(GLenum
, GLuint
);
285 extern void (APIENTRY
*MultiTexCoord2f
)(GLenum
, GLfloat
, GLfloat
);
286 extern void (APIENTRY
*GenPrograms
)(GLsizei
, GLuint
*);
287 extern void (APIENTRY
*DeletePrograms
)(GLsizei
, const GLuint
*);
288 extern void (APIENTRY
*BindProgram
)(GLenum
, GLuint
);
289 extern void (APIENTRY
*ProgramString
)(GLenum
, GLenum
, GLsizei
, const GLvoid
*);
290 extern void (APIENTRY
*ProgramEnvParameter4f
)(GLenum
, GLuint
, GLfloat
, GLfloat
,
292 extern int (APIENTRY
*SwapInterval
)(int);