12#ifndef CSCI441_COMPUTE_SHADER_PROGRAM_HPP
13#define CSCI441_COMPUTE_SHADER_PROGRAM_HPP
65 [[maybe_unused]]
void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) const;
86 glGetIntegerv(GL_MAJOR_VERSION, &major);
87 glGetIntegerv(GL_MINOR_VERSION, &minor);
89 if(major < 4 || (major == 4 && minor < 3)) {
90 fprintf(stderr,
"[ERROR]: Compute Shaders only supported in OpenGL 4.3+\n");
94 if(
sDEBUG ) printf(
"\n[INFO]: /--------------------------------------------------------\\\n");
97 if( strcmp( computeShaderFilename,
"" ) != 0 ) {
98 if(
sDEBUG ) printf(
"[INFO]: | Compute Shader: %38s |\n", computeShaderFilename );
99 mComputeShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(computeShaderFilename, GL_COMPUTE_SHADER );
115 if(
sDEBUG ) printf(
"[INFO]: | Shader Program: %41s",
"|\n" );
130 GLint max_uniform_name_size;
132 if( numUniforms > 0 ) {
133 for(GLuint i = 0; i < numUniforms; i++) {
134 char* name = (
char*) malloc(max_uniform_name_size *
sizeof(
char));
135 int actual_length = 0;
138 glGetActiveUniform(
mShaderProgramHandle, i, max_uniform_name_size, &actual_length, &size, &type, name );
141 for(
int j = 0; j < size; j++) {
142 int max_array_size = actual_length + 4 + 2 + 1;
143 char* array_name = (
char*) malloc(max_array_size *
sizeof(
char));
144 snprintf(array_name, max_array_size,
"%s[%i]", name, j);
160 if(linkStatus == 1) {
162 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(
mShaderProgramHandle,
false,
false,
false,
false,
false,
169 glDispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
174 GLbitfield shaderBits = 0;
Class to work with OpenGL 4.0+ Shaders.
Handles registration and compilation of Compute Shaders.
Definition: ComputeShaderProgram.hpp:24
ComputeShaderProgram & operator=(const ComputeShaderProgram &)=delete
do not allow shader programs to be copied
GLuint mComputeShaderHandle
compute shader handle
Definition: ComputeShaderProgram.hpp:77
ComputeShaderProgram(ComputeShaderProgram &&) noexcept=default
construct a new compute shader program by moving an existing computer shader program
void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) const
dispatches work to the Compute Shader on the GPU
Definition: ComputeShaderProgram.hpp:168
ComputeShaderProgram(const ComputeShaderProgram &)=delete
do not allow shader programs to be copied
GLbitfield getProgramStages() const override
returns a single value corresponding to which shader stages are present in this shader program
Definition: ComputeShaderProgram.hpp:173
~ComputeShaderProgram() override=default
Clean up memory associated with the Compute Shader Program.
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:36
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:896
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:901
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:870
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17