Skip to content

Commit 475bd55

Browse files
committed
glgsg: add gl-forward-compatible config variable
This is meant to be used alongside gl-version to request a "forward compatible" OpenGL 3.0 or 3.1 context, which removes support for deprecated features such as the fixed-function pipeline.
1 parent 5361251 commit 475bd55

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

panda/src/glstuff/glmisc_src.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ ConfigVariableInt gl_version
1717
("gl-version", "",
1818
PRC_DESC("Set this to get an OpenGL context with a specific version."));
1919

20+
ConfigVariableBool gl_forward_compatible
21+
("gl-forward-compatible", false,
22+
PRC_DESC("Setting this to true will request a forward-compatible OpenGL "
23+
"context, which will not support the fixed-function pipeline."));
24+
2025
ConfigVariableBool gl_support_fbo
2126
("gl-support-fbo", true,
2227
PRC_DESC("Configure this false if your GL's implementation of "

panda/src/glstuff/glmisc_src.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
// #define GSG_VERBOSE 1
4242

4343
extern EXPCL_GL ConfigVariableInt gl_version;
44+
extern EXPCL_GL ConfigVariableBool gl_forward_compatible;
4445
extern EXPCL_GL ConfigVariableBool gl_support_fbo;
4546
extern ConfigVariableBool gl_cheap_textures;
4647
extern ConfigVariableBool gl_ignore_clamp;

panda/src/glxdisplay/glxGraphicsStateGuardian.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,20 @@ choose_pixel_format(const FrameBufferProperties &properties,
352352
attrib_list[n++] = gl_version[1];
353353
}
354354
}
355+
int flags = 0;
355356
if (gl_debug) {
357+
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
358+
}
359+
if (gl_forward_compatible) {
360+
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
361+
if (gl_version.get_num_words() == 0 || gl_version[0] < 2) {
362+
glxdisplay_cat.error()
363+
<< "gl-forward-compatible requires gl-version >= 3 0\n";
364+
}
365+
}
366+
if (flags != 0) {
356367
attrib_list[n++] = GLX_CONTEXT_FLAGS_ARB;
357-
attrib_list[n++] = GLX_CONTEXT_DEBUG_BIT_ARB;
368+
attrib_list[n++] = flags;
358369
}
359370
attrib_list[n] = None;
360371
_context = _glXCreateContextAttribs(_display, _fbconfig, _share_context,

panda/src/wgldisplay/wglGraphicsStateGuardian.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,20 @@ make_context(HDC hdc) {
609609
attrib_list[n++] = gl_version[1];
610610
}
611611
}
612+
int flags = 0;
612613
if (gl_debug) {
614+
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
615+
}
616+
if (gl_forward_compatible) {
617+
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
618+
if (gl_version.get_num_words() == 0 || gl_version[0] < 2) {
619+
wgldisplay_cat.error()
620+
<< "gl-forward-compatible requires gl-version >= 3 0\n";
621+
}
622+
}
623+
if (flags != 0) {
613624
attrib_list[n++] = WGL_CONTEXT_FLAGS_ARB;
614-
attrib_list[n++] = WGL_CONTEXT_DEBUG_BIT_ARB;
625+
attrib_list[n++] = flags;
615626
}
616627
#ifndef SUPPORT_FIXED_FUNCTION
617628
attrib_list[n++] = WGL_CONTEXT_PROFILE_MASK_ARB;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy