aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-09-28 20:04:20 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-09-28 20:04:20 +0200
commit09a86896ca5a4a07143778005b09bee0a46404a9 (patch)
tree65461ec8798b938d66883ca0b37a48d5852a363a
parent3e0e9be4124b949457c35748c16f74e140f38ae4 (diff)
downloadd2tk-09a86896ca5a4a07143778005b09bee0a46404a9.tar.xz
Squashed 'pugl/' changes from 320124db..077d5fd3
077d5fd3 Add Tab+Return to PuglKeys, implement missing ones 799f4f7c Mac: Fix missing NSWindowStyleMask type on 10.11 7bbbf3ce Fix memory leak fd68302b Windows: Fix Cairo backend build dd6a9c09 Add support for using a debug OpenGL context 2c8d8e23 Wrap deprecated declarations in PUGL_DISABLE_DEPRECATED c1a4ccae Build documentation on CI 92937b14 Improve documentation and use LV2 documentation style dc9f1d85 Clean up error handling 7162fa4f Add clipboard support 27e43183 Cleanup: Fix whitespace 178e747d Windows: Fix library leak during world creation 8b8ada46 Add OpenGL 3 test program 5fac75bd Windows: Fix puglGetProcAddress() for OpenGL 1.1 functions 67a57996 Make almost everything return a status 59359e4f Make event handler return a status 4c6ac6b1 Factor out parsing test options 36f9c9dd Reorganize header and documentation into coherent sections 4c07a013 Add puglSetWindowTitle() 89af2b1e Rename remaining init functions b0ac6dcb Add puglSetClassName() 075c5c59 Replace puglInitTransientFor() with puglSetTransientFor() e7ccbec8 Replace size and aspect ratio init functions with dynamic ones f98e804c Move trivial deprecated implementations to header 411c7ddb Move deprecated API to a separate section of the header d015bf0d Add puglGetWorld() e4446d09 X11: Factor out size hints calculation 1c585b57 Use consistent naming conventions 7d72d835 Windows: Fix configured size of child views 9b2bbb1c Windows: Draw while application menu is open 0e6f60a8 Windows: Improve resize smoothness slightly bb01cc1b Add swap interval hint 2a0287b0 X11: Improve puglPostRedisplay() performance 2d19fe67 Windows: Improve puglPostRedisplay() performance 69f38f68 Windows: Prevent event loop from running forever e5481cb3 Make pugl_test use a nested view and test focus and movement 81660702 Add functions to get and set view size and position f7695435 Windows: Factor out window flag functions 93f4920c Add puglDispatchEvents() 496f17c3 Add puglPollEvents() dacaaa5f Move puglGetTime() to PuglWorld 61476f5d X11: Move input method to world 9995566f X11: Move atoms to world e83c2b42 Add PuglWorld 5081d49f Add puglHasFocus() da0f76d2 Fix puglGrabFocus() to work between parent and children e148e8f3 Windows: Fix class registration for multiple views e3b2f305 Simplify hints implementation 0706f4a1 Mac: Dispatch expose events from drawing view 10bb9a28 Cleanup: Fix whitespace REVERT: 320124db Build documentation on CI REVERT: abd06cc9 Improve documentation and use LV2 documentation style REVERT: 4a8cb07c Add clipboard support REVERT: 48f741d9 Cleanup: Fix whitespace REVERT: 0e9eb9cb Windows: Fix library leak during world creation REVERT: 4e924bcc Add OpenGL 3 test program REVERT: bbb5a165 Windows: Fix puglGetProcAddress() for OpenGL 1.1 functions REVERT: ea02b164 Make almost everything return a status REVERT: 360662f8 Make event handler return a status REVERT: b1cc625c Factor out parsing test options REVERT: e03d9687 Reorganize header and documentation into coherent sections REVERT: dd003488 Add puglSetWindowTitle() REVERT: 73757f82 Rename remaining init functions REVERT: 9cd81370 Add puglSetClassName() REVERT: 0b3d2494 Replace puglInitTransientFor() with puglSetTransientFor() REVERT: 9c66697b Replace size and aspect ratio init functions with dynamic ones REVERT: 24a52e71 Move trivial deprecated implementations to header REVERT: 0db5b9e0 Move deprecated API to a separate section of the header REVERT: ce2f5c20 Add puglGetWorld() REVERT: 9e2f7a86 X11: Factor out size hints calculation REVERT: 1bb62ce5 Use consistent naming conventions REVERT: 49563c75 Windows: Fix configured size of child views REVERT: 71766846 Windows: Draw while application menu is open REVERT: 0edbce93 Windows: Improve resize smoothness slightly REVERT: 9612e3e5 Add swap interval hint REVERT: a7a65262 X11: Improve puglPostRedisplay() performance REVERT: 8803cb79 Windows: Improve puglPostRedisplay() performance REVERT: 3edc576f Windows: Prevent event loop from running forever REVERT: 093825d7 Make pugl_test use a nested view and test focus and movement REVERT: 353d9139 Add functions to get and set view size and position REVERT: d3a2a4ba Windows: Factor out window flag functions REVERT: b39f2ee3 Add puglDispatchEvents() REVERT: 3107c195 Add puglPollEvents() REVERT: 4bf5c047 Move puglGetTime() to PuglWorld REVERT: 92a65eae X11: Move input method to world REVERT: 30062da2 X11: Move atoms to world REVERT: 0179761f Add PuglWorld REVERT: 46742f73 Add puglHasFocus() REVERT: aa4619e9 Fix puglGrabFocus() to work between parent and children REVERT: 58d16272 Windows: Fix class registration for multiple views REVERT: ec19e1de Simplify hints implementation git-subtree-dir: pugl git-subtree-split: 077d5fd3dd2d1acfdf58839c40b6c96730ca9c69
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--doc/mainpage.md5
-rw-r--r--doc/reference.doxygen.in17
-rw-r--r--pugl/detail/implementation.c3
-rw-r--r--pugl/detail/mac.h2
-rw-r--r--pugl/detail/mac.m86
-rw-r--r--pugl/detail/mac_cairo.m34
-rw-r--r--pugl/detail/mac_gl.m34
-rw-r--r--pugl/detail/types.h12
-rw-r--r--pugl/detail/win.c26
-rw-r--r--pugl/detail/win.h4
-rw-r--r--pugl/detail/win_cairo.c40
-rw-r--r--pugl/detail/win_gl.c48
-rw-r--r--pugl/detail/x11.c27
-rw-r--r--pugl/detail/x11_cairo.c28
-rw-r--r--pugl/detail/x11_gl.c40
-rw-r--r--pugl/pugl.h24
-rw-r--r--test/pugl_gl3_test.c2
18 files changed, 239 insertions, 195 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c7d493d..0a2215c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -115,3 +115,5 @@ pages:
artifacts:
paths:
- public
+ only:
+ - master
diff --git a/doc/mainpage.md b/doc/mainpage.md
index 5ff2781..b16551a 100644
--- a/doc/mainpage.md
+++ b/doc/mainpage.md
@@ -1,5 +1,6 @@
-The complete Pugl C API is documented in the [Pugl](@ref pugl) group,
-and the C++ API wrapper in the [Puglmm](@ref puglmm) group.
+This is the API documentation for Pugl.
+The complete C API is documented in the [Pugl](@ref pugl) group,
+and the C++ wrapper in the [Puglmm](@ref puglmm) group.
The Pugl API revolves around two main objects:
the [World](@ref world) and the [View](@ref view).
diff --git a/doc/reference.doxygen.in b/doc/reference.doxygen.in
index 0035bc1..eb64d58 100644
--- a/doc/reference.doxygen.in
+++ b/doc/reference.doxygen.in
@@ -829,7 +829,7 @@ INPUT_ENCODING = UTF-8
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
-FILE_PATTERNS =
+FILE_PATTERNS = *.h *.hpp
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
@@ -2157,12 +2157,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH = /usr/bin/perl
-
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@@ -2176,15 +2170,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index f1fd57a..80a7a32 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -140,6 +140,7 @@ puglFreeView(PuglView* view)
}
}
+ free(view->title);
free(view->clipboard.data);
puglFreeViewInternals(view);
free(view);
@@ -306,7 +307,7 @@ puglSetInternalClipboard(PuglView* const view,
const size_t len)
{
if (type && strcmp(type, "text/plain")) {
- return PUGL_ERR_UNSUPPORTED_TYPE;
+ return PUGL_UNSUPPORTED_TYPE;
}
puglSetBlob(&view->clipboard, data, len);
diff --git a/pugl/detail/mac.h b/pugl/detail/mac.h
index 754c346..0652733 100644
--- a/pugl/detail/mac.h
+++ b/pugl/detail/mac.h
@@ -36,6 +36,8 @@
bool reshaped;
}
+- (void) dispatchConfigure:(NSRect)bounds;
+- (void) dispatchExpose:(NSRect)rect;
- (void) setReshaped;
@end
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m
index 9f68919..830db02 100644
--- a/pugl/detail/mac.m
+++ b/pugl/detail/mac.m
@@ -31,6 +31,14 @@
#include <stdlib.h>
+#ifndef __MAC_10_10
+typedef NSUInteger NSEventModifierFlags;
+#endif
+
+#ifndef __MAC_10_12
+typedef NSUInteger NSWindowStyleMask;
+#endif
+
static NSRect
rectToScreen(NSRect rect)
{
@@ -102,7 +110,7 @@ updateViewRect(PuglView* view)
puglview->backend->resize(puglview, bounds.size.width, bounds.size.height);
}
-- (void) drawRect:(NSRect)rect
+- (void) dispatchExpose:(NSRect)rect
{
if (reshaped) {
updateViewRect(puglview);
@@ -120,7 +128,7 @@ updateViewRect(PuglView* view)
reshaped = false;
}
- const PuglEventExpose ev = {
+ const PuglEventExpose ev = {
PUGL_EXPOSE,
0,
rect.origin.x,
@@ -165,34 +173,38 @@ keySymToSpecial(const NSEvent* const ev)
NSString* chars = [ev charactersIgnoringModifiers];
if ([chars length] == 1) {
switch ([chars characterAtIndex:0]) {
- case NSF1FunctionKey: return PUGL_KEY_F1;
- case NSF2FunctionKey: return PUGL_KEY_F2;
- case NSF3FunctionKey: return PUGL_KEY_F3;
- case NSF4FunctionKey: return PUGL_KEY_F4;
- case NSF5FunctionKey: return PUGL_KEY_F5;
- case NSF6FunctionKey: return PUGL_KEY_F6;
- case NSF7FunctionKey: return PUGL_KEY_F7;
- case NSF8FunctionKey: return PUGL_KEY_F8;
- case NSF9FunctionKey: return PUGL_KEY_F9;
- case NSF10FunctionKey: return PUGL_KEY_F10;
- case NSF11FunctionKey: return PUGL_KEY_F11;
- case NSF12FunctionKey: return PUGL_KEY_F12;
- case NSDeleteCharacter: return PUGL_KEY_BACKSPACE;
- case NSDeleteFunctionKey: return PUGL_KEY_DELETE;
- case NSLeftArrowFunctionKey: return PUGL_KEY_LEFT;
- case NSUpArrowFunctionKey: return PUGL_KEY_UP;
- case NSRightArrowFunctionKey: return PUGL_KEY_RIGHT;
- case NSDownArrowFunctionKey: return PUGL_KEY_DOWN;
- case NSPageUpFunctionKey: return PUGL_KEY_PAGE_UP;
- case NSPageDownFunctionKey: return PUGL_KEY_PAGE_DOWN;
- case NSHomeFunctionKey: return PUGL_KEY_HOME;
- case NSEndFunctionKey: return PUGL_KEY_END;
- case NSInsertFunctionKey: return PUGL_KEY_INSERT;
- case NSMenuFunctionKey: return PUGL_KEY_MENU;
- case NSScrollLockFunctionKey: return PUGL_KEY_SCROLL_LOCK;
- case NSClearLineFunctionKey: return PUGL_KEY_NUM_LOCK;
- case NSPrintScreenFunctionKey: return PUGL_KEY_PRINT_SCREEN;
- case NSPauseFunctionKey: return PUGL_KEY_PAUSE;
+ case NSDeleteCharacter: return PUGL_KEY_BACKSPACE;
+ case NSTabCharacter: return PUGL_KEY_TAB;
+ case NSCarriageReturnCharacter: return PUGL_KEY_ENTER;
+ case 0x001B: return PUGL_KEY_ESCAPE;
+ case NSDeleteFunctionKey: return PUGL_KEY_DELETE;
+ case NSF1FunctionKey: return PUGL_KEY_F1;
+ case NSF2FunctionKey: return PUGL_KEY_F2;
+ case NSF3FunctionKey: return PUGL_KEY_F3;
+ case NSF4FunctionKey: return PUGL_KEY_F4;
+ case NSF5FunctionKey: return PUGL_KEY_F5;
+ case NSF6FunctionKey: return PUGL_KEY_F6;
+ case NSF7FunctionKey: return PUGL_KEY_F7;
+ case NSF8FunctionKey: return PUGL_KEY_F8;
+ case NSF9FunctionKey: return PUGL_KEY_F9;
+ case NSF10FunctionKey: return PUGL_KEY_F10;
+ case NSF11FunctionKey: return PUGL_KEY_F11;
+ case NSF12FunctionKey: return PUGL_KEY_F12;
+ case NSLeftArrowFunctionKey: return PUGL_KEY_LEFT;
+ case NSUpArrowFunctionKey: return PUGL_KEY_UP;
+ case NSRightArrowFunctionKey: return PUGL_KEY_RIGHT;
+ case NSDownArrowFunctionKey: return PUGL_KEY_DOWN;
+ case NSPageUpFunctionKey: return PUGL_KEY_PAGE_UP;
+ case NSPageDownFunctionKey: return PUGL_KEY_PAGE_DOWN;
+ case NSHomeFunctionKey: return PUGL_KEY_HOME;
+ case NSEndFunctionKey: return PUGL_KEY_END;
+ case NSInsertFunctionKey: return PUGL_KEY_INSERT;
+ case NSMenuFunctionKey: return PUGL_KEY_MENU;
+ case NSScrollLockFunctionKey: return PUGL_KEY_SCROLL_LOCK;
+ case NSClearLineFunctionKey: return PUGL_KEY_NUM_LOCK;
+ case NSPrintScreenFunctionKey: return PUGL_KEY_PRINT_SCREEN;
+ case NSPauseFunctionKey: return PUGL_KEY_PAUSE;
+ default: break;
}
// SHIFT, CTRL, ALT, and SUPER are handled in [flagsChanged]
}
@@ -227,7 +239,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
{
const NSPoint wloc = [view eventLocation:event];
const NSPoint rloc = [NSEvent mouseLocation];
- const PuglEventCrossing ev = {
+ const PuglEventCrossing ev = {
type,
0,
[event timestamp],
@@ -255,7 +267,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
{
const NSPoint wloc = [self eventLocation:event];
const NSPoint rloc = [NSEvent mouseLocation];
- const PuglEventMotion ev = {
+ const PuglEventMotion ev = {
PUGL_MOTION_NOTIFY,
0,
[event timestamp],
@@ -289,7 +301,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
{
const NSPoint wloc = [self eventLocation:event];
const NSPoint rloc = [NSEvent mouseLocation];
- const PuglEventButton ev = {
+ const PuglEventButton ev = {
PUGL_BUTTON_PRESS,
0,
[event timestamp],
@@ -307,7 +319,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
{
const NSPoint wloc = [self eventLocation:event];
const NSPoint rloc = [NSEvent mouseLocation];
- const PuglEventButton ev = {
+ const PuglEventButton ev = {
PUGL_BUTTON_RELEASE,
0,
[event timestamp],
@@ -345,7 +357,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
{
const NSPoint wloc = [self eventLocation:event];
const NSPoint rloc = [NSEvent mouseLocation];
- const PuglEventScroll ev = {
+ const PuglEventScroll ev = {
PUGL_SCROLL,
0,
[event timestamp],
@@ -374,7 +386,7 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
const uint32_t code = (
spec ? spec : puglDecodeUTF8((const uint8_t*)str));
- const PuglEventKey ev = {
+ const PuglEventKey ev = {
PUGL_KEY_PRESS,
0,
[event timestamp],
@@ -939,7 +951,7 @@ puglGetTime(const PuglWorld* world)
PuglStatus
puglPostRedisplay(PuglView* view)
{
- [view->impl->wrapperView setNeedsDisplay: YES];
+ [view->impl->drawView setNeedsDisplay: YES];
return PUGL_SUCCESS;
}
diff --git a/pugl/detail/mac_cairo.m b/pugl/detail/mac_cairo.m
index f47e42e..143fbb0 100644
--- a/pugl/detail/mac_cairo.m
+++ b/pugl/detail/mac_cairo.m
@@ -53,15 +53,21 @@
[wrapper setReshaped];
}
+- (void) drawRect:(NSRect)rect
+{
+ PuglWrapperView* wrapper = (PuglWrapperView*)[self superview];
+ [wrapper dispatchExpose:rect];
+}
+
@end
-static int
+static PuglStatus
puglMacCairoConfigure(PuglView* PUGL_UNUSED(view))
{
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoCreate(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -76,10 +82,10 @@ puglMacCairoCreate(PuglView* view)
}
impl->drawView = drawView;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoDestroy(PuglView* view)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
@@ -88,15 +94,15 @@ puglMacCairoDestroy(PuglView* view)
[drawView release];
view->impl->drawView = nil;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoEnter(PuglView* view, bool drawing)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
assert(!drawView->surface);
@@ -109,15 +115,15 @@ puglMacCairoEnter(PuglView* view, bool drawing)
drawView->cr = cairo_create(drawView->surface);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoLeave(PuglView* view, bool drawing)
{
PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
assert(drawView->surface);
@@ -132,16 +138,16 @@ puglMacCairoLeave(PuglView* view, bool drawing)
CGContextFlush(context);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacCairoResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
// No need to resize, the surface is created for the drawing context
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/mac_gl.m b/pugl/detail/mac_gl.m
index 61c0193..cb9117e 100644
--- a/pugl/detail/mac_gl.m
+++ b/pugl/detail/mac_gl.m
@@ -23,9 +23,7 @@
#include "pugl/pugl_gl_backend.h"
#ifndef __MAC_10_10
-#define NSOpenGLProfileVersion4_1Core NSOpenGLProfileVersion3_2Core
-typedef NSUInteger NSEventModifierFlags;
-typedef NSUInteger NSWindowStyleMask;
+# define NSOpenGLProfileVersion4_1Core NSOpenGLProfileVersion3_2Core
#endif
@interface PuglOpenGLView : NSOpenGLView
@@ -85,15 +83,21 @@ typedef NSUInteger NSWindowStyleMask;
[wrapper setReshaped];
}
+- (void) drawRect:(NSRect)rect
+{
+ PuglWrapperView* wrapper = (PuglWrapperView*)[self superview];
+ [wrapper dispatchExpose:rect];
+}
+
@end
-static int
+static PuglStatus
puglMacGlConfigure(PuglView* PUGL_UNUSED(view))
{
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlCreate(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -110,10 +114,10 @@ puglMacGlCreate(PuglView* view)
}
impl->drawView = drawView;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlDestroy(PuglView* view)
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
@@ -122,19 +126,19 @@ puglMacGlDestroy(PuglView* view)
[drawView release];
view->impl->drawView = nil;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlEnter(PuglView* view, bool PUGL_UNUSED(drawing))
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
[[drawView openGLContext] makeCurrentContext];
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlLeave(PuglView* view, bool drawing)
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
@@ -145,17 +149,17 @@ puglMacGlLeave(PuglView* view, bool drawing)
[NSOpenGLContext clearCurrentContext];
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglMacGlResize(PuglView* view, int PUGL_UNUSED(width), int PUGL_UNUSED(height))
{
PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView;
[drawView reshape];
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/types.h b/pugl/detail/types.h
index 4ac224b..d018be5 100644
--- a/pugl/detail/types.h
+++ b/pugl/detail/types.h
@@ -89,22 +89,22 @@ typedef void PuglSurface;
/** Graphics backend interface. */
struct PuglBackendImpl {
/** Get visual information from display and setup view as necessary. */
- int (*configure)(PuglView*);
+ PuglStatus (*configure)(PuglView*);
/** Create surface and drawing context. */
- int (*create)(PuglView*);
+ PuglStatus (*create)(PuglView*);
/** Destroy surface and drawing context. */
- int (*destroy)(PuglView*);
+ PuglStatus (*destroy)(PuglView*);
/** Enter drawing context, for drawing if parameter is true. */
- int (*enter)(PuglView*, bool);
+ PuglStatus (*enter)(PuglView*, bool);
/** Leave drawing context, after drawing if parameter is true. */
- int (*leave)(PuglView*, bool);
+ PuglStatus (*leave)(PuglView*, bool);
/** Resize drawing context to the given width and height. */
- int (*resize)(PuglView*, int, int);
+ PuglStatus (*resize)(PuglView*, int, int);
/** Return the puglGetContext() handle for the application, if any. */
void* (*getContext)(PuglView*);
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index 25780e0..8886496 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -163,18 +163,18 @@ puglCreateWindow(PuglView* view, const char* title)
// Register window class if necessary
if (!puglRegisterWindowClass(view->world->className)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_REGISTRATION_FAILED;
}
if (!view->backend || !view->backend->configure) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_BAD_BACKEND;
}
- int st = view->backend->configure(view);
+ PuglStatus st = view->backend->configure(view);
if (st || !impl->surface) {
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
} else if ((st = view->backend->create(view))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
if (title) {
@@ -229,6 +229,11 @@ static PuglKey
keySymToSpecial(WPARAM sym)
{
switch (sym) {
+ case VK_BACK: return PUGL_KEY_BACKSPACE;
+ case VK_TAB: return PUGL_KEY_TAB;
+ case VK_RETURN: return PUGL_KEY_RETURN;
+ case VK_ESCAPE: return PUGL_KEY_ESCAPE;
+ case VK_DELETE: return PUGL_KEY_DELETE;
case VK_F1: return PUGL_KEY_F1;
case VK_F2: return PUGL_KEY_F2;
case VK_F3: return PUGL_KEY_F3;
@@ -241,8 +246,6 @@ keySymToSpecial(WPARAM sym)
case VK_F10: return PUGL_KEY_F10;
case VK_F11: return PUGL_KEY_F11;
case VK_F12: return PUGL_KEY_F12;
- case VK_BACK: return PUGL_KEY_BACKSPACE;
- case VK_DELETE: return PUGL_KEY_DELETE;
case VK_LEFT: return PUGL_KEY_LEFT;
case VK_UP: return PUGL_KEY_UP;
case VK_RIGHT: return PUGL_KEY_RIGHT;
@@ -268,6 +271,7 @@ keySymToSpecial(WPARAM sym)
case VK_NUMLOCK: return PUGL_KEY_NUM_LOCK;
case VK_SNAPSHOT: return PUGL_KEY_PRINT_SCREEN;
case VK_PAUSE: return PUGL_KEY_PAUSE;
+ default: break;
}
return (PuglKey)0;
}
@@ -828,7 +832,7 @@ puglSetFrame(PuglView* view, const PuglRect frame)
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
(SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER))) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
}
@@ -896,7 +900,7 @@ puglSetClipboard(PuglView* const view,
if (st) {
return st;
} else if (!OpenClipboard(impl->hwnd)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Measure string and allocate global memory for clipboard
@@ -905,7 +909,7 @@ puglSetClipboard(PuglView* const view,
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (wlen + 1) * sizeof(wchar_t));
if (!mem) {
CloseClipboard();
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Lock global memory
@@ -913,7 +917,7 @@ puglSetClipboard(PuglView* const view,
if (!wstr) {
GlobalFree(mem);
CloseClipboard();
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
// Convert string into global memory and set it as clipboard data
diff --git a/pugl/detail/win.h b/pugl/detail/win.h
index b9e554c..6d89759 100644
--- a/pugl/detail/win.h
+++ b/pugl/detail/win.h
@@ -104,11 +104,11 @@ puglWinCreateWindow(const PuglView* const view,
CW_USEDEFAULT, CW_USEDEFAULT,
wr.right-wr.left, wr.bottom-wr.top,
(HWND)view->parent, NULL, NULL, NULL))) {
- return PUGL_ERR_CREATE_WINDOW;
+ return PUGL_CREATE_WINDOW_FAILED;
} else if (!(*hdc = GetDC(*hwnd))) {
DestroyWindow(*hwnd);
*hwnd = NULL;
- return PUGL_ERR_CREATE_WINDOW;
+ return PUGL_CREATE_WINDOW_FAILED;
}
return PUGL_SUCCESS;
diff --git a/pugl/detail/win_cairo.c b/pugl/detail/win_cairo.c
index cbca7e8..497711b 100644
--- a/pugl/detail/win_cairo.c
+++ b/pugl/detail/win_cairo.c
@@ -34,7 +34,7 @@ typedef struct {
HBITMAP drawBitmap;
} PuglWinCairoSurface;
-static int
+static PuglStatus
puglWinCairoCreateDrawContext(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -51,14 +51,14 @@ puglWinCairoCreateDrawContext(PuglView* view)
(st = cairo_surface_status(surface->surface)) ||
!(surface->cr = cairo_create(surface->surface)) ||
(st = cairo_status(surface->cr))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
cairo_save(surface->cr);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoDestroyDrawContext(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -74,10 +74,10 @@ puglWinCairoDestroyDrawContext(PuglView* view)
surface->drawDc = NULL;
surface->drawBitmap = NULL;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -95,22 +95,22 @@ puglWinCairoConfigure(PuglView* view)
DestroyWindow(impl->hwnd);
impl->hwnd = NULL;
impl->hdc = NULL;
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
}
impl->surface = (PuglWinCairoSurface*)calloc(
1, sizeof(PuglWinCairoSurface));
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoCreate(PuglView* view)
{
return puglWinCairoCreateDrawContext(view);
}
-static int
+static PuglStatus
puglWinCairoDestroy(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -120,32 +120,32 @@ puglWinCairoDestroy(PuglView* view)
free(surface);
impl->surface = NULL;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoEnter(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
PuglWinCairoSurface* const surface = (PuglWinCairoSurface*)impl->surface;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
PAINTSTRUCT ps;
BeginPaint(view->impl->hwnd, &ps);
cairo_save(surface->cr);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoLeave(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
PuglWinCairoSurface* const surface = (PuglWinCairoSurface*)impl->surface;
if (!drawing) {
- return 0;
+ return PUGL_SUCCESS;
}
cairo_restore(surface->cr);
@@ -158,21 +158,21 @@ puglWinCairoLeave(PuglView* view, bool drawing)
EndPaint(view->impl->hwnd, &ps);
SwapBuffers(view->impl->hdc);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinCairoResize(PuglView* view,
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
- int st = 0;
+ PuglStatus st = PUGL_SUCCESS;
if ((st = puglWinCairoDestroyDrawContext(view)) ||
(st = puglWinCairoCreateDrawContext(view))) {
return st;
}
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/win_gl.c b/pugl/detail/win_gl.c
index b7b03a4..4cbb796 100644
--- a/pugl/detail/win_gl.c
+++ b/pugl/detail/win_gl.c
@@ -54,6 +54,7 @@
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
typedef HGLRC (*WglCreateContextAttribs)(HDC, HGLRC, const int*);
typedef BOOL (*WglSwapInterval)(int);
@@ -77,8 +78,8 @@ typedef struct {
HDC hdc;
} PuglFakeWindow;
-static int
-puglWinError(PuglFakeWindow* fakeWin, const int status)
+static PuglStatus
+puglWinError(PuglFakeWindow* fakeWin, const PuglStatus status)
{
if (fakeWin->hwnd) {
ReleaseDC(fakeWin->hwnd, fakeWin->hdc);
@@ -102,7 +103,7 @@ static PuglWinGlProcs puglWinGlGetProcs(void)
return procs;
}
-static int
+static PuglStatus
puglWinGlConfigure(PuglView* view)
{
PuglInternals* impl = view->impl;
@@ -140,15 +141,15 @@ puglWinGlConfigure(PuglView* view)
const PuglWinPFD fakePfd = puglWinGetPixelFormatDescriptor(view->hints);
const int fakePfId = ChoosePixelFormat(fakeWin.hdc, &fakePfd);
if (!fakePfId) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
} else if (!SetPixelFormat(fakeWin.hdc, fakePfId, &fakePfd)) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
}
// Create fake GL context to get at the functions we need
HGLRC fakeRc = wglCreateContext(fakeWin.hdc);
if (!fakeRc) {
- return puglWinError(&fakeWin, PUGL_ERR_CREATE_CONTEXT);
+ return puglWinError(&fakeWin, PUGL_CREATE_CONTEXT_FAILED);
}
// Enter fake context and get extension functions
@@ -160,7 +161,7 @@ puglWinGlConfigure(PuglView* view)
UINT numFormats = 0;
if (!surface->procs.wglChoosePixelFormat(
fakeWin.hdc, pixelAttrs, NULL, 1u, &impl->pfId, &numFormats)) {
- return puglWinError(&fakeWin, PUGL_ERR_SET_FORMAT);
+ return puglWinError(&fakeWin, PUGL_SET_FORMAT_FAILED);
}
DescribePixelFormat(
@@ -177,10 +178,10 @@ puglWinGlConfigure(PuglView* view)
ReleaseDC(fakeWin.hwnd, fakeWin.hdc);
DestroyWindow(fakeWin.hwnd);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -190,7 +191,9 @@ puglWinGlCreate(PuglView* view)
const int contextAttribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, view->hints[PUGL_CONTEXT_VERSION_MAJOR],
WGL_CONTEXT_MINOR_VERSION_ARB, view->hints[PUGL_CONTEXT_VERSION_MINOR],
- WGL_CONTEXT_PROFILE_MASK_ARB,
+ WGL_CONTEXT_FLAGS_ARB, (view->hints[PUGL_USE_DEBUG_CONTEXT]
+ ? WGL_CONTEXT_DEBUG_BIT_ARB
+ : 0),
(view->hints[PUGL_USE_COMPAT_PROFILE]
? WGL_CONTEXT_CORE_PROFILE_BIT_ARB
: WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB),
@@ -205,16 +208,16 @@ puglWinGlCreate(PuglView* view)
DestroyWindow(impl->hwnd);
impl->hwnd = NULL;
impl->hdc = NULL;
- return PUGL_ERR_SET_FORMAT;
+ return PUGL_SET_FORMAT_FAILED;
}
// Create GL context
if (surface->procs.wglCreateContextAttribs &&
!(surface->hglrc = surface->procs.wglCreateContextAttribs(
impl->hdc, 0, contextAttribs))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
} else if (!(surface->hglrc = wglCreateContext(impl->hdc))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
// Enter context and set swap interval
@@ -223,10 +226,10 @@ puglWinGlCreate(PuglView* view)
surface->procs.wglSwapInterval(view->hints[PUGL_SWAP_INTERVAL]);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlDestroy(PuglView* view)
{
PuglWinGlSurface* surface = (PuglWinGlSurface*)view->impl->surface;
@@ -237,10 +240,10 @@ puglWinGlDestroy(PuglView* view)
view->impl->surface = NULL;
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlEnter(PuglView* view, bool drawing)
{
PuglWinGlSurface* surface = (PuglWinGlSurface*)view->impl->surface;
@@ -252,10 +255,10 @@ puglWinGlEnter(PuglView* view, bool drawing)
BeginPaint(view->impl->hwnd, &ps);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlLeave(PuglView* view, bool drawing)
{
if (drawing) {
@@ -265,16 +268,15 @@ puglWinGlLeave(PuglView* view, bool drawing)
}
wglMakeCurrent(NULL, NULL);
-
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglWinGlResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index adf8c9d..c891604 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -127,7 +127,8 @@ puglPollEvents(PuglWorld* world, const double timeout)
ret = select(nfds, &fds, NULL, NULL, &tv);
}
- return ret < 0 ? PUGL_ERR_UNKNOWN : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS;
+ return ret < 0 ? PUGL_UNKNOWN_ERROR
+ : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS;
}
static PuglView*
@@ -185,10 +186,13 @@ puglCreateWindow(PuglView* view, const char* title)
impl->screen = DefaultScreen(display);
if (!view->backend || !view->backend->configure) {
- return 1;
- } else if (view->backend->configure(view) || !impl->vi) {
+ return PUGL_BAD_BACKEND;
+ }
+
+ PuglStatus st = view->backend->configure(view);
+ if (st || !impl->vi) {
view->backend->destroy(view);
- return 2;
+ return st ? st : PUGL_BACKEND_FAILED;
}
Window xParent = view->parent ? (Window)view->parent
@@ -207,8 +211,8 @@ puglCreateWindow(PuglView* view, const char* title)
0, impl->vi->depth, InputOutput,
impl->vi->visual, CWColormap | CWEventMask, &attr);
- if (view->backend->create(view)) {
- return 3;
+ if ((st = view->backend->create(view))) {
+ return st;
}
XSizeHints sizeHints = getSizeHints(view);
@@ -239,7 +243,7 @@ puglCreateWindow(PuglView* view, const char* title)
fprintf(stderr, "warning: XCreateIC failed\n");
}
- return 0;
+ return PUGL_SUCCESS;
}
PuglStatus
@@ -287,6 +291,11 @@ static PuglKey
keySymToSpecial(KeySym sym)
{
switch (sym) {
+ case XK_BackSpace: return PUGL_KEY_BACKSPACE;
+ case XK_Tab: return PUGL_KEY_TAB;
+ case XK_Return: return PUGL_KEY_RETURN;
+ case XK_Escape: return PUGL_KEY_ESCAPE;
+ case XK_Delete: return PUGL_KEY_DELETE;
case XK_F1: return PUGL_KEY_F1;
case XK_F2: return PUGL_KEY_F2;
case XK_F3: return PUGL_KEY_F3;
@@ -323,7 +332,7 @@ keySymToSpecial(KeySym sym)
case XK_Num_Lock: return PUGL_KEY_NUM_LOCK;
case XK_Print: return PUGL_KEY_PRINT_SCREEN;
case XK_Pause: return PUGL_KEY_PAUSE;
- default: break;
+ default: break;
}
return (PuglKey)0;
}
@@ -793,7 +802,7 @@ puglSetFrame(PuglView* view, const PuglRect frame)
XMoveResizeWindow(view->world->impl->display, view->impl->win,
(int)frame.x, (int)frame.y,
(int)frame.width, (int)frame.height)) {
- return PUGL_ERR_UNKNOWN;
+ return PUGL_UNKNOWN_ERROR;
}
return PUGL_SUCCESS;
diff --git a/pugl/detail/x11_cairo.c b/pugl/detail/x11_cairo.c
index 550144a..0753317 100644
--- a/pugl/detail/x11_cairo.c
+++ b/pugl/detail/x11_cairo.c
@@ -38,7 +38,7 @@ typedef struct {
cairo_t* frontCr;
} PuglX11CairoSurface;
-static int
+static PuglStatus
puglX11CairoConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -48,10 +48,10 @@ puglX11CairoConfigure(PuglView* view)
pat.screen = impl->screen;
impl->vi = XGetVisualInfo(impl->display, VisualScreenMask, &pat, &n);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -77,16 +77,16 @@ puglX11CairoCreate(PuglView* view)
cairo_destroy(surface.backCr);
cairo_surface_destroy(surface.front);
cairo_surface_destroy(surface.back);
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
impl->surface = calloc(1, sizeof(PuglX11CairoSurface));
*(PuglX11CairoSurface*)impl->surface = surface;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoDestroy(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -98,10 +98,10 @@ puglX11CairoDestroy(PuglView* view)
cairo_surface_destroy(surface->back);
free(surface);
impl->surface = NULL;
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoEnter(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
@@ -111,10 +111,10 @@ puglX11CairoEnter(PuglView* view, bool drawing)
cairo_save(surface->frontCr);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoLeave(PuglView* view, bool drawing)
{
PuglInternals* const impl = view->impl;
@@ -126,10 +126,10 @@ puglX11CairoLeave(PuglView* view, bool drawing)
cairo_restore(surface->frontCr);
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11CairoResize(PuglView* view, int width, int height)
{
PuglInternals* const impl = view->impl;
@@ -141,13 +141,13 @@ puglX11CairoResize(PuglView* view, int width, int height)
cairo_surface_destroy(surface->front);
if (!(surface->front = cairo_surface_create_similar(
surface->back, CAIRO_CONTENT_COLOR, width, height))) {
- return PUGL_ERR_CREATE_CONTEXT;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
surface->frontCr = cairo_create(surface->front);
cairo_save(surface->frontCr);
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/detail/x11_gl.c b/pugl/detail/x11_gl.c
index b6f3c51..f5dbe2c 100644
--- a/pugl/detail/x11_gl.c
+++ b/pugl/detail/x11_gl.c
@@ -39,13 +39,13 @@ typedef struct {
int double_buffered;
} PuglX11GlSurface;
-static int
+static PuglStatus
puglX11GlHintValue(const int value)
{
return value == PUGL_DONT_CARE ? (int)GLX_DONT_CARE : value;
}
-static int
+static PuglStatus
puglX11GlGetAttrib(Display* const display,
const GLXFBConfig fb_config,
const int attrib)
@@ -55,7 +55,7 @@ puglX11GlGetAttrib(Display* const display,
return value;
}
-static int
+static PuglStatus
puglX11GlConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -86,7 +86,7 @@ puglX11GlConfigure(PuglView* view)
GLXFBConfig* fbc = glXChooseFBConfig(display, screen, attrs, &n_fbc);
if (n_fbc <= 0) {
fprintf(stderr, "error: Failed to create GL context\n");
- return 1;
+ return PUGL_CREATE_CONTEXT_FAILED;
}
surface->fb_config = fbc[0];
@@ -105,10 +105,10 @@ puglX11GlConfigure(PuglView* view)
XFree(fbc);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
@@ -119,6 +119,9 @@ puglX11GlCreate(PuglView* view)
const int ctx_attrs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, view->hints[PUGL_CONTEXT_VERSION_MAJOR],
GLX_CONTEXT_MINOR_VERSION_ARB, view->hints[PUGL_CONTEXT_VERSION_MINOR],
+ GLX_CONTEXT_FLAGS_ARB, (view->hints[PUGL_USE_DEBUG_CONTEXT]
+ ? GLX_CONTEXT_DEBUG_BIT_ARB
+ : 0),
GLX_CONTEXT_PROFILE_MASK_ARB, (view->hints[PUGL_USE_COMPAT_PROFILE]
? GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
: GLX_CONTEXT_CORE_PROFILE_BIT_ARB),
@@ -131,22 +134,25 @@ puglX11GlCreate(PuglView* view)
(CreateContextAttribs)glXGetProcAddress(
(const GLubyte*)"glXCreateContextAttribsARB");
- impl->surface = surface;
- surface->ctx = create_context(display, fb_config, 0, GL_TRUE, ctx_attrs);
+ surface->ctx = create_context(display, fb_config, 0, GL_TRUE, ctx_attrs);
if (!surface->ctx) {
surface->ctx =
glXCreateNewContext(display, fb_config, GLX_RGBA_TYPE, 0, True);
}
+ if (!surface->ctx) {
+ return PUGL_CREATE_CONTEXT_FAILED;
+ }
+
glXGetConfig(impl->display,
impl->vi,
GLX_DOUBLEBUFFER,
&surface->double_buffered);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlDestroy(PuglView* view)
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
@@ -155,18 +161,18 @@ puglX11GlDestroy(PuglView* view)
free(surface);
view->impl->surface = NULL;
}
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlEnter(PuglView* view, bool PUGL_UNUSED(drawing))
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
glXMakeCurrent(view->impl->display, view->impl->win, surface->ctx);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlLeave(PuglView* view, bool drawing)
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
@@ -179,15 +185,15 @@ puglX11GlLeave(PuglView* view, bool drawing)
glXMakeCurrent(view->impl->display, None, NULL);
- return 0;
+ return PUGL_SUCCESS;
}
-static int
+static PuglStatus
puglX11GlResize(PuglView* PUGL_UNUSED(view),
int PUGL_UNUSED(width),
int PUGL_UNUSED(height))
{
- return 0;
+ return PUGL_SUCCESS;
}
static void*
diff --git a/pugl/pugl.h b/pugl/pugl.h
index cdb73af..1299fa7 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -61,13 +61,16 @@ typedef void* PuglHandle;
Return status code.
*/
typedef enum {
- PUGL_SUCCESS,
- PUGL_FAILURE,
- PUGL_ERR_UNKNOWN,
- PUGL_ERR_CREATE_WINDOW,
- PUGL_ERR_SET_FORMAT,
- PUGL_ERR_CREATE_CONTEXT,
- PUGL_ERR_UNSUPPORTED_TYPE,
+ PUGL_SUCCESS, /**< Success */
+ PUGL_FAILURE, /**< Non-fatal failure */
+ PUGL_UNKNOWN_ERROR, /**< Unknown system error */
+ PUGL_BAD_BACKEND, /**< Invalid or missing backend */
+ PUGL_BACKEND_FAILED, /**< Backend initialisation failed */
+ PUGL_REGISTRATION_FAILED, /**< Window class registration failed */
+ PUGL_CREATE_WINDOW_FAILED, /**< Window creation failed */
+ PUGL_SET_FORMAT_FAILED, /**< Failed to set pixel format */
+ PUGL_CREATE_CONTEXT_FAILED, /**< Failed to create drawing context */
+ PUGL_UNSUPPORTED_TYPE, /**< Unsupported data type */
} PuglStatus;
/**
@@ -75,6 +78,7 @@ typedef enum {
*/
typedef enum {
PUGL_USE_COMPAT_PROFILE, /**< Use compatible (not core) OpenGL profile */
+ PUGL_USE_DEBUG_CONTEXT, /**< True to use a debug OpenGL context */
PUGL_CONTEXT_VERSION_MAJOR, /**< OpenGL context major version */
PUGL_CONTEXT_VERSION_MINOR, /**< OpenGL context minor version */
PUGL_RED_BITS, /**< Number of bits for red channel */
@@ -139,6 +143,8 @@ typedef enum {
typedef enum {
// ASCII control codes
PUGL_KEY_BACKSPACE = 0x08,
+ PUGL_KEY_TAB = 0x09,
+ PUGL_KEY_RETURN = 0x0D,
PUGL_KEY_ESCAPE = 0x1B,
PUGL_KEY_DELETE = 0x7F,
@@ -802,6 +808,8 @@ puglSetClipboard(PuglView* view,
PUGL_API PuglStatus
puglRequestAttention(PuglView* view);
+#ifndef PUGL_DISABLE_DEPRECATED
+
/**
@}
@name Deprecated API
@@ -1012,6 +1020,8 @@ puglWaitForEvent(PuglView* view);
PUGL_API PUGL_DEPRECATED_BY("puglDispatchEvents") PuglStatus
puglProcessEvents(PuglView* view);
+#endif /* PUGL_DISABLE_DEPRECATED */
+
/**
@}
@}
diff --git a/test/pugl_gl3_test.c b/test/pugl_gl3_test.c
index f2d77f9..c939930 100644
--- a/test/pugl_gl3_test.c
+++ b/test/pugl_gl3_test.c
@@ -95,7 +95,7 @@ static const char* vertexSource = //
The use of pixel units here is handy because the border width can be
specified precisely in pixels to draw sharp lines. The border width is just
- hardcoded, but code be made a uniform or vertex attribute easily enough. */
+ hardcoded, but could be made a uniform or vertex attribute easily enough. */
static const char* fragmentSource = //
"#version 330\n"
"uniform vec2 u_size;\n"