michael@0: // michael@0: // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // Program.h: Defines the gl::Program class. Implements GL program objects michael@0: // and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28. michael@0: michael@0: #ifndef LIBGLESV2_PROGRAM_H_ michael@0: #define LIBGLESV2_PROGRAM_H_ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "common/angleutils.h" michael@0: #include "common/RefCountObject.h" michael@0: #include "libGLESv2/Constants.h" michael@0: michael@0: namespace rx michael@0: { michael@0: class Renderer; michael@0: } michael@0: michael@0: namespace gl michael@0: { michael@0: class ResourceManager; michael@0: class FragmentShader; michael@0: class VertexShader; michael@0: class ProgramBinary; michael@0: class Shader; michael@0: michael@0: extern const char * const g_fakepath; michael@0: michael@0: class AttributeBindings michael@0: { michael@0: public: michael@0: AttributeBindings(); michael@0: ~AttributeBindings(); michael@0: michael@0: void bindAttributeLocation(GLuint index, const char *name); michael@0: int getAttributeBinding(const std::string &name) const; michael@0: michael@0: private: michael@0: std::set mAttributeBinding[MAX_VERTEX_ATTRIBS]; michael@0: }; michael@0: michael@0: class InfoLog michael@0: { michael@0: public: michael@0: InfoLog(); michael@0: ~InfoLog(); michael@0: michael@0: int getLength() const; michael@0: void getLog(GLsizei bufSize, GLsizei *length, char *infoLog); michael@0: michael@0: void appendSanitized(const char *message); michael@0: void append(const char *info, ...); michael@0: void reset(); michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(InfoLog); michael@0: char *mInfoLog; michael@0: }; michael@0: michael@0: class Program michael@0: { michael@0: public: michael@0: Program(rx::Renderer *renderer, ResourceManager *manager, GLuint handle); michael@0: michael@0: ~Program(); michael@0: michael@0: bool attachShader(Shader *shader); michael@0: bool detachShader(Shader *shader); michael@0: int getAttachedShadersCount() const; michael@0: michael@0: void bindAttributeLocation(GLuint index, const char *name); michael@0: michael@0: bool link(); michael@0: bool isLinked(); michael@0: bool setProgramBinary(const void *binary, GLsizei length); michael@0: ProgramBinary *getProgramBinary(); michael@0: michael@0: int getInfoLogLength() const; michael@0: void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog); michael@0: void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders); michael@0: michael@0: void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); michael@0: GLint getActiveAttributeCount(); michael@0: GLint getActiveAttributeMaxLength(); michael@0: michael@0: void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); michael@0: GLint getActiveUniformCount(); michael@0: GLint getActiveUniformMaxLength(); michael@0: michael@0: void addRef(); michael@0: void release(); michael@0: unsigned int getRefCount() const; michael@0: void flagForDeletion(); michael@0: bool isFlaggedForDeletion() const; michael@0: michael@0: void validate(); michael@0: bool isValidated() const; michael@0: michael@0: GLint getProgramBinaryLength() const; michael@0: michael@0: private: michael@0: DISALLOW_COPY_AND_ASSIGN(Program); michael@0: michael@0: void unlink(bool destroy = false); michael@0: michael@0: FragmentShader *mFragmentShader; michael@0: VertexShader *mVertexShader; michael@0: michael@0: AttributeBindings mAttributeBindings; michael@0: michael@0: BindingPointer mProgramBinary; michael@0: bool mLinked; michael@0: bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use michael@0: michael@0: unsigned int mRefCount; michael@0: michael@0: ResourceManager *mResourceManager; michael@0: rx::Renderer *mRenderer; michael@0: const GLuint mHandle; michael@0: michael@0: InfoLog mInfoLog; michael@0: }; michael@0: } michael@0: michael@0: #endif // LIBGLESV2_PROGRAM_H_