]> git.mxchange.org Git - simgear.git/commitdiff
Add VGInitOperation for initializing OpenVG
authorThomas Geymayer <tomgey@gmail.com>
Wed, 31 Oct 2012 00:38:59 +0000 (01:38 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Wed, 31 Oct 2012 00:38:59 +0000 (01:38 +0100)
simgear/canvas/CMakeLists.txt
simgear/canvas/ShivaVG/src/shContext.c
simgear/canvas/VGInitOperation.hxx [new file with mode: 0644]

index dac03aba813e01267eef4cdc151b0b687101ae98..0a10e585ea32899f3ce436e014ebb30a2d85ca92 100644 (file)
@@ -2,6 +2,7 @@ include (SimGearComponent)
 
 set(HEADERS
     ODGauge.hxx
+    VGInitOperation.hxx
     )
 
 set(SOURCES
index a78bfcc56bfa399e1f85b4f2f041b9f58c20cc62..6f2fe5974081b3435728d0773d620d3dde3fb27f 100644 (file)
@@ -47,6 +47,8 @@ VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height)
   g_context->surfaceHeight = height;
   
   /* setup GL projection */
+  /* We handle viewport and projection ourselves...
+
   glViewport(0,0,width,height);
   
   glMatrixMode(GL_PROJECTION);
@@ -54,7 +56,7 @@ VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height)
   gluOrtho2D(0,width,0,height);
   
   glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
+  glLoadIdentity();*/
   
   return VG_TRUE;
 }
diff --git a/simgear/canvas/VGInitOperation.hxx b/simgear/canvas/VGInitOperation.hxx
new file mode 100644 (file)
index 0000000..9fb650c
--- /dev/null
@@ -0,0 +1,59 @@
+// osg::Operation to initialize the OpenVG context used for path rendering
+//
+// Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+#ifndef CANVAS_VG_INITOPERATION_HXX_
+#define CANVAS_VG_INITOPERATION_HXX_
+
+#include <vg/openvg.h>
+#include <osg/GraphicsThread>
+
+namespace simgear
+{
+namespace canvas
+{
+
+  /**
+   * Deferred graphics operation to setup OpenVG which needs a valid OpenGL
+   * context. Pass to osg::GraphicsContext::add and ensure it's executed before
+   * doing any path rendering
+   */
+  class VGInitOperation:
+    public osg::GraphicsOperation
+  {
+    public:
+
+      VGInitOperation():
+        GraphicsOperation("canvas::VGInit", false)
+      {}
+
+      virtual void operator()(osg::GraphicsContext* context)
+      {
+        GLint vp[4];
+        glGetIntegerv(GL_VIEWPORT, vp);
+
+        // ATTENTION: If using another OpenVG implementation ensure it doesn't
+        //            change any OpenGL state!
+        vgCreateContextSH(vp[2], vp[3]);
+      }
+
+  };
+
+} // namespace canvas
+} // namespace simgear
+
+#endif /* CANVAS_VG_INITOPERATION_HXX_ */