Add GL test helper to make compute program

This commit is contained in:
baldurk
2019-12-18 19:07:59 +00:00
parent 7f6308b065
commit c22a5f3622
2 changed files with 55 additions and 2 deletions
+53 -1
View File
@@ -193,6 +193,58 @@ GLuint OpenGLGraphicsTest::MakeProgram(std::string vertSrc, std::string fragSrc,
return program;
}
GLuint OpenGLGraphicsTest::MakeProgram(std::string compSrc)
{
GLuint cs = glCreateShader(GL_COMPUTE_SHADER);
const char *cstr = NULL;
if(cs)
{
cstr = compSrc.c_str();
glShaderSource(cs, 1, &cstr, NULL);
glCompileShader(cs);
}
char buffer[1024];
GLint status = 0;
if(cs)
glGetShaderiv(cs, GL_COMPILE_STATUS, &status);
else
status = 1;
if(status == 0)
{
glGetShaderInfoLog(cs, 1024, NULL, buffer);
TEST_ERROR("Shader error: %s", buffer);
glDeleteShader(cs);
return 0;
}
GLuint program = glCreateProgram();
glAttachShader(program, cs);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &status);
if(status == 0)
{
glGetProgramInfoLog(program, 1024, NULL, buffer);
TEST_ERROR("Link error: %s", buffer);
glDeleteProgram(program);
program = 0;
}
glDetachShader(program, cs);
glDeleteShader(cs);
if(program)
managedResources.progs.push_back(program);
return program;
}
GLuint OpenGLGraphicsTest::MakeProgram()
{
GLuint program = glCreateProgram();
@@ -270,4 +322,4 @@ bool OpenGLGraphicsTest::Running()
return false;
return mainWindow->Update();
}
}
+2 -1
View File
@@ -45,6 +45,7 @@ struct OpenGLGraphicsTest : public GraphicsTest
void PostInit();
GLuint MakeProgram(std::string vertSrc, std::string fragSrc, std::string geomSrc = "");
GLuint MakeProgram(std::string compSrc);
GLuint MakeProgram();
GLuint MakePipeline();
GLuint MakeBuffer();
@@ -72,4 +73,4 @@ struct OpenGLGraphicsTest : public GraphicsTest
{
std::vector<GLuint> bufs, texs, progs, pipes, vaos, fbos;
} managedResources;
};
};