ProgramObject.hpp
Default mainpageApplicationProgramObject.hpp
Description Overview Included files Included by Source
/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef _PROGRAM_OBJECT_HPP_
#define _PROGRAM_OBJECT_HPP_

#include <GL/glew.h>
#include "ShaderObject.hpp"

#include <cassert>
using namespace std;

class ProgramObject
{
    public:
        ProgramObject();
        virtual ~ProgramObject();

        void addShader(ShaderObject* shader);
        void removeShader(ShaderObject* shader);

        void link();

        void begin();
        void end();

        void setUniform1f(const char* varname, GLfloat v0);
        void setUniform2f(const char* varname, GLfloat v0, GLfloat v1);
        void setUniform3f(const char* varname, GLfloat v0, GLfloat v1, GLfloat v2);
        void setUniform4f(const char* varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);  

        void setUniform1i(const char* varname, GLint v0);
        void setUniform2i(const char* varname, GLint v0, GLint v1);
        void setUniform3i(const char* varname, GLint v0, GLint v1, GLint v2);
        void setUniform4i(const char* varname, GLint v0, GLint v1, GLint v2, GLint v3);

        void setUniform1fv(const char* varname, GLsizei count, GLfloat *value);
        void setUniform2fv(const char* varname, GLsizei count, GLfloat *value);
        void setUniform3fv(const char* varname, GLsizei count, GLfloat *value);
        void setUniform4fv(const char* varname, GLsizei count, GLfloat *value);
        void setUniform1iv(const char* varname, GLsizei count, GLint *value);
        void setUniform2iv(const char* varname, GLsizei count, GLint *value);
        void setUniform3iv(const char* varname, GLsizei count, GLint *value);
        void setUniform4iv(const char* varname, GLsizei count, GLint *value);

        void setUniformMatrix2fv(const char* varname, GLsizei count, GLboolean transpose, GLfloat *value);
        void setUniformMatrix3fv(const char* varname, GLsizei count, GLboolean transpose, GLfloat *value);
        void setUniformMatrix4fv(const char* varname, GLsizei count, GLboolean transpose, GLfloat *value);

        void setVertexAttrib1f(GLuint index, GLfloat v0);
        void setVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1);
        void setVertexAttrib3f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2);
        void setVertexAttrib4f(GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);

    private:
        GLhandleARB program;
    
        GLint getUniformLocation(const char* name);
} ;

#endif