12#ifndef CSCI441_COMPUTE_SHADER_PROGRAM_HPP
13#define CSCI441_COMPUTE_SHADER_PROGRAM_HPP
53 [[maybe_unused]] virtual
void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) final;
61 glGetIntegerv(GL_MAJOR_VERSION, &major);
62 glGetIntegerv(GL_MINOR_VERSION, &minor);
64 if(major < 4 || (major == 4 && minor < 3)) {
65 fprintf(stderr,
"[ERROR]: Compute Shaders only supported in OpenGL 4.3+\n");
69 if(
sDEBUG ) printf(
"\n[INFO]: /--------------------------------------------------------\\\n");
72 GLuint computeShaderHandle;
75 if( strcmp( computeShaderFilename,
"" ) != 0 ) {
76 if(
sDEBUG ) printf(
"[INFO]: | Compute Shader: %38s |\n", computeShaderFilename );
77 computeShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(computeShaderFilename, GL_COMPUTE_SHADER );
79 computeShaderHandle = 0;
86 if(computeShaderHandle != 0 ) {
93 if(
sDEBUG ) printf(
"[INFO]: | Shader Program: %41s",
"|\n" );
99 if(computeShaderHandle != 0 ) {
101 glDeleteShader(computeShaderHandle );
108 if( numUniforms > 0 ) {
109 for(GLuint i = 0; i < numUniforms; i++) {
112 int actual_length = 0;
118 for(
int j = 0; j < size; j++) {
120 sprintf(long_name,
"%s[%i]", name, j);
133 if(linkStatus == 1) {
135 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(
mShaderProgramHandle,
false,
false,
false,
false,
false,
136 computeShaderHandle != 0,
true);
142 glDispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
Class to work with OpenGL 4.0+ Shaders.
Handles registration and compilation of Compute Shaders.
Definition: ComputeShaderProgram.hpp:24
virtual void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) final
dispatches work to the Compute Shader on the GPU
Definition: ComputeShaderProgram.hpp:141
~ComputeShaderProgram() final=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:845
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:850
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:819
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17