From 2759a3f45b5cd095bb79eff77b35978c8f8069c6 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sat, 10 Mar 2018 20:34:35 +0100 Subject: Prepare install script, and make shader loading work from PREFIX/share/... --- BuddhaTest/src/BuddhaTest.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'BuddhaTest/src/BuddhaTest.cpp') 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"); -- cgit v1.2.3