nkeynes@635 | 1 | /**
|
nkeynes@636 | 2 | * $Id$
|
nkeynes@635 | 3 | *
|
nkeynes@635 | 4 | * GL-based support functions
|
nkeynes@635 | 5 | *
|
nkeynes@635 | 6 | * Copyright (c) 2005 Nathan Keynes.
|
nkeynes@635 | 7 | *
|
nkeynes@635 | 8 | * This program is free software; you can redistribute it and/or modify
|
nkeynes@635 | 9 | * it under the terms of the GNU General Public License as published by
|
nkeynes@635 | 10 | * the Free Software Foundation; either version 2 of the License, or
|
nkeynes@635 | 11 | * (at your option) any later version.
|
nkeynes@635 | 12 | *
|
nkeynes@635 | 13 | * This program is distributed in the hope that it will be useful,
|
nkeynes@635 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nkeynes@635 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nkeynes@635 | 16 | * GNU General Public License for more details.
|
nkeynes@635 | 17 | */
|
nkeynes@635 | 18 |
|
nkeynes@635 | 19 | #ifndef lxdream_glutil_H
|
nkeynes@635 | 20 | #define lxdream_glutil_H
|
nkeynes@635 | 21 |
|
nkeynes@687 | 22 | #include <stdio.h>
|
nkeynes@635 | 23 | #include "display.h"
|
nkeynes@635 | 24 |
|
nkeynes@736 | 25 | #ifdef __cplusplus
|
nkeynes@736 | 26 | extern "C" {
|
nkeynes@736 | 27 | #endif
|
nkeynes@736 | 28 |
|
nkeynes@635 | 29 | /**
|
nkeynes@635 | 30 | * Test if a specific extension is supported. From opengl.org
|
nkeynes@635 | 31 | * @param extension extension name to check for
|
nkeynes@635 | 32 | * @return TRUE if supported, otherwise FALSE.
|
nkeynes@635 | 33 | */
|
nkeynes@635 | 34 | gboolean isGLExtensionSupported( const char *extension );
|
nkeynes@635 | 35 |
|
nkeynes@1245 | 36 | gboolean isOpenGLES2();
|
nkeynes@1245 | 37 |
|
nkeynes@667 | 38 | /**
|
nkeynes@687 | 39 | * Dump GL information to the output stream, usually for debugging purposes
|
nkeynes@687 | 40 | */
|
nkeynes@687 | 41 | void glPrintInfo( FILE *out );
|
nkeynes@687 | 42 |
|
nkeynes@687 | 43 | /**
|
nkeynes@1150 | 44 | * Check for a GL error and print a message if there is one
|
nkeynes@1150 | 45 | * @param context If not null, a string to be printed along side an error message
|
nkeynes@1159 | 46 | * @return FALSE if there was an error, otherwise TRUE
|
nkeynes@1150 | 47 | */
|
nkeynes@1150 | 48 | gboolean gl_check_error( const char *context );
|
nkeynes@1150 | 49 | /**
|
nkeynes@667 | 50 | * Test if secondary color (GL_COLOR_SUM) is supported.
|
nkeynes@667 | 51 | */
|
nkeynes@667 | 52 | gboolean isGLSecondaryColorSupported();
|
nkeynes@667 | 53 |
|
nkeynes@667 | 54 | gboolean isGLVertexBufferSupported();
|
nkeynes@1134 | 55 | gboolean isGLVertexRangeSupported();
|
nkeynes@667 | 56 | gboolean isGLPixelBufferSupported();
|
nkeynes@1140 | 57 | gboolean isGLMultitextureSupported();
|
nkeynes@667 | 58 | gboolean isGLMirroredTextureSupported();
|
nkeynes@1223 | 59 | GLint glGetMaxColourAttachments();
|
nkeynes@635 | 60 |
|
nkeynes@1207 | 61 | /****** Extension variant wrangling *****/
|
nkeynes@1207 | 62 |
|
nkeynes@1210 | 63 | #if defined(GL_MIRRORED_REPEAT_ARB) && !defined(GL_MIRRORED_REPEAT)
|
nkeynes@1210 | 64 | #define GL_MIRRORED_REPEAT GL_MIRRORED_REPEAT_ARB
|
nkeynes@1210 | 65 | #endif
|
nkeynes@1207 | 66 |
|
nkeynes@1219 | 67 | #if defined(GL_MAX_TEXTURE_UNITS_ARB) && !defined(GL_MAX_TEXTURE_UNITS)
|
nkeynes@1219 | 68 | #define GL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS_ARB
|
nkeynes@1219 | 69 | #endif
|
nkeynes@1219 | 70 |
|
nkeynes@1210 | 71 | #if defined(GL_FRAMEBUFFER_EXT) && !defined(GL_FRAMEBUFFER)
|
nkeynes@1210 | 72 | #define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
nkeynes@1210 | 73 | #endif
|
nkeynes@1210 | 74 |
|
nkeynes@1210 | 75 | #if defined(GL_RENDERBUFFER_EXT) && !defined(GL_RENDERBUFFER)
|
nkeynes@1210 | 76 | #define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
nkeynes@1210 | 77 | #endif
|
nkeynes@1210 | 78 |
|
nkeynes@1210 | 79 | #if defined(GL_COLOR_ATTACHMENT0_EXT) && !defined(GL_COLOR_ATTACHMENT0)
|
nkeynes@1210 | 80 | #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
nkeynes@1210 | 81 | #endif
|
nkeynes@1210 | 82 |
|
nkeynes@1210 | 83 | #if defined(GL_MAX_COLOR_ATTACHMENTS_EXT) && !defined(GL_MAX_COLOR_ATTACHMENTS)
|
nkeynes@1210 | 84 | #define GL_MAX_COLOR_ATTACHMENTS GL_MAX_COLOR_ATTACHMENTS_EXT
|
nkeynes@1210 | 85 | #endif
|
nkeynes@1210 | 86 |
|
nkeynes@1210 | 87 | #if defined(GL_STENCIL_ATTACHMENT_EXT) && !defined(GL_STENCIL_ATTACHMENT)
|
nkeynes@1210 | 88 | #define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
nkeynes@1210 | 89 | #endif
|
nkeynes@1210 | 90 |
|
nkeynes@1210 | 91 | #if defined(GL_DEPTH_ATTACHMENT_EXT) && !defined(GL_DEPTH_ATTACHMENT)
|
nkeynes@1210 | 92 | #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
nkeynes@1210 | 93 | #endif
|
nkeynes@1210 | 94 |
|
nkeynes@1223 | 95 | #if defined(GL_DEPTH_COMPONENT24_OES) && !defined(GL_DEPTH_COMPONENT24)
|
nkeynes@1223 | 96 | #define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
|
nkeynes@1223 | 97 | #endif
|
nkeynes@1223 | 98 |
|
nkeynes@1222 | 99 | #ifndef GL_DEPTH24_STENCIL8
|
nkeynes@1222 | 100 | #if defined(GL_DEPTH24_STENCIL8_EXT)
|
nkeynes@1222 | 101 | #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
nkeynes@1222 | 102 | #elif defined(GL_DEPTH24_STENCIL8_OES)
|
nkeynes@1222 | 103 | #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
nkeynes@1222 | 104 | #endif
|
nkeynes@1222 | 105 | #endif
|
nkeynes@1222 | 106 |
|
nkeynes@1210 | 107 | #if defined(GL_FRAMEBUFFER_COMPLETE_EXT) && !defined(GL_FRAMEBUFFER_COMPLETE)
|
nkeynes@1210 | 108 | #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
nkeynes@1210 | 109 | #endif
|
nkeynes@1210 | 110 |
|
nkeynes@1245 | 111 | #if defined(GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT) && !defined(GL_UNSIGNED_SHORT_1_5_5_5_REV)
|
nkeynes@1245 | 112 | #define GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
|
nkeynes@1245 | 113 | #endif
|
nkeynes@1245 | 114 |
|
nkeynes@1245 | 115 | #if defined(GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT) && !defined(GL_UNSIGNED_SHORT_4_4_4_4_REV)
|
nkeynes@1245 | 116 | #define GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT
|
nkeynes@1245 | 117 | #endif
|
nkeynes@1245 | 118 |
|
nkeynes@1245 | 119 | #if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
|
nkeynes@1245 | 120 | #define GL_BGRA GL_BGRA_EXT
|
nkeynes@1245 | 121 | #endif
|
nkeynes@1245 | 122 |
|
nkeynes@1210 | 123 | #if defined(HAVE_OPENGL_FBO_EXT) && !defined(HAVE_OPENGL_FBO)
|
nkeynes@1210 | 124 | #define glGenFramebuffers glGenFramebuffersEXT
|
nkeynes@1210 | 125 | #define glGenRenderbuffers glGenRenderbuffersEXT
|
nkeynes@1210 | 126 | #define glBindFramebuffer glBindFramebufferEXT
|
nkeynes@1210 | 127 | #define glDeleteFramebuffers glDeleteFramebuffersEXT
|
nkeynes@1210 | 128 | #define glDeleteRenderbuffers glDeleteRenderbuffersEXT
|
nkeynes@1210 | 129 | #define glBindFramebuffer glBindFramebufferEXT
|
nkeynes@1210 | 130 | #define glBindRenderbuffer glBindRenderbufferEXT
|
nkeynes@1210 | 131 | #define glRenderbufferStorage glRenderbufferStorageEXT
|
nkeynes@1210 | 132 | #define glFramebufferRenderbuffer glFramebufferRenderbufferEXT
|
nkeynes@1210 | 133 | #define glFramebufferTexture2D glFramebufferTexture2DEXT
|
nkeynes@1210 | 134 | #define glCheckFramebufferStatus glCheckFramebufferStatusEXT
|
nkeynes@1210 | 135 | #endif
|
nkeynes@1207 | 136 |
|
nkeynes@1207 | 137 |
|
nkeynes@635 | 138 | /****** Shader handling (gl_sl.c) *****/
|
nkeynes@635 | 139 | gboolean glsl_is_supported(void);
|
nkeynes@1134 | 140 | const char *glsl_get_version(void);
|
nkeynes@1130 | 141 | gboolean glsl_load_shaders( );
|
nkeynes@635 | 142 | void glsl_unload_shaders(void);
|
nkeynes@1130 | 143 | void glsl_clear_shader();
|
nkeynes@635 | 144 |
|
nkeynes@1236 | 145 | /* Define an orthographic transform matrix, given the bounding box (assuming origin at 0) */
|
nkeynes@1236 | 146 | void defineOrthoMatrix( GLfloat *matrix, GLfloat width, GLfloat height, GLfloat znear, GLfloat zfar );
|
nkeynes@1236 | 147 |
|
nkeynes@1134 | 148 | /* Convenience formatting function for driver use */
|
nkeynes@1134 | 149 | void fprint_extensions( FILE *out, const char *extensions );
|
nkeynes@1134 | 150 |
|
nkeynes@736 | 151 | #ifdef __cplusplus
|
nkeynes@736 | 152 | }
|
nkeynes@736 | 153 | #endif
|
nkeynes@736 | 154 |
|
nkeynes@635 | 155 | #endif /* !lxdream_glutil_H */
|