Gazebo logo

ShaderObject.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: Wrapper around openGL shader objects
00022  * Author: Nate Koenig
00023  * Date: 10 March 2005
00024  * CVS: $Id$
00025  */
00026 
00027 #ifndef SHADEROBJECT_HH
00028 #define SHADEROBJECT_HH
00029 
00030 #include <GL/gl.h>
00031 #include <GL/glext.h>
00032 
00033 #include "ShaderProgram.hh"
00034 
00035 class ShaderObject
00036 {
00037   public: ShaderObject();
00038   public: virtual ~ShaderObject();
00039 
00040   // Add a vertex or fragment shader program
00041   public: void AddShaderProgram( ShaderProgram *program );
00042 
00043   // Link all shaders
00044   public: bool Link();
00045   // Return the linker messages
00046   public: char *GetLinkerLog();
00047 
00048   // Start using this shader
00049   public: void Begin();
00050   // Stop using this shader
00051   public: void End();
00052 
00053   // Turn the shader on/off
00054   public: void EnableShader(bool b);
00055 
00056   // Returns true if OGSL is enabled
00057   public: bool OGSLEnabled();
00058 
00059   public: bool SendUniform1f(char *var, GLfloat v0);
00060   public: bool SendUniform2f(char *var, GLfloat v0, GLfloat v1);
00061   public: bool SendUniform3f(char *var, GLfloat v0, GLfloat v1, GLfloat v2);
00062   public: bool SendUniform4f(char *var, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
00063 
00064   public: bool SendUniform1i(char *var, GLint v0);
00065   public: bool SendUniform2i(char *var, GLint v0, GLint v1);
00066   public: bool SendUniform3i(char *var, GLint v0, GLint v1, GLint v2);
00067   public: bool SendUniform4i(char *var, GLint v0, GLint v1, GLint v2, GLint v3);
00068 
00069   public: bool SendUniform1fv(char *var, GLsizei count, GLfloat *value);
00070   public: bool SendUniform2fv(char *var, GLsizei count, GLfloat *value);
00071   public: bool SendUniform3fv(char *var, GLsizei count, GLfloat *value);
00072   public: bool SendUniform4fv(char *var, GLsizei count, GLfloat *value);
00073 
00074   public: bool SendUniform1fi(char *var, GLsizei count, GLint *value);
00075   public: bool SendUniform2fi(char *var, GLsizei count, GLint *value);
00076   public: bool SendUniform3fi(char *var, GLsizei count, GLint *value);
00077   public: bool SendUniform4fi(char *var, GLsizei count, GLint *value);
00078 
00079   public: bool SendUniformMatrix2fv(char *var, GLsizei count, 
00080               GLboolean transpose, GLfloat *value);
00081   public: bool SendUniformMatrix3fv(char *var, GLsizei count, 
00082               GLboolean transpose, GLfloat *value);
00083   public: bool SendUniformMatrix4fv(char *var, GLsizei count, 
00084               GLboolean transpose, GLfloat *value);
00085 
00086 
00087   public: void GetUniformfv(char *name, GLfloat *values);
00088   public: void GetUniformiv(char *name, GLint *values);
00089 
00090   public: bool IsLinked();
00091 
00092   private: GLint GetUniformLocation(const GLcharARB *name);
00093 
00094   private: GLhandleARB shaderObject;
00095   private: GLcharARB *linkerLog;
00096 
00097   private: GLint isLinked;
00098   private: bool enabled;
00099 
00100   private: int shaderProgramCount;
00101   private: int shaderProgramMaxCount;
00102   private: ShaderProgram **shaderPrograms;
00103 
00104 };
00105 
00106 #endif

Last updated 12 September 2005 21:38:45