12#ifndef CSCI441_COMPUTE_SHADER_PROGRAM_HPP
13#define CSCI441_COMPUTE_SHADER_PROGRAM_HPP
15#include "LogUtils.hpp"
66 [[maybe_unused]]
void dispatchWork(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ) const;
87 glGetIntegerv(GL_MAJOR_VERSION, &major);
88 glGetIntegerv(GL_MINOR_VERSION, &minor);
90 if(major < 4 || (major == 4 && minor < 3)) {
98 if( strcmp( computeShaderFilename,
"" ) != 0 ) {
100 mComputeShaderHandle = CSCI441_INTERNAL::ShaderUtils::compileShader(computeShaderFilename, GL_COMPUTE_SHADER );
131 GLint max_uniform_name_size;
133 if( numUniforms > 0 ) {
134 for(GLuint i = 0; i < numUniforms; i++) {
135 char* name = (
char*) malloc(max_uniform_name_size *
sizeof(
char));
136 int actual_length = 0;
139 glGetActiveUniform(
mShaderProgramHandle, i, max_uniform_name_size, &actual_length, &size, &type, name );
142 for(
int j = 0; j < size; j++) {
143 int max_array_size = actual_length + 4 + 2 + 1;
144 char* array_name = (
char*) malloc(max_array_size *
sizeof(
char));
145 snprintf(array_name, max_array_size,
"%s[%i]", name, j);
161 if(linkStatus == 1) {
163 CSCI441_INTERNAL::ShaderUtils::printShaderProgramInfo(
mShaderProgramHandle,
false,
false,
false,
false,
false,
170 glDispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
175 GLbitfield shaderBits = 0;
Class to work with OpenGL 4.0+ Shaders.
Handles registration and compilation of Compute Shaders.
Definition: ComputeShaderProgram.hpp:25
ComputeShaderProgram & operator=(const ComputeShaderProgram &)=delete
do not allow shader programs to be copied
GLuint mComputeShaderHandle
compute shader handle
Definition: ComputeShaderProgram.hpp:78
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:169
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:174
~ComputeShaderProgram() override=default
Clean up memory associated with the Compute Shader Program.
Handles registration and compilation of Shaders.
Definition: ShaderProgram.hpp:37
GLuint mShaderProgramHandle
handle to the shader program
Definition: ShaderProgram.hpp:897
std::map< std::string, GLint > * mpUniformLocationsMap
caches locations of uniform names within shader program
Definition: ShaderProgram.hpp:902
static bool sDEBUG
if DEBUG information should be printed or not
Definition: ShaderProgram.hpp:871
void log(const char *MSG,...)
log a message to both the standard output stream and file
Definition: LogUtils.hpp:116
void logError(const char *MSG,...)
log a message to both the standard error stream and file
Definition: LogUtils.hpp:128
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17