Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / libvo / gl_common.h
bloba2e74671933899faf867a4f94bb8221af9e22071
1 #ifndef GL_COMMON_H
2 #define GL_COMMON_H
4 #include "mp_msg.h"
5 #include "config.h"
7 #include <GL/gl.h>
8 #include "video_out.h"
10 #ifdef GL_WIN32
11 #include <windows.h>
12 #include <GL/glext.h>
13 #include "w32_common.h"
14 #else
15 #include <X11/Xlib.h>
16 #include <GL/glx.h>
17 #include "x11_common.h"
18 #endif
20 // workaround for some gl.h headers
21 #ifndef APIENTRY
22 #ifdef GLAPIENTRY
23 #define APIENTRY GLAPIENTRY
24 #elif defined(GL_WIN32)
25 #define APIENTRY __stdcall
26 #else
27 #define APIENTRY
28 #endif
29 #endif
31 /**
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.
37 * \{
39 #ifndef GL_REGISTER_COMBINERS_NV
40 #define GL_REGISTER_COMBINERS_NV 0x8522
41 #endif
42 #ifndef GL_MAX_GENERAL_COMBINERS_NV
43 #define GL_MAX_GENERAL_COMBINERS_NV 0x854D
44 #endif
45 #ifndef GL_NUM_GENERAL_COMBINERS_NV
46 #define GL_NUM_GENERAL_COMBINERS_NV 0x854E
47 #endif
48 #ifndef GL_CONSTANT_COLOR0_NV
49 #define GL_CONSTANT_COLOR0_NV 0x852A
50 #endif
51 #ifndef GL_CONSTANT_COLOR1_NV
52 #define GL_CONSTANT_COLOR1_NV 0x852B
53 #endif
54 #ifndef GL_COMBINER0_NV
55 #define GL_COMBINER0_NV 0x8550
56 #endif
57 #ifndef GL_COMBINER1_NV
58 #define GL_COMBINER1_NV 0x8551
59 #endif
60 #ifndef GL_VARIABLE_A_NV
61 #define GL_VARIABLE_A_NV 0x8523
62 #endif
63 #ifndef GL_VARIABLE_B_NV
64 #define GL_VARIABLE_B_NV 0x8524
65 #endif
66 #ifndef GL_VARIABLE_C_NV
67 #define GL_VARIABLE_C_NV 0x8525
68 #endif
69 #ifndef GL_VARIABLE_D_NV
70 #define GL_VARIABLE_D_NV 0x8526
71 #endif
72 #ifndef GL_UNSIGNED_INVERT_NV
73 #define GL_UNSIGNED_INVERT_NV 0x8537
74 #endif
75 #ifndef GL_HALF_BIAS_NORMAL_NV
76 #define GL_HALF_BIAS_NORMAL_NV 0x853A
77 #endif
78 #ifndef GL_SIGNED_IDENTITY_NV
79 #define GL_SIGNED_IDENTITY_NV 0x853C
80 #endif
81 #ifndef GL_SCALE_BY_FOUR_NV
82 #define GL_SCALE_BY_FOUR_NV 0x853F
83 #endif
84 #ifndef GL_DISCARD_NV
85 #define GL_DISCARD_NV 0x8530
86 #endif
87 #ifndef GL_SPARE0_NV
88 #define GL_SPARE0_NV 0x852E
89 #endif
90 #ifndef GL_FRAGMENT_SHADER_ATI
91 #define GL_FRAGMENT_SHADER_ATI 0x8920
92 #endif
93 #ifndef GL_NUM_FRAGMENT_REGISTERS_ATI
94 #define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
95 #endif
96 #ifndef GL_REG_0_ATI
97 #define GL_REG_0_ATI 0x8921
98 #endif
99 #ifndef GL_REG_1_ATI
100 #define GL_REG_1_ATI 0x8922
101 #endif
102 #ifndef GL_REG_2_ATI
103 #define GL_REG_2_ATI 0x8923
104 #endif
105 #ifndef GL_CON_0_ATI
106 #define GL_CON_0_ATI 0x8941
107 #endif
108 #ifndef GL_CON_1_ATI
109 #define GL_CON_1_ATI 0x8942
110 #endif
111 #ifndef GL_ADD_ATI
112 #define GL_ADD_ATI 0x8963
113 #endif
114 #ifndef GL_MUL_ATI
115 #define GL_MUL_ATI 0x8964
116 #endif
117 #ifndef GL_MAD_ATI
118 #define GL_MAD_ATI 0x8968
119 #endif
120 #ifndef GL_SWIZZLE_STR_ATI
121 #define GL_SWIZZLE_STR_ATI 0x8976
122 #endif
123 #ifndef GL_4X_BIT_ATI
124 #define GL_4X_BIT_ATI 2
125 #endif
126 #ifndef GL_BIAS_BIT_ATI
127 #define GL_BIAS_BIT_ATI 8
128 #endif
129 #ifndef GL_MAX_TEXTURE_UNITS
130 #define GL_MAX_TEXTURE_UNITS 0x84E2
131 #endif
132 #ifndef GL_TEXTURE0
133 #define GL_TEXTURE0 0x84C0
134 #endif
135 #ifndef GL_TEXTURE1
136 #define GL_TEXTURE1 0x84C1
137 #endif
138 #ifndef GL_TEXTURE2
139 #define GL_TEXTURE2 0x84C2
140 #endif
141 #ifndef GL_TEXTURE3
142 #define GL_TEXTURE3 0x84C3
143 #endif
144 #ifndef GL_TEXTURE_RECTANGLE
145 #define GL_TEXTURE_RECTANGLE 0x84F5
146 #endif
147 #ifndef GL_PIXEL_UNPACK_BUFFER
148 #define GL_PIXEL_UNPACK_BUFFER 0x88EC
149 #endif
150 #ifndef GL_STREAM_DRAW
151 #define GL_STREAM_DRAW 0x88E0
152 #endif
153 #ifndef GL_DYNAMIC_DRAW
154 #define GL_DYNAMIC_DRAW 0x88E8
155 #endif
156 #ifndef GL_WRITE_ONLY
157 #define GL_WRITE_ONLY 0x88B9
158 #endif
159 #ifndef GL_BGR
160 #define GL_BGR 0x80E0
161 #endif
162 #ifndef GL_BGRA
163 #define GL_BGRA 0x80E1
164 #endif
165 #ifndef GL_UNSIGNED_BYTE_3_3_2
166 #define GL_UNSIGNED_BYTE_3_3_2 0x8032
167 #endif
168 #ifndef GL_UNSIGNED_BYTE_2_3_3_REV
169 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
170 #endif
171 #ifndef GL_UNSIGNED_SHORT_5_6_5
172 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
173 #endif
174 #ifndef GL_UNSIGNED_SHORT_5_6_5_REV
175 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
176 #endif
177 #ifndef GL_UNSIGNED_SHORT_5_5_5_1
178 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
179 #endif
180 #ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV
181 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
182 #endif
183 #ifndef GL_RGB32F
184 #define GL_RGB32F 0x8815
185 #endif
186 #ifndef GL_FLOAT_RGB32_NV
187 #define GL_FLOAT_RGB32_NV 0x8889
188 #endif
189 #ifndef GL_FRAGMENT_PROGRAM
190 #define GL_FRAGMENT_PROGRAM 0x8804
191 #endif
192 #ifndef GL_PROGRAM_FORMAT_ASCII
193 #define GL_PROGRAM_FORMAT_ASCII 0x8875
194 #endif
195 #ifndef GL_PROGRAM_ERROR_POSITION
196 #define GL_PROGRAM_ERROR_POSITION 0x864B
197 #endif
198 #ifndef GL_PROGRAM_ERROR_STRING
199 #define GL_PROGRAM_ERROR_STRING 0x8874
200 #endif
201 /** \} */ // end of glextdefines group
203 void glAdjustAlignment(int stride);
205 const char *glValName(GLint value);
207 int glFindFormat(uint32_t format, int *bpp, GLint *gl_texfmt,
208 GLenum *gl_format, GLenum *gl_type);
209 int glFmt2bpp(GLenum format, GLenum type);
210 void glCreateClearTex(GLenum target, GLenum fmt, GLint filter,
211 int w, int h, unsigned char val);
212 int glCreatePPMTex(GLenum target, GLenum fmt, GLint filter,
213 FILE *f, int *width, int *height, int *maxval);
214 void glUploadTex(GLenum target, GLenum format, GLenum type,
215 const void *dataptr, int stride,
216 int x, int y, int w, int h, int slice);
217 void glDrawTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
218 GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th,
219 int sx, int sy, int rect_tex, int is_yv12, int flip);
220 int loadGPUProgram(GLenum target, char *prog);
222 /** \addtogroup glconversion
223 * \{ */
224 //! do not use YUV conversion, this should always stay 0
225 #define YUV_CONVERSION_NONE 0
226 //! use nVidia specific register combiners for YUV conversion
227 #define YUV_CONVERSION_COMBINERS 1
228 //! use a fragment program for YUV conversion
229 #define YUV_CONVERSION_FRAGMENT 2
230 //! use a fragment program for YUV conversion with gamma using POW
231 #define YUV_CONVERSION_FRAGMENT_POW 3
232 //! use a fragment program with additional table lookup for YUV conversion
233 #define YUV_CONVERSION_FRAGMENT_LOOKUP 4
234 //! use ATI specific register combiners ("fragment program")
235 #define YUV_CONVERSION_COMBINERS_ATI 5
236 //! use a fragment program with 3D table lookup for YUV conversion
237 #define YUV_CONVERSION_FRAGMENT_LOOKUP3D 6
238 //! use normal bilinear scaling for textures
239 #define YUV_SCALER_BILIN 0
240 //! use higher quality bicubic scaling for textures
241 #define YUV_SCALER_BICUB 1
242 //! use cubic scaling in X and normal linear scaling in Y direction
243 #define YUV_SCALER_BICUB_X 2
244 //! use cubic scaling without additional lookup texture
245 #define YUV_SCALER_BICUB_NOTEX 3
246 //! mask for conversion type
247 #define YUV_CONVERSION_MASK 0xF
248 //! mask for scaler type
249 #define YUV_SCALER_MASK 0xF
250 //! shift value for luminance scaler type
251 #define YUV_LUM_SCALER_SHIFT 8
252 //! shift value for chrominance scaler type
253 #define YUV_CHROM_SCALER_SHIFT 12
254 //! extract conversion out of type
255 #define YUV_CONVERSION(t) (t & YUV_CONVERSION_MASK)
256 //! extract luminance scaler out of type
257 #define YUV_LUM_SCALER(t) ((t >> YUV_LUM_SCALER_SHIFT) & YUV_SCALER_MASK)
258 //! extract chrominance scaler out of type
259 #define YUV_CHROM_SCALER(t) ((t >> YUV_CHROM_SCALER_SHIFT) & YUV_SCALER_MASK)
260 /** \} */
261 void glSetupYUVConversion(GLenum target, int type,
262 float brightness, float contrast,
263 float hue, float saturation,
264 float rgamma, float ggamma, float bgamma,
265 int texw, int texh);
266 void glEnableYUVConversion(GLenum target, int type);
267 void glDisableYUVConversion(GLenum target, int type);
269 /** \addtogroup glcontext
270 * \{ */
271 //! could not set new window, will continue drawing into the old one.
272 #define SET_WINDOW_FAILED -1
273 //! new window is set, could even transfer the OpenGL context.
274 #define SET_WINDOW_OK 0
275 //! new window is set, but the OpenGL context needs to be reinitialized.
276 #define SET_WINDOW_REINIT 1
277 /** \} */
279 #ifdef GL_WIN32
280 #define vo_check_events() vo_w32_check_events()
281 #define vo_fullscreen() vo_w32_fullscreen()
282 #define vo_ontop() vo_w32_ontop()
283 #define vo_uninit() vo_w32_uninit()
284 int setGlWindow(int *vinfo, HGLRC *context, HWND win);
285 void releaseGlContext(int *vinfo, HGLRC *context);
286 #else
287 #define vo_check_events() vo_x11_check_events(mDisplay)
288 #define vo_fullscreen() vo_x11_fullscreen()
289 #define vo_ontop() vo_x11_ontop()
290 #define vo_uninit() vo_x11_uninit()
291 int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win);
292 void releaseGlContext(XVisualInfo **vinfo, GLXContext *context);
293 #endif
294 void swapGlBuffers(void);
296 extern void (APIENTRY *GenBuffers)(GLsizei, GLuint *);
297 extern void (APIENTRY *DeleteBuffers)(GLsizei, const GLuint *);
298 extern void (APIENTRY *BindBuffer)(GLenum, GLuint);
299 extern GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum);
300 extern GLboolean (APIENTRY *UnmapBuffer)(GLenum);
301 extern void (APIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
302 extern void (APIENTRY *CombinerParameterfv)(GLenum, const GLfloat *);
303 extern void (APIENTRY *CombinerParameteri)(GLenum, GLint);
304 extern void (APIENTRY *CombinerInput)(GLenum, GLenum, GLenum, GLenum, GLenum,
305 GLenum);
306 extern void (APIENTRY *CombinerOutput)(GLenum, GLenum, GLenum, GLenum, GLenum,
307 GLenum, GLenum, GLboolean, GLboolean,
308 GLboolean);
309 extern void (APIENTRY *BeginFragmentShader)(void);
310 extern void (APIENTRY *EndFragmentShader)(void);
311 extern void (APIENTRY *SampleMap)(GLuint, GLuint, GLenum);
312 extern void (APIENTRY *ColorFragmentOp2)(GLenum, GLuint, GLuint, GLuint, GLuint,
313 GLuint, GLuint, GLuint, GLuint, GLuint);
314 extern void (APIENTRY *ColorFragmentOp3)(GLenum, GLuint, GLuint, GLuint, GLuint,
315 GLuint, GLuint, GLuint, GLuint, GLuint,
316 GLuint, GLuint, GLuint);
317 extern void (APIENTRY *SetFragmentShaderConstant)(GLuint, const GLfloat *);
318 extern void (APIENTRY *ActiveTexture)(GLenum);
319 extern void (APIENTRY *BindTexture)(GLenum, GLuint);
320 extern void (APIENTRY *MultiTexCoord2f)(GLenum, GLfloat, GLfloat);
321 extern void (APIENTRY *GenPrograms)(GLsizei, GLuint *);
322 extern void (APIENTRY *DeletePrograms)(GLsizei, const GLuint *);
323 extern void (APIENTRY *BindProgram)(GLenum, GLuint);
324 extern void (APIENTRY *ProgramString)(GLenum, GLenum, GLsizei, const GLvoid *);
325 extern void (APIENTRY *ProgramEnvParameter4f)(GLenum, GLuint, GLfloat, GLfloat,
326 GLfloat, GLfloat);
327 extern int (APIENTRY *SwapInterval)(int);
328 extern void (APIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei,
329 GLsizei, GLint, GLenum, GLenum, const GLvoid *);
331 #endif /* GL_COMMON_H */