Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

GLShader Class Reference

#include <glshader.h>

Inheritance diagram for GLShader:

Inheritance graph
List of all members.

Public Member Functions

int getID () const

Protected Member Functions

 GLShader (int _id)
virtual ~GLShader ()

Private Member Functions

GLShaderStatus compile (const std::vector< std::string > &source)

Private Attributes

int id

Friends

class GLShaderLoader

Constructor & Destructor Documentation

GLShader::GLShader int  _id  )  [protected]
 

Definition at line 24 of file glshader.cpp.

00024                           :
00025     id(_id)
00026 {
00027 }

GLShader::~GLShader  )  [protected, virtual]
 

Definition at line 65 of file glshader.cpp.

References glx::glDeleteObjectARB.

00066 {
00067     glx::glDeleteObjectARB(id);
00068 }


Member Function Documentation

GLShaderStatus GLShader::compile const std::vector< std::string > &  source  )  [private]
 

Definition at line 38 of file glshader.cpp.

References GL_OBJECT_COMPILE_STATUS_ARB, glx::glCompileShaderARB, glx::glGetObjectParameterivARB, glx::glShaderSourceARB, ShaderStatus_CompileError, ShaderStatus_EmptyProgram, and ShaderStatus_OK.

00039 {
00040     if (source.empty())
00041         return ShaderStatus_EmptyProgram;
00042     
00043     // Convert vector of shader source strings to an array for OpenGL
00044     const char** sourceStrings = new const char*[source.size()];
00045     for (unsigned int i = 0; i < source.size(); i++)
00046         sourceStrings[i] = source[i].c_str();
00047 
00048     // Copy shader source to OpenGL
00049     glx::glShaderSourceARB(id, source.size(), sourceStrings, NULL);
00050     delete[] sourceStrings;
00051 
00052     // Actually compile the shader
00053     glx::glCompileShaderARB(id);
00054     
00055     GLint compileSuccess;
00056     glx::glGetObjectParameterivARB(id, GL_OBJECT_COMPILE_STATUS_ARB,
00057                                    &compileSuccess);
00058     if (compileSuccess == GL_FALSE)
00059         return ShaderStatus_CompileError;
00060 
00061     return ShaderStatus_OK;
00062 }

int GLShader::getID  )  const
 

Definition at line 31 of file glshader.cpp.

References id.

Referenced by GLShaderLoader::CreateFragmentShader(), and GLShaderLoader::CreateVertexShader().

00032 {
00033     return id;
00034 }


Friends And Related Function Documentation

friend class GLShaderLoader [friend]
 

Reimplemented in GLVertexShader, and GLFragmentShader.

Definition at line 43 of file glshader.h.


Member Data Documentation

int GLShader::id [private]
 

Definition at line 39 of file glshader.h.

Referenced by getID().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:21 2006 for Celestia by  doxygen 1.4.1