diff options
author | David Robillard <d@drobilla.net> | 2012-05-02 20:49:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-02 20:49:13 +0000 |
commit | f027f3810baaa93bd4b8273b774421053e8e1cac (patch) | |
tree | 8fad8d4ffe6c1e37962b45ce66333c8d9eae5c94 /pugl | |
parent | 56cc27fe0eec999f5e01e9b40f5bd16929713eed (diff) | |
download | pugl-f027f3810baaa93bd4b8273b774421053e8e1cac.tar.gz pugl-f027f3810baaa93bd4b8273b774421053e8e1cac.tar.bz2 pugl-f027f3810baaa93bd4b8273b774421053e8e1cac.zip |
Remove GLU dependency.
Fix compilation errors on X11.
Make default resize function set up a 2D view.
Set appropriate reshape callback in pugl_test.
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/pugl.h | 2 | ||||
-rw-r--r-- | pugl/pugl_internal.h | 12 | ||||
-rw-r--r-- | pugl/pugl_osx.m | 15 | ||||
-rw-r--r-- | pugl/pugl_win.cpp | 15 | ||||
-rw-r--r-- | pugl/pugl_x11.c | 26 |
5 files changed, 26 insertions, 44 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h index 7512aa1..4a8a599 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -30,13 +30,11 @@ */ #ifdef __APPLE__ # include "OpenGL/gl.h" -# include "OpenGL/glu.h" #else # ifdef _WIN32 # include <windows.h> /* Broken Windows GL headers require this */ # endif # include "GL/gl.h" -# include "GL/glu.h" #endif #ifdef PUGL_SHARED diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h index 5235db3..981c0fb 100644 --- a/pugl/pugl_internal.h +++ b/pugl/pugl_internal.h @@ -65,6 +65,18 @@ puglGetModifiers(PuglView* view) } void +puglDefaultReshape(PuglView* view, int width, int height) +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, height, 0, 0, 1); + glViewport(0, 0, width, height); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void puglIgnoreKeyRepeat(PuglView* view, bool ignore) { view->ignoreKeyRepeat = ignore; diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 3c5425e..2f4a0e9 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -93,22 +93,13 @@ int height = bounds.size.height; if (view->reshapeFunc) { - // User provided a reshape function, defer to that view->reshapeFunc(view, width, height); } else { - // No custom reshape function, do something reasonable - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0f, width/(float)height, 1.0f, 10.0f); - glViewport(0, 0, width, height); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + puglDefaultReshape(view, width, height); } - view->width = width; - view->height = height; - view->redisplay = true; + view->width = width; + view->height = height; } - (void) drawRect:(NSRect)rect diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp index 3128daf..cc69036 100644 --- a/pugl/pugl_win.cpp +++ b/pugl/pugl_win.cpp @@ -21,7 +21,6 @@ #include <windows.h> #include <windowsx.h> #include <GL/gl.h> -#include <GL/glu.h> #include "pugl_internal.h" @@ -123,21 +122,13 @@ puglReshape(PuglView* view, int width, int height) wglMakeCurrent(view->impl->hdc, view->impl->hglrc); if (view->reshapeFunc) { - // User provided a reshape function, defer to that view->reshapeFunc(view, width, height); } else { - // No custom reshape function, do something reasonable - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0f, view->width/(float)view->height, 1.0f, 10.0f); - glViewport(0, 0, view->width, view->height); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + puglDefaultReshape(view, width, height); } - view->width = width; - view->height = height; + view->width = width; + view->height = height; } void diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index 755dd87..d80b71b 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -24,7 +24,6 @@ #include <string.h> #include <GL/gl.h> -#include <GL/glu.h> #include <GL/glx.h> #include <X11/Xatom.h> #include <X11/Xlib.h> @@ -174,22 +173,13 @@ puglReshape(PuglView* view, int width, int height) glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx); if (view->reshapeFunc) { - // User provided a reshape function, defer to that view->reshapeFunc(view, width, height); } else { - // No custom reshape function, do something reasonable - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0f, width/(float)height, 1.0f, 10.0f); - glViewport(0, 0, width, height); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + puglDefaultReshape(view, width, height); } - view->width = width; - view->height = height; - view->redisplay = true; + view->width = width; + view->height = height; } void @@ -310,11 +300,11 @@ puglProcessEvents(PuglView* view) if (view->mouseFunc && (event.xbutton.button < 4 || event.xbutton.button > 7)) { view->mouseFunc(view, - event.xbutton.button, event.type == ButtonPress, - event.xbutton.x, event.xbutton.y); + event.xbutton.button, event.type == ButtonPress, + event.xbutton.x, event.xbutton.y); } break; - case KeyPress: + case KeyPress: { setModifiers(view, event.xkey.state); KeySym sym; char str[5]; @@ -329,7 +319,7 @@ puglProcessEvents(PuglView* view) } else if (view->specialFunc) { view->specialFunc(view, true, key); } - break; + } break; case KeyRelease: { setModifiers(view, event.xkey.state); bool repeated = false; @@ -355,7 +345,7 @@ puglProcessEvents(PuglView* view) view->specialFunc(view, false, special); } } - } + } break; case ClientMessage: if (!strcmp(XGetAtomName(view->impl->display, event.xclient.message_type), |