From Farshid Lashkari, "This patch adds a CoordOriginMode to the osg::PointSprite attribute.
The mode needs to be changed to LOWER_LEFT when rendering point sprites to pbuffers or FBOs, otherwise the points will be transformed on the CPU."
This commit is contained in:
@@ -116,6 +116,7 @@ Point::Extensions::Extensions(const Extensions& rhs):
|
||||
void Point::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isPointParametersSupported) _isPointParametersSupported = false;
|
||||
if (!rhs._glPointParameteri) _glPointParameteri = 0;
|
||||
if (!rhs._glPointParameterf) _glPointParameterf = 0;
|
||||
if (!rhs._glPointParameterfv) _glPointParameterfv = 0;
|
||||
}
|
||||
@@ -126,7 +127,10 @@ void Point::Extensions::setupGLExtenions(unsigned int contextID)
|
||||
isGLExtensionSupported(contextID,"GL_ARB_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_EXT_point_parameters") ||
|
||||
isGLExtensionSupported(contextID,"GL_SGIS_point_parameters");
|
||||
|
||||
|
||||
_glPointParameteri = getGLExtensionFuncPtr("glPointParameteri", "glPointParameteriARB");
|
||||
if (!_glPointParameteri) _glPointParameteri = getGLExtensionFuncPtr("glPointParameteriEXT", "glPointParameteriSGIS");
|
||||
|
||||
_glPointParameterf = getGLExtensionFuncPtr("glPointParameterf", "glPointParameterfARB");
|
||||
if (!_glPointParameterf) _glPointParameterf = getGLExtensionFuncPtr("glPointParameterfEXT", "glPointParameterfSGIS");
|
||||
|
||||
@@ -134,6 +138,18 @@ void Point::Extensions::setupGLExtenions(unsigned int contextID)
|
||||
if (!_glPointParameterfv) _glPointParameterfv = getGLExtensionFuncPtr("glPointParameterfvEXT", "glPointParameterfvSGIS");
|
||||
}
|
||||
|
||||
void Point::Extensions::glPointParameteri(GLenum pname, GLint param) const
|
||||
{
|
||||
if (_glPointParameteri)
|
||||
{
|
||||
typedef void (APIENTRY * GLPointParameteriProc) (GLenum pname, GLint param);
|
||||
((GLPointParameteriProc)_glPointParameteri)(pname, param);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify(WARN)<<"Error: glPointParameteri not supported by OpenGL driver"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Point::Extensions::glPointParameterf(GLenum pname, GLfloat param) const
|
||||
{
|
||||
|
||||
@@ -14,19 +14,27 @@
|
||||
#include <osg/GLExtensions>
|
||||
#include <osg/GL>
|
||||
#include <osg/PointSprite>
|
||||
#include <osg/Point>
|
||||
#include <osg/State>
|
||||
#include <osg/buffered_value>
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
PointSprite::PointSprite()
|
||||
: _coordOriginMode(UPPER_LEFT)
|
||||
{
|
||||
}
|
||||
|
||||
PointSprite::~PointSprite()
|
||||
{
|
||||
}
|
||||
|
||||
int PointSprite::compare(const StateAttribute& sa) const
|
||||
{
|
||||
if (this==&sa) return 0;\
|
||||
const std::type_info* type_lhs = &typeid(*this);\
|
||||
const std::type_info* type_rhs = &typeid(sa);\
|
||||
if (type_lhs->before(*type_rhs)) return -1;\
|
||||
if (*type_lhs != *type_rhs) return 1;\
|
||||
COMPARE_StateAttribute_Types(PointSprite,sa)
|
||||
|
||||
COMPARE_StateAttribute_Parameter(_coordOriginMode)
|
||||
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
@@ -46,6 +54,11 @@ void PointSprite::apply(osg::State& state) const
|
||||
if(!isPointSpriteSupported(state.getContextID())) return;
|
||||
|
||||
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, 1);
|
||||
|
||||
const Point::Extensions* extensions = Point::getExtensions(state.getContextID(),true);
|
||||
|
||||
if (extensions->isPointParametersSupported())
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,_coordOriginMode);
|
||||
}
|
||||
|
||||
struct IntializedSupportedPair
|
||||
|
||||
Reference in New Issue
Block a user