aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/src/BuddhaTest.cpp
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2018-03-10 20:34:35 +0100
committerAndreas Grois <andi@grois.info>2018-03-10 20:34:35 +0100
commit2759a3f45b5cd095bb79eff77b35978c8f8069c6 (patch)
tree4d0ded492e5de077fdad86f52729c1f9da556d86 /BuddhaTest/src/BuddhaTest.cpp
parent5127d05dfdc877b0fc06e6ec228cfef09b98539a (diff)
Prepare install script, and make shader loading work from PREFIX/share/...
Diffstat (limited to 'BuddhaTest/src/BuddhaTest.cpp')
-rw-r--r--BuddhaTest/src/BuddhaTest.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/BuddhaTest/src/BuddhaTest.cpp b/BuddhaTest/src/BuddhaTest.cpp
index 38bd0b5..c29a220 100644
--- a/BuddhaTest/src/BuddhaTest.cpp
+++ b/BuddhaTest/src/BuddhaTest.cpp
@@ -54,6 +54,33 @@ int main(int argc, char * argv[])
return 1;
}
+ // Create and compile our GLSL program from the shaders
+ std::string vertexPath("Shaders/BuddhaVertex.glsl");
+ std::string fragmentPath("Shaders/BuddhaFragment.glsl");
+ std::string computePath("Shaders/BuddhaCompute.glsl");
+
+ if(!Helpers::DoesFileExist(vertexPath))
+ {
+#if defined _WIN32 || defined __CYGWIN__
+ std::string separator("\\");
+#else
+ std::string separator("/");
+#endif
+ vertexPath = INSTALL_PREFIX + separator + "share" + separator + "BuddhaShader" + separator + vertexPath;
+ fragmentPath = INSTALL_PREFIX + separator + "share" + separator + "BuddhaShader" + separator + fragmentPath;
+ computePath = INSTALL_PREFIX + separator + "share" + separator + "BuddhaShader" + separator + computePath;
+ }
+
+ GLuint VertexAndFragmentShaders = Helpers::LoadShaders(vertexPath, fragmentPath);
+ //Do the same for the compute shader:
+ GLuint ComputeShader = Helpers::LoadComputeShader(computePath, settings.localWorkgroupSizeX, settings.localWorkgroupSizeY, settings.localWorkgroupSizeZ);
+ if(VertexAndFragmentShaders == 0 || ComputeShader == 0)
+ {
+ std::cout << "Something went wrong with loading the shaders. Abort." << std::endl;
+ glfwTerminate();
+ return 1;
+ }
+
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
@@ -81,11 +108,6 @@ int main(int argc, char * argv[])
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, drawBuffer);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
- // Create and compile our GLSL program from the shaders
- GLuint VertexAndFragmentShaders = Helpers::LoadShaders("Shaders/BuddhaVertex.glsl", "Shaders/BuddhaFragment.glsl");
- //Do the same for the compute shader:
- GLuint ComputeShader = Helpers::LoadComputeShader("Shaders/BuddhaCompute.glsl", settings.localWorkgroupSizeX, settings.localWorkgroupSizeY, settings.localWorkgroupSizeZ);
-
uint32_t iterationCount{0};
glUseProgram(ComputeShader);
GLint iterationCountUniformHandle = glGetUniformLocation(ComputeShader, "iterationCount");