Search
lxdream.org :: lxdream/src/pvr2/glutil.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glutil.h
changeset 1258:f8a9c0fd2abb
prev1256:a9d29fe74bf3
next1259:8a69f4d0b31d
author nkeynes
date Mon Mar 05 11:41:03 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change Small cleanups:
Refactor the post-windowing setup into gl_init_driver() in video_gl.c
Move gl_sl.c into src/drivers and tidy up a bit.
Fix OS X compiling plugins with -mdynamic-no-pic
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * GL-based support functions 
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    19 #ifndef lxdream_glutil_H
    20 #define lxdream_glutil_H
    22 #include <stdio.h>
    23 #include "display.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 /**
    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.
    33  */
    34 gboolean isGLExtensionSupported( const char *extension );
    36 gboolean isOpenGLES2();
    38 /**
    39  * Dump GL information to the output stream, usually for debugging purposes
    40  */
    41 void glPrintInfo( FILE *out );
    43 /**
    44  * Check for a GL error and print a message if there is one
    45  * @param context If not null, a string to be printed along side an error message
    46  * @return FALSE if there was an error, otherwise TRUE
    47  */
    48 gboolean gl_check_error( const char *context );
    49 /**
    50  * Test if secondary color (GL_COLOR_SUM) is supported.
    51  */
    52 gboolean isGLSecondaryColorSupported();
    54 gboolean isGLVertexBufferSupported();
    55 gboolean isGLVertexRangeSupported();
    56 gboolean isGLPixelBufferSupported();
    57 gboolean isGLMultitextureSupported();
    58 gboolean isGLMirroredTextureSupported();
    59 gboolean isGLShaderSupported();
    60 GLint glGetMaxColourAttachments();
    62 /****** Extension variant wrangling *****/
    64 #if defined(GL_MIRRORED_REPEAT_ARB) && !defined(GL_MIRRORED_REPEAT)
    65 #define GL_MIRRORED_REPEAT GL_MIRRORED_REPEAT_ARB
    66 #endif
    68 #if defined(GL_MAX_TEXTURE_UNITS_ARB) && !defined(GL_MAX_TEXTURE_UNITS)
    69 #define GL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS_ARB
    70 #endif
    72 #if defined(GL_FRAMEBUFFER_EXT) && !defined(GL_FRAMEBUFFER)
    73 #define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
    74 #endif
    76 #if defined(GL_RENDERBUFFER_EXT) && !defined(GL_RENDERBUFFER)
    77 #define GL_RENDERBUFFER GL_RENDERBUFFER_EXT
    78 #endif
    80 #if defined(GL_COLOR_ATTACHMENT0_EXT) && !defined(GL_COLOR_ATTACHMENT0)
    81 #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
    82 #endif
    84 #if defined(GL_MAX_COLOR_ATTACHMENTS_EXT) && !defined(GL_MAX_COLOR_ATTACHMENTS)
    85 #define GL_MAX_COLOR_ATTACHMENTS GL_MAX_COLOR_ATTACHMENTS_EXT
    86 #endif
    88 #if defined(GL_STENCIL_ATTACHMENT_EXT) && !defined(GL_STENCIL_ATTACHMENT)
    89 #define GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
    90 #endif
    92 #if defined(GL_DEPTH_ATTACHMENT_EXT) && !defined(GL_DEPTH_ATTACHMENT)
    93 #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
    94 #endif
    96 #if defined(GL_DEPTH_COMPONENT24_OES) && !defined(GL_DEPTH_COMPONENT24)
    97 #define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
    98 #endif
   100 #ifndef GL_DEPTH24_STENCIL8
   101 #if defined(GL_DEPTH24_STENCIL8_EXT)
   102 #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
   103 #elif defined(GL_DEPTH24_STENCIL8_OES)
   104 #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
   105 #endif
   106 #endif
   108 #if defined(GL_FRAMEBUFFER_COMPLETE_EXT) && !defined(GL_FRAMEBUFFER_COMPLETE)
   109 #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
   110 #endif
   112 #if defined(GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT) && !defined(GL_UNSIGNED_SHORT_1_5_5_5_REV)
   113 #define GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
   114 #endif
   116 #if defined(GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT) && !defined(GL_UNSIGNED_SHORT_4_4_4_4_REV)
   117 #define GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT
   118 #endif
   120 #if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
   121 #define GL_BGRA GL_BGRA_EXT
   122 #endif
   124 #if defined(GL_SHADING_LANGUAGE_VERSION_ARB) && !defined(GL_SHADING_LANGUAGE_VERSION)
   125 #define GL_SHADING_LANGUAGE_VERSION GL_SHADING_LANGUAGE_VERSION_ARB
   126 #endif
   129 #if defined(HAVE_OPENGL_FBO_EXT) && !defined(HAVE_OPENGL_FBO)
   130 #define glGenFramebuffers glGenFramebuffersEXT
   131 #define glGenRenderbuffers glGenRenderbuffersEXT
   132 #define glBindFramebuffer glBindFramebufferEXT
   133 #define glDeleteFramebuffers glDeleteFramebuffersEXT
   134 #define glDeleteRenderbuffers glDeleteRenderbuffersEXT
   135 #define glBindFramebuffer glBindFramebufferEXT
   136 #define glBindRenderbuffer glBindRenderbufferEXT
   137 #define glRenderbufferStorage glRenderbufferStorageEXT
   138 #define glFramebufferRenderbuffer glFramebufferRenderbufferEXT
   139 #define glFramebufferTexture2D glFramebufferTexture2DEXT
   140 #define glCheckFramebufferStatus glCheckFramebufferStatusEXT
   141 #endif
   144 /****** Shader handling (gl_sl.c) *****/
   145 void glsl_clear_shader();
   147 /* Define an orthographic transform matrix, given the bounding box (assuming origin at 0) */
   148 void defineOrthoMatrix( GLfloat *matrix, GLfloat width, GLfloat height, GLfloat znear, GLfloat zfar );
   150 /* Convenience formatting function for driver use */
   151 void fprint_extensions( FILE *out, const char *extensions );
   153 #ifdef __cplusplus
   154 }
   155 #endif
   157 #endif /* !lxdream_glutil_H */
.