From 8130955575d373c80e6a22ab18052a838526c7d1 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 20 Jun 2016 22:05:26 -0400 Subject: [PATCH] add initial GL module --- src/gui/GL.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/gui/GL.h | 7 +++++++ 2 files changed, 53 insertions(+) create mode 100644 src/gui/GL.cc create mode 100644 src/gui/GL.h 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