Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ogl.h File Reference
#include "lib/config2.h"
#include "lib/sysdep/os.h"
#include <glad/gl.h>
Include dependency graph for ogl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ogl_WarnIfError()   ogl_WarnIfErrorLoc(__FILE__, __LINE__)
 

Functions

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...
 
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,...) SENTINEL_ARG
 check if a list of extensions are all supported (as determined by ogl_HaveExtension). More...
 
const char * ogl_ExtensionString ()
 get a list of all supported extensions. More...
 
void ogl_WarnIfErrorLoc (const char *file, int line)
 raise a warning (break into the debugger) if an OpenGL error is pending. More...
 
const char * ogl_GetErrorName (GLenum err)
 get a name of the error. More...
 
bool ogl_SquelchError (GLenum err_to_ignore)
 ignore and reset the specified OpenGL error. More...
 

Macro Definition Documentation

◆ ogl_WarnIfError

#define ogl_WarnIfError ( )    ogl_WarnIfErrorLoc(__FILE__, __LINE__)

Function Documentation

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