Pyrogenesis  trunk
Macros | Functions | Variables
ogl.cpp File Reference
#include "precompiled.h"
#include "lib/ogl.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "lib/external_libraries/libsdl.h"
#include "lib/debug.h"
#include "lib/sysdep/gfx.h"
#include "lib/res/h_mgr.h"
#include "lib/external_libraries/glext_funcs.h"
Include dependency graph for ogl.cpp:

Macros

#define FUNC(ret, name, params)   ret (GL_CALL_CONV *p##name) params;
 
#define FUNC2(ret, nameARB, nameCore, version, params)   ret (GL_CALL_CONV *p##nameARB) params;
 
#define FUNC3(ret, nameARB, nameCore, version, params)   ret (GL_CALL_CONV *p##nameCore) params;
 
#define MATCH(known_ext)
 
#define FUNC(ret, name, params)   p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name);
 
#define FUNC23(pname, ret, nameARB, nameCore, version, params)
 
#define FUNC2(ret, nameARB, nameCore, version, params)   FUNC23(p##nameARB, ret, nameARB, nameCore, version, params)
 
#define FUNC3(ret, nameARB, nameCore, version, params)   FUNC23(p##nameCore, ret, nameARB, nameCore, version, params)
 
#define E(e)   case e: debug_printf("%s\n", #e); break;
 

Functions

const char * ogl_ExtensionString ()
 get a list of all supported extensions. More...
 
static bool isImplementedInCore (const char *ext)
 
bool ogl_HaveExtension (const char *ext)
 check if an extension is supported by the OpenGL implementation. More...
 
bool ogl_HaveVersion (const char *desired_version)
 make sure the OpenGL implementation version matches or is newer than the given version. More...
 
const char * ogl_HaveExtensions (int dummy,...)
 check if a list of extensions are all supported (as determined by ogl_HaveExtension). More...
 
static void GL_CALL_CONV dummy_glDrawRangeElementsEXT (GLenum mode, GLuint, GLuint, GLsizei count, GLenum type, GLvoid *indices)
 
static void GL_CALL_CONV dummy_glActiveTextureARB (int)
 
static void GL_CALL_CONV dummy_glClientActiveTextureARB (int)
 
static void GL_CALL_CONV dummy_glMultiTexCoord2fARB (int, float s, float t)
 
static void GL_CALL_CONV dummy_glMultiTexCoord3fARB (int, float s, float t, float r)
 
static void enableDummyFunctions ()
 
static void importExtensionFunctions ()
 
static void dump_gl_error (GLenum err)
 
void ogl_WarnIfErrorLoc (const char *file, int line)
 raise a warning (break into the debugger) if an OpenGL error is pending. More...
 
bool ogl_SquelchError (GLenum err_to_ignore)
 ignore and reset the specified OpenGL error. More...
 
void ogl_Init ()
 initialization: import extension function pointers and do feature detect. More...
 

Variables

static const char * exts = NULL
 
static bool have_30
 
static bool have_21
 
static bool have_20
 
static bool have_15
 
static bool have_14
 
static bool have_13
 
static bool have_12
 
GLint ogl_max_tex_size = -1
 
GLint ogl_max_tex_units = -1
 [pixels] More...
 

Macro Definition Documentation

#define E (   e)    case e: debug_printf("%s\n", #e); break;
#define FUNC (   ret,
  name,
  params 
)    ret (GL_CALL_CONV *p##name) params;
#define FUNC (   ret,
  name,
  params 
)    p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name);
#define FUNC2 (   ret,
  nameARB,
  nameCore,
  version,
  params 
)    ret (GL_CALL_CONV *p##nameARB) params;
#define FUNC2 (   ret,
  nameARB,
  nameCore,
  version,
  params 
)    FUNC23(p##nameARB, ret, nameARB, nameCore, version, params)
#define FUNC23 (   pname,
  ret,
  nameARB,
  nameCore,
  version,
  params 
)
Value:
pname = NULL; \
if(ogl_HaveVersion(version)) \
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameCore); \
if(!pname) /* use the ARB name if the driver lied about what version it supports */ \
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameARB);
#define GL_CALL_CONV
Definition: ogl.h:128
bool ogl_HaveVersion(const char *desired_version)
make sure the OpenGL implementation version matches or is newer than the given version.
Definition: ogl.cpp:219
#define FUNC3 (   ret,
  nameARB,
  nameCore,
  version,
  params 
)    ret (GL_CALL_CONV *p##nameCore) params;
#define FUNC3 (   ret,
  nameARB,
  nameCore,
  version,
  params 
)    FUNC23(p##nameCore, ret, nameARB, nameCore, version, params)
#define MATCH (   known_ext)
Value:
if(!strcmp(ext, #known_ext))\
return true;

Function Documentation

static void GL_CALL_CONV dummy_glActiveTextureARB ( int  )
static
static void GL_CALL_CONV dummy_glClientActiveTextureARB ( int  )
static
static void GL_CALL_CONV dummy_glDrawRangeElementsEXT ( GLenum  mode,
GLuint  ,
GLuint  ,
GLsizei  count,
GLenum  type,
GLvoid *  indices 
)
static
static void GL_CALL_CONV dummy_glMultiTexCoord2fARB ( int  ,
float  s,
float  t 
)
static
static void GL_CALL_CONV dummy_glMultiTexCoord3fARB ( int  ,
float  s,
float  t,
float  r 
)
static
static void dump_gl_error ( GLenum  err)
static
static void enableDummyFunctions ( )
static
static void importExtensionFunctions ( )
static
static bool isImplementedInCore ( const char *  ext)
static
const char* ogl_ExtensionString ( )

get a list of all supported extensions.

useful for crash logs / system information.

Returns
read-only C string of unspecified length containing all advertised extension names, separated by space.
bool ogl_HaveExtension ( const char *  ext)

check if an extension is supported by the OpenGL implementation.

takes subsequently added core support for some extensions into account (in case drivers forget to advertise extensions).

Parameters
extextension string; exact case.
Returns
bool.
const char* ogl_HaveExtensions ( int  dummy,
  ... 
)

check if a list of extensions are all supported (as determined by ogl_HaveExtension).

Parameters
dummyvalue ignored; varargs requires a placeholder. follow it by a list of const char* extension string parameters, terminated by a 0 pointer.
Returns
0 if all are present; otherwise, the first extension in the list that's not supported (useful for reporting errors).
bool ogl_HaveVersion ( const char *  version)

make sure the OpenGL implementation version matches or is newer than the given version.

Parameters
versionversion string; format: ("%d.%d", major, minor). example: "1.2".
void ogl_Init ( )

initialization: import extension function pointers and do feature detect.

call before using any other function, and after each video mode change. fails if OpenGL not ready for use.

bool ogl_SquelchError ( GLenum  err_to_ignore)

ignore and reset the specified OpenGL error.

this is useful for suppressing annoying error messages, e.g. "invalid enum" for GL_CLAMP_TO_EDGE even though we've already warned the user that their OpenGL implementation is too old.

call after the fact, i.e. the error has been raised. if another or different error is pending, those are reported immediately.

Parameters
err_to_ignoreone of the glGetError enums.
Returns
true if the requested error was seen and ignored
void ogl_WarnIfErrorLoc ( const char *  file,
int  line 
)

raise a warning (break into the debugger) if an OpenGL error is pending.

resets the OpenGL error state afterwards.

when an error is reported, insert calls to this in a binary-search scheme to quickly narrow down the actual error location.

reports a bogus invalid_operation error if called before OpenGL is initialized, so don't!

disabled in release mode for efficiency and to avoid annoying errors.

Variable Documentation

const char* exts = NULL
static
bool have_12
static
bool have_13
static
bool have_14
static
bool have_15
static
bool have_20
static
bool have_21
static
bool have_30
static
GLint ogl_max_tex_size = -1
GLint ogl_max_tex_units = -1

[pixels]