aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bindings/cpp/include/pugl/pugl.hpp5
-rw-r--r--doc/c/view.rst4
-rw-r--r--examples/pugl_clipboard_demo.c2
-rw-r--r--examples/pugl_cursor_demo.c2
-rw-r--r--examples/pugl_embed_demo.c4
-rw-r--r--examples/pugl_shader_demo.c5
-rw-r--r--examples/pugl_window_demo.c2
-rw-r--r--include/pugl/pugl.h15
-rw-r--r--src/common.c10
-rw-r--r--src/mac_gl.m4
-rw-r--r--src/win_gl.c4
-rw-r--r--src/x11_gl.c10
-rw-r--r--test/test_gl_hints.c13
-rw-r--r--test/test_stub_hints.c8
-rw-r--r--test/test_utils.h10
15 files changed, 59 insertions, 39 deletions
diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp
index 4fe7244..88d8fd5 100644
--- a/bindings/cpp/include/pugl/pugl.hpp
+++ b/bindings/cpp/include/pugl/pugl.hpp
@@ -342,10 +342,11 @@ enum class SizeHint {
/// @copydoc PuglViewHint
enum class ViewHint {
- useCompatProfile, ///< @copydoc PUGL_USE_COMPAT_PROFILE
- useDebugContext, ///< @copydoc PUGL_USE_DEBUG_CONTEXT
+ contextAPI, ///< @copydoc PUGL_CONTEXT_API
contextVersionMajor, ///< @copydoc PUGL_CONTEXT_VERSION_MAJOR
contextVersionMinor, ///< @copydoc PUGL_CONTEXT_VERSION_MINOR
+ contextProfile, ///< @copydoc PUGL_CONTEXT_PROFILE
+ contextDebug, ///< @copydoc PUGL_CONTEXT_DEBUG
redBits, ///< @copydoc PUGL_RED_BITS
greenBits, ///< @copydoc PUGL_GREEN_BITS
blueBits, ///< @copydoc PUGL_BLUE_BITS
diff --git a/doc/c/view.rst b/doc/c/view.rst
index ea261ff..ff8d3db 100644
--- a/doc/c/view.rst
+++ b/doc/c/view.rst
@@ -159,9 +159,11 @@ For example, to use OpenGL 3.3 Core Profile:
.. code-block:: c
- puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3);
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MINOR, 3);
+ puglSetViewHint(view,
+ PUGL_CONTEXT_PROFILE,
+ PUGL_OPENGL_COMPATIBILITY_PROFILE);
If you need to perform some setup using the OpenGL API,
there are two ways to do so.
diff --git a/examples/pugl_clipboard_demo.c b/examples/pugl_clipboard_demo.c
index ddb29e0..31bc7f6 100644
--- a/examples/pugl_clipboard_demo.c
+++ b/examples/pugl_clipboard_demo.c
@@ -224,7 +224,7 @@ main(int argc, char** argv)
puglSetSizeHint(view, PUGL_MIN_SIZE, 128, 128);
puglSetBackend(view, puglGlBackend());
- puglSetViewHint(view, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking);
+ puglSetViewHint(view, PUGL_CONTEXT_DEBUG, opts.errorChecking);
puglSetViewHint(view, PUGL_RESIZABLE, opts.resizable);
puglSetViewHint(view, PUGL_SAMPLES, opts.samples);
puglSetViewHint(view, PUGL_DOUBLE_BUFFER, opts.doubleBuffer);
diff --git a/examples/pugl_cursor_demo.c b/examples/pugl_cursor_demo.c
index 50bf0da..c4a4e8d 100644
--- a/examples/pugl_cursor_demo.c
+++ b/examples/pugl_cursor_demo.c
@@ -129,7 +129,7 @@ main(int argc, char** argv)
puglSetSizeHint(view, PUGL_MAX_SIZE, 512, 256);
puglSetBackend(view, puglGlBackend());
- puglSetViewHint(view, PUGL_USE_DEBUG_CONTEXT, app.opts.errorChecking);
+ puglSetViewHint(view, PUGL_CONTEXT_DEBUG, app.opts.errorChecking);
puglSetViewHint(view, PUGL_RESIZABLE, app.opts.resizable);
puglSetViewHint(view, PUGL_SAMPLES, app.opts.samples);
puglSetViewHint(view, PUGL_DOUBLE_BUFFER, app.opts.doubleBuffer);
diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c
index 5c75ffc..3b80110 100644
--- a/examples/pugl_embed_demo.c
+++ b/examples/pugl_embed_demo.c
@@ -269,7 +269,7 @@ main(int argc, char** argv)
puglSetSizeHint(app.parent, PUGL_MAX_ASPECT, 16, 9);
puglSetBackend(app.parent, puglGlBackend());
- puglSetViewHint(app.parent, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking);
+ puglSetViewHint(app.parent, PUGL_CONTEXT_DEBUG, opts.errorChecking);
puglSetViewHint(app.parent, PUGL_RESIZABLE, opts.resizable);
puglSetViewHint(app.parent, PUGL_SAMPLES, opts.samples);
puglSetViewHint(app.parent, PUGL_DOUBLE_BUFFER, opts.doubleBuffer);
@@ -291,7 +291,7 @@ main(int argc, char** argv)
puglSetFrame(app.child, getChildFrame(parentFrame));
puglSetParentWindow(app.child, puglGetNativeView(app.parent));
- puglSetViewHint(app.child, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking);
+ puglSetViewHint(app.child, PUGL_CONTEXT_DEBUG, opts.errorChecking);
puglSetViewHint(app.child, PUGL_SAMPLES, opts.samples);
puglSetViewHint(app.child, PUGL_DOUBLE_BUFFER, opts.doubleBuffer);
puglSetViewHint(app.child, PUGL_SWAP_INTERVAL, opts.sync);
diff --git a/examples/pugl_shader_demo.c b/examples/pugl_shader_demo.c
index d8b9252..f273e31 100644
--- a/examples/pugl_shader_demo.c
+++ b/examples/pugl_shader_demo.c
@@ -271,10 +271,11 @@ setupPugl(PuglTestApp* app)
puglSetSizeHint(app->view, PUGL_MIN_ASPECT, 1, 1);
puglSetSizeHint(app->view, PUGL_MAX_ASPECT, 16, 9);
puglSetBackend(app->view, puglGlBackend());
- puglSetViewHint(app->view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
- puglSetViewHint(app->view, PUGL_USE_DEBUG_CONTEXT, app->opts.errorChecking);
+ puglSetViewHint(app->view, PUGL_CONTEXT_API, PUGL_OPENGL_API);
puglSetViewHint(app->view, PUGL_CONTEXT_VERSION_MAJOR, app->glMajorVersion);
puglSetViewHint(app->view, PUGL_CONTEXT_VERSION_MINOR, app->glMinorVersion);
+ puglSetViewHint(app->view, PUGL_CONTEXT_PROFILE, PUGL_OPENGL_CORE_PROFILE);
+ puglSetViewHint(app->view, PUGL_CONTEXT_DEBUG, app->opts.errorChecking);
puglSetViewHint(app->view, PUGL_RESIZABLE, app->opts.resizable);
puglSetViewHint(app->view, PUGL_SAMPLES, app->opts.samples);
puglSetViewHint(app->view, PUGL_DOUBLE_BUFFER, app->opts.doubleBuffer);
diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c
index 4596b61..c672780 100644
--- a/examples/pugl_window_demo.c
+++ b/examples/pugl_window_demo.c
@@ -195,7 +195,7 @@ main(int argc, char** argv)
puglSetSizeHint(view, PUGL_MAX_SIZE, 2048, 2048);
puglSetBackend(view, puglGlBackend());
- puglSetViewHint(view, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking);
+ puglSetViewHint(view, PUGL_CONTEXT_DEBUG, opts.errorChecking);
puglSetViewHint(view, PUGL_RESIZABLE, opts.resizable);
puglSetViewHint(view, PUGL_SAMPLES, opts.samples);
puglSetViewHint(view, PUGL_DOUBLE_BUFFER, opts.doubleBuffer);
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 0e97f91..ea2f3a9 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -872,10 +872,11 @@ typedef void* PuglHandle;
/// A hint for configuring a view
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_API, ///< OpenGL render API (GL/GLES)
PUGL_CONTEXT_VERSION_MAJOR, ///< OpenGL context major version
PUGL_CONTEXT_VERSION_MINOR, ///< OpenGL context minor version
+ PUGL_CONTEXT_PROFILE, ///< OpenGL context profile (core/compatibility)
+ PUGL_CONTEXT_DEBUG, ///< OpenGL context debugging enabled
PUGL_RED_BITS, ///< Number of bits for red channel
PUGL_GREEN_BITS, ///< Number of bits for green channel
PUGL_BLUE_BITS, ///< Number of bits for blue channel
@@ -897,9 +898,13 @@ typedef enum {
/// A special view hint value
typedef enum {
- PUGL_DONT_CARE = -1, ///< Use best available value
- PUGL_FALSE = 0, ///< Explicitly false
- PUGL_TRUE = 1 ///< Explicitly true
+ PUGL_DONT_CARE = -1, ///< Generic trinary: Use best default
+ PUGL_FALSE = 0, ///< Generic trinary: Explicitly false
+ PUGL_TRUE = 1, ///< Generic trinary: Explicitly true
+ PUGL_OPENGL_API = 2, ///< For #PUGL_CONTEXT_API
+ PUGL_OPENGL_ES_API = 3, ///< For #PUGL_CONTEXT_API
+ PUGL_OPENGL_CORE_PROFILE = 4, ///< For #PUGL_CONTEXT_PROFILE
+ PUGL_OPENGL_COMPATIBILITY_PROFILE = 5, ///< For #PUGL_CONTEXT_PROFILE
} PuglViewHintValue;
/// View type
diff --git a/src/common.c b/src/common.c
index 90a75cf..5c39b39 100644
--- a/src/common.c
+++ b/src/common.c
@@ -91,10 +91,11 @@ puglGetClassName(const PuglWorld* world)
static void
puglSetDefaultHints(PuglHints hints)
{
- hints[PUGL_USE_COMPAT_PROFILE] = PUGL_TRUE;
- hints[PUGL_USE_DEBUG_CONTEXT] = PUGL_FALSE;
+ hints[PUGL_CONTEXT_API] = PUGL_OPENGL_API;
hints[PUGL_CONTEXT_VERSION_MAJOR] = 2;
hints[PUGL_CONTEXT_VERSION_MINOR] = 0;
+ hints[PUGL_CONTEXT_PROFILE] = PUGL_OPENGL_CORE_PROFILE;
+ hints[PUGL_CONTEXT_DEBUG] = PUGL_FALSE;
hints[PUGL_RED_BITS] = 8;
hints[PUGL_GREEN_BITS] = 8;
hints[PUGL_BLUE_BITS] = 8;
@@ -203,10 +204,11 @@ puglSetViewHint(PuglView* view, PuglViewHint hint, int value)
{
if (value == PUGL_DONT_CARE) {
switch (hint) {
- case PUGL_USE_COMPAT_PROFILE:
- case PUGL_USE_DEBUG_CONTEXT:
+ case PUGL_CONTEXT_API:
case PUGL_CONTEXT_VERSION_MAJOR:
case PUGL_CONTEXT_VERSION_MINOR:
+ case PUGL_CONTEXT_PROFILE:
+ case PUGL_CONTEXT_DEBUG:
case PUGL_SWAP_INTERVAL:
return PUGL_BAD_PARAMETER;
default:
diff --git a/src/mac_gl.m b/src/mac_gl.m
index b1430d9..f177bf9 100644
--- a/src/mac_gl.m
+++ b/src/mac_gl.m
@@ -29,7 +29,9 @@ ensureHint(PuglView* const view, const PuglViewHint hint, const int value)
- (id)initWithFrame:(NSRect)frame
{
- const bool compat = puglview->hints[PUGL_USE_COMPAT_PROFILE];
+ const bool compat =
+ puglview->hints[PUGL_CONTEXT_PROFILE] == PUGL_OPENGL_COMPATIBILITY_PROFILE;
+
const unsigned samples = (unsigned)puglview->hints[PUGL_SAMPLES];
const int major = puglview->hints[PUGL_CONTEXT_VERSION_MAJOR];
const unsigned profile =
diff --git a/src/win_gl.c b/src/win_gl.c
index 444f87f..0ca9909 100644
--- a/src/win_gl.c
+++ b/src/win_gl.c
@@ -198,10 +198,10 @@ puglWinGlCreate(PuglView* view)
view->hints[PUGL_CONTEXT_VERSION_MINOR],
WGL_CONTEXT_FLAGS_ARB,
- (view->hints[PUGL_USE_DEBUG_CONTEXT] ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
+ (view->hints[PUGL_CONTEXT_DEBUG] ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
WGL_CONTEXT_PROFILE_MASK_ARB,
- (view->hints[PUGL_USE_COMPAT_PROFILE]
+ ((view->hints[PUGL_CONTEXT_PROFILE] == PUGL_OPENGL_COMPATIBILITY_PROFILE)
? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
: WGL_CONTEXT_CORE_PROFILE_BIT_ARB),
diff --git a/src/x11_gl.c b/src/x11_gl.c
index f1dc56b..de22b34 100644
--- a/src/x11_gl.c
+++ b/src/x11_gl.c
@@ -145,12 +145,14 @@ puglX11GlCreate(PuglView* view)
view->hints[PUGL_CONTEXT_VERSION_MINOR],
GLX_CONTEXT_FLAGS_ARB,
- (view->hints[PUGL_USE_DEBUG_CONTEXT] ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
+ (view->hints[PUGL_CONTEXT_DEBUG] ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
GLX_CONTEXT_PROFILE_MASK_ARB,
- (view->hints[PUGL_USE_COMPAT_PROFILE]
- ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
- : GLX_CONTEXT_CORE_PROFILE_BIT_ARB),
+ (view->hints[PUGL_CONTEXT_API] == PUGL_OPENGL_ES_API
+ ? GLX_CONTEXT_ES2_PROFILE_BIT_EXT
+ : (view->hints[PUGL_CONTEXT_PROFILE] == PUGL_OPENGL_COMPATIBILITY_PROFILE
+ ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
+ : GLX_CONTEXT_CORE_PROFILE_BIT_ARB)),
0};
const char* const extensions =
diff --git a/test/test_gl_hints.c b/test/test_gl_hints.c
index 64c7342..9a0b168 100644
--- a/test/test_gl_hints.c
+++ b/test/test_gl_hints.c
@@ -37,14 +37,16 @@ main(void)
puglSetSizeHint(view, PUGL_DEFAULT_SIZE, 512, 512);
// Check invalid cases
- assert(puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_DONT_CARE) ==
- PUGL_BAD_PARAMETER);
- assert(puglSetViewHint(view, PUGL_USE_DEBUG_CONTEXT, PUGL_DONT_CARE) ==
+ assert(puglSetViewHint(view, PUGL_CONTEXT_API, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
assert(puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
assert(puglSetViewHint(view, PUGL_CONTEXT_VERSION_MINOR, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
+ assert(puglSetViewHint(view, PUGL_CONTEXT_PROFILE, PUGL_DONT_CARE) ==
+ PUGL_BAD_PARAMETER);
+ assert(puglSetViewHint(view, PUGL_CONTEXT_DEBUG, PUGL_DONT_CARE) ==
+ PUGL_BAD_PARAMETER);
assert(puglSetViewHint(view, PUGL_SWAP_INTERVAL, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
@@ -65,10 +67,11 @@ main(void)
printViewHints(view);
// Check that no hints are set to PUGL_DONT_CARE
- assert(puglGetViewHint(view, PUGL_USE_COMPAT_PROFILE) != PUGL_DONT_CARE);
- assert(puglGetViewHint(view, PUGL_USE_DEBUG_CONTEXT) != PUGL_DONT_CARE);
+ assert(puglGetViewHint(view, PUGL_CONTEXT_API) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_CONTEXT_VERSION_MINOR) != PUGL_DONT_CARE);
+ assert(puglGetViewHint(view, PUGL_CONTEXT_PROFILE) != PUGL_DONT_CARE);
+ assert(puglGetViewHint(view, PUGL_CONTEXT_DEBUG) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_RED_BITS) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_GREEN_BITS) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_BLUE_BITS) != PUGL_DONT_CARE);
diff --git a/test/test_stub_hints.c b/test/test_stub_hints.c
index d5331c8..09205b3 100644
--- a/test/test_stub_hints.c
+++ b/test/test_stub_hints.c
@@ -50,9 +50,9 @@ main(void)
assert(!puglSetViewHint(view, PUGL_REFRESH_RATE, PUGL_DONT_CARE));
// Check failure to set PUGL_DONT_CARE for hints that don't support it
- assert(puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_DONT_CARE) ==
+ assert(puglSetViewHint(view, PUGL_CONTEXT_PROFILE, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
- assert(puglSetViewHint(view, PUGL_USE_DEBUG_CONTEXT, PUGL_DONT_CARE) ==
+ assert(puglSetViewHint(view, PUGL_CONTEXT_DEBUG, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
assert(puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, PUGL_DONT_CARE) ==
PUGL_BAD_PARAMETER);
@@ -66,8 +66,8 @@ main(void)
printViewHints(view);
// Check that no relevant hints are set to PUGL_DONT_CARE
- assert(puglGetViewHint(view, PUGL_USE_COMPAT_PROFILE) != PUGL_DONT_CARE);
- assert(puglGetViewHint(view, PUGL_USE_DEBUG_CONTEXT) != PUGL_DONT_CARE);
+ assert(puglGetViewHint(view, PUGL_CONTEXT_PROFILE) != PUGL_DONT_CARE);
+ assert(puglGetViewHint(view, PUGL_CONTEXT_DEBUG) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_CONTEXT_VERSION_MINOR) != PUGL_DONT_CARE);
assert(puglGetViewHint(view, PUGL_RED_BITS) != PUGL_DONT_CARE);
diff --git a/test/test_utils.h b/test/test_utils.h
index db3485b..8e21d97 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -255,14 +255,16 @@ static inline const char*
puglViewHintString(const PuglViewHint hint)
{
switch (hint) {
- case PUGL_USE_COMPAT_PROFILE:
- return "Use compatible profile";
- case PUGL_USE_DEBUG_CONTEXT:
- return "Use debug context";
+ case PUGL_CONTEXT_API:
+ return "Context API";
case PUGL_CONTEXT_VERSION_MAJOR:
return "Context major version";
case PUGL_CONTEXT_VERSION_MINOR:
return "Context minor version";
+ case PUGL_CONTEXT_PROFILE:
+ return "Context profile";
+ case PUGL_CONTEXT_DEBUG:
+ return "Context debug";
case PUGL_RED_BITS:
return "Red bits";
case PUGL_GREEN_BITS: