diff --git a/Make/dependencies b/Make/dependencies index 2ad12c0f1..7fb854b1b 100644 --- a/Make/dependencies +++ b/Make/dependencies @@ -1,16 +1,12 @@ ################################################################ # Dependency library which have been installed on this system - # should we compile osgIntrospection? COMPILE_INTROSPECTION = no # should we compile any of the examples? COMPILE_EXAMPLES ?= no -# should we compile the deprecated osgGL2 library. -COMPILE_osgGL2 ?= no - # follows are dependenices on the various plugins. GDAL_INSTALLED ?= no diff --git a/Make/makedirdefs b/Make/makedirdefs index 9da147445..aa9397fec 100644 --- a/Make/makedirdefs +++ b/Make/makedirdefs @@ -19,15 +19,10 @@ SRC_DIRS = \ osgGA\ osgParticle\ osgText\ + osgFX\ osgSim\ osgProducer -ifeq ($(COMPILE_osgGL2),yes) -SRC_DIRS += osgGL2 -endif - -SRC_DIRS += osgFX - ifeq ($(GDAL_INSTALLED),yes) SRC_DIRS += osgTerrain endif @@ -243,10 +238,6 @@ EXAMPLE_DIRS = \ osgvolume\ osgwindows\ -ifeq ($(COMPILE_osgGL2),yes) - EXAMPLE_DIRS += osgGL2Shaders -endif - ifeq ($(COMPILE_INTROSPECTION),yes) EXAMPLE_DIRS += osgintrospection endif diff --git a/VisualStudio/VisualStudio.dsw b/VisualStudio/VisualStudio.dsw index 7c2b862f8..41d596f65 100644 --- a/VisualStudio/VisualStudio.dsw +++ b/VisualStudio/VisualStudio.dsw @@ -78,27 +78,6 @@ Package=<4> ############################################################################### -Project: "Core osgGL2"=.\osgGL2\osgGL2.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 osgUtil - End Project Dependency - Begin Project Dependency - Project_Dep_Name Core osgDB - End Project Dependency -}}} - -############################################################################### - Project: "Core osgFX"=.\osgFX\osgFX.dsp - Package Owner=<4> Package=<5> diff --git a/VisualStudio/osgGL2/osgGL2.dsp b/VisualStudio/osgGL2/osgGL2.dsp deleted file mode 100644 index 180c5551a..000000000 --- a/VisualStudio/osgGL2/osgGL2.dsp +++ /dev/null @@ -1,142 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Core osgGL2" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=Core osgGL2 - 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 "osgGL2.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 "osgGL2.mak" CFG="Core osgGL2 - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Core osgGL2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "Core osgGL2 - 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)" == "Core osgGL2 - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "../../lib" -# 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 "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "OSGGL2_LIBRARY" /D "WIN32" /D "_WINDOWS" /YX /FD /Zm200 /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 OpenThreadsWin32.lib opengl32.lib glu32.lib /nologo /dll /pdb:none /machine:I386 /out:"../../bin/osgGL2.dll" /libpath:"../../lib" /libpath:"../../../OpenThreads/lib/win32" /libpath:"../../../Producer/lib" /libpath:"../../../3rdParty/lib" - -!ELSEIF "$(CFG)" == "Core osgGL2 - 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 /vd0 /GR /GX /Zi /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSGGL2_LIBRARY" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /Zm200 /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 OpenThreadsWin32d.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/osgGL2d.dll" /pdbtype:sept /libpath:"../../lib" /libpath:"../../../OpenThreads/lib/win32" /libpath:"../../../Producer/lib" /libpath:"../../../3rdParty/lib" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "Core osgGL2 - Win32 Release" -# Name "Core osgGL2 - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=..\..\src\osgGL2\Extensions.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\src\osgGL2\ProgramObject.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\src\osgGL2\UniformValue.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\src\osgGL2\Version.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter ";h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=..\..\include\osgGL2\Export -# End Source File -# Begin Source File - -SOURCE=..\..\include\osgGL2\Extensions -# End Source File -# Begin Source File - -SOURCE=..\..\include\osgGL2\ProgramObject -# End Source File -# Begin Source File - -SOURCE=..\..\include\osgGL2\UniformValue -# End Source File -# Begin Source File - -SOURCE=..\..\include\osgGL2\Version -# End Source File -# 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 diff --git a/include/osg/StateAttribute b/include/osg/StateAttribute index 41d1a110f..287a3259a 100644 --- a/include/osg/StateAttribute +++ b/include/osg/StateAttribute @@ -158,17 +158,16 @@ class OSG_EXPORT StateAttribute : public Object VERTEXPROGRAM, FRAGMENTPROGRAM, - POINTSPRITE, - /// osgGL2 namespace - PROGRAMOBJECT, - + /// core GLSL support + PROGRAM, + /// osgFX namespace VALIDATOR, VIEWMATRIXEXTRACTOR, - // osgNV namespace + /// osgNV namespace OSGNV_PARAMETER_BLOCK, // osgNVExt namespace @@ -176,17 +175,15 @@ class OSG_EXPORT StateAttribute : public Object OSGNVEXT_VERTEX_PROGRAM, OSGNVEXT_REGISTER_COMBINERS, - // osgNVCg namespace + /// osgNVCg namespace OSGNVCG_PROGRAM, // osgNVSlang namespace OSGNVSLANG_PROGRAM, // osgNVParse - OSGNVPARSE_PROGRAM_PARSER, + OSGNVPARSE_PROGRAM_PARSER - /// core GLSL support - PROGRAM }; /** Simple pairing between an attribute type and the member within that attribute type group.*/ diff --git a/include/osgGL2/Export b/include/osgGL2/Export deleted file mode 100644 index 220ef21d6..000000000 --- a/include/osgGL2/Export +++ /dev/null @@ -1,54 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 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 OSGGL2_EXPORT_ -#define OSGGL2_EXPORT_ 1 - -#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__)) - #pragma warning( disable : 4244 ) - #pragma warning( disable : 4251 ) - #pragma warning( disable : 4275 ) - #pragma warning( disable : 4786 ) - #pragma warning( disable : 4290 ) - #pragma warning( disable : 4305 ) -#endif - -#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__) - # ifdef OSGGL2_LIBRARY - # define OSGGL2_EXPORT __declspec(dllexport) - # else - # define OSGGL2_EXPORT __declspec(dllimport) - # endif -#else - # define OSGGL2_EXPORT -#endif - -/* Define NULL pointer value */ - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - -/** - -\namespace osgGL2 - -The osgGL2 is a NodeKit library that extends the core scene graph to support OpenGL Shader Language. -*/ - -#endif /* OSGGL2_EXPORT_ */ - diff --git a/include/osgGL2/Extensions b/include/osgGL2/Extensions deleted file mode 100644 index cae6ac2cd..000000000 --- a/include/osgGL2/Extensions +++ /dev/null @@ -1,272 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield - * Copyright (C) 2003-2004 3Dlabs Inc. Ltd. - * - * This application is open source and may be redistributed and/or modified - * freely and without restriction, both in commericial and non commericial - * applications, as long as this copyright notice is maintained. - * - * This application 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. -*/ - -/* file: include/osgGL2/Extensions - * author: Mike Weiblen 2004-07-06 - * modifications: Bob Kuehne 2004-06-03 - * - * See http://www.3dlabs.com/opengl2/ for more information regarding - * the OpenGL Shading Language. - * See also: - * http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_shader.txt - * http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_shader.txt - * http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt - * http://oss.sgi.com/projects/ogl-sample/registry/ARB/shading_language_100.txt -*/ - -#ifndef OSGGL2_EXTENSIONS -#define OSGGL2_EXTENSIONS 1 - -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// -// If not defined by the OpenGL headers, use #defines from the glext.h -// header available from http://oss.sgi.com/projects/ogl-sample/registry/ - -// These enums were copied verbatim from: -// glext.h, updated 2004/6/22, GL_GLEXT_VERSION 23 - -#ifndef GL_ARB_vertex_program -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#endif - -#ifndef GL_ARB_fragment_program -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and characters */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/////////////////////////////////////////////////////////////////////////// - -namespace osgGL2 { - -/** Extensions class which encapsulates the querying of extensions and - * associated function pointers, and provide convenience wrappers to - * check for the extensions or use the associated functions.*/ -class OSGGL2_EXPORT Extensions : public osg::Referenced -{ - public: - Extensions(); - - Extensions(const Extensions& rhs); - - void lowestCommonDenominator(const Extensions& rhs); - - void setupGLExtensions(); - - /** are all the extensions required for GLSL supported? */ - bool isGlslSupported() const { return ( _isShaderObjectsSupported && - _isVertexShaderSupported && - _isFragmentShaderSupported ); } - - void setShaderObjectsSupported(bool flag) { _isShaderObjectsSupported = flag; } - bool isShaderObjectsSupported() const { return _isShaderObjectsSupported; } - - void setVertexShaderSupported(bool flag) { _isVertexShaderSupported = flag; } - bool isVertexShaderSupported() const { return _isVertexShaderSupported; } - - void setFragmentShaderSupported(bool flag) { _isFragmentShaderSupported = flag; } - bool isFragmentShaderSupported() const { return _isFragmentShaderSupported; } - - void setLanguage100Supported(bool flag) { _isLanguage100Supported = flag; } - bool isLanguage100Supported() const { return _isLanguage100Supported; } - - float getLanguageVersion() const { return _languageVersion; } - - /** Function to call to get the extension of a specified context. - * If the Exentsion object for that context has not yet been created then - * and the 'createIfNotInitalized' flag been set to false then returns NULL. - * If 'createIfNotInitalized' is true then the Extensions object is - * automatically created. However, in this case the extension object - * only be created with the graphics context associated with ContextID..*/ - static Extensions* Get(unsigned int contextID,bool createIfNotInitalized); - - /** allows users to override the extensions across graphics contexts. - * typically used when you have different extensions supported across graphics pipes - * but need to ensure that they all use the same low common denominator extensions.*/ - static void Set(unsigned int contextID,Extensions* extensions); - - - - GLhandleARB glCreateShaderObject(GLenum shaderType) const; - GLhandleARB glCreateProgramObject() const; - void glDeleteObject(GLhandleARB obj) const; - void glAttachObject(GLhandleARB containerObj, GLhandleARB obj) const; - void glDetachObject(GLhandleARB containerObj, GLhandleARB attachedObj) const; - void glShaderSource(GLhandleARB shaderObj, GLsizei count, const GLcharARB **strings, const GLint *length) const; - void glCompileShader(GLhandleARB shaderObj) const; - void glBindAttribLocation(GLhandleARB programObj, GLuint index, const GLcharARB *name) const; - void glLinkProgram(GLhandleARB programObj) const; - void glUseProgramObject(GLhandleARB programObj) const; - void glGetInfoLog(GLhandleARB obj,GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) const; - void glGetAttachedObjects(GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj) const; - void glGetShaderSource(GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source) const; - void glUniform1f(GLint location, GLfloat v0) const; - void glUniform2f(GLint location, GLfloat v0, GLfloat v1) const; - void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) const; - void glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const; - void glUniform1i(GLint location, GLint v0) const; - void glUniform2i(GLint location, GLint v0, GLint v1) const; - void glUniform3i(GLint location, GLint v0, GLint v1, GLint v2) const; - void glUniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) const; - void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) const; - void glUniform1iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform2iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform3iv(GLint location, GLsizei count, const GLint *value) const; - void glUniform4iv(GLint location, GLsizei count, const GLint *value) const; - void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) const; - GLint glGetUniformLocation(GLhandleARB programObject, const GLcharARB *name) const; - GLint glGetAttribLocation(GLhandleARB programObj, const GLcharARB *name) const; - void glGetActiveUniform(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLint *type, GLcharARB *name) const; - void glGetActiveAttribs(GLhandleARB programObj, GLint *count, const GLint **size, const GLenum **type, const GLcharARB* const **attributes) const; - void glGetUniformfv(GLhandleARB programObj, GLint location, GLfloat *params) const; - void glGetUniformiv(GLhandleARB programObj, GLint location, GLint *params) const; - void glGetObjectParameterfv(GLhandleARB obj, GLenum pname, GLfloat *params) const; - void glGetObjectParameteriv(GLhandleARB obj, GLenum pname, GLint *params) const; - GLhandleARB glGetHandle(GLenum pname) const; - - protected: - - ~Extensions() {} - - bool _isShaderObjectsSupported; - bool _isVertexShaderSupported; - bool _isFragmentShaderSupported; - bool _isLanguage100Supported; - float _languageVersion; - - void* _glCreateShaderObject; - void* _glCreateProgramObject; - void* _glDeleteObject; - void* _glAttachObject; - void* _glDetachObject; - void* _glShaderSource; - void* _glCompileShader; - void* _glBindAttribLocation; - void* _glLinkProgram; - void* _glUseProgramObject; - void* _glGetInfoLog; - void* _glGetAttachedObjects; - void* _glGetShaderSource; - void* _glUniform1f; - void* _glUniform2f; - void* _glUniform3f; - void* _glUniform4f; - void* _glUniform1i; - void* _glUniform2i; - void* _glUniform3i; - void* _glUniform4i; - void* _glUniform1fv; - void* _glUniform2fv; - void* _glUniform3fv; - void* _glUniform4fv; - void* _glUniform1iv; - void* _glUniform2iv; - void* _glUniform3iv; - void* _glUniform4iv; - void* _glUniformMatrix2fv; - void* _glUniformMatrix3fv; - void* _glUniformMatrix4fv; - void* _glGetUniformLocation; - void* _glGetAttribLocation; - void* _glGetActiveUniform; - void* _glGetActiveAttribs; - void* _glGetUniformfv; - void* _glGetUniformiv; - void* _glGetObjectParameterfv; - void* _glGetObjectParameteriv; - void* _glGetHandle; - -}; - -} - -#endif - diff --git a/include/osgGL2/ProgramObject b/include/osgGL2/ProgramObject deleted file mode 100644 index 0cb24d75e..000000000 --- a/include/osgGL2/ProgramObject +++ /dev/null @@ -1,296 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield - * Copyright (C) 2003-2004 3Dlabs Inc. Ltd. - * - * This application is open source and may be redistributed and/or modified - * freely and without restriction, both in commericial and non commericial - * applications, as long as this copyright notice is maintained. - * - * This application 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. -*/ - -/* file: include/osgGL2/ProgramObject - * author: Mike Weiblen 2004-11-09 - * - * See http://www.3dlabs.com/opengl2/ for more information regarding - * the OpenGL Shading Language. -*/ - - -#ifndef OSGGL2_PROGRAMOBJECT -#define OSGGL2_PROGRAMOBJECT 1 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - - -namespace osgGL2 { - -class ProgramObject; -typedef osg::ref_ptr ProgramObjectPtr; - -class ShaderObject; -typedef osg::ref_ptr ShaderObjectPtr; - -/////////////////////////////////////////////////////////////////////////// -/** osgGL2::ProgramObject is an application-level abstraction of the OpenGL Shading Language glProgramObject. - * It is an osg::StateAttribute that, when applied, will install an OGLSL - * shader program for subsequent rendering. - * osgGL2::ShaderObjects containing the actual shader source code are - * attached to the ProgramObject, which will then manage the compilation, - * linking, and installation of the GL shader program. - * ProgramObject will automatically manage per-context instancing of the - * internal objects, if that is necessary for a particular display - * configuration. - */ - -class OSGGL2_EXPORT ProgramObject : public osg::StateAttribute -{ - public: - ProgramObject(); - - /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ - ProgramObject(const ProgramObject& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); - - META_StateAttribute(osgGL2, ProgramObject, PROGRAMOBJECT); - - /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ - virtual int compare(const osg::StateAttribute& sa) const; - - /** If enabled, install our shader program in the GL pipeline, - * performing any shader program rebuild operations that might - * be pending. */ - virtual void apply(osg::State& state) const; - - virtual void compileGLObjects(osg::State& state) const; - - /** release an OpenGL objects in specified graphics context if State - object is passed, otherwise release OpenGL objexts for all graphics context if - State object pointer NULL.*/ - virtual void releaseGLObjects(osg::State* state=0) const; - - // data access methods. - - /** Mark us as "dirty" and in need of relinking. */ - void dirtyProgramObject(); - - /** Mark our attached ShaderObjects as "dirty" and in need of - * recompilation. */ - void dirtyShaderObjects(); - - /** An override to control whether the shader program will - * actually be installed when OSG attempts to apply() */ - void enable( bool enabled ) { _enabled = enabled; } - - /** Attach a ShaderObject to this ProgramObject */ - void addShader( ShaderObject* shadObj ); - - /** Assign a value to a ProgramObject's uniform variable */ - void setUniform( const char* uniformName, int value ); - void setUniform( const char* uniformName, float value ); - void setUniform( const char* uniformName, osg::Vec2 value ); - void setUniform( const char* uniformName, osg::Vec3 value ); - void setUniform( const char* uniformName, osg::Vec4 value ); - - inline void setSampler( const char* uniformName, int value ) - { - // emphatic alias for setUniform(int) - setUniform( uniformName, static_cast(value) ); - } - - /** Mark internal GL objects for deletion. - * Deletion requests are queued until they can be executed - * in the proper GL context. */ - static void deleteObject(unsigned int contextID, GLhandleARB handle); - - /** flush all the cached glProgramObjects which need to be deleted - * in the OpenGL context related to contextID.*/ - static void flushDeletedGL2Objects(unsigned int contextID,double currentTime, double& availableTime); - - - protected: - /** PCPO is an OSG-internal encapsulation of glProgramObjects per-GL context. */ - class PerContextProgObj : public osg::Referenced - { - public: - PerContextProgObj(const ProgramObject* progObj, unsigned int contextID); - PerContextProgObj(const PerContextProgObj& rhs); - - GLhandleARB& getHandle() {return _glProgObjHandle;} - - bool isDirty() const {return _dirty;} - void markAsDirty() {_dirty = true; } - void build(); - void use() const; - - /** Add a list of UniformValues to our per-context queue */ - void updateUniforms( const UniformValueList& univalList ); - - /** Apply our queue of pending UniformValue updates to the glProgramObjects */ - void applyUniformValues(); - - protected: /*methods*/ - PerContextProgObj(); - ~PerContextProgObj(); - - protected: /*data*/ - /** Pointer to our parent ProgramObject */ - const ProgramObject* _progObj; - /** Pointer to this context's extension functions */ - osg::ref_ptr _extensions; - /** Handle to the actual glProgramObject */ - GLhandleARB _glProgObjHandle; - /** Do we need to be linked? */ - bool _dirty; - /** Queue of UniformValues awaiting assignment */ - UniformValueList _univalList; - const unsigned int _contextID; - }; - - protected: /*methods*/ - virtual ~ProgramObject(); - /** Get the PCPO for a particular GL context */ - PerContextProgObj* getPCPO(unsigned int contextID) const; - - /** Per frame, copy the list of pending UniformValue updates to - * each of the PCPOs. */ - void updateUniforms( int frameNumber ) const; - - protected: /*data*/ - bool _enabled; - - typedef std::vector< ShaderObjectPtr > ShaderObjectList; - ShaderObjectList _shaderObjectList; - mutable osg::buffered_value< osg::ref_ptr > _pcpoList; - mutable int _frameNumberOfLastPCPOUpdate; - mutable UniformValueList _univalList; - - private: - const ProgramObject& operator=(const ProgramObject&); -}; - -/////////////////////////////////////////////////////////////////////////// -/** osgGL2::ShaderObject is an application-level abstraction of the OpenGL Shading Language glShaderObject. - * It is a container to load the shader source code text and manage its - * compilation. - * A ShaderObject may be attached to more than one osgGL2::ProgramObject. - * ShaderObject will automatically manage per-context instancing of the - * internal objects, if that is necessary for a particular display - * configuration. - */ - -class OSGGL2_EXPORT ShaderObject : public osg::Object -{ - public: - - enum Type { - VERTEX = GL_VERTEX_SHADER_ARB, - FRAGMENT = GL_FRAGMENT_SHADER_ARB, - UNKNOWN = -1 - }; - - ShaderObject(); - ShaderObject(Type type); - ShaderObject(Type type, const char* sourceText); - - /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ - ShaderObject(const ShaderObject& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); - META_Object(osgGL2, ShaderObject); - - int compare(const ShaderObject& sa) const; - - // data access methods. - - /** Load the ShaderObject's source code text from a string. */ - void setShaderSource( const char* sourceText ); - - /** Retreive the source code text */ - inline const std::string& getShaderSource() const {return _shaderSource; } - - /** Load the ShaderObject's source code text from a file. */ - bool loadShaderSourceFromFile( const char* fileName ); - - /** Get the ShaderObject type as an enum. */ - inline Type getType() const { return _type; } - - /** Get the ShaderObject type as a descriptive string. */ - const char* getTypename() const; - - /** Mark us as "dirty" and in need of recompilation */ - void dirtyShaderObject(); - - /** Perform a recompilation of all our PCSOs */ - void build(unsigned int contextID) const; - - /** For a given GL context, attach a glShaderObject to a glProgramObject */ - void attach(unsigned int contextID, GLhandleARB progObj) const; - - - protected: - /** PCSO is an OSG-internal encapsulation of glShaderObjects per-GL context. */ - class PerContextShaderObj : public osg::Referenced - { - public: - PerContextShaderObj(const ShaderObject* shadObj, unsigned int contextID); - PerContextShaderObj(const PerContextShaderObj& rhs); - - GLhandleARB& getHandle() {return _glShaderObjHandle;} - - bool isDirty() const {return _dirty;} - void markAsDirty() {_dirty = true; } - void build(); - - /** Attach our glShaderObject to a glProgramObject */ - void attach(GLhandleARB progObj) const; - - protected: /*methods*/ - PerContextShaderObj(); - ~PerContextShaderObj(); - - protected: /*data*/ - /** Pointer to our parent ShaderObject */ - const ShaderObject* _shadObj; - /** Pointer to this context's extension functions. */ - osg::ref_ptr _extensions; - /** Handle to the actual glShaderObject. */ - GLhandleARB _glShaderObjHandle; - /** Do we need to be recompiled? */ - bool _dirty; - const unsigned int _contextID; - }; - - protected: /*methods*/ - virtual ~ShaderObject(); - PerContextShaderObj* getPCSO(unsigned int contextID) const; - - friend void ProgramObject::addShader( ShaderObject* shadObj ); // to access addProgObjRef() - void addProgObjRef( ProgramObject* progObj ); - - protected: /*data*/ - Type _type; - std::string _shaderSource; - std::vector< ProgramObjectPtr > _programObjectList; - mutable osg::buffered_value< osg::ref_ptr > _pcsoList; - - private: - const ShaderObject& operator=(const ShaderObject&); -}; - -} - -#endif - -/*EOF*/ diff --git a/include/osgGL2/UniformValue b/include/osgGL2/UniformValue deleted file mode 100644 index 73a5c682f..000000000 --- a/include/osgGL2/UniformValue +++ /dev/null @@ -1,114 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield - * Copyright (C) 2003 3Dlabs Inc. Ltd. - * - * This application is open source and may be redistributed and/or modified - * freely and without restriction, both in commericial and non commericial - * applications, as long as this copyright notice is maintained. - * - * This application 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. -*/ - -/* file: include/osgGL2/UniformValue - * author: Mike Weiblen 2003-12-28 - * - * See http://www.3dlabs.com/opengl2/ for more information regarding - * the OpenGL Shading Language. -*/ - -#ifndef OSGGL2_UNIFORMVALUE -#define OSGGL2_UNIFORMVALUE 1 - -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace osgGL2 { - -/////////////////////////////////////////////////////////////////////////// -/** osgGL2::UniformValue is for internal use by osgGL2::ProgramObject. - * UniformValue is an abstract class to encapsulate a new value for a glUniform. - * osgGL2::ProgramObject.setUniform() constructs and sends a UniformValue - * to all its PerContextProgramObjects (PCPOs) to set the value of a - * glUniform. - * The value contained in each UniformValue value is propagated to the - * glProgramObjects during the next osgGL2::ProgramObject.apply(). - */ - -class OSGGL2_EXPORT UniformValue : public osg::Referenced -{ - public: - virtual void apply( Extensions *ext, const GLhandleARB progObj ) const = 0; - - virtual int compare(const UniformValue& uv) const; - - protected: - UniformValue( const char* uniformName ) : _name( uniformName ) {}; - virtual ~UniformValue() {}; - UniformValue(); - UniformValue(const UniformValue&); - UniformValue& operator=(const UniformValue&); - - int getLocation( Extensions *ext, const GLhandleARB progObj ) const; - - std::string _name; -}; - -typedef std::vector< osg::ref_ptr > UniformValueList; - - -/////////////////////////////////////////////////////////////////////////// -/** UniformValueTemplate creates the concrete classes for each of the - * uniform value types */ - -template -class UniformValueTemplate: public UniformValue -{ - public: - UniformValueTemplate( const char* uniformName, T value ) : - UniformValue( uniformName ), _value( value ) {} - - virtual void apply( Extensions *ext, const GLhandleARB progObj ) const; - - virtual int compare(const UniformValue& uv) const - { - if (this==&uv) return 0; - const std::type_info* type_lhs = &typeid(*this); - const std::type_info* type_rhs = &typeid(uv); - if (type_lhs->before(*type_rhs)) return -1; - if (*type_lhs != *type_rhs) return 1; - const UniformValueTemplate& rhs = static_cast(uv); - - if (_name UniformValue_int; -typedef UniformValueTemplate UniformValue_float; -typedef UniformValueTemplate UniformValue_Vec2; -typedef UniformValueTemplate UniformValue_Vec3; -typedef UniformValueTemplate UniformValue_Vec4; - -} - -#endif - -/*EOF*/ diff --git a/include/osgGL2/Version b/include/osgGL2/Version deleted file mode 100644 index 7c9b63df0..000000000 --- a/include/osgGL2/Version +++ /dev/null @@ -1,49 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 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 OSGGL2_VERSION -#define OSGGL2_VERSION 1 - -#include - -extern "C" { - -/* - * osgGL2GetVersion() returns the library version number. - * Numbering convention : OpenSceneGraph-GL2-0.1 will return 0.1 from osgGL2getVersion. - * - * This C function can be also used to check for the existence of the OpenSceneGraph - * library using autoconf and its m4 macro AC_CHECK_LIB. - * - * Here is the code to add to your configure.in: - \verbatim - # - # Check for the OpenSceneGraph-GL2 library - # - AC_CHECK_LIB(osg, osgGL2GetVersion, , - [AC_MSG_ERROR(OpenSceneGraph library not found. See http://www.openscenegraph.org)],) - \endverbatim - */ - -extern OSGGL2_EXPORT const char* osgGL2GetVersion(); - -/* - * osgGL2GetLibraryName() returns the library name in human friendly form. - */ - -extern OSGGL2_EXPORT const char* osgGL2GetLibraryName(); - -} - -#endif - diff --git a/src/osgGL2/Extensions.cpp b/src/osgGL2/Extensions.cpp deleted file mode 100644 index 5381eeefe..000000000 --- a/src/osgGL2/Extensions.cpp +++ /dev/null @@ -1,767 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield - * Copyright (C) 2003-2004 3Dlabs Inc. Ltd. - * - * This application is open source and may be redistributed and/or modified - * freely and without restriction, both in commericial and non commericial - * applications, as long as this copyright notice is maintained. - * - * This application 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. -*/ - -/* file: src/osgGL2/Extensions.cpp - * author: Mike Weiblen 2004-07-08 - * - * See http://www.3dlabs.com/opengl2/ for more information regarding - * the OpenGL Shading Language. -*/ - - -#include -#include -#include -#include - -#include - -using namespace osgGL2; - - -Extensions::Extensions() -{ - setupGLExtensions(); -} - -Extensions::Extensions(const Extensions& rhs) : osg::Referenced() -{ - _isShaderObjectsSupported = rhs._isShaderObjectsSupported; - _isVertexShaderSupported = rhs._isVertexShaderSupported; - _isFragmentShaderSupported = rhs._isFragmentShaderSupported; - _isLanguage100Supported = rhs._isLanguage100Supported; - _languageVersion = rhs._languageVersion; - - _glCreateShaderObject = rhs._glCreateShaderObject; - _glCreateProgramObject = rhs._glCreateProgramObject; - _glDeleteObject = rhs._glDeleteObject; - _glAttachObject = rhs._glAttachObject; - _glDetachObject = rhs._glDetachObject; - _glShaderSource = rhs._glShaderSource; - _glCompileShader = rhs._glCompileShader; - _glBindAttribLocation = rhs._glBindAttribLocation; - _glLinkProgram = rhs._glLinkProgram; - _glUseProgramObject = rhs._glUseProgramObject; - _glGetInfoLog = rhs._glGetInfoLog; - _glGetAttachedObjects = rhs._glGetAttachedObjects; - _glGetShaderSource = rhs._glGetShaderSource; - _glUniform1f = rhs._glUniform1f; - _glUniform2f = rhs._glUniform2f; - _glUniform3f = rhs._glUniform3f; - _glUniform4f = rhs._glUniform4f; - _glUniform1i = rhs._glUniform1i; - _glUniform2i = rhs._glUniform2i; - _glUniform3i = rhs._glUniform3i; - _glUniform4i = rhs._glUniform4i; - _glUniform1fv = rhs._glUniform1fv; - _glUniform2fv = rhs._glUniform2fv; - _glUniform3fv = rhs._glUniform3fv; - _glUniform4fv = rhs._glUniform4fv; - _glUniform1iv = rhs._glUniform1iv; - _glUniform2iv = rhs._glUniform2iv; - _glUniform3iv = rhs._glUniform3iv; - _glUniform4iv = rhs._glUniform4iv; - _glUniformMatrix2fv = rhs._glUniformMatrix2fv; - _glUniformMatrix3fv = rhs._glUniformMatrix3fv; - _glUniformMatrix4fv = rhs._glUniformMatrix4fv; - _glGetUniformLocation = rhs._glGetUniformLocation; - _glGetAttribLocation = rhs._glGetAttribLocation; - _glGetActiveUniform = rhs._glGetActiveUniform; - _glGetActiveAttribs = rhs._glGetActiveAttribs; - _glGetUniformfv = rhs._glGetUniformfv; - _glGetUniformiv = rhs._glGetUniformiv; - _glGetObjectParameterfv = rhs._glGetObjectParameterfv; - _glGetObjectParameteriv = rhs._glGetObjectParameteriv; - _glGetHandle = rhs._glGetHandle; -} - - -void Extensions::lowestCommonDenominator(const Extensions& rhs) -{ - if (!rhs._isShaderObjectsSupported) _isShaderObjectsSupported = false; - if (!rhs._isVertexShaderSupported) _isVertexShaderSupported = false; - if (!rhs._isFragmentShaderSupported) _isFragmentShaderSupported = false; - if (!rhs._isLanguage100Supported) _isLanguage100Supported = false; - if (rhs._languageVersion < _languageVersion) _languageVersion = rhs._languageVersion; - - if (!rhs._glCreateShaderObject) _glCreateShaderObject = 0; - if (!rhs._glCreateProgramObject) _glCreateProgramObject = 0; - if (!rhs._glDeleteObject) _glDeleteObject = 0; - if (!rhs._glAttachObject) _glAttachObject = 0; - if (!rhs._glDetachObject) _glDetachObject = 0; - if (!rhs._glShaderSource) _glShaderSource = 0; - if (!rhs._glCompileShader) _glCompileShader = 0; - if (!rhs._glBindAttribLocation) _glBindAttribLocation = 0; - if (!rhs._glLinkProgram) _glLinkProgram = 0; - if (!rhs._glUseProgramObject) _glUseProgramObject = 0; - if (!rhs._glGetInfoLog) _glGetInfoLog = 0; - if (!rhs._glGetAttachedObjects) _glGetAttachedObjects = 0; - if (!rhs._glGetShaderSource) _glGetShaderSource = 0; - if (!rhs._glUniform1f) _glUniform1f = 0; - if (!rhs._glUniform2f) _glUniform2f = 0; - if (!rhs._glUniform3f) _glUniform3f = 0; - if (!rhs._glUniform4f) _glUniform4f = 0; - if (!rhs._glUniform1i) _glUniform1i = 0; - if (!rhs._glUniform2i) _glUniform2i = 0; - if (!rhs._glUniform3i) _glUniform3i = 0; - if (!rhs._glUniform4i) _glUniform4i = 0; - if (!rhs._glUniform1fv) _glUniform1fv = 0; - if (!rhs._glUniform2fv) _glUniform2fv = 0; - if (!rhs._glUniform3fv) _glUniform3fv = 0; - if (!rhs._glUniform4fv) _glUniform4fv = 0; - if (!rhs._glUniform1iv) _glUniform1iv = 0; - if (!rhs._glUniform2iv) _glUniform2iv = 0; - if (!rhs._glUniform3iv) _glUniform3iv = 0; - if (!rhs._glUniform4iv) _glUniform4iv = 0; - if (!rhs._glUniformMatrix2fv) _glUniformMatrix2fv = 0; - if (!rhs._glUniformMatrix3fv) _glUniformMatrix3fv = 0; - if (!rhs._glUniformMatrix4fv) _glUniformMatrix4fv = 0; - if (!rhs._glGetUniformLocation) _glGetUniformLocation = 0; - if (!rhs._glGetAttribLocation) _glGetAttribLocation = 0; - if (!rhs._glGetActiveUniform) _glGetActiveUniform = 0; - if (!rhs._glGetActiveAttribs) _glGetActiveAttribs = 0; - if (!rhs._glGetUniformfv) _glGetUniformfv = 0; - if (!rhs._glGetUniformiv) _glGetUniformiv = 0; - if (!rhs._glGetObjectParameterfv) _glGetObjectParameterfv = 0; - if (!rhs._glGetObjectParameteriv) _glGetObjectParameteriv = 0; - if (!rhs._glGetHandle) _glGetHandle = 0; -} - -void Extensions::setupGLExtensions() -{ - _isShaderObjectsSupported = osg::isGLExtensionSupported("GL_ARB_shader_objects"); - _isVertexShaderSupported = osg::isGLExtensionSupported("GL_ARB_vertex_shader"); - _isFragmentShaderSupported = osg::isGLExtensionSupported("GL_ARB_fragment_shader"); - _isLanguage100Supported = osg::isGLExtensionSupported("GL_ARB_shading_language_100"); - _languageVersion = 0.0f; - - if( _isLanguage100Supported ) - { - // If glGetString raises an error, assume initial release "1.00" - glGetError(); // reset error flag - const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB); - const GLenum errorNum = glGetError(); - if( (errorNum != GL_NO_ERROR) || (langVerStr == 0) ) - { - langVerStr = "1.00 (default)"; - } - osg::notify(osg::INFO) << "GL_SHADING_LANGUAGE_VERSION_ARB: \"" << langVerStr << "\"" << std::endl; - - // TODO verify this parser is sufficiently robust - _languageVersion = atof( langVerStr ); - } - - osg::notify(osg::INFO) << "GLSL language version = " << _languageVersion << std::endl; - - _glCreateShaderObject = osg::getGLExtensionFuncPtr("glCreateShaderObjectARB"); - _glCreateProgramObject = osg::getGLExtensionFuncPtr("glCreateProgramObjectARB"); - _glDeleteObject = osg::getGLExtensionFuncPtr("glDeleteObjectARB"); - _glAttachObject = osg::getGLExtensionFuncPtr("glAttachObjectARB"); - _glDetachObject = osg::getGLExtensionFuncPtr("glDetachObjectARB"); - _glShaderSource = osg::getGLExtensionFuncPtr("glShaderSourceARB"); - _glCompileShader = osg::getGLExtensionFuncPtr("glCompileShaderARB"); - _glBindAttribLocation = osg::getGLExtensionFuncPtr("glBindAttribLocationARB"); - _glLinkProgram = osg::getGLExtensionFuncPtr("glLinkProgramARB"); - _glUseProgramObject = osg::getGLExtensionFuncPtr("glUseProgramObjectARB"); - _glGetInfoLog = osg::getGLExtensionFuncPtr("glGetInfoLogARB"); - _glGetAttachedObjects = osg::getGLExtensionFuncPtr("glGetAttachedObjectsARB"); - _glGetShaderSource = osg::getGLExtensionFuncPtr("glGetShaderSourceARB"); - _glUniform1f = osg::getGLExtensionFuncPtr("glUniform1fARB"); - _glUniform2f = osg::getGLExtensionFuncPtr("glUniform2fARB"); - _glUniform3f = osg::getGLExtensionFuncPtr("glUniform3fARB"); - _glUniform4f = osg::getGLExtensionFuncPtr("glUniform4fARB"); - _glUniform1i = osg::getGLExtensionFuncPtr("glUniform1iARB"); - _glUniform2i = osg::getGLExtensionFuncPtr("glUniform2iARB"); - _glUniform3i = osg::getGLExtensionFuncPtr("glUniform3iARB"); - _glUniform4i = osg::getGLExtensionFuncPtr("glUniform4iARB"); - _glUniform1fv = osg::getGLExtensionFuncPtr("glUniform1fvARB"); - _glUniform2fv = osg::getGLExtensionFuncPtr("glUniform2fvARB"); - _glUniform3fv = osg::getGLExtensionFuncPtr("glUniform3fvARB"); - _glUniform4fv = osg::getGLExtensionFuncPtr("glUniform4fvARB"); - _glUniform1iv = osg::getGLExtensionFuncPtr("glUniform1ivARB"); - _glUniform2iv = osg::getGLExtensionFuncPtr("glUniform2ivARB"); - _glUniform3iv = osg::getGLExtensionFuncPtr("glUniform3ivARB"); - _glUniform4iv = osg::getGLExtensionFuncPtr("glUniform4ivARB"); - _glUniformMatrix2fv = osg::getGLExtensionFuncPtr("glUniformMatrix2fvARB"); - _glUniformMatrix3fv = osg::getGLExtensionFuncPtr("glUniformMatrix3fvARB"); - _glUniformMatrix4fv = osg::getGLExtensionFuncPtr("glUniformMatrix4fvARB"); - _glGetUniformLocation = osg::getGLExtensionFuncPtr("glGetUniformLocationARB"); - _glGetAttribLocation = osg::getGLExtensionFuncPtr("glGetAttribLocationARB"); - _glGetActiveUniform = osg::getGLExtensionFuncPtr("glGetActiveUniformARB"); - _glGetActiveAttribs = osg::getGLExtensionFuncPtr("glGetActiveAttribsARB"); - _glGetUniformfv = osg::getGLExtensionFuncPtr("glGetUniformfvARB"); - _glGetUniformiv = osg::getGLExtensionFuncPtr("glGetUniformivARB"); - _glGetObjectParameterfv = osg::getGLExtensionFuncPtr("glGetObjectParameterfvARB"); - _glGetObjectParameteriv = osg::getGLExtensionFuncPtr("glGetObjectParameterivARB"); - _glGetHandle = osg::getGLExtensionFuncPtr("glGetHandleARB"); -} - -/***************************************************************************/ -// Static array of per-context osgGL2::Extensions instances - -typedef osg::buffered_value< osg::ref_ptr > BufferedExtensions; -static BufferedExtensions s_extensions; - -Extensions* Extensions::Get(unsigned int contextID, bool createIfNotInitalized) -{ - if (!s_extensions[contextID] && createIfNotInitalized) - s_extensions[contextID] = new Extensions; - - return s_extensions[contextID].get(); -} - -void Extensions::Set(unsigned int contextID, Extensions* extensions) -{ - s_extensions[contextID] = extensions; -} - -/***************************************************************************/ - -GLhandleARB Extensions::glCreateShaderObject(GLenum shaderType) const -{ - if (_glCreateShaderObject) - { - typedef GLhandleARB (APIENTRY * CreateShaderObjectProc) (GLenum shaderType); - return ((CreateShaderObjectProc)_glCreateShaderObject)(shaderType); - } - else - { - osg::notify(osg::WARN)<<"Error: glCreateShaderObject not supported by OpenGL driver"< - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -using namespace osgGL2; - - -/////////////////////////////////////////////////////////////////////////// - -namespace { - -class InfoLog -{ -public: - InfoLog( Extensions* ext, const GLhandleARB handle ) - { - GLint blen = 0; // length of buffer to allocate - GLint slen = 0; // strlen GL actually wrote to buffer - - ext->glGetObjectParameteriv(handle, GL_OBJECT_INFO_LOG_LENGTH_ARB , &blen); - if (blen > 1) - { - GLcharARB* infoLog = new GLcharARB[blen]; - ext->glGetInfoLog( handle, blen, &slen, infoLog ); - _text = infoLog; - delete [] infoLog; - } - } - - friend std::ostream& operator<< ( std::ostream& o, const InfoLog& log ) - { - return o << log._text; - } - -private: - InfoLog(); - std::string _text; -}; - -} - - -/////////////////////////////////////////////////////////////////////////// -// static cache of deleted GL2 objects which may only -// by actually deleted in the correct GL context. - -typedef std::list GL2ObjectList; -typedef std::map DeletedGL2ObjectCache; - -static OpenThreads::Mutex s_mutex_deletedGL2ObjectCache; -static DeletedGL2ObjectCache s_deletedGL2ObjectCache; - -void ProgramObject::deleteObject(unsigned int contextID, GLhandleARB handle) -{ - if (handle!=0) - { - OpenThreads::ScopedLock lock(s_mutex_deletedGL2ObjectCache); - - // add handle to the cache for the appropriate context. - s_deletedGL2ObjectCache[contextID].push_back(handle); - } -} - -void ProgramObject::flushDeletedGL2Objects(unsigned int contextID,double /*currentTime*/, double& availableTime) -{ - // if no time available don't try to flush objects. - if (availableTime<=0.0) return; - - const osg::Timer& timer = *osg::Timer::instance(); - osg::Timer_t start_tick = timer.tick(); - double elapsedTime = 0.0; - - { - OpenThreads::ScopedLock lock(s_mutex_deletedGL2ObjectCache); - - DeletedGL2ObjectCache::iterator citr = s_deletedGL2ObjectCache.find(contextID); - if( citr != s_deletedGL2ObjectCache.end() ) - { - const Extensions* extensions = Extensions::Get(contextID,true); - - if (!extensions->isGlslSupported()) - { - // can we really get here? - osg::notify(osg::WARN) << "flushDeletedGL2Objects not supported by OpenGL driver" << std::endl; - return; - } - - GL2ObjectList& vpObjectList = citr->second; - - for(GL2ObjectList::iterator titr=vpObjectList.begin(); - titr!=vpObjectList.end() && elapsedTimeglDeleteObject( *titr ); - titr = vpObjectList.erase( titr ); - elapsedTime = timer.delta_s(start_tick,timer.tick()); - } - } - } - - availableTime -= elapsedTime; -} - - -/////////////////////////////////////////////////////////////////////////// -// osgGL2::ProgramObject -/////////////////////////////////////////////////////////////////////////// - -ProgramObject::ProgramObject() -{ - // To ensure all PCPOs consistently get the same values, we must - // postpone updates until all PCPOs have been created. - // They are created during ProgramObject::apply(), so let a frame - // go by before sending the updates. - _frameNumberOfLastPCPOUpdate = 1; - _enabled = true; -} - - -ProgramObject::ProgramObject(const ProgramObject& rhs, const osg::CopyOp& copyop): - osg::StateAttribute(rhs, copyop) -{ - osg::notify(osg::FATAL) << "how got here?" << std::endl; -} - - -// virtual -ProgramObject::~ProgramObject() -{ - for( unsigned int cxt=0; cxt < _pcpoList.size(); ++cxt ) - { - if( ! _pcpoList[cxt] ) continue; - - PerContextProgObj* pcpo = _pcpoList[cxt].get(); - - deleteObject( cxt, pcpo->getHandle() ); - // TODO add shader objects to delete list. - _pcpoList[cxt] = 0; - } -} - -int ProgramObject::compare(const osg::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(ProgramObject,sa) - - if (_shaderObjectList.size()rhs._shaderObjectList.size()) return 1; - - ShaderObjectList::const_iterator litr=_shaderObjectList.begin(); - ShaderObjectList::const_iterator ritr=rhs._shaderObjectList.begin(); - for(; - litr!=_shaderObjectList.end(); - ++litr,++ritr) - { - int result = (*litr)->compare(*(*ritr)); - if (result!=0) return result; - } - - - if (_univalList.size()rhs._univalList.size()) return 1; - - UniformValueList::const_iterator luitr=_univalList.begin(); - UniformValueList::const_iterator ruitr=rhs._univalList.begin(); - for(; - luitr!=_univalList.end(); - ++luitr,++ruitr) - { - int result = (*luitr)->compare(*(*ruitr)); - if (result!=0) return result; - } - - return 0; // passed all the above comparison macro's, must be equal. -} - - -void ProgramObject::compileGLObjects(osg::State&) const -{ -} - - -// mark all PCPOs as needing a relink -void ProgramObject::dirtyProgramObject() -{ - for( unsigned int cxt=0; cxt < _pcpoList.size(); ++cxt ) - { - if( ! _pcpoList[cxt] ) continue; - - PerContextProgObj* pcpo = _pcpoList[cxt].get(); - pcpo->markAsDirty(); - } -} - - -// mark all attached ShaderObjects as needing a rebuild -void ProgramObject::dirtyShaderObjects() -{ - for( unsigned int i=0; i < _shaderObjectList.size() ; ++i ) - { - _shaderObjectList[i]->dirtyShaderObject(); - } -} - -void ProgramObject::releaseGLObjects(osg::State* state) const -{ - - if (!state) const_cast(this)->dirtyShaderObjects(); - else - { - unsigned int contextID = state->getContextID(); - const_cast(this)->_shaderObjectList[contextID]->dirtyShaderObject(); - } -} - - -void ProgramObject::addShader( ShaderObject* shadObj ) -{ - _shaderObjectList.push_back( shadObj ); - shadObj->addProgObjRef( this ); - dirtyProgramObject(); -} - - -void ProgramObject::setUniform( const char* uniformName, int value ) -{ - _univalList.push_back( new UniformValue_int( uniformName, value ) ); -} - -void ProgramObject::setUniform( const char* uniformName, float value ) -{ - _univalList.push_back( new UniformValue_float( uniformName, value ) ); -} - -void ProgramObject::setUniform( const char* uniformName, osg::Vec2 value ) -{ - _univalList.push_back( new UniformValue_Vec2( uniformName, value ) ); -} - -void ProgramObject::setUniform( const char* uniformName, osg::Vec3 value ) -{ - _univalList.push_back( new UniformValue_Vec3( uniformName, value ) ); -} - -void ProgramObject::setUniform( const char* uniformName, osg::Vec4 value ) -{ - _univalList.push_back( new UniformValue_Vec4( uniformName, value ) ); -} - - -void ProgramObject::apply(osg::State& state) const -{ - const unsigned int contextID = state.getContextID(); - const Extensions* extensions = Extensions::Get(contextID,true); - - // if there are no ShaderObjects on this ProgramObject, - // use GL 1.x "fixed functionality" rendering. - if( !_enabled || _shaderObjectList.empty() ) - { - if( extensions->isGlslSupported() ) - { - extensions->glUseProgramObject( 0 ); - } - return; - } - - if( ! extensions->isGlslSupported() ) - { - osg::notify(osg::WARN) << "GLSL not supported by OpenGL driver" << std::endl; - return; - } - - const osg::FrameStamp* frameStamp = state.getFrameStamp(); - const int frameNumber = (frameStamp) ? frameStamp->getFrameNumber() : -1; - - PerContextProgObj* pcpo = getPCPO( contextID ); - - if( pcpo->isDirty() ) - { - for( unsigned int i=0; i < _shaderObjectList.size() ; ++i ) - { - _shaderObjectList[i]->build( contextID ); - } - pcpo->build(); - } - - updateUniforms( frameNumber ); - - // make this glProgramObject part of current GL state - pcpo->use(); - - // consume any pending setUniform messages - pcpo->applyUniformValues(); -} - - -ProgramObject::PerContextProgObj* ProgramObject::getPCPO(unsigned int contextID) const -{ - if( ! _pcpoList[contextID].valid() ) - { - _pcpoList[contextID] = new PerContextProgObj( this, contextID ); - - // attach all PCSOs to this new PCPO - for( unsigned int i=0; i < _shaderObjectList.size() ; ++i ) - { - _shaderObjectList[i]->attach( contextID, _pcpoList[contextID]->getHandle() ); - } - } - return _pcpoList[contextID].get(); -} - - -void ProgramObject::updateUniforms( int frameNumber ) const -{ - if( frameNumber <= _frameNumberOfLastPCPOUpdate ) - return; - - _frameNumberOfLastPCPOUpdate = frameNumber; - - if( _univalList.empty() ) - return; - - for( unsigned int cxt=0; cxt < _pcpoList.size(); ++cxt ) - { - if( ! _pcpoList[cxt] ) continue; - - PerContextProgObj* pcpo = _pcpoList[cxt].get(); - pcpo->updateUniforms( _univalList ); - } - _univalList.clear(); -} - - -/////////////////////////////////////////////////////////////////////////// -// PCPO : OSG abstraction of the per-context Program Object - -ProgramObject::PerContextProgObj::PerContextProgObj(const ProgramObject* progObj, unsigned int contextID ) : - osg::Referenced(), - _contextID( contextID ) -{ - _progObj = progObj; - _extensions = Extensions::Get( _contextID, true ); - _glProgObjHandle = _extensions->glCreateProgramObject(); - markAsDirty(); -} - -ProgramObject::PerContextProgObj::PerContextProgObj(const PerContextProgObj& rhs) : - osg::Referenced(), - _contextID( rhs._contextID ) -{ - _progObj = rhs._progObj; - _extensions = rhs._extensions; - _glProgObjHandle = rhs._glProgObjHandle ; - _dirty = rhs._dirty; -} - -ProgramObject::PerContextProgObj::~PerContextProgObj() -{ -} - -void ProgramObject::PerContextProgObj::build() -{ - GLint linked; - - _extensions->glLinkProgram( _glProgObjHandle ); - _extensions->glGetObjectParameteriv(_glProgObjHandle, - GL_OBJECT_LINK_STATUS_ARB, &linked); - - _dirty = (linked == 0); - if( _dirty ) - { - InfoLog log( _extensions.get(), _glProgObjHandle ); - osg::notify(osg::WARN) << "glLinkProgram FAILED:\n" << log << std::endl; - } -} - - -void ProgramObject::PerContextProgObj::use() const -{ - _extensions->glUseProgramObject( _glProgObjHandle ); -} - -void ProgramObject::PerContextProgObj::updateUniforms( const UniformValueList& univalList ) -{ - // TODO: should the incoming list be appended rather than assigned? - _univalList = univalList; -} - -void ProgramObject::PerContextProgObj::applyUniformValues() -{ - Extensions *ext = _extensions.get(); - for( unsigned int i=0; i < _univalList.size() ; ++i ) - { - _univalList[i]->apply( ext, _glProgObjHandle ); - } - _univalList.clear(); -} - - -/////////////////////////////////////////////////////////////////////////// -// osgGL2::ShaderObject -/////////////////////////////////////////////////////////////////////////// - -ShaderObject::ShaderObject() : - _type(UNKNOWN) -{ -} - -ShaderObject::ShaderObject(Type type) : - _type(type) -{ -} - -ShaderObject::ShaderObject(Type type, const char* sourceText) : - _type(type) -{ - setShaderSource(sourceText); -} - -ShaderObject::ShaderObject(const ShaderObject& rhs, const osg::CopyOp& copyop): - osg::Object(rhs, copyop) -{ - /*TODO*/ -} - -ShaderObject::~ShaderObject() -{ - /*TODO*/ -} - -int ShaderObject::compare(const ShaderObject& so) const -{ - if (getShaderSource()markAsDirty(); - } - - // mark attached ProgramObjects dirty as well - for( unsigned int i=0; i < _programObjectList.size(); ++i ) - { - _programObjectList[i]->dirtyProgramObject(); - } -} - -void ShaderObject::setShaderSource( const char* sourceText ) -{ - _shaderSource = sourceText; - dirtyShaderObject(); -} - -bool ShaderObject::loadShaderSourceFromFile( const char* fileName ) -{ - std::ifstream sourceFile; - - sourceFile.open(fileName, std::ios::binary); - if(!sourceFile) - { - osg::notify(osg::WARN)<<"Error: can't open file \""<isDirty() ) - { - pcso->build(); - } -} - - -ShaderObject::PerContextShaderObj* ShaderObject::getPCSO(unsigned int contextID) const -{ - if( ! _pcsoList[contextID].valid() ) - { - _pcsoList[contextID] = new PerContextShaderObj( this, contextID ); - } - return _pcsoList[contextID].get(); -} - - -void ShaderObject::attach(unsigned int contextID, GLhandleARB progObj) const -{ - getPCSO( contextID )->attach( progObj ); -} - - -void ShaderObject::addProgObjRef( ProgramObject* progObj ) -{ - _programObjectList.push_back( progObj ); -} - - -/////////////////////////////////////////////////////////////////////////// -// PCSO : OSG abstraction of the per-context Shader Object - -ShaderObject::PerContextShaderObj::PerContextShaderObj(const ShaderObject* shadObj, unsigned int contextID) : - osg::Referenced(), - _contextID( contextID ) -{ - _shadObj = shadObj; - _extensions = Extensions::Get( _contextID, true ); - _glShaderObjHandle = _extensions->glCreateShaderObject( shadObj->getType() ); - markAsDirty(); -} - -ShaderObject::PerContextShaderObj::PerContextShaderObj(const PerContextShaderObj& rhs) : - osg::Referenced(), - _contextID( rhs._contextID ) -{ - _shadObj = rhs._shadObj; - _extensions = rhs._extensions; - _glShaderObjHandle = rhs._glShaderObjHandle; - _dirty = rhs._dirty; -} - -ShaderObject::PerContextShaderObj::~PerContextShaderObj() -{ -} - -void ShaderObject::PerContextShaderObj::build() -{ - GLint compiled; - const char* sourceText = _shadObj->getShaderSource().c_str(); - - _extensions->glShaderSource( _glShaderObjHandle, 1, &sourceText, NULL ); - _extensions->glCompileShader( _glShaderObjHandle ); - _extensions->glGetObjectParameteriv(_glShaderObjHandle, - GL_OBJECT_COMPILE_STATUS_ARB, &compiled); - - _dirty = (compiled == 0); - if( _dirty ) - { - InfoLog log( _extensions.get(), _glShaderObjHandle ); - osg::notify(osg::WARN) << _shadObj->getTypename() << - " glCompileShader FAILED:\n" << log << std::endl; - } -} - -void ShaderObject::PerContextShaderObj::attach(GLhandleARB progObj) const -{ - _extensions->glAttachObject( progObj, _glShaderObjHandle ); -} - -/*EOF*/ diff --git a/src/osgGL2/UniformValue.cpp b/src/osgGL2/UniformValue.cpp deleted file mode 100644 index 9434934c1..000000000 --- a/src/osgGL2/UniformValue.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield - * Copyright (C) 2003 3Dlabs Inc. Ltd. - * - * This application is open source and may be redistributed and/or modified - * freely and without restriction, both in commericial and non commericial - * applications, as long as this copyright notice is maintained. - * - * This application 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. -*/ - -/* file: src/osgGL2/UniformValue - * author: Mike Weiblen 2003-12-27 - * - * See http://www.3dlabs.com/opengl2/ for more information regarding - * the OpenGL Shading Language. -*/ - -#include - -#include -#include - -using namespace osgGL2; -using namespace osg; - -int UniformValue::compare(const UniformValue& uv) const -{ - if (_nameglGetUniformLocation( progObj, _name.c_str() ); - if( loc == -1 ) - { - osg::notify(osg::INFO) << "Uniform \"" << _name << - "\" not found in ProgramObject" << std::endl; - } - return loc; -} - -/////////////////////////////////////////////////////////////////////////// - -#ifdef sgi -template <> -#endif -void UniformValue_int::apply( Extensions *ext, const GLhandleARB progObj ) const -{ - int loc = getLocation( ext, progObj ); - if( loc != -1 ) - { - ext->glUniform1i( loc, _value ); - } -} - -#ifdef sgi -template <> -#endif -void UniformValue_float::apply( Extensions *ext, const GLhandleARB progObj ) const -{ - int loc = getLocation( ext, progObj ); - if( loc != -1 ) - { - ext->glUniform1f( loc, _value ); - } -} - -#ifdef sgi -template <> -#endif -void UniformValue_Vec2::apply( Extensions *ext, const GLhandleARB progObj ) const -{ - int loc = getLocation( ext, progObj ); - if( loc != -1 ) - { - ext->glUniform2fv( loc, 1, _value.ptr() ); - } -} - -#ifdef sgi -template <> -#endif -void UniformValue_Vec3::apply( Extensions *ext, const GLhandleARB progObj ) const -{ - int loc = getLocation( ext, progObj ); - if( loc != -1 ) - { - ext->glUniform3fv( loc, 1, _value.ptr() ); - } -} - -#ifdef sgi -template <> -#endif -void UniformValue_Vec4::apply( Extensions *ext, const GLhandleARB progObj ) const -{ - int loc = getLocation( ext, progObj ); - if( loc != -1 ) - { - ext->glUniform4fv( loc, 1, _value.ptr() ); - } -} - -/*EOF*/ diff --git a/src/osgGL2/Version.cpp b/src/osgGL2/Version.cpp deleted file mode 100644 index 9f384edca..000000000 --- a/src/osgGL2/Version.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -const char* osgGL2GetVersion() -{ - return "0.9.8"; -} - - -const char* osgGL2GetLibraryName() -{ - return "OpenSceneGraph OpenGL Shading Language Library"; -} -