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);
73 glGetIntegerv(GL_MAJOR_VERSION, &major);
74 glGetIntegerv(GL_MINOR_VERSION, &minor);
76 if(major < 4 || (major == 4 && minor < 3)) {
77 fprintf(stderr,
"[ERROR]: Compute Shaders only supported in OpenGL 4.3+\n");
81 if(
sDEBUG ) printf(
"\n[INFO]: /--------------------------------------------------------\\\n");
84 GLuint computeShaderHandle;
87 if( strcmp( computeShaderFilename,
"" ) != 0 ) {
88 if(
sDEBUG ) printf(
"[INFO]: | Compute Shader: %38s |\n", computeShaderFilename );
89 computeShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(computeShaderFilename, GL_COMPUTE_SHADER );
91 computeShaderHandle = 0;
98 if(computeShaderHandle != 0 ) {
105 if(
sDEBUG ) printf(
"[INFO]: | Shader Program: %41s",
"|\n" );
111 if(computeShaderHandle != 0 ) {
113 glDeleteShader(computeShaderHandle );
120 GLint max_uniform_name_size;
122 if( numUniforms > 0 ) {
123 for(GLuint i = 0; i < numUniforms; i++) {
124 char* name = (
char*) malloc(max_uniform_name_size *
sizeof(
char));
125 int actual_length = 0;
128 glGetActiveUniform(
mShaderProgramHandle, i, max_uniform_name_size, &actual_length, &size, &type, name );
131 for(
int j = 0; j < size; j++) {
132 int max_array_size = actual_length + 4 + 2 + 1;
133 char* array_name = (
char*) malloc(max_array_size *
sizeof(
char));
134 snprintf(array_name, max_array_size,
"%s[%i]", name, j);
150 if(linkStatus == 1) {
152 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(
mShaderProgramHandle,
false,
false,
false,
false,
false,
153 computeShaderHandle != 0,
true);
159 glDispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
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
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)
dispatches work to the Compute Shader on the GPU
Definition: ComputeShaderProgram.hpp:158
ComputeShaderProgram(const ComputeShaderProgram &)=delete
do not allow shader programs to be copied
~ComputeShaderProgram() override=default
Clean up memory associated with the Compute Shader Program.
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:35
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:875
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:880
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:849
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17