Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > media > contrib > by-pkgid > 06719cf03808e17ae6f0852ca1052dc2 > files > 679

libogre1-devel-0.13.0-1mdk.i586.rpm

<html>
<head>
<title>OgreGLGpuProgram.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> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>OgreGLGpuProgram.cpp</h1><a href="OgreGLGpuProgram_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="OgreGLGpuProgram_8h.html">OgreGLGpuProgram.h</a>"</font>
00027 <font class="preprocessor">#include "<a class="code" href="OgreException_8h.html">OgreException.h</a>"</font>
00028 
00029 <font class="keyword">using</font> <font class="keyword">namespace </font>Ogre;
00030 
<a name="l00031"></a><a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuPrograma0">00031</a> GLGpuProgram::GLGpuProgram(<font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>&amp; 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>&amp; syntaxCode) :
00032     <a class="code" href="classOgre_1_1GpuProgram.html">GpuProgram</a>(name, gptype, syntaxCode)
00033 {
00034 }
00035 
<a name="l00036"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuPrograma0">00036</a> GLArbGpuProgram::GLArbGpuProgram(<font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>&amp; 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>&amp; syntaxCode) :
00037     <a class="code" href="classOgre_1_1GLGpuProgram.html">GLGpuProgram</a>(name, gptype, syntaxCode)
00038 {
00039     <a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a> = (gptype == <a class="code" href="namespaceOgre.html#a626a133">GPT_VERTEX_PROGRAM</a>) ? GL_VERTEX_PROGRAM_ARB : GL_FRAGMENT_PROGRAM_ARB;
00040     <a class="code" href="OgreGLRenderSystem_8cpp.html#a12">glGenProgramsARB_ptr</a>(1, &amp;<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn0">mProgramID</a>);
00041 }
00042 
<a name="l00043"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuPrograma3">00043</a> <font class="keywordtype">void</font> GLArbGpuProgram::bindProgram(<font class="keywordtype">void</font>)
00044 {
00045     glEnable(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>);
00046     <a class="code" href="OgreGLRenderSystem_8cpp.html#a14">glBindProgramARB_ptr</a>(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>, <a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn0">mProgramID</a>);
00047 }
00048 
<a name="l00049"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuPrograma4">00049</a> <font class="keywordtype">void</font> GLArbGpuProgram::unbindProgram(<font class="keywordtype">void</font>)
00050 {
00051     <a class="code" href="OgreGLRenderSystem_8cpp.html#a14">glBindProgramARB_ptr</a>(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>, 0);
00052     glDisable(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>);
00053 }
00054 
<a name="l00055"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuPrograma5">00055</a> <font class="keywordtype">void</font> GLArbGpuProgram::bindProgramParameters(<a class="code" href="namespaceOgre.html#a132">GpuProgramParametersSharedPtr</a> params)
00056 {
00057     GLenum type = (<a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn3">mType</a> == <a class="code" href="namespaceOgre.html#a626a133">GPT_VERTEX_PROGRAM</a>) ? 
00058         GL_VERTEX_PROGRAM_ARB : GL_FRAGMENT_PROGRAM_ARB;
00059     
00060     <font class="keywordflow">if</font> (params-&gt;hasRealConstantParams())
00061     {
00062         <font class="comment">// Iterate over params and set the relevant ones</font>
00063         GpuProgramParameters::RealConstantIterator realIt = 
00064             params-&gt;getRealConstantIterator();
00065         <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> index = 0;
00066         <font class="keywordflow">while</font> (realIt.hasMoreElements())
00067         {
00068             <a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html">GpuProgramParameters::RealConstantEntry</a>* e = realIt.peekNextPtr();
00069             <font class="keywordflow">if</font> (e-&gt;<a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html#Ogre_1_1GpuProgramParameters_1_1RealConstantEntrym1">isSet</a>)
00070             {
00071                 <a class="code" href="OgreGLRenderSystem_8cpp.html#a16">glProgramLocalParameter4fvARB_ptr</a>(type, index, e-&gt;<a class="code" href="structOgre_1_1GpuProgramParameters_1_1RealConstantEntry.html#Ogre_1_1GpuProgramParameters_1_1RealConstantEntrym0">val</a>);
00072             }
00073             index++;
00074             realIt.moveNext();
00075         }
00076     }
00077 
00078 }
00079 
<a name="l00080"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuPrograma2">00080</a> <font class="keywordtype">void</font> GLArbGpuProgram::unload(<font class="keywordtype">void</font>)
00081 {
00082     <a class="code" href="OgreGLRenderSystem_8cpp.html#a13">glDeleteProgramsARB_ptr</a>(1, &amp;<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn0">mProgramID</a>);
00083 }
00084 
<a name="l00085"></a><a class="code" href="classOgre_1_1GLArbGpuProgram.html#Ogre_1_1GLArbGpuProgramb0">00085</a> <font class="keywordtype">void</font> GLArbGpuProgram::loadFromSource(<font class="keywordtype">void</font>)
00086 {
00087     <a class="code" href="OgreGLRenderSystem_8cpp.html#a14">glBindProgramARB_ptr</a>(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>, <a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn0">mProgramID</a>);
00088     <a class="code" href="OgreGLRenderSystem_8cpp.html#a15">glProgramStringARB_ptr</a>(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>, GL_PROGRAM_FORMAT_ASCII_ARB, <a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn5">mSource</a>.length(), <a class="code" href="classOgre_1_1GpuProgram.html#Ogre_1_1HighLevelGpuProgramn5">mSource</a>.c_str());
00089     <font class="keywordflow">if</font> (GL_INVALID_OPERATION == glGetError())
00090     {
00091         <font class="keywordtype">int</font> errPos;
00092         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &amp;errPos);
00093         <font class="keywordtype">char</font> errPosStr[16];
00094         snprintf(errPosStr, 16, <font class="stringliteral">"%d"</font>, errPos);
00095         <font class="keywordtype">char</font>* errStr = (<font class="keywordtype">char</font>*)glGetString(GL_PROGRAM_ERROR_STRING_ARB);
00096         <font class="comment">// XXX New exception code?</font>
00097         <a class="code" href="OgreException_8h.html#a0">Except</a>(Exception::ERR_INTERNAL_ERROR, 
00098             <font class="stringliteral">"Cannot load GL vertex program "</font> + <a class="code" href="classOgre_1_1Resource.html#Ogre_1_1Zipn0">mName</a> + 
00099             <font class="stringliteral">".  Line "</font> + errPosStr + <font class="stringliteral">":\n"</font> + errStr, <a class="code" href="classOgre_1_1Resource.html#Ogre_1_1Zipn0">mName</a>);
00100     }
00101     <a class="code" href="OgreGLRenderSystem_8cpp.html#a14">glBindProgramARB_ptr</a>(<a class="code" href="classOgre_1_1GLGpuProgram.html#Ogre_1_1GLGpuProgramn1">mProgramType</a>, 0);
00102 }
00103 
</pre></div><p>
Copyright &copy; 2002-2003 by The OGRE Team<br />
Last modified Wed Jan 21 00:10:11 2004
</p>
</body>
</html>