# HG changeset patch # User John W. Eaton # Date 1462817662 14400 # Node ID 1449e3b98941b6400fafb0e0cfc11f411d07be28 # Parent 54fa4dcba7308255313e5fc8dce81575d8e1cbae store OpenGL version info in figure properties * gl-render.cc (gl_get_string): New static function. (opengl_renderer::draw_figure): Set OpenGL version info in figure properties. * graphics.in.h (figure::properties::__gl_extensions__, figure::properties::__gl_renderer__, figure::properties::__gl_vendor__, figure::properties::__gl_version__): New properties. * genprops.awk (emit_declarations): Make set function const for mutable properties. Don't call mark_modified from set function for mutable properties. diff -r 54fa4dcba730 -r 1449e3b98941 libinterp/corefcn/gl-render.cc --- a/libinterp/corefcn/gl-render.cc Mon May 09 12:53:49 2016 +0200 +++ b/libinterp/corefcn/gl-render.cc Mon May 09 14:14:22 2016 -0400 @@ -646,6 +646,18 @@ } } +static std::string +gl_get_string (GLenum id) +{ + // This is kind of ugly, but glGetString returns a pointer to GLubyte + // and there is no std::string constructor that matches. Is there a + // better way? + + std::ostringstream buf; + buf << glGetString (id); + return std::string (buf.str ()); +} + void opengl_renderer::draw_figure (const figure::properties& props) { @@ -653,6 +665,11 @@ init_gl_context (props.is___enhanced__ (), props.get_color_rgb ()); + props.set___gl_extensions__ (gl_get_string (GL_EXTENSIONS)); + props.set___gl_renderer__ (gl_get_string (GL_RENDERER)); + props.set___gl_vendor__ (gl_get_string (GL_VENDOR)); + props.set___gl_version__ (gl_get_string (GL_VERSION)); + // Draw children draw (props.get_all_children (), false); diff -r 54fa4dcba730 -r 1449e3b98941 libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Mon May 09 12:53:49 2016 +0200 +++ b/libinterp/corefcn/graphics.in.h Mon May 09 14:14:22 2016 -0400 @@ -3440,6 +3440,10 @@ radio_property xvisualmode , "{auto}|manual" // Octave-specific properties bool_property __enhanced__ h , "on" + mutable string_property __gl_extensions__ hr , "" + mutable string_property __gl_renderer__ hr , "" + mutable string_property __gl_vendor__ hr , "" + mutable string_property __gl_version__ hr , "" string_property __graphics_toolkit__ hs , gtk_manager::default_toolkit () any_property __guidata__ h , Matrix () radio_property __mouse_mode__ hS , "{none}|pan|rotate|select|text|zoom" diff -r 54fa4dcba730 -r 1449e3b98941 libinterp/genprops.awk --- a/libinterp/genprops.awk Mon May 09 12:53:49 2016 +0200 +++ b/libinterp/genprops.awk Mon May 09 14:14:22 2016 -0400 @@ -364,7 +364,16 @@ { if (emit_set[i]) { - printf (" void set_%s (const octave_value& val)", name[i], type[i]); + ## Allow mutable properties to be set from const methods by + ## declaring the corresponding set method const. The idea here is + ## to allow "constant" properties to be set after initialization. + ## For example, info about the OpenGL context for a figure can + ## only be set once the context is established, and that happens + ## after the figure object is created. Properties handled this + ## way should probably also be declared read only. + + printf (" void set_%s (const octave_value& val)%s", + name[i], mutable[i] ? " const" : ""); if (emit_set[i] == "definition") { @@ -383,7 +392,8 @@ printf (" update_axis_limits (\"%s\");\n", name[i]); if (has_builtin_listeners) printf (" %s.run_listeners (POSTSET);\n", name[i]); - printf (" mark_modified ();\n"); + if (! mutable[i]) + printf (" mark_modified ();\n"); printf (" }\n"); if (mode[i]) printf (" else\n set_%smode (\"manual\");\n", name[i]);