Browse Source

Toggle GL2, GL3, and GLES2 with macros

tags/v0.6.0
Andrew Belt 7 years ago
parent
commit
ee2be22c80
1 changed files with 32 additions and 5 deletions
  1. +32
    -5
      src/gui.cpp

+ 32
- 5
src/gui.cpp View File

@@ -8,11 +8,13 @@

#include "../ext/osdialog/osdialog.h"

#define NANOVG_GL2_IMPLEMENTATION
// #define NANOVG_GL3_IMPLEMENTATION
#define NANOVG_GL2 1
// #define NANOVG_GL3 1
// #define NANOVG_GLES2 1
#define NANOVG_GL_IMPLEMENTATION 1
#include "../ext/nanovg/src/nanovg_gl.h"
// Hack to get framebuffer objects working on OpenGL 2 (we blindly assume the extension is supported)
#define NANOVG_FBO_VALID 1
// #define NANOVG_FBO_VALID 1
#include "../ext/nanovg/src/nanovg_gl_utils.h"
#define BLENDISH_IMPLEMENTATION
#include "../ext/oui-blendish/blendish.h"
@@ -353,11 +355,22 @@ void guiInit() {
glfwSetWindowSizeLimits(gWindow, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);

// Set up NanoVG
#if defined NANOVG_GL2
gVg = nvgCreateGL2(NVG_ANTIALIAS);
// gVg = nvgCreateGL3(NVG_ANTIALIAS);
#elif defined NANOVG_GL3
gVg = nvgCreateGL3(NVG_ANTIALIAS);
#elif defined NANOVG_GLES2
gVg = nvgCreateGLES2(NVG_ANTIALIAS);
#endif
assert(gVg);

#if defined NANOVG_GL2
gFramebufferVg = nvgCreateGL2(NVG_ANTIALIAS);
#elif defined NANOVG_GL3
gFramebufferVg = nvgCreateGL3(NVG_ANTIALIAS);
#elif defined NANOVG_GLES2
gFramebufferVg = nvgCreateGLES2(NVG_ANTIALIAS);
#endif
assert(gFramebufferVg);

// Set up Blendish
@@ -375,9 +388,23 @@ void guiInit() {

void guiDestroy() {
gGuiFont.reset();

#if defined NANOVG_GL2
nvgDeleteGL2(gVg);
// nvgDeleteGL3(gVg);
#elif defined NANOVG_GL3
nvgDeleteGL3(gVg);
#elif defined NANOVG_GLES2
nvgDeleteGLES2(gVg);
#endif

#if defined NANOVG_GL2
nvgDeleteGL2(gFramebufferVg);
#elif defined NANOVG_GL3
nvgDeleteGL3(gFramebufferVg);
#elif defined NANOVG_GLES2
nvgDeleteGLES2(gFramebufferVg);
#endif

glfwDestroyWindow(gWindow);
glfwTerminate();
}


Loading…
Cancel
Save