Pyrogenesis  trunk
Macros | Functions | Variables
ogl.cpp File Reference
#include "precompiled.h"
#include "lib/ogl.h"
#include "lib/code_annotation.h"
#include "lib/config2.h"
#include "lib/debug.h"
#include "lib/external_libraries/libsdl.h"
#include "ps/CLogger.h"
#include <SDL_syswm.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
Include dependency graph for ogl.cpp:

Macros

#define MATCH(known_ext)
 
#define E(e)   case e: return #e;
 
#define LOAD_ERROR(ERROR_STRING)
 

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 whether the given OpenGL extension is supported. More...
 
bool ogl_HaveVersion (int major, int minor)
 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 GLAD_API_PTR dummy_glDrawRangeElementsEXT (GLenum mode, GLuint, GLuint, GLsizei count, GLenum type, GLvoid *indices)
 
static void GLAD_API_PTR dummy_glActiveTextureARB (GLenum texture)
 
static void GLAD_API_PTR dummy_glClientActiveTextureARB (GLenum texture)
 
static void GLAD_API_PTR dummy_glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t)
 
static void GLAD_API_PTR dummy_glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r)
 
static void enableDummyFunctions ()
 
const char * ogl_GetErrorName (GLenum err)
 get a name of the error. More...
 
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...
 
bool ogl_Init (void *(load)(const char *), void *display, int subsystem)
 initialization: import extension function pointers and do feature detect. More...
 
void ogl_SetVsyncEnabled (bool enabled)
 Change vsync state. More...
 

Variables

static const char * exts = nullptr
 
static bool have_30 = false
 
static bool have_21 = false
 
static bool have_20 = false
 
static bool have_15 = false
 
static bool have_14 = false
 
static bool have_13 = false
 
static bool have_12 = false
 
static int GLVersion
 

Macro Definition Documentation

◆ E

#define E (   e)    case e: return #e;

◆ LOAD_ERROR

#define LOAD_ERROR (   ERROR_STRING)
Value:
if (g_Logger) \
LOGERROR(ERROR_STRING); \
debug_printf(ERROR_STRING); \
static LogFn g_Logger
Definition: DLL.cpp:33
void debug_printf(const char *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
Definition: debug.cpp:148

◆ MATCH

#define MATCH (   known_ext)
Value:
if(!strcmp(ext, #known_ext))\
return true;

Function Documentation

◆ dummy_glActiveTextureARB()

static void GLAD_API_PTR dummy_glActiveTextureARB ( GLenum  texture)
static

◆ dummy_glClientActiveTextureARB()

static void GLAD_API_PTR dummy_glClientActiveTextureARB ( GLenum  texture)
static

◆ dummy_glDrawRangeElementsEXT()

static void GLAD_API_PTR dummy_glDrawRangeElementsEXT ( GLenum  mode,
GLuint  ,
GLuint  ,
GLsizei  count,
GLenum  type,
GLvoid *  indices 
)
static

◆ dummy_glMultiTexCoord2fARB()

static void GLAD_API_PTR dummy_glMultiTexCoord2fARB ( GLenum  target,
GLfloat  s,
GLfloat  t 
)
static

◆ dummy_glMultiTexCoord3fARB()

static void GLAD_API_PTR dummy_glMultiTexCoord3fARB ( GLenum  target,
GLfloat  s,
GLfloat  t,
GLfloat  r 
)
static

◆ dump_gl_error()

static void dump_gl_error ( GLenum  err)
static

◆ enableDummyFunctions()

static void enableDummyFunctions ( )
static

◆ isImplementedInCore()

static bool isImplementedInCore ( const char *  ext)
static

◆ ogl_ExtensionString()

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.

◆ ogl_GetErrorName()

const char* ogl_GetErrorName ( GLenum  err)

get a name of the error.

useful for debug.

Returns
read-only C string of unspecified length containing the error's name.

◆ ogl_HaveExtension()

bool ogl_HaveExtension ( const char *  ext)

Check whether the given OpenGL extension is supported.

NOTE: this does not check whether the extensions is loaded. for that, check whether GLAD_<extension name> is not null.

Parameters
extextension string; exact case.
Returns
bool.

◆ ogl_HaveExtensions()

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).

◆ ogl_HaveVersion()

bool ogl_HaveVersion ( int  major,
int  minor 
)

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

◆ ogl_Init()

bool ogl_Init ( void *  load)(const char *,
void *  display,
int  subsystem 
)

initialization: import extension function pointers and do feature detect.

call before using any other function. fails if OpenGL not ready for use. TODO: move loading functionality to GL backend.

◆ ogl_SetVsyncEnabled()

void ogl_SetVsyncEnabled ( bool  enabled)

Change vsync state.

◆ ogl_SquelchError()

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

◆ ogl_WarnIfErrorLoc()

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

◆ exts

const char* exts = nullptr
static

◆ GLVersion

int GLVersion
static

◆ have_12

bool have_12 = false
static

◆ have_13

bool have_13 = false
static

◆ have_14

bool have_14 = false
static

◆ have_15

bool have_15 = false
static

◆ have_20

bool have_20 = false
static

◆ have_21

bool have_21 = false
static

◆ have_30

bool have_30 = false
static