changeset 21684:1449e3b98941

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.
author John W. Eaton <jwe@octave.org>
date Mon, 09 May 2016 14:14:22 -0400
parents 54fa4dcba730
children fc8cc7730514
files libinterp/corefcn/gl-render.cc libinterp/corefcn/graphics.in.h libinterp/genprops.awk
diffstat 3 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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"
--- 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]);