00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2003 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 00026 #include "OgreGLSLExtSupport.h" 00027 #include "OgreGLSLGpuProgram.h" 00028 #include "OgreGLSLLinkProgramManager.h" 00029 #include "OgreGLSLLinkProgram.h" 00030 #include "OgreGLSLProgram.h" 00031 00032 namespace Ogre { 00033 00034 GLuint GLSLGpuProgram::mVertexShaderCount = 0; 00035 GLuint GLSLGpuProgram::mFragmentShaderCount = 0; 00036 00037 //----------------------------------------------------------------------------- 00038 GLSLGpuProgram::GLSLGpuProgram(GLSLProgram* parent) : GLGpuProgram(parent->getName(), parent->getType(), "glsl"), mGLSLProgram(parent) 00039 { 00040 if (parent->getType() == GPT_VERTEX_PROGRAM) 00041 { 00042 mProgramID = ++mVertexShaderCount; 00043 } 00044 else 00045 { 00046 mProgramID = ++mFragmentShaderCount; 00047 } 00048 00049 // there is nothing to load 00050 mLoadFromFile = false; 00051 00052 } 00053 00054 //----------------------------------------------------------------------------- 00055 void GLSLGpuProgram::load(void) 00056 { 00057 mIsLoaded = true; 00058 } 00059 00060 //----------------------------------------------------------------------------- 00061 void GLSLGpuProgram::unload(void) 00062 { 00063 // nothing to unload 00064 } 00065 00066 //----------------------------------------------------------------------------- 00067 void GLSLGpuProgram::loadFromSource(void) 00068 { 00069 // nothing to load 00070 } 00071 00072 //----------------------------------------------------------------------------- 00073 void GLSLGpuProgram::bindProgram(void) 00074 { 00075 // tell the Link Program Manager what shader is to become active 00076 if (mType == GPT_VERTEX_PROGRAM) 00077 { 00078 GLSLLinkProgramManager::getSingleton().setActiveVertexShader( this ); 00079 } 00080 else // its a fragment shader 00081 { 00082 GLSLLinkProgramManager::getSingleton().setActiveFragmentShader( this ); 00083 } 00084 } 00085 00086 //----------------------------------------------------------------------------- 00087 void GLSLGpuProgram::unbindProgram(void) 00088 { 00089 // tell the Link Program Manager what shader is to become inactive 00090 if (mType == GPT_VERTEX_PROGRAM) 00091 { 00092 GLSLLinkProgramManager::getSingleton().setActiveVertexShader( NULL ); 00093 } 00094 else // its a fragment shader 00095 { 00096 GLSLLinkProgramManager::getSingleton().setActiveFragmentShader( NULL ); 00097 } 00098 00099 } 00100 00101 //----------------------------------------------------------------------------- 00102 void GLSLGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params) 00103 { 00104 // activate the link program object 00105 GLSLLinkProgram* linkProgram = GLSLLinkProgramManager::getSingleton().getActiveLinkProgram(); 00106 // pass on parameters from params to program object uniforms 00107 linkProgram->updateUniforms( params ); 00108 00109 } 00110 00111 00112 } 00113
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:26 2004