Permalink
Browse files

SDLVideo: install the shaders too and look for them

build dir still has precedence, so running without installing works
  • Loading branch information...
lynxlynxlynx committed May 4, 2014
1 parent 6db0218 commit b1af817ecac875ac34b924746e7082bf0e1ff44b
Showing with 23 additions and 1 deletion.
  1. +2 −0 gemrb/plugins/SDLVideo/CMakeLists.txt
  2. +21 −1 gemrb/plugins/SDLVideo/GLSLProgram.cpp
@@ -5,6 +5,8 @@ IF(SDL2_FOUND)
IF(USE_OPENGL)
ADD_GEMRB_PLUGIN( SDLVideo ${COMMON_FILES} SDL20Video.cpp SDL20GLVideo.cpp GLSLProgram.cpp Matrix.cpp GLTextureSprite2D.cpp GLPaletteManager.cpp)
TARGET_LINK_LIBRARIES( SDLVideo ${SDL_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${COCOA_LIBRARY_PATH})
+ INSTALL(DIRECTORY Shaders DESTINATION ${DATA_DIR})
+ # also copy to the build dir for no-install runs
FILE(COPY Shaders DESTINATION ${CMAKE_BINARY_DIR})
ELSE()
ADD_GEMRB_PLUGIN( SDLVideo ${COMMON_FILES} SDL20Video.cpp)
@@ -5,6 +5,11 @@
#include <cctype>
#include <sstream>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "System/VFS.h" // for PathDelimiter
+
#include "GLSLProgram.h"
using namespace GemRB;
@@ -26,8 +31,16 @@ GLSLProgram* GLSLProgram::CreateFromFiles(std::string vertexSourceFileName, std:
{
std::string vertexContent;
std::string fragmentContent;
-
+
+ // first check the build dir then fallback to DATA_DIR
std::ifstream fileStream(vertexSourceFileName.c_str());
+#ifdef DATA_DIR
+ if (!fileStream.is_open()) {
+ vertexSourceFileName.insert(0, 1, PathDelimiter);
+ vertexSourceFileName.insert(0, DATA_DIR);
+ fileStream.open(vertexSourceFileName.c_str());
+ }
+#endif
if(!fileStream.is_open())
{
GLSLProgram::errMessage = "GLSLProgram error: Can't open file: " + vertexSourceFileName;
@@ -47,6 +60,13 @@ GLSLProgram* GLSLProgram::CreateFromFiles(std::string vertexSourceFileName, std:
fileStream.close();
std::ifstream fileStream2(fragmentSourceFileName.c_str());
+#ifdef DATA_DIR
+ if (!fileStream2.is_open()) {
+ fragmentSourceFileName.insert(0, 1, PathDelimiter);
+ fragmentSourceFileName.insert(0, DATA_DIR);
+ fileStream2.open(fragmentSourceFileName.c_str());
+ }
+#endif
if(!fileStream2.is_open())
{
GLSLProgram::errMessage = "GLSLProgram error: Can't open file: " + fragmentSourceFileName;

0 comments on commit b1af817

Please sign in to comment.