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