aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2024-04-08 13:50:41 +0200
committerAndre Weissflog <floooh@gmail.com>2024-04-08 13:50:41 +0200
commitcb7bcf650d47aa05cd905da0190e506e97d71cc5 (patch)
treee482e0adcc12ab965df23fb4346b4d47272bb933
parentc2c709baf2b97288ed21a59f5eb5f1a7a49b7d90 (diff)
sokol_app.h gl: update GL context initialization
- on macOS: use default version 4.1 - elsewhere: use default version 4.3 - new funcs sapp_get_gl_major/minor_version
-rw-r--r--sokol_app.h38
1 files changed, 35 insertions, 3 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 95dcf640..c59a47cc 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -313,10 +313,15 @@
objects and values required for rendering. If sokol_app.h
is not compiled with SOKOL_WGPU, these functions return null.
- const uint32_t sapp_gl_get_framebuffer(void)
+ uint32_t sapp_gl_get_framebuffer(void)
This returns the 'default framebuffer' of the GL context.
Typically this will be zero.
+ int sapp_gl_get_major_version(void)
+ int sapp_gl_get_minor_version(void)
+ Returns the major and minor version of the GL context
+ (only for SOKOL_GLCORE, all other backends return zero here, including SOKOL_GLES3)
+
const void* sapp_android_get_native_activity(void);
On Android, get the native activity ANativeActivity pointer, otherwise
a null pointer.
@@ -1892,6 +1897,10 @@ SOKOL_APP_API_DECL const void* sapp_wgpu_get_depth_stencil_view(void);
/* GL: get framebuffer object */
SOKOL_APP_API_DECL uint32_t sapp_gl_get_framebuffer(void);
+/* GL: get major version (only valid for desktop GL) */
+SOKOL_APP_API_DECL int sapp_gl_get_major_version(void);
+/* GL: get minor version (only valid for desktop GL) */
+SOKOL_APP_API_DECL int sapp_gl_get_minor_version(void);
/* Android: get native activity handle */
SOKOL_APP_API_DECL const void* sapp_android_get_native_activity(void);
@@ -3085,8 +3094,13 @@ _SOKOL_PRIVATE sapp_desc _sapp_desc_defaults(const sapp_desc* desc) {
// (or expressed differently: zero is a valid value for gl_minor_version
// and can't be used to indicate 'default')
if (0 == res.gl_major_version) {
- res.gl_major_version = 3;
- res.gl_minor_version = 2;
+ #if defined(_SAPP_APPLE)
+ res.gl_major_version = 4;
+ res.gl_minor_version = 1;
+ #else
+ res.gl_major_version = 4;
+ res.gl_minor_version = 3;
+ #endif
}
res.html5_canvas_name = _sapp_def(res.html5_canvas_name, "canvas");
res.clipboard_size = _sapp_def(res.clipboard_size, 8192);
@@ -11753,6 +11767,24 @@ SOKOL_API_IMPL uint32_t sapp_gl_get_framebuffer(void) {
#endif
}
+SOKOL_API_IMPL int sapp_gl_get_major_version(void) {
+ SOKOL_ASSERT(_sapp.valid);
+ #if defined(SOKOL_GLCORE)
+ return _sapp.desc.gl_major_version;
+ #else
+ return 0;
+ #endif
+}
+
+SOKOL_API_IMPL int sapp_gl_get_minor_version(void) {
+ SOKOL_ASSERT(_sapp.valid);
+ #if defined(SOKOL_GLCORE)
+ return _sapp.desc.gl_minor_version;
+ #else
+ return 0;
+ #endif
+}
+
SOKOL_API_IMPL const void* sapp_android_get_native_activity(void) {
// NOTE: _sapp.valid is not asserted here because sapp_android_get_native_activity()
// needs to be callable from within sokol_main() (see: https://github.com/floooh/sokol/issues/708)