add initial GL module
This commit is contained in:
parent
e16e81375b
commit
8130955575
46
src/gui/GL.cc
Normal file
46
src/gui/GL.cc
Normal 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
7
src/gui/GL.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef JES_GL_H
|
||||
#define JES_GL_H
|
||||
|
||||
bool GL_Init();
|
||||
void GL_Resize(int width, int height);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user