From f8f1456654f1edf81ea65f606f6e968047c0da77 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 2 Mar 2004 22:36:11 +0000 Subject: [PATCH] From Ruben, addition of osg::PointSprite and osgpointsprite example. --- Make/makedirdefs | 1 + VisualStudio/VisualStudio.dsw | 27 ++++++ .../osgpointsprite/osgpointsprite.dsp | 97 +++++++++++++++++++ VisualStudio/osg/osg.dsp | 8 ++ VisualStudio/osgPlugins/osg/dot_osg.dsp | 4 + include/osg/PointSprite | 55 +++++++++++ src/osg/GNUmakefile | 1 + src/osg/PointSprite.cpp | 36 +++++++ src/osgPlugins/osg/GNUmakefile | 1 + src/osgPlugins/osg/PointSprite.cpp | 38 ++++++++ 10 files changed, 268 insertions(+) create mode 100644 VisualStudio/examples/osgpointsprite/osgpointsprite.dsp create mode 100644 include/osg/PointSprite create mode 100644 src/osg/PointSprite.cpp create mode 100644 src/osgPlugins/osg/PointSprite.cpp diff --git a/Make/makedirdefs b/Make/makedirdefs index 2f436b61a..11e22a1ab 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -152,6 +152,7 @@ EXAMPLE_DIRS = \ osgparticle\ osgpick\ osgpoints\ + osgpointsprite\ osgprerender\ osgprerendercubemap\ osgreflect\ diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw index f837acfa9..3d0336541 100644 --- a/VisualStudio/VisualStudio.dsw +++ b/VisualStudio/VisualStudio.dsw @@ -726,6 +726,33 @@ Package=<4> ############################################################################### +Project: "Example osgpointsprite"=.\examples\osgpointsprite\osgpointsprite.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name Core osg + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgDB + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgGA + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgProducer + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgUtil + End Project Dependency +}}} + +############################################################################### + Project: "Example osgscalarbar"=.\examples\osgscalarbar\osgscalarbar.dsp - Package Owner=<4> Package=<5> diff --git a/VisualStudio/examples/osgpointsprite/osgpointsprite.dsp b/VisualStudio/examples/osgpointsprite/osgpointsprite.dsp new file mode 100644 index 000000000..90cfda107 --- /dev/null +++ b/VisualStudio/examples/osgpointsprite/osgpointsprite.dsp @@ -0,0 +1,97 @@ +# Microsoft Developer Studio Project File - Name="Example osgpointsprite" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=Example osgpointsprite - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "osgpointsprite.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "osgpointsprite.mak" CFG="Example osgpointsprite - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Example osgpointsprite - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "Example osgpointsprite - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Example osgpointsprite - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /Zm200 /c +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 /nologo /subsystem:console /pdb:none /machine:I386 /out:"../../../bin/osgpointsprite.exe" /libpath:"../../../lib" + +!ELSEIF "$(CFG)" == "Example osgpointsprite - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +MTL=midl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /FR /YX /FD /Zm200 /c +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 glu32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgpointsprited.exe" /pdbtype:sept /libpath:"../../../lib" +# SUBTRACT LINK32 /incremental:no + +!ENDIF + +# Begin Target + +# Name "Example osgpointsprite - Win32 Release" +# Name "Example osgpointsprite - Win32 Debug" +# Begin Source File + +SOURCE=..\..\..\examples\osgpointsprite\osgpointsprite.cpp +# End Source File +# End Target +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Project diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index ea7464c2a..1c716ce2f 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -327,6 +327,10 @@ SOURCE=..\..\src\osg\Point.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osg\PointSprite.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osg\PolygonMode.cpp # End Source File # Begin Source File @@ -739,6 +743,10 @@ SOURCE=..\..\Include\Osg\Point # End Source File # Begin Source File +SOURCE=..\..\Include\Osg\PointSprite +# End Source File +# Begin Source File + SOURCE=..\..\Include\Osg\PolygonMode # End Source File # Begin Source File diff --git a/VisualStudio/osgPlugins/osg/dot_osg.dsp b/VisualStudio/osgPlugins/osg/dot_osg.dsp index 11a83db4b..324bbe324 100755 --- a/VisualStudio/osgPlugins/osg/dot_osg.dsp +++ b/VisualStudio/osgPlugins/osg/dot_osg.dsp @@ -226,6 +226,10 @@ SOURCE=..\..\..\src\osgPlugins\osg\Point.cpp # End Source File # Begin Source File +SOURCE=..\..\..\src\osgPlugins\osg\PointSprite.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\src\osgPlugins\osg\PolygonMode.cpp # End Source File # Begin Source File diff --git a/include/osg/PointSprite b/include/osg/PointSprite new file mode 100644 index 000000000..996b5c8e3 --- /dev/null +++ b/include/osg/PointSprite @@ -0,0 +1,55 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * 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 + * OpenSceneGraph Public License for more details. + */ + +#ifndef OSG_POINT_SPRITE +#define OSG_POINT_SPRITE 1 + +#include +#include + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +namespace osg { + +/** PointSprite base class which encapsulates enabling of point sprites .*/ +class SG_EXPORT PointSprite : public osg::StateAttribute { +public: + + PointSprite() {} + + /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ + PointSprite(const PointSprite& texenv,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): + StateAttribute(texenv,copyop) {} + + + META_StateAttribute(osg, PointSprite, GL_POINT_SPRITE_ARB); + + /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ + virtual int compare(const StateAttribute& sa) const; + + virtual void getAssociatedModes(std::vector& modes) const; + + virtual bool isTextureAttribute() const { return true; } + + virtual void apply(osg::State& state) const; + +protected: + virtual ~PointSprite( void ) {} +}; + +} + +#endif diff --git a/src/osg/GNUmakefile b/src/osg/GNUmakefile index 95ae89a8d..73d981b3e 100644 --- a/src/osg/GNUmakefile +++ b/src/osg/GNUmakefile @@ -60,6 +60,7 @@ CXXFILES =\ OccluderNode.cpp\ PagedLOD.cpp\ Point.cpp\ + PointSprite.cpp\ PolygonMode.cpp\ PolygonOffset.cpp\ PolygonStipple.cpp\ diff --git a/src/osg/PointSprite.cpp b/src/osg/PointSprite.cpp new file mode 100644 index 000000000..4ec2081f8 --- /dev/null +++ b/src/osg/PointSprite.cpp @@ -0,0 +1,36 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * 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 + * OpenSceneGraph Public License for more details. + */ + +#include +#include +#include + +using namespace osg; + +int PointSprite::compare(const StateAttribute& sa) const +{ + // check the types are equal and then create the rhs variable + // used by the COMPARE_StateAttribute_Paramter macro's below. + COMPARE_StateAttribute_Types(PointSprite,sa) + return 0; // passed all the above comparison macro's, must be equal. +} + +void PointSprite::getAssociatedModes(std::vector& modes) const +{ + modes.push_back(GL_POINT_SPRITE_ARB); +} + +void PointSprite::apply(osg::State&) const +{ + glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, 1); +} diff --git a/src/osgPlugins/osg/GNUmakefile b/src/osgPlugins/osg/GNUmakefile index 1bb73eff0..5eb5c9ec2 100644 --- a/src/osgPlugins/osg/GNUmakefile +++ b/src/osgPlugins/osg/GNUmakefile @@ -36,6 +36,7 @@ CXXFILES =\ OccluderNode.cpp\ PagedLOD.cpp\ Point.cpp\ + PointSprite.cpp\ PolygonMode.cpp\ PolygonOffset.cpp\ PositionAttitudeTransform.cpp\ diff --git a/src/osgPlugins/osg/PointSprite.cpp b/src/osgPlugins/osg/PointSprite.cpp new file mode 100644 index 000000000..25b84e560 --- /dev/null +++ b/src/osgPlugins/osg/PointSprite.cpp @@ -0,0 +1,38 @@ +#if defined(_MSC_VER) + #pragma warning( disable : 4786 ) +#endif + +#include "osg/PointSprite" + +#include "osgDB/Registry" +#include "osgDB/Input" +#include "osgDB/Output" + +using namespace osg; +using namespace osgDB; + +// forward declare functions to use later. +bool PointSprite_readLocalData(Object& obj, Input& fr); +bool PointSprite_writeLocalData(const Object& obj, Output& fw); + +// register the read and write functions with the osgDB::Registry. +RegisterDotOsgWrapperProxy g_PointSpriteProxy +( + new osg::PointSprite, + "PointSprite", + "Object StateAttribute PointSprite", + &PointSprite_readLocalData, + &PointSprite_writeLocalData +); + + +bool PointSprite_readLocalData(Object&, Input&) +{ + return false; +} + + +bool PointSprite_writeLocalData(const Object&,Output&) +{ + return true; +}