Mercurial > octave
diff libinterp/corefcn/gl-render.h @ 25862:e5a73a8c116c
use wrapper class to call OpenGL functions
The motivation for this change is to allow calling OpenGL functions
through the Qt wrapper classes (QOpenGLFunctions and related classes)
so that we can fall back to a software implementation of OpenGL (at
least on Windows systems when using Qt) as described here
http://doc.qt.io/qt-5/windows-requirements.html in the section
"Dynamically Loading Graphics Drivers".
However, we can't use the Qt wrappers directly since we also need to
use OpenGL functions from the FLTK graphics widget. The new
opengl_functions base class and the qopengl_functions class derived
from it allows both the Qt and FLTK graphics widgets do continue using
a common set of classes (opengl_render, etc.) for most OpenGL
rendering.
* oct-opengl.h (opengl_functions): New class. Forward calls to OpenGL
functions. Don't define anything unless HAVE_OPENGL is defined.
* gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h,
gl-select.cc, gl-select.h: Fix constructors to accept opengl_functions
object. Change all uses. Store reference to opengl_functions in all
classes that call OpenGL functions. Use opengl_functions wrapper
object to call all OpenGL functions.
* gl-render.h, gl-render.cc (opengl_renderer::get_opengl_functions):
New function.
(opengl_renderer::m__max_lights): New data member.
(opengl_renderer::init_maxlights): New member function to replace
static function get_maxlights.
(opengl_renderer::get_string): New member function to replace static
function gl_get_string.
* __init_fltk__.cc (OpenGL_fltk::m_glfcns): New opengl_functions data
member. Use wrapper object to call all OpenGL functions.
* libgui/graphics/qopengl-functions.h: New file.
* libgui/graphics/module.mk: Update.
* acinclude.m4 (OCTAVE_CHECK_QT_OPENGL_OK): Check for QGLFunctions_1_1
header file.
* GLCanvas.cc, GLCanvas.h (GLCanvas::m_glfcns): New qopengl_functions
data member. Use wrapper object to call all OpenGL functions.
(GLCanvas::initializeGL): Initialize qopengl_functions object.
(GLCanvas::drawZoomRect): New member function to replace static
function glDrawZoomBox. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 06 Sep 2018 16:29:56 -0400 |
parents | 13b1b9a0d9c5 |
children | 8a6bf76abf31 |
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.h Fri Sep 07 09:48:33 2018 -0700 +++ b/libinterp/corefcn/gl-render.h Thu Sep 06 16:29:56 2018 -0400 @@ -26,6 +26,7 @@ #include "octave-config.h" #include "graphics.h" +#include "oct-opengl.h" #include "text-renderer.h" namespace octave @@ -36,7 +37,7 @@ { public: - opengl_renderer (void); + opengl_renderer (opengl_functions& glfcns); // No copying! @@ -46,6 +47,8 @@ virtual ~opengl_renderer (void) = default; + opengl_functions& get_opengl_functions (void) const { return m_glfcns; } + virtual void draw (const graphics_object& go, bool toplevel = true); virtual void draw (const Matrix& hlist, bool toplevel = false) @@ -152,6 +155,10 @@ private: + void init_maxlights (void); + + std::string get_string (GLenum id) const; + bool is_nan_or_inf (double x, double y, double z) const { return (math::isnan (x) || math::isnan (y) @@ -189,7 +196,12 @@ void draw_all_lights (const base_properties& props, std::list<graphics_object>& obj_list); + protected: + + opengl_functions& m_glfcns; + private: + // The graphics toolkit associated with the figure being rendered. graphics_toolkit toolkit; @@ -216,8 +228,8 @@ text_renderer txt_renderer; // light object present and visible - unsigned int current_light; - unsigned int max_lights; + unsigned int m_current_light; + unsigned int m_max_lights; // Indicate we are drawing for selection purpose bool selecting;