5 #include <unordered_map> 14 #include <globjects/globjects_api.h> 25 class AbstractUniform;
81 friend class ProgramBinaryImplementation_GetProgramBinaryARB;
82 friend class ProgramBinaryImplementation_None;
100 static void release();
103 bool isLinked()
const;
105 void attach(
Shader * shader);
106 template <
class ...Shaders>
107 void attach(
Shader * shader, Shaders... shaders);
109 void detach(
Shader * shader);
111 std::set<Shader*> shaders()
const;
114 void invalidate()
const;
119 std::string infoLog()
const;
120 gl::GLint
get(gl::GLenum pname)
const;
122 bool isValid()
const;
125 void setParameter(gl::GLenum pname, gl::GLint value)
const;
126 void setParameter(gl::GLenum pname, gl::GLboolean value)
const;
128 void getActiveAttrib(gl::GLuint index, gl::GLsizei bufSize, gl::GLsizei * length, gl::GLint * size, gl::GLenum * type, gl::GLchar * name)
const;
130 gl::GLint getAttributeLocation(
const std::string & name)
const;
131 gl::GLint getUniformLocation(
const std::string & name)
const;
133 std::vector<gl::GLint> getAttributeLocations(
const std::vector<std::string> & names)
const;
134 std::vector<gl::GLint> getUniformLocations(
const std::vector<std::string> & names)
const;
136 void bindAttributeLocation(gl::GLuint index,
const std::string & name)
const;
137 void bindFragDataLocation(gl::GLuint index,
const std::string & name)
const;
139 gl::GLint getFragDataLocation(
const std::string & name)
const;
140 gl::GLint getFragDataIndex(
const std::string & name)
const;
142 void getInterface(gl::GLenum programInterface, gl::GLenum pname, gl::GLint * params)
const;
143 gl::GLuint getResourceIndex(gl::GLenum programInterface,
const std::string & name)
const;
144 void getResourceName(gl::GLenum programInterface, gl::GLuint index, gl::GLsizei bufSize, gl::GLsizei * length,
char * name)
const;
145 void getResource(gl::GLenum programInterface, gl::GLuint index, gl::GLsizei propCount,
const gl::GLenum * props, gl::GLsizei bufSize, gl::GLsizei * length, gl::GLint * params)
const;
146 gl::GLint getResourceLocation(gl::GLenum programInterface,
const std::string & name)
const;
147 gl::GLint getResourceLocationIndex(gl::GLenum programInterface,
const std::string & name)
const;
151 gl::GLint getInterface(gl::GLenum programInterface, gl::GLenum pname)
const;
156 gl::GLint getResource(gl::GLenum programInterface, gl::GLuint index, gl::GLenum prop, gl::GLsizei * length =
nullptr)
const;
157 std::vector<gl::GLint> getResource(gl::GLenum programInterface, gl::GLuint index,
const std::vector<gl::GLenum> & props, gl::GLsizei * length =
nullptr)
const;
158 void getResource(gl::GLenum programInterface, gl::GLuint index,
const std::vector<gl::GLenum> & props, gl::GLsizei bufSize, gl::GLsizei * length, gl::GLint * params)
const;
160 gl::GLuint getUniformBlockIndex(
const std::string& name)
const;
161 UniformBlock * uniformBlock(gl::GLuint uniformBlockIndex);
162 const UniformBlock * uniformBlock(gl::GLuint uniformBlockIndex)
const;
164 const UniformBlock * uniformBlock(
const std::string& name)
const;
165 void getActiveUniforms(gl::GLsizei uniformCount,
const gl::GLuint * uniformIndices, gl::GLenum pname, gl::GLint * params)
const;
166 std::vector<gl::GLint> getActiveUniforms(
const std::vector<gl::GLuint> & uniformIndices, gl::GLenum pname)
const;
167 std::vector<gl::GLint> getActiveUniforms(
const std::vector<gl::GLint> & uniformIndices, gl::GLenum pname)
const;
168 gl::GLint getActiveUniform(gl::GLuint uniformIndex, gl::GLenum pname)
const;
169 std::string getActiveUniformName(gl::GLuint uniformIndex)
const;
172 void setUniform(
const std::string & name,
const T & value);
174 void setUniform(gl::GLint location,
const T & value);
179 Uniform<T> * getUniform(
const std::string & name);
181 const Uniform<T> * getUniform(
const std::string & name)
const;
185 const Uniform<T> * getUniform(gl::GLint location)
const;
194 void setShaderStorageBlockBinding(gl::GLuint storageBlockIndex, gl::GLuint storageBlockBinding)
const;
196 void dispatchCompute(gl::GLuint numGroupsX, gl::GLuint numGroupsY, gl::GLuint numGroupsZ);
197 void dispatchCompute(
const glm::uvec3 & numGroups);
198 void dispatchComputeGroupSize(gl::GLuint numGroupsX, gl::GLuint numGroupsY, gl::GLuint numGroupsZ, gl::GLuint groupSizeX, gl::GLuint groupSizeY, gl::GLuint groupSizeZ);
199 void dispatchComputeGroupSize(
const glm::uvec3 & numGroups,
const glm::uvec3 & groupSizes);
201 virtual gl::GLenum objectType()
const override;
206 bool checkLinkStatus()
const;
207 void checkDirty()
const;
209 bool compileAttachedShaders()
const;
210 void updateUniforms()
const;
211 void updateUniformBlockBindings()
const;
215 virtual void notifyChanged(
const Changeable * sender)
override;
218 static gl::GLuint createProgram();
221 void setUniformByIdentity(
const LocationIdentity & identity,
const T & value);
234 std::unordered_map<LocationIdentity, ref_ptr<AbstractUniform>>
m_uniforms;
245 #include <globjects/Program.inl>
The ref_ptr class provides the interface for a reference pointer.
Definition: LogMessageBuilder.h:20
Contains all the classes that wrap OpenGL functionality.
Superclass of all wrapped OpenGL objects.
Definition: Object.h:26
Wraps an OpenGL program.
Definition: Program.h:78
bool m_linked
Definition: Program.h:237
BinaryImplementation
Definition: Program.h:85
std::set< ref_ptr< Shader > > m_shaders
Definition: Program.h:231
Superclass of all objects that want others to signal that they have changed.
Definition: Changeable.h:22
Implements a Visitor Pattern to iterate over all tracked globjects objects.
Definition: ObjectVisitor.h:29
std::unordered_map< LocationIdentity, UniformBlock > m_uniformBlocks
Definition: Program.h:235
The ProgramBinary class is used for directly setting binary sources for a Program.
Definition: ProgramBinary.h:27
bool m_dirty
Definition: Program.h:238
Allows listening to any Changeable.
Definition: ChangeListener.h:22
std::unordered_map< LocationIdentity, ref_ptr< AbstractUniform > > m_uniforms
Definition: Program.h:234
Encapsulates OpenGL shaders.
Definition: Shader.h:40
Definition: LocationIdentity.h:16
ref_ptr< ProgramBinary > m_binary
Definition: Program.h:232