Added new osg::GraphicsContext base class

This commit is contained in:
Robert Osfield 2005-07-20 15:55:07 +00:00
parent 9120a0ca2c
commit b9e651baf1
13 changed files with 96 additions and 212 deletions

View File

@ -260,6 +260,10 @@ SOURCE=..\..\src\osg\GLExtensions.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\GraphicsContext.cpp
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\Group.cpp
# End Source File
# Begin Source File
@ -720,6 +724,10 @@ SOURCE=..\..\Include\Osg\Group
# End Source File
# Begin Source File
SOURCE=..\..\Include\Osg\GraphicsContext
# End Source File
# Begin Source File
SOURCE=..\..\src\osg\dxtctool.h
# End Source File
# Begin Source File

View File

@ -263,6 +263,10 @@ SOURCE=..\..\..\src\osgWrappers\osg\Geode.cpp
SOURCE=..\..\..\src\osgWrappers\osg\Geometry.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osg\GraphicsContext.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osg\Group.cpp
# End Source File

View File

@ -1,173 +0,0 @@
# Microsoft Developer Studio Project File - Name="osgWrapper osgIntrospection" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=osgWrapper osgIntrospection - 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 "wrapper_osgIntrospection.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 "wrapper_osgIntrospection.mak" CFG="osgWrapper osgIntrospection - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "osgWrapper osgIntrospection - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "osgWrapper osgIntrospection - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "osgWrapper osgIntrospection - 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 "../../../lib"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# 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 /dll /machine:I386
# ADD LINK32 opengl32.lib OpenThreadsWin32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgwrapper_osgIntrospection.dll" /libpath:"../../../lib" /libpath:"../../../../OpenThreads/lib/win32" /libpath:"../../../../Producer/lib" /libpath:"../../../../3rdParty/lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "osgWrapper osgIntrospection - 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 "../../../lib"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# 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 /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 opengl32.lib OpenThreadsWin32d.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgwrapper_osgIntrospectiond.dll" /pdbtype:sept /libpath:"../../../lib" /libpath:"../../../../OpenThreads/lib/win32" /libpath:"../../../../Producer/lib" /libpath:"../../../../3rdParty/lib"
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ENDIF
# Begin Target
# Name "osgWrapper osgIntrospection - Win32 Release"
# Name "osgWrapper osgIntrospection - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Attributes.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Comparator.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\ConstructorInfo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Converter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\ConverterProxy.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\CustomAttribute.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\CustomAttributeProvider.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Exceptions.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\MethodInfo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\ParameterInfo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\PropertyInfo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\ReaderWriter.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Reflection.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Reflector.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Type.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgIntrospection\Value.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -111,14 +111,6 @@ SOURCE=..\..\..\src\osgWrappers\osgText\String.cpp
SOURCE=..\..\..\src\osgWrappers\osgText\Text.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgText\Text.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\osgWrappers\osgText\Text.cpp
# End Source File
# End Group
# Begin Group "Header Files"

View File

@ -49,11 +49,27 @@ class PBufferTexture2D : public osg::Texture2D
glTexImage2D( GL_TEXTURE_2D, 0,
format, width, height, 0, format, GL_UNSIGNED_BYTE, 0 );
textureObject->setAllocated(true);
std::cout<<"Created texture"<<std::endl;
}
else
{
textureObject->bind();
_pbuffer->bindPBufferToTexture( Producer::RenderSurface::FrontBuffer );
static unsigned int frameNum = 0;
if ((frameNum % 100)==0)
{
std::cout<<"binding texture"<<std::endl;
_pbuffer->bindPBufferToTexture( Producer::RenderSurface::FrontBuffer );
}
else
{
std::cout<<"..."<<std::endl;
}
++frameNum;
}
}

View File

@ -20,8 +20,7 @@
#include <osgProducer/Viewer>
#include <osg/Geode>
#include <osg/Projection>
#include <osg/MatrixTransform>
#include <osg/CameraNode>
#include <osg/ShapeDrawable>
#include <osg/Sequence>
@ -502,18 +501,15 @@ int main( int argc, char **argv )
{
// create the hud.
osg::Projection* projection = new osg::Projection;
projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
osg::CameraNode* camera = new osg::CameraNode;
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setProjectionMatrixAsOrtho2D(0,1280,0,1024);
camera->setViewMatrix(osg::Matrix::identity());
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->addChild(createHUDText());
camera->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
osg::MatrixTransform* modelview_abs = new osg::MatrixTransform;
modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
modelview_abs->setMatrix(osg::Matrix::identity());
modelview_abs->addChild(createHUDText());
projection->addChild(modelview_abs);
group->addChild(projection);
group->addChild(camera);
}
group->addChild(create3DText(center,radius));

View File

@ -20,6 +20,7 @@
#include <osg/CullSettings>
#include <osg/Texture>
#include <osg/Image>
#include <osg/GraphicsContext>
namespace osg {
@ -258,6 +259,16 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
/** Set the GraphicsContext that provides the mechansim for managing the OpenGL graphics context associated with this camera.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the GraphicsContext.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext.get(); }
/** Get the const GraphicsContext.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext.get(); }
/** Set the Rendering object that is used to implement rendering of the subgraph.*/
void setRenderingCache(osg::Object* rc) { _renderingCache = rc; }
@ -297,6 +308,7 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
RenderTargetImplementation _renderTargetImplementation;
BufferAttachmentMap _bufferAttachmentMap;
ref_ptr<GraphicsContext> _graphicsContext;
ref_ptr<Object> _renderingCache;
};

View File

@ -63,6 +63,10 @@ namespace osg {
}\
}
// forward decalr GraphicsContext
class GraphicsContext;
/** Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,.
* implements lazy state updating and provides accessors for querrying the current state.
. The venerable Red Book says that "OpenGL is a state machine", and this class
@ -83,6 +87,32 @@ class OSG_EXPORT State : public Referenced
public :
State();
/** Set the graphics context associated with that owns this State object.*/
void setGraphicsContext(GraphicsContext* context) { _graphicsContext = context; }
/** Get the graphics context associated with that owns this State object.*/
GraphicsContext* getGraphicsContext() { return _graphicsContext; }
/** Get the const graphics context associated with that owns this State object.*/
const GraphicsContext* getGraphicsContext() const { return _graphicsContext; }
/** Set the current OpenGL context uniqueID.
Note, it is the application developers responsibility to
set up unique ID for each OpenGL context. This value is
then used by osg::StateAttribute's and osg::Drawable's to
help manage OpenGL display list and texture binds appropriate
for each context, the contextID simply acts as an index in local
arrays that they maintain for the purpose.
Typical settings for contextID are 0,1,2,3... up to the maximum
number of graphics contexts you have set up.
By default contextID is 0.*/
inline void setContextID(unsigned int contextID) { _contextID=contextID; }
/** Get the current OpenGL context unique ID.*/
inline unsigned int getContextID() const { return _contextID; }
/** Push stateset onto state stack.*/
void pushStateSet(const StateSet* dstate);
@ -669,21 +699,6 @@ class OSG_EXPORT State : public Referenced
inline GLint getUniformLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getUniformLocation(name) : -1; }
inline GLint getAttribLocation( const std::string& name ) const { return _lastAppliedProgramObject ? _lastAppliedProgramObject->getAttribLocation(name) : -1; }
/** Set the current OpenGL context uniqueID.
Note, it is the application developers responsibility to
set up unique ID for each OpenGL context. This value is
then used by osg::StateAttribute's and osg::Drawable's to
help manage OpenGL display list and texture binds appropriate
for each context, the contextID simply acts as an index in local
arrays that they maintain for the purpose.
Typical settings for contextID are 0,1,2,3... up to the maximum
number of graphics contexts you have set up.
By default contextID is 0.*/
inline void setContextID(unsigned int contextID) { _contextID=contextID; }
/** Get the current OpenGL context unique ID.*/
inline unsigned int getContextID() const { return _contextID; }
/** Set the frame stamp for the current frame.*/
inline void setFrameStamp(FrameStamp* fs) { _frameStamp = fs; }
@ -738,6 +753,7 @@ class OSG_EXPORT State : public Referenced
virtual ~State();
GraphicsContext* _graphicsContext;
unsigned int _contextID;
ref_ptr<FrameStamp> _frameStamp;

View File

@ -44,6 +44,7 @@ CXXFILES =\
Geode.cpp\
Geometry.cpp\
GLExtensions.cpp\
GraphicsContext.cpp\
Group.cpp\
Image.cpp\
ImageStream.cpp\

View File

@ -21,6 +21,7 @@ using namespace osg;
State::State()
{
_graphicsContext = 0;
_contextID = 0;
_identity = new osg::RefMatrix(); // default RefMatrix constructs to identity.
_initialViewMatrix = _identity;

View File

@ -12,6 +12,7 @@
#include <osg/CameraNode>
#include <osg/ColorMask>
#include <osg/CopyOp>
#include <osg/GraphicsContext>
#include <osg/Image>
#include <osg/Matrix>
#include <osg/Matrixd>
@ -125,6 +126,9 @@ BEGIN_OBJECT_REFLECTOR(osg::CameraNode)
I_Method1(void, detach, IN, osg::CameraNode::BufferComponent, buffer);
I_Method0(osg::CameraNode::BufferAttachmentMap &, getBufferAttachmentMap);
I_Method0(const osg::CameraNode::BufferAttachmentMap &, getBufferAttachmentMap);
I_Method1(void, setGraphicsContext, IN, osg::GraphicsContext *, context);
I_Method0(osg::GraphicsContext *, getGraphicsContext);
I_Method0(const osg::GraphicsContext *, getGraphicsContext);
I_Method1(void, setRenderingCache, IN, osg::Object *, rc);
I_Method0(osg::Object *, getRenderingCache);
I_Method0(const osg::Object *, getRenderingCache);
@ -136,6 +140,7 @@ BEGIN_OBJECT_REFLECTOR(osg::CameraNode)
I_Property(osg::ColorMask *, ColorMask);
I_IndexedProperty1(GLenum, DrawBuffer, unsigned int, pos);
I_ReadOnlyProperty(osg::CameraNode::DrawBufferList &, DrawBufferList);
I_Property(osg::GraphicsContext *, GraphicsContext);
I_ReadOnlyProperty(osg::Matrixd, InverseViewMatrix);
I_Property(const osg::Matrixd &, ProjectionMatrix);
I_Property(GLenum, ReadBuffer);

View File

@ -44,6 +44,7 @@ CXXFILES =\
GL2Extensions.cpp\
Geode.cpp\
Geometry.cpp\
GraphicsContext.cpp\
Group.cpp\
Image.cpp\
ImageStream.cpp\

View File

@ -11,6 +11,7 @@
#include <osg/DisplaySettings>
#include <osg/FrameStamp>
#include <osg/GraphicsContext>
#include <osg/Matrix>
#include <osg/Polytope>
#include <osg/Program>
@ -36,6 +37,11 @@ END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::State)
I_BaseType(osg::Referenced);
I_Constructor0();
I_Method1(void, setGraphicsContext, IN, osg::GraphicsContext *, context);
I_Method0(osg::GraphicsContext *, getGraphicsContext);
I_Method0(const osg::GraphicsContext *, getGraphicsContext);
I_Method1(void, setContextID, IN, unsigned int, contextID);
I_Method0(unsigned int, getContextID);
I_Method1(void, pushStateSet, IN, const osg::StateSet *, dstate);
I_Method0(void, popStateSet);
I_Method0(void, popAllStateSets);
@ -119,8 +125,6 @@ BEGIN_OBJECT_REFLECTOR(osg::State)
I_Method0(const osg::Program::PerContextProgram *, getLastAppliedProgramObject);
I_Method1(GLint, getUniformLocation, IN, const std::string &, name);
I_Method1(GLint, getAttribLocation, IN, const std::string &, name);
I_Method1(void, setContextID, IN, unsigned int, contextID);
I_Method0(unsigned int, getContextID);
I_Method1(void, setFrameStamp, IN, osg::FrameStamp *, fs);
I_Method0(const osg::FrameStamp *, getFrameStamp);
I_Method1(void, setDisplaySettings, IN, osg::DisplaySettings *, vs);
@ -144,6 +148,7 @@ BEGIN_OBJECT_REFLECTOR(osg::State)
I_WriteOnlyProperty(const osg::StateAttribute *, GlobalDefaultAttribute);
I_IndexedProperty1(bool, GlobalDefaultModeValue, osg::StateAttribute::GLMode, mode);
I_IndexedProperty2(bool, GlobalDefaultTextureModeValue, unsigned int, unit, osg::StateAttribute::GLMode, mode);
I_Property(osg::GraphicsContext *, GraphicsContext);
I_ReadOnlyProperty(const osg::Matrix &, InitialInverseViewMatrix);
I_WriteOnlyProperty(const osg::RefMatrix *, InitialViewMatrix);
I_Property(const osg::Program::PerContextProgram *, LastAppliedProgramObject);