aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-08-28 22:13:17 +0000
committerDavid Robillard <d@drobilla.net>2014-08-28 22:13:17 +0000
commitdd9b6fe61373e0f1ff0015a2d6b01360897fa8fc (patch)
treeca1e01e0e33ebda96c904b8753742f8547e2f14a
parentd0c878fe0e496083a1e892795c23a1ac939714a9 (diff)
Fix compilation on Windows.
-rw-r--r--pugl/pugl_win.cpp32
-rw-r--r--wscript10
2 files changed, 27 insertions, 15 deletions
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 9dfa70c..16c6b0b 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -71,6 +71,27 @@ puglInitInternals()
return (PuglInternals*)calloc(1, sizeof(PuglInternals));
}
+void
+puglEnterContext(PuglView* view)
+{
+#ifdef PUGL_HAVE_GL
+ if (view->ctx_type == PUGL_GL) {
+ wglMakeCurrent(view->impl->hdc, view->impl->hglrc);
+ }
+#endif
+}
+
+void
+puglLeaveContext(PuglView* view, bool flush)
+{
+#ifdef PUGL_HAVE_GL
+ if (view->ctx_type == PUGL_GL && flush) {
+ glFlush();
+ SwapBuffers(view->impl->hdc);
+ }
+#endif
+}
+
int
puglCreateWindow(PuglView* view, const char* title)
{
@@ -178,12 +199,10 @@ puglDestroy(PuglView* view)
static void
puglReshape(PuglView* view, int width, int height)
{
- wglMakeCurrent(view->impl->hdc, view->impl->hglrc);
+ puglEnterContext(view);
if (view->reshapeFunc) {
view->reshapeFunc(view, width, height);
- } else {
- puglDefaultReshape(view, width, height);
}
view->width = width;
@@ -193,16 +212,13 @@ puglReshape(PuglView* view, int width, int height)
static void
puglDisplay(PuglView* view)
{
- wglMakeCurrent(view->impl->hdc, view->impl->hglrc);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
+ puglEnterContext(view);
if (view->displayFunc) {
view->displayFunc(view);
}
- glFlush();
- SwapBuffers(view->impl->hdc);
+ puglLeaveContext(view, true);
view->redisplay = false;
}
diff --git a/wscript b/wscript
index cebf807..fb4c90b 100644
--- a/wscript
+++ b/wscript
@@ -54,13 +54,9 @@ def configure(conf):
autowaf.display_header('Pugl Configuration')
if not Options.options.no_gl:
- conf.check(function_name = 'glLoadIdentity',
- header_name = 'GL/gl.h',
- define_name = 'HAVE_GL',
- lib = ['GL'],
- mandatory = False)
- if conf.is_defined('HAVE_GL'):
- autowaf.define(conf, 'PUGL_HAVE_GL', 1)
+ # TODO: Portable check for OpenGL
+ conf.define('HAVE_GL', 1)
+ autowaf.define(conf, 'PUGL_HAVE_GL', 1)
if not Options.options.no_cairo:
autowaf.check_pkg(conf, 'cairo',