NVidia Gameworks
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

NvGLSLProgram.h

Go to the documentation of this file.
00001 // TAGRELEASE: PUBLIC
00002 
00003 #ifndef NV_GLSL_PROGRAM_H
00004 #define NV_GLSL_PROGRAM_H
00005 
00006 #include <NvFoundation.h>
00007 #include "NV/NvPlatformGL.h"
00008 
00011 
00017 class NvGLSLProgram
00018 {
00019 public:
00023     struct ShaderSourceItem {
00024         const char* src; 
00025         GLint type; 
00026     };
00027 
00032     NvGLSLProgram();
00033     ~NvGLSLProgram();
00034 
00042     static NvGLSLProgram* createFromFiles(const char* vertFilename, const char* fragFilename, bool strict = false);
00043 
00051     static NvGLSLProgram* createFromStrings(const char* vertSrc, const char* fragSrc, bool strict = false);
00052 
00060     bool setSourceFromFiles(const char* vertFilename, const char* fragFilename, bool strict = false);
00061 
00068     bool setSourceFromStrings(const char* vertSrc, const char* fragSrc, bool strict = false);
00069 
00078     bool setSourceFromStrings(ShaderSourceItem* src, int32_t count, bool strict = false);
00079 
00081         void enable();
00082 
00084         void disable();
00085 
00092         void bindTexture2D(const char *name, int32_t unit, GLuint tex);
00093 
00100         void bindTexture2D(GLint index, int32_t unit, GLuint tex);
00101 
00108     void bindTextureArray(const char *name, int32_t unit, GLuint tex);
00109 
00116         void bindTextureArray(GLint index, int32_t unit, GLuint tex);
00117 
00119 
00120 
00121 
00122 
00123     void setUniform1i(const char *name, int32_t value);
00124         void setUniform1f(const char *name, float value);
00126 
00128 
00129 
00130 
00131 
00132 
00133         void setUniform2i(const char *name, int32_t x, int32_t y);
00134     void setUniform2f(const char *name, float x, float y);
00136 
00138 
00139 
00140 
00141 
00142 
00143 
00144         void setUniform3i(const char *name, int32_t x, int32_t y, int32_t z);
00145     void setUniform3f(const char *name, float x, float y, float z);
00147 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156     void setUniform4f(const char *name, float x, float y, float z, float w);
00158 
00160 
00161 
00162 
00163 
00164     void setUniform3fv(const char *name, const float *value, int32_t count=1);
00165     void setUniform4fv(const char *name, const float *value, int32_t count=1);
00167 
00173     void setUniform1i(GLint index, int32_t value);
00174         void setUniform1f(GLint index, float value);
00176 
00183         void setUniform2i(GLint index, int32_t x, int32_t y);
00184         void setUniform2f(GLint index, float x, float y);
00186 
00194         void setUniform3i(GLint index, int32_t x, int32_t y, int32_t z);
00195     void setUniform3f(GLint index, float x, float y, float z);
00197 
00206     void setUniform4f(GLint index, float x, float y, float z, float w);
00208 
00210 
00211 
00212 
00213 
00214 
00215     void setUniform3fv(GLint index, const float *value, int32_t count=1);
00216     void setUniform4fv(GLint index, const float *value, int32_t count=1);
00218 
00225     void setUniformMatrix4fv(const GLchar *name, GLfloat *m, int32_t count=1, bool transpose=false);
00226 
00233     void setUniformMatrix4fv(GLint index, GLfloat *m, int32_t count=1, bool transpose=false);
00234 
00239         GLint getAttribLocation(const char* attribute, bool isOptional = false);
00240 
00245         GLint getUniformLocation(const char* uniform, bool isOptional = false);
00246 
00249     GLuint getProgram() { return m_program; }
00250 
00252     bool relink();
00253 
00257     static void setLogAllMissing(bool logMissing) { ms_logAllMissing = logMissing; }
00258 
00259 protected:
00260         bool checkCompileError(GLuint object, int32_t target);
00261         GLuint compileProgram(const char *vsource, const char *fsource);
00262     GLuint compileProgram(ShaderSourceItem* src, int32_t count);
00263 
00264         bool m_strict;
00265         GLuint m_program;
00266 
00267     static bool ms_logAllMissing;
00268 };
00269 
00270 #endif // NV_GLSL_PROGRAM_H
Generated on Sat Mar 8 14:58:35 2014 for NVIDIA GameWorks OpenGL App Framework and Libraries by Doxygen
©2014 NVIDIA Corporation.