Add VGInitOperation for initializing OpenVG
This commit is contained in:
@@ -2,6 +2,7 @@ include (SimGearComponent)
|
|||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
ODGauge.hxx
|
ODGauge.hxx
|
||||||
|
VGInitOperation.hxx
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height)
|
|||||||
g_context->surfaceHeight = height;
|
g_context->surfaceHeight = height;
|
||||||
|
|
||||||
/* setup GL projection */
|
/* setup GL projection */
|
||||||
|
/* We handle viewport and projection ourselves...
|
||||||
|
|
||||||
glViewport(0,0,width,height);
|
glViewport(0,0,width,height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@@ -54,7 +56,7 @@ VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height)
|
|||||||
gluOrtho2D(0,width,0,height);
|
gluOrtho2D(0,width,0,height);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();*/
|
||||||
|
|
||||||
return VG_TRUE;
|
return VG_TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_ */
|
||||||
Reference in New Issue
Block a user