<html> <head> <title>OgreGLGpuNvparseProgram.cpp Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <!-- Generated by Doxygen 1.2.16 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>OgreGLGpuNvparseProgram.cpp</h1><a href="OgreGLGpuNvparseProgram_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font> 00002 <font class="comment">-----------------------------------------------------------------------------</font> 00003 <font class="comment">This source file is part of OGRE</font> 00004 <font class="comment"> (Object-oriented Graphics Rendering Engine)</font> 00005 <font class="comment">For the latest info, see http://www.stevestreeting.com/ogre/</font> 00006 <font class="comment"></font> 00007 <font class="comment">Copyright © 2000-2003 The OGRE Teameeting</font> 00008 <font class="comment">Also see acknowledgements in Readme.html</font> 00009 <font class="comment"></font> 00010 <font class="comment">This program is free software; you can redistribute it and/or modify it under</font> 00011 <font class="comment">the terms of the GNU General Public License as published by the Free Software</font> 00012 <font class="comment">Foundation; either version 2 of the License, or (at your option) any later</font> 00013 <font class="comment">version.</font> 00014 <font class="comment"></font> 00015 <font class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</font> 00016 <font class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</font> 00017 <font class="comment">FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</font> 00018 <font class="comment"></font> 00019 <font class="comment">You should have received a copy of the GNU General Public License along with</font> 00020 <font class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</font> 00021 <font class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</font> 00022 <font class="comment">http://www.gnu.org/copyleft/gpl.html.</font> 00023 <font class="comment">-----------------------------------------------------------------------------</font> 00024 <font class="comment">*/</font> 00025 00026 <font class="preprocessor">#include "<a class="code" href="OgreGLGpuNvparseProgram_8h.html">OgreGLGpuNvparseProgram.h</a>"</font> 00027 <font class="preprocessor">#include "<a class="code" href="OgreException_8h.html">OgreException.h</a>"</font> 00028 <font class="preprocessor">#include "<a class="code" href="OgreRoot_8h.html">OgreRoot.h</a>"</font> 00029 <font class="preprocessor">#include "<a class="code" href="OgreRenderSystem_8h.html">OgreRenderSystem.h</a>"</font> 00030 <font class="preprocessor">#include "<a class="code" href="OgreRenderSystemCapabilities_8h.html">OgreRenderSystemCapabilities.h</a>"</font> 00031 <font class="preprocessor">#include "<a class="code" href="OgreLogManager_8h.html">OgreLogManager.h</a>"</font> 00032 <font class="preprocessor">#include "nvparse.h"</font> 00033 00034 <font class="keyword">using</font> <font class="keyword">namespace </font>Ogre; 00035 <a name="l00036"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparsePrograma0">00036</a> GLGpuNvparseProgram::GLGpuNvparseProgram(<font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>& name, <a class="code" href="namespaceOgre.html#a626">GpuProgramType</a> gptype, <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>& syntaxCode) : 00037 <a class="code" href="classOgre_1_1GLGpuProgram.html">GLGpuProgram</a>(name, gptype, syntaxCode) 00038 { 00039 <a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparseProgramo0">mProgramID</a> = glGenLists(1); 00040 } 00041 <a name="l00042"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparsePrograma3">00042</a> <font class="keywordtype">void</font> GLGpuNvparseProgram::bindProgram(<font class="keywordtype">void</font>) 00043 { 00044 glCallList(<a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparseProgramo0">mProgramID</a>); 00045 glEnable(GL_TEXTURE_SHADER_NV); 00046 glEnable(GL_REGISTER_COMBINERS_NV); 00047 glEnable(GL_PER_STAGE_CONSTANTS_NV); 00048 } 00049 <a name="l00050"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparsePrograma4">00050</a> <font class="keywordtype">void</font> GLGpuNvparseProgram::unbindProgram(<font class="keywordtype">void</font>) 00051 { 00052 00053 glDisable(GL_TEXTURE_SHADER_NV); 00054 glDisable(GL_REGISTER_COMBINERS_NV); 00055 glDisable(GL_PER_STAGE_CONSTANTS_NV); 00056 } 00057 <a name="l00058"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparsePrograma5">00058</a> <font class="keywordtype">void</font> GLGpuNvparseProgram::bindProgramParameters(<a class="code" href="namespaceOgre.html#a132">GpuProgramParametersSharedPtr</a> params) 00059 { 00060 <font class="comment">// NB, register combiners uses 2 constants per texture stage (0 and 1)</font> 00061 <font class="comment">// We have stored these as (stage * 2) + const_index</font> 00062 00063 <font class="keywordflow">if</font> (params->hasRealConstantParams()) 00064 { 00065 <font class="comment">// Iterate over params and set the relevant ones</font> 00066 GpuProgramParameters::RealConstantIterator realIt = 00067 params->getRealConstantIterator(); 00068 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> index = 0; 00069 <font class="keywordflow">while</font> (realIt.hasMoreElements()) 00070 { 00071 <a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html">GpuProgramParameters::RealConstantEntry</a>* e = realIt.peekNextPtr(); 00072 <font class="keywordflow">if</font> (e-><a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html#Ogre_1_1GpuProgramParameters_1_1RealConstantEntrym1">isSet</a>) 00073 { 00074 GLenum combinerStage = GL_COMBINER0_NV + (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font>)(index / 2); 00075 GLenum pname = GL_CONSTANT_COLOR0_NV + (index % 2); 00076 <a class="code" href="OgreGLRenderSystem_8cpp.html#a18">glCombinerStageParameterfvNV_ptr</a>(combinerStage, pname, e-><a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html#Ogre_1_1GpuProgramParameters_1_1RealConstantEntrym0">val</a>); 00077 } 00078 index++; 00079 realIt.moveNext(); 00080 } 00081 } 00082 00083 } <a name="l00084"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparsePrograma2">00084</a> <font class="keywordtype">void</font> GLGpuNvparseProgram::unload(<font class="keywordtype">void</font>) 00085 { 00086 glDeleteLists(<a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparseProgramo0">mProgramID</a>,1); 00087 } 00088 <a name="l00089"></a><a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparseProgramb0">00089</a> <font class="keywordtype">void</font> GLGpuNvparseProgram::loadFromSource(<font class="keywordtype">void</font>) 00090 { 00091 glNewList(<a class="code" href="classOgre_1_1GLGpuNvparseProgram.html#Ogre_1_1GLGpuNvparseProgramo0">mProgramID</a>, GL_COMPILE); 00092 00093 String::size_type pos = <a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn5">mSource</a>.find(<font class="stringliteral">"!!"</font>); 00094 00095 <font class="keywordflow">while</font> (pos != String::npos) { 00096 String::size_type newPos = <a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn5">mSource</a>.find(<font class="stringliteral">"!!"</font>, pos + 1); 00097 00098 <a class="code" href="classOgre_1_1String.html">String</a> script = <a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn5">mSource</a>.substr(pos, newPos - pos); 00099 nvparse(script.c_str(), 0); 00100 00101 <font class="keywordflow">for</font> (<font class="keywordtype">char</font>* <font class="keyword">const</font> * errors= nvparse_get_errors(); *errors; errors++) 00102 { 00103 LogManager::getSingleton().logMessage(<font class="stringliteral">"Warning: nvparse reported the following errors:"</font>); 00104 LogManager::getSingleton().logMessage(<font class="stringliteral">"\t"</font> + <a class="code" href="classOgre_1_1String.html">String</a>(*errors)); 00105 } 00106 00107 pos = newPos; 00108 } 00109 00110 glEndList(); 00111 } 00112 </pre></div><p> Copyright © 2002-2003 by The OGRE Team<br /> Last modified Wed Jan 21 00:10:11 2004 </p> </body> </html>