4 * GL-based support functions
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_glutil_H
20 #define lxdream_glutil_H
30 * Test if a specific extension is supported. From opengl.org
31 * @param extension extension name to check for
32 * @return TRUE if supported, otherwise FALSE.
34 gboolean isGLExtensionSupported( const char *extension );
37 * Dump GL information to the output stream, usually for debugging purposes
39 void glPrintInfo( FILE *out );
42 * Check for a GL error and print a message if there is one
43 * @param context If not null, a string to be printed along side an error message
44 * @return FALSE if there was an error, otherwise TRUE
46 gboolean gl_check_error( const char *context );
48 * Test if secondary color (GL_COLOR_SUM) is supported.
50 gboolean isGLSecondaryColorSupported();
52 gboolean isGLVertexBufferSupported();
53 gboolean isGLVertexRangeSupported();
54 gboolean isGLPixelBufferSupported();
55 gboolean isGLMultitextureSupported();
56 gboolean isGLMirroredTextureSupported();
57 GLint glGetMaxColourAttachments();
59 /****** Extension variant wrangling *****/
61 #if defined(GL_MIRRORED_REPEAT_ARB) && !defined(GL_MIRRORED_REPEAT)
62 #define GL_MIRRORED_REPEAT GL_MIRRORED_REPEAT_ARB
65 #if defined(GL_MAX_TEXTURE_UNITS_ARB) && !defined(GL_MAX_TEXTURE_UNITS)
66 #define GL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS_ARB
69 #if defined(GL_FRAMEBUFFER_EXT) && !defined(GL_FRAMEBUFFER)
70 #define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
73 #if defined(GL_RENDERBUFFER_EXT) && !defined(GL_RENDERBUFFER)
74 #define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
77 #if defined(GL_COLOR_ATTACHMENT0_EXT) && !defined(GL_COLOR_ATTACHMENT0)
78 #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
81 #if defined(GL_MAX_COLOR_ATTACHMENTS_EXT) && !defined(GL_MAX_COLOR_ATTACHMENTS)
82 #define GL_MAX_COLOR_ATTACHMENTS GL_MAX_COLOR_ATTACHMENTS_EXT
85 #if defined(GL_STENCIL_ATTACHMENT_EXT) && !defined(GL_STENCIL_ATTACHMENT)
86 #define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
89 #if defined(GL_DEPTH_ATTACHMENT_EXT) && !defined(GL_DEPTH_ATTACHMENT)
90 #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
93 #if defined(GL_DEPTH_COMPONENT24_OES) && !defined(GL_DEPTH_COMPONENT24)
94 #define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
97 #ifndef GL_DEPTH24_STENCIL8
98 #if defined(GL_DEPTH24_STENCIL8_EXT)
99 #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
100 #elif defined(GL_DEPTH24_STENCIL8_OES)
101 #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
105 #if defined(GL_FRAMEBUFFER_COMPLETE_EXT) && !defined(GL_FRAMEBUFFER_COMPLETE)
106 #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
109 #if defined(HAVE_OPENGL_FBO_EXT) && !defined(HAVE_OPENGL_FBO)
110 #define glGenFramebuffers glGenFramebuffersEXT
111 #define glGenRenderbuffers glGenRenderbuffersEXT
112 #define glBindFramebuffer glBindFramebufferEXT
113 #define glDeleteFramebuffers glDeleteFramebuffersEXT
114 #define glDeleteRenderbuffers glDeleteRenderbuffersEXT
115 #define glBindFramebuffer glBindFramebufferEXT
116 #define glBindRenderbuffer glBindRenderbufferEXT
117 #define glRenderbufferStorage glRenderbufferStorageEXT
118 #define glFramebufferRenderbuffer glFramebufferRenderbufferEXT
119 #define glFramebufferTexture2D glFramebufferTexture2DEXT
120 #define glCheckFramebufferStatus glCheckFramebufferStatusEXT
124 /****** Shader handling (gl_sl.c) *****/
125 gboolean glsl_is_supported(void);
126 const char *glsl_get_version(void);
127 gboolean glsl_load_shaders( );
128 void glsl_unload_shaders(void);
129 void glsl_clear_shader();
131 /* Define an orthographic transform matrix, given the bounding box (assuming origin at 0) */
132 void defineOrthoMatrix( GLfloat *matrix, GLfloat width, GLfloat height, GLfloat znear, GLfloat zfar );
134 /* Convenience formatting function for driver use */
135 void fprint_extensions( FILE *out, const char *extensions );
141 #endif /* !lxdream_glutil_H */
.