diff --git a/src/gui/GL.cc b/src/gui/GL.cc new file mode 100644 index 0000000..621e4b8 --- /dev/null +++ b/src/gui/GL.cc @@ -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); +} diff --git a/src/gui/GL.h b/src/gui/GL.h new file mode 100644 index 0000000..2093334 --- /dev/null +++ b/src/gui/GL.h @@ -0,0 +1,7 @@ +#ifndef JES_GL_H +#define JES_GL_H + +bool GL_Init(); +void GL_Resize(int width, int height); + +#endif