66 #else |
66 #else |
67 # define APIENTRY |
67 # define APIENTRY |
68 # define APIENTRYP * |
68 # define APIENTRYP * |
69 #endif |
69 #endif |
70 |
70 |
|
71 #ifndef QT_NO_EGL |
|
72 // Needed for EGLImageKHR definition: |
|
73 #include <QtGui/private/qegl_p.h> |
|
74 #endif |
|
75 |
71 #include <QtCore/qglobal.h> |
76 #include <QtCore/qglobal.h> |
72 |
77 |
73 #ifndef GL_ARB_vertex_buffer_object |
78 #ifndef GL_ARB_vertex_buffer_object |
|
79 typedef ptrdiff_t GLintptrARB; |
74 typedef ptrdiff_t GLsizeiptrARB; |
80 typedef ptrdiff_t GLsizeiptrARB; |
75 #endif |
81 #endif |
76 |
82 |
77 #ifndef GL_VERSION_2_0 |
83 #ifndef GL_VERSION_2_0 |
78 typedef char GLchar; |
84 typedef char GLchar; |
79 #endif |
85 #endif |
80 |
86 |
81 // ARB_pixel_buffer_object |
87 // ARB_vertex_buffer_object |
82 typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint); |
88 typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint); |
83 typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *); |
89 typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *); |
84 typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *); |
90 typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *); |
85 typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); |
91 typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); |
|
92 typedef void (APIENTRY *_glBufferSubData) (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); |
|
93 typedef void (APIENTRY *_glGetBufferSubData) (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); |
|
94 typedef void (APIENTRY *_glGetBufferParameteriv) (GLenum, GLenum, GLint *); |
86 typedef GLvoid* (APIENTRY *_glMapBufferARB) (GLenum, GLenum); |
95 typedef GLvoid* (APIENTRY *_glMapBufferARB) (GLenum, GLenum); |
87 typedef GLboolean (APIENTRY *_glUnmapBufferARB) (GLenum); |
96 typedef GLboolean (APIENTRY *_glUnmapBufferARB) (GLenum); |
|
97 // We can call the buffer functions directly in OpenGL/ES 1.1 or higher, |
|
98 // but all other platforms need to resolve the extensions. |
|
99 #if defined(QT_OPENGL_ES) |
|
100 #if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) |
|
101 #define QGL_RESOLVE_BUFFER_FUNCS 1 |
|
102 #endif |
|
103 #else |
|
104 #define QGL_RESOLVE_BUFFER_FUNCS 1 |
|
105 #endif |
88 |
106 |
89 // ARB_fragment_program |
107 // ARB_fragment_program |
90 typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); |
108 typedef void (APIENTRY *_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); |
91 typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); |
109 typedef void (APIENTRY *_glBindProgramARB) (GLenum, GLuint); |
92 typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); |
110 typedef void (APIENTRY *_glDeleteProgramsARB) (GLsizei, const GLuint *); |
182 |
200 |
183 // EXT_GL_framebuffer_multisample |
201 // EXT_GL_framebuffer_multisample |
184 typedef void (APIENTRY *_glRenderbufferStorageMultisampleEXT) (GLenum target, GLsizei samples, |
202 typedef void (APIENTRY *_glRenderbufferStorageMultisampleEXT) (GLenum target, GLsizei samples, |
185 GLenum internalformat, GLsizei width, GLsizei height); |
203 GLenum internalformat, GLsizei width, GLsizei height); |
186 |
204 |
|
205 // GL_EXT_geometry_shader4 |
|
206 typedef void (APIENTRY *_glProgramParameteriEXT)(GLuint program, GLenum pname, GLint value); |
|
207 typedef void (APIENTRY *_glFramebufferTextureEXT)(GLenum target, GLenum attachment, |
|
208 GLuint texture, GLint level); |
|
209 typedef void (APIENTRY *_glFramebufferTextureLayerEXT)(GLenum target, GLenum attachment, |
|
210 GLuint texture, GLint level, GLint layer); |
|
211 typedef void (APIENTRY *_glFramebufferTextureFaceEXT)(GLenum target, GLenum attachment, |
|
212 GLuint texture, GLint level, GLenum face); |
|
213 |
187 // ARB_texture_compression |
214 // ARB_texture_compression |
188 typedef void (APIENTRY *_glCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, |
215 typedef void (APIENTRY *_glCompressedTexImage2DARB) (GLenum, GLint, GLenum, GLsizei, |
189 GLsizei, GLint, GLsizei, const GLvoid *); |
216 GLsizei, GLint, GLsizei, const GLvoid *); |
|
217 |
|
218 #ifndef QT_NO_EGL |
|
219 // OES_EGL_image |
|
220 // Note: We define these to take EGLImage whereas spec says they take a new GLeglImageOES |
|
221 // type, which the EGL image should be cast to. |
|
222 typedef void (APIENTRY *_glEGLImageTargetTexture2DOES) (GLenum, EGLImageKHR); |
|
223 typedef void (APIENTRY *_glEGLImageTargetRenderbufferStorageOES) (GLenum, EGLImageKHR); |
|
224 #endif |
190 |
225 |
191 QT_BEGIN_NAMESPACE |
226 QT_BEGIN_NAMESPACE |
192 |
227 |
193 struct QGLExtensionFuncs |
228 struct QGLExtensionFuncs |
194 { |
229 { |
283 #endif |
318 #endif |
284 qt_glBlitFramebufferEXT = 0; |
319 qt_glBlitFramebufferEXT = 0; |
285 qt_glRenderbufferStorageMultisampleEXT = 0; |
320 qt_glRenderbufferStorageMultisampleEXT = 0; |
286 |
321 |
287 // Buffer objects: |
322 // Buffer objects: |
288 #if !defined(QT_OPENGL_ES_2) |
323 #if defined(QGL_RESOLVE_BUFFER_FUNCS) |
289 qt_glBindBuffer = 0; |
324 qt_glBindBuffer = 0; |
290 qt_glDeleteBuffers = 0; |
325 qt_glDeleteBuffers = 0; |
291 qt_glGenBuffers = 0; |
326 qt_glGenBuffers = 0; |
292 qt_glBufferData = 0; |
327 qt_glBufferData = 0; |
|
328 qt_glBufferSubData = 0; |
|
329 qt_glGetBufferSubData = 0; |
|
330 qt_glGetBufferParameteriv = 0; |
293 #endif |
331 #endif |
294 qt_glMapBufferARB = 0; |
332 qt_glMapBufferARB = 0; |
295 qt_glUnmapBufferARB = 0; |
333 qt_glUnmapBufferARB = 0; |
296 |
334 |
|
335 qt_glProgramParameteriEXT = 0; |
|
336 qt_glFramebufferTextureEXT = 0; |
|
337 qt_glFramebufferTextureLayerEXT = 0; |
|
338 qt_glFramebufferTextureFaceEXT = 0; |
297 #if !defined(QT_OPENGL_ES) |
339 #if !defined(QT_OPENGL_ES) |
298 // Texture compression |
340 // Texture compression |
299 qt_glCompressedTexImage2DARB = 0; |
341 qt_glCompressedTexImage2DARB = 0; |
|
342 #endif |
|
343 |
|
344 #ifndef QT_NO_EGL |
|
345 // OES_EGL_image |
|
346 qt_glEGLImageTargetTexture2DOES = 0; |
|
347 qt_glEGLImageTargetRenderbufferStorageOES = 0; |
300 #endif |
348 #endif |
301 } |
349 } |
302 |
350 |
303 |
351 |
304 #if !defined(QT_OPENGL_ES_2) |
352 #if !defined(QT_OPENGL_ES_2) |
395 #endif |
443 #endif |
396 _glBlitFramebufferEXT qt_glBlitFramebufferEXT; |
444 _glBlitFramebufferEXT qt_glBlitFramebufferEXT; |
397 _glRenderbufferStorageMultisampleEXT qt_glRenderbufferStorageMultisampleEXT; |
445 _glRenderbufferStorageMultisampleEXT qt_glRenderbufferStorageMultisampleEXT; |
398 |
446 |
399 // Buffer objects |
447 // Buffer objects |
400 #if !defined(QT_OPENGL_ES_2) |
448 #if defined(QGL_RESOLVE_BUFFER_FUNCS) |
401 _glBindBuffer qt_glBindBuffer; |
449 _glBindBuffer qt_glBindBuffer; |
402 _glDeleteBuffers qt_glDeleteBuffers; |
450 _glDeleteBuffers qt_glDeleteBuffers; |
403 _glGenBuffers qt_glGenBuffers; |
451 _glGenBuffers qt_glGenBuffers; |
404 _glBufferData qt_glBufferData; |
452 _glBufferData qt_glBufferData; |
|
453 _glBufferSubData qt_glBufferSubData; |
|
454 _glGetBufferSubData qt_glGetBufferSubData; |
|
455 _glGetBufferParameteriv qt_glGetBufferParameteriv; |
405 #endif |
456 #endif |
406 _glMapBufferARB qt_glMapBufferARB; |
457 _glMapBufferARB qt_glMapBufferARB; |
407 _glUnmapBufferARB qt_glUnmapBufferARB; |
458 _glUnmapBufferARB qt_glUnmapBufferARB; |
408 |
459 |
|
460 // Geometry shaders... |
|
461 _glProgramParameteriEXT qt_glProgramParameteriEXT; |
|
462 _glFramebufferTextureEXT qt_glFramebufferTextureEXT; |
|
463 _glFramebufferTextureLayerEXT qt_glFramebufferTextureLayerEXT; |
|
464 _glFramebufferTextureFaceEXT qt_glFramebufferTextureFaceEXT; |
409 #if !defined(QT_OPENGL_ES) |
465 #if !defined(QT_OPENGL_ES) |
410 // Texture compression |
466 // Texture compression |
411 _glCompressedTexImage2DARB qt_glCompressedTexImage2DARB; |
467 _glCompressedTexImage2DARB qt_glCompressedTexImage2DARB; |
412 #endif |
468 #endif |
|
469 |
|
470 #ifndef QT_NO_EGL |
|
471 // OES_EGL_image |
|
472 _glEGLImageTargetTexture2DOES qt_glEGLImageTargetTexture2DOES; |
|
473 _glEGLImageTargetRenderbufferStorageOES qt_glEGLImageTargetRenderbufferStorageOES; |
|
474 #endif |
|
475 |
413 }; |
476 }; |
414 |
477 |
415 |
478 |
416 // OpenGL constants |
479 // OpenGL constants |
|
480 |
|
481 #ifndef GL_ARRAY_BUFFER |
|
482 #define GL_ARRAY_BUFFER 0x8892 |
|
483 #endif |
|
484 |
|
485 #ifndef GL_STATIC_DRAW |
|
486 #define GL_STATIC_DRAW 0x88E4 |
|
487 #endif |
417 |
488 |
418 /* NV_texture_rectangle */ |
489 /* NV_texture_rectangle */ |
419 #ifndef GL_NV_texture_rectangle |
490 #ifndef GL_NV_texture_rectangle |
420 #define GL_TEXTURE_RECTANGLE_NV 0x84F5 |
491 #define GL_TEXTURE_RECTANGLE_NV 0x84F5 |
421 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 |
492 #define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 |
597 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 |
668 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 |
598 #define GL_INCR_WRAP 0x8507 |
669 #define GL_INCR_WRAP 0x8507 |
599 #define GL_DECR_WRAP 0x8508 |
670 #define GL_DECR_WRAP 0x8508 |
600 #endif |
671 #endif |
601 |
672 |
|
673 #ifndef GL_VERSION_1_5 |
|
674 #define GL_ARRAY_BUFFER 0x8892 |
|
675 #define GL_ELEMENT_ARRAY_BUFFER 0x8893 |
|
676 #define GL_STREAM_DRAW 0x88E0 |
|
677 #define GL_STREAM_READ 0x88E1 |
|
678 #define GL_STREAM_COPY 0x88E2 |
|
679 #define GL_STATIC_DRAW 0x88E4 |
|
680 #define GL_STATIC_READ 0x88E5 |
|
681 #define GL_STATIC_COPY 0x88E6 |
|
682 #define GL_DYNAMIC_DRAW 0x88E8 |
|
683 #define GL_DYNAMIC_READ 0x88E9 |
|
684 #define GL_DYNAMIC_COPY 0x88EA |
|
685 #endif |
|
686 |
602 #ifndef GL_VERSION_2_0 |
687 #ifndef GL_VERSION_2_0 |
603 #define GL_FRAGMENT_SHADER 0x8B30 |
688 #define GL_FRAGMENT_SHADER 0x8B30 |
604 #define GL_VERTEX_SHADER 0x8B31 |
689 #define GL_VERTEX_SHADER 0x8B31 |
605 #define GL_FLOAT_VEC2 0x8B50 |
690 #define GL_FLOAT_VEC2 0x8B50 |
606 #define GL_FLOAT_VEC3 0x8B51 |
691 #define GL_FLOAT_VEC3 0x8B51 |
626 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 |
711 #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 |
627 #define GL_ACTIVE_ATTRIBUTES 0x8B89 |
712 #define GL_ACTIVE_ATTRIBUTES 0x8B89 |
628 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A |
713 #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A |
629 #endif |
714 #endif |
630 |
715 |
|
716 // Geometry shader defines |
|
717 #ifndef GL_GEOMETRY_SHADER_EXT |
|
718 # define GL_GEOMETRY_SHADER_EXT 0x8DD9 |
|
719 # define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA |
|
720 # define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB |
|
721 # define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC |
|
722 # define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 |
|
723 # define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD |
|
724 # define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE |
|
725 # define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B |
|
726 # define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF |
|
727 # define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 |
|
728 # define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 |
|
729 # define GL_LINES_ADJACENCY_EXT 0xA |
|
730 # define GL_LINE_STRIP_ADJACENCY_EXT 0xB |
|
731 # define GL_TRIANGLES_ADJACENCY_EXT 0xC |
|
732 # define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD |
|
733 # define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 |
|
734 # define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 |
|
735 # define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 |
|
736 # define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 |
|
737 # define GL_PROGRAM_POINT_SIZE_EXT 0x8642 |
|
738 #endif |
631 |
739 |
632 #if !defined(QT_OPENGL_ES_2) |
740 #if !defined(QT_OPENGL_ES_2) |
633 #define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB |
741 #define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB |
634 #define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB |
742 #define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB |
635 #define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB |
743 #define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB |
665 #define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT |
773 #define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT |
666 #define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT |
774 #define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT |
667 |
775 |
668 |
776 |
669 // Buffer objects |
777 // Buffer objects |
670 #if !defined(QT_OPENGL_ES_2) |
778 #if defined(QGL_RESOLVE_BUFFER_FUNCS) |
671 #define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer |
779 #define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer |
672 #define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers |
780 #define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers |
673 #define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers |
781 #define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers |
674 #define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData |
782 #define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData |
|
783 #define glBufferSubData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferSubData |
|
784 #define glGetBufferSubData QGLContextPrivate::extensionFuncs(ctx).qt_glGetBufferSubData |
|
785 #define glGetBufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetBufferParameteriv |
675 #endif |
786 #endif |
676 #define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB |
787 #define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB |
677 #define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB |
788 #define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB |
678 |
789 |
679 |
790 |
743 |
854 |
744 #if defined(QT_OPENGL_ES_2) |
855 #if defined(QT_OPENGL_ES_2) |
745 #define glClearDepth glClearDepthf |
856 #define glClearDepth glClearDepthf |
746 #endif |
857 #endif |
747 |
858 |
|
859 #define glProgramParameteriEXT QGLContextPrivate::extensionFuncs(ctx).qt_glProgramParameteriEXT |
|
860 #define glFramebufferTextureEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureEXT |
|
861 #define glFramebufferTextureLayerEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureLayerEXT |
|
862 #define glFramebufferTextureFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTextureFaceEXT |
|
863 |
748 #if !defined(QT_OPENGL_ES) |
864 #if !defined(QT_OPENGL_ES) |
749 #define glCompressedTexImage2D QGLContextPrivate::extensionFuncs(ctx).qt_glCompressedTexImage2DARB |
865 #define glCompressedTexImage2D QGLContextPrivate::extensionFuncs(ctx).qt_glCompressedTexImage2DARB |
|
866 #endif |
|
867 |
|
868 #ifndef QT_NO_EGL |
|
869 // OES_EGL_image |
|
870 #define glEGLImageTargetTexture2DOES QGLContextPrivate::extensionFuncs(ctx).qt_glEGLImageTargetTexture2DOES |
|
871 #define glEGLImageTargetRenderbufferStorageOES QGLContextPrivate::extensionFuncs(ctx).qt_glEGLImageTargetRenderbufferStorageOES |
750 #endif |
872 #endif |
751 |
873 |
752 extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx); |
874 extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx); |
753 bool qt_resolve_buffer_extensions(QGLContext *ctx); |
875 bool qt_resolve_buffer_extensions(QGLContext *ctx); |
754 |
876 |