aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pugl/pugl_internal_types.h46
-rw-r--r--pugl/pugl_osx.m16
-rw-r--r--pugl/pugl_win.c20
-rw-r--r--pugl/pugl_win.h1
-rw-r--r--pugl/pugl_x11.c22
-rw-r--r--pugl/pugl_x11.h1
6 files changed, 53 insertions, 53 deletions
diff --git a/pugl/pugl_internal_types.h b/pugl/pugl_internal_types.h
index 7dcfc9f..4a1ba42 100644
--- a/pugl/pugl_internal_types.h
+++ b/pugl/pugl_internal_types.h
@@ -38,6 +38,9 @@
/** Platform-specific internals. */
typedef struct PuglInternalsImpl PuglInternals;
+/** Graphics backend interface. */
+typedef struct PuglBackendImpl PuglBackend;
+
typedef struct {
int context_version_major;
int context_version_minor;
@@ -55,32 +58,33 @@ typedef struct {
/** Cross-platform view definition. */
struct PuglViewImpl {
- PuglInternals* impl;
- PuglHandle handle;
- PuglEventFunc eventFunc;
- char* windowClass;
- PuglNativeWindow parent;
- double start_time;
- uintptr_t transient_parent;
- PuglContextType ctx_type;
- PuglHints hints;
- int width;
- int height;
- int min_width;
- int min_height;
- int min_aspect_x;
- int min_aspect_y;
- int max_aspect_x;
- int max_aspect_y;
- bool ignoreKeyRepeat;
- bool visible;
+ const PuglBackend* backend;
+ PuglInternals* impl;
+ PuglHandle handle;
+ PuglEventFunc eventFunc;
+ char* windowClass;
+ PuglNativeWindow parent;
+ double start_time;
+ uintptr_t transient_parent;
+ PuglContextType ctx_type;
+ PuglHints hints;
+ int width;
+ int height;
+ int min_width;
+ int min_height;
+ int min_aspect_x;
+ int min_aspect_y;
+ int max_aspect_x;
+ int max_aspect_y;
+ bool ignoreKeyRepeat;
+ bool visible;
};
/** Opaque surface used by draw context. */
typedef void PuglSurface;
/** Graphics backend interface. */
-typedef struct {
+struct PuglBackendImpl {
/** Get visual information from display and setup view as necessary. */
int (*configure)(PuglView*);
@@ -101,6 +105,6 @@ typedef struct {
/** Return the puglGetContext() handle for the application, if any. */
void* (*getContext)(PuglView*);
-} PuglBackend;
+};
#endif // PUGL_INTERNAL_TYPES_H
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index 1da1354..9db9d87 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -45,8 +45,6 @@ typedef NSUInteger NSWindowStyleMask;
@class PuglOpenGLView;
struct PuglInternalsImpl {
- const PuglBackend* backend;
-
NSApplication* app;
PuglOpenGLView* glview;
id window;
@@ -175,7 +173,7 @@ struct PuglInternalsImpl {
bounds.size.height,
};
- puglview->impl->backend->resize(puglview, ev.width, ev.height);
+ puglview->backend->resize(puglview, ev.width, ev.height);
puglDispatchEvent(puglview, (const PuglEvent*)&ev);
}
@@ -729,13 +727,13 @@ puglInitInternals(void)
void
puglEnterContext(PuglView* view, bool drawing)
{
- view->impl->backend->enter(view, drawing);
+ view->backend->enter(view, drawing);
}
void
puglLeaveContext(PuglView* view, bool drawing)
{
- view->impl->backend->leave(view, drawing);
+ view->backend->leave(view, drawing);
}
static NSLayoutConstraint*
@@ -759,10 +757,10 @@ puglCreateWindow(PuglView* view, const char* title)
[NSAutoreleasePool new];
impl->app = [NSApplication sharedApplication];
- impl->backend = puglGlBackend();
+ view->backend = puglGlBackend();
if (view->ctx_type == PUGL_CAIRO) {
#ifdef PUGL_HAVE_CAIRO
- impl->backend = puglCairoBackend();
+ view->backend = puglCairoBackend();
#endif
}
@@ -848,7 +846,7 @@ puglHideWindow(PuglView* view)
void
puglDestroy(PuglView* view)
{
- view->impl->backend->destroy(view);
+ view->backend->destroy(view);
view->impl->glview->puglview = NULL;
[view->impl->glview removeFromSuperview];
if (view->impl->window) {
@@ -956,7 +954,7 @@ puglGetNativeWindow(PuglView* view)
void*
puglGetContext(PuglView* view)
{
- return view->impl->backend->getContext(view);
+ return view->backend->getContext(view);
}
// Backend
diff --git a/pugl/pugl_win.c b/pugl/pugl_win.c
index c4c7187..d3bea51 100644
--- a/pugl/pugl_win.c
+++ b/pugl/pugl_win.c
@@ -85,13 +85,13 @@ puglInitInternals(void)
void
puglEnterContext(PuglView* view, bool drawing)
{
- view->impl->backend->enter(view, drawing);
+ view->backend->enter(view, drawing);
}
void
puglLeaveContext(PuglView* view, bool drawing)
{
- view->impl->backend->leave(view, drawing);
+ view->backend->leave(view, drawing);
}
int
@@ -105,12 +105,12 @@ puglCreateWindow(PuglView* view, const char* title)
if (view->ctx_type == PUGL_GL) {
#ifdef PUGL_HAVE_GL
- impl->backend = puglGlBackend();
+ view->backend = puglGlBackend();
#endif
}
if (view->ctx_type == PUGL_CAIRO) {
#ifdef PUGL_HAVE_CAIRO
- impl->backend = puglCairoBackend();
+ view->backend = puglCairoBackend();
#endif
}
@@ -134,14 +134,14 @@ puglCreateWindow(PuglView* view, const char* title)
return 1;
}
- if (!impl->backend->configure) {
+ if (!view->backend || !view->backend->configure) {
return 1;
}
- int st = impl->backend->configure(view);
+ int st = view->backend->configure(view);
if (st || !impl->surface) {
return 2;
- } else if ((st = impl->backend->create(view))) {
+ } else if ((st = view->backend->create(view))) {
return 3;
}
@@ -174,7 +174,7 @@ void
puglDestroy(PuglView* view)
{
if (view) {
- view->impl->backend->destroy(view);
+ view->backend->destroy(view);
ReleaseDC(view->impl->hwnd, view->impl->hdc);
DestroyWindow(view->impl->hwnd);
UnregisterClass(view->windowClass ? view->windowClass : DEFAULT_CLASSNAME, NULL);
@@ -387,7 +387,7 @@ handleConfigure(PuglView* view, PuglEvent* event)
event->configure.width = view->width;
event->configure.height = view->height;
- view->impl->backend->resize(view, view->width, view->height);
+ view->backend->resize(view, view->width, view->height);
return rect;
}
@@ -709,5 +709,5 @@ puglGetNativeWindow(PuglView* view)
void*
puglGetContext(PuglView* view)
{
- return view->impl->backend->getContext(view);
+ return view->backend->getContext(view);
}
diff --git a/pugl/pugl_win.h b/pugl/pugl_win.h
index edbd7c6..e297c3a 100644
--- a/pugl/pugl_win.h
+++ b/pugl/pugl_win.h
@@ -27,7 +27,6 @@ struct PuglInternalsImpl {
int pfId;
HWND hwnd;
HDC hdc;
- const PuglBackend* backend;
PuglSurface* surface;
DWORD refreshRate;
double timerFrequency;
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 3a0f4c2..e249ea6 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -70,13 +70,13 @@ puglInitInternals(void)
void
puglEnterContext(PuglView* view, bool drawing)
{
- view->impl->backend->enter(view, drawing);
+ view->backend->enter(view, drawing);
}
void
puglLeaveContext(PuglView* view, bool drawing)
{
- view->impl->backend->leave(view, drawing);
+ view->backend->leave(view, drawing);
}
int
@@ -97,19 +97,19 @@ puglCreateWindow(PuglView* view, const char* title)
if (view->ctx_type == PUGL_GL) {
#ifdef PUGL_HAVE_GL
- impl->backend = puglGlBackend();
+ view->backend = puglGlBackend();
#endif
}
if (view->ctx_type == PUGL_CAIRO) {
#ifdef PUGL_HAVE_CAIRO
- impl->backend = puglCairoBackend();
+ view->backend = puglCairoBackend();
#endif
}
- if (!impl->backend->configure) {
+ if (!view->backend || !view->backend->configure) {
return 1;
- } else if (impl->backend->configure(view) || !impl->vi) {
- impl->backend->destroy(view);
+ } else if (view->backend->configure(view) || !impl->vi) {
+ view->backend->destroy(view);
return 2;
}
@@ -128,7 +128,7 @@ puglCreateWindow(PuglView* view, const char* title)
0, 0, view->width, view->height, 0, impl->vi->depth, InputOutput,
impl->vi->visual, CWColormap | CWEventMask, &attr);
- if (impl->backend->create(view)) {
+ if (view->backend->create(view)) {
return 3;
}
@@ -211,7 +211,7 @@ puglDestroy(PuglView* view)
if (view->impl->xim) {
XCloseIM(view->impl->xim);
}
- view->impl->backend->destroy(view);
+ view->backend->destroy(view);
XDestroyWindow(view->impl->display, view->impl->win);
XCloseDisplay(view->impl->display);
XFree(view->impl->vi);
@@ -566,7 +566,7 @@ puglProcessEvents(PuglView* view)
if (config_event.type) {
view->width = (int)config_event.configure.width;
view->height = (int)config_event.configure.height;
- impl->backend->resize(view, view->width, view->height);
+ view->backend->resize(view, view->width, view->height);
view->eventFunc(view, (const PuglEvent*)&config_event);
}
@@ -609,5 +609,5 @@ puglGetNativeWindow(PuglView* view)
void*
puglGetContext(PuglView* view)
{
- return view->impl->backend->getContext(view);
+ return view->backend->getContext(view);
}
diff --git a/pugl/pugl_x11.h b/pugl/pugl_x11.h
index 18b49f7..6e528ca 100644
--- a/pugl/pugl_x11.h
+++ b/pugl/pugl_x11.h
@@ -27,7 +27,6 @@ struct PuglInternalsImpl {
Window win;
XIM xim;
XIC xic;
- const PuglBackend* backend;
PuglSurface* surface;
struct {