summaryrefslogtreecommitdiff
path: root/examples/OpenGL3test.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-29 09:39:21 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-29 09:39:21 +0200
commitda66e21e1d5826639da2b8d3bd5ccd27920a4aad (patch)
treee775f7d34d94970fedebf03da64b1d5e7cfcee38 /examples/OpenGL3test.cxx
parent283184a09a360724a61b9e256c16f799a73cf405 (diff)
Support of FLTK widgets in OpenGL 3 windows - cont'd.
This commit allows to switch between FL_DOUBLE / FL_SINGLE modes in widget-containing GL3 windows. Demo program examples/OpenGL3test is modified to show FLTK widgets even if the platform does not support OpenGL 3.
Diffstat (limited to 'examples/OpenGL3test.cxx')
-rw-r--r--examples/OpenGL3test.cxx22
1 files changed, 14 insertions, 8 deletions
diff --git a/examples/OpenGL3test.cxx b/examples/OpenGL3test.cxx
index 40d0bf74e..d9216c4a3 100644
--- a/examples/OpenGL3test.cxx
+++ b/examples/OpenGL3test.cxx
@@ -30,7 +30,7 @@
# endif
# include <GL/glew.h>
#endif
-
+#include <FL/gl.h> // for gl_texture_reset()
void add_output(const char *format, ...);
@@ -50,8 +50,7 @@ public:
gl_version_major = 0;
}
void draw(void) {
- if (gl_version_major < 3) return;
- if (!shaderProgram) {
+ if (gl_version_major >= 3 && !shaderProgram) {
GLuint vs;
GLuint fs;
int Mslv, mslv; // major and minor version numbers of the shading language
@@ -135,9 +134,11 @@ public:
}
glClearColor(0.08, 0.8, 0.8, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
- GLfloat p[]={0,0};
- glUniform2fv(positionUniform, 1, (const GLfloat *)&p);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ if (shaderProgram) {
+ GLfloat p[]={0,0};
+ glUniform2fv(positionUniform, 1, (const GLfloat *)&p);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ }
Fl_Gl_Window::draw(); // Draw FLTK child widgets.
}
virtual int handle(int event) {
@@ -158,7 +159,12 @@ public:
const uchar *glv = glGetString(GL_VERSION);
add_output("GL_VERSION=%s\n", glv);
sscanf((const char *)glv, "%d", &gl_version_major);
- if (gl_version_major < 3) add_output("\nThis platform does not support OpenGL V3\n\n");
+ if (gl_version_major < 3) {
+ add_output("\nThis platform does not support OpenGL V3 :\n"
+ "FLTK widgets will appear but the programmed "
+ "rendering pipeline will not run.\n");
+ mode(mode() & !FL_OPENGL3);
+ }
redraw();
}
@@ -181,7 +187,7 @@ public:
}
return retval;
}
- void reset(void) { shaderProgram = 0; }
+ void reset(void) { shaderProgram = 0; gl_texture_reset(); }
};