add initial GL module

This commit is contained in:
Josh Holtrop 2016-06-20 22:05:26 -04:00
parent e16e81375b
commit 8130955575
2 changed files with 53 additions and 0 deletions

46
src/gui/GL.cc Normal file
View File

@ -0,0 +1,46 @@
#include "GL.h"
#include "gl3w.h"
/**
* Initialize OpenGL.
*
* @retval true OpenGL was loaded successfully.
* @retval false Loading OpenGL failed.
*/
bool GL_Init()
{
static bool loaded = false;
if (loaded)
return true;
if (gl3wInit() != 0)
{
/* Failed to gl3wInit() */
return false;
}
if (!gl3wIsSupported(3, 0))
{
/* OpenGL 3.0 is not supported */
return false;
}
glEnable(GL_SCISSOR_TEST);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
return loaded = true;
}
/**
* Resize the OpenGL viewport.
*
* @param[in] width Width of the new viewport.
* @param[in] height Height of the new viewport.
*/
void GL_Resize(int width, int height)
{
glViewport(0, 0, width, height);
}

7
src/gui/GL.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef JES_GL_H
#define JES_GL_H
bool GL_Init();
void GL_Resize(int width, int height);
#endif