diff --git a/Makefile.am b/Makefile.am index 97a1b46..e92b0d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,11 +5,22 @@ ACLOCAL_AMFLAGS = -I m4 --install bin_PROGRAMS = Game +dist_pkgdata_DATA = \ + data/shaders/vertex.glsl \ + data/shaders/fragment.glsl \ + data/container.jpg + Game_SOURCES = \ src/main.cpp \ src/Error.h \ src/Error.cpp \ src/ShaderLoader.h \ src/ShaderLoader.cpp + + Game_CPPFLAGS = @sdl2_CFLAGS@ @glew_CFLAGS@ @opengl_CFLAGS@ @glm_CFLAGS@ @sdl2_image_CFLAGS@ + Game_LDFLAGS = @sdl2_LIBS@ @glew_LIBS@ @opengl_LIBS@ @glm_LIBS@ @sdl2_image_LIBS@ + +#AM_CPPFLAGS = -DDATADIR=\"$(pkgdatadir)\" +Game_CPPFLAGS += -DDATADIR=\"$(pkgdatadir)\" diff --git a/configure.ac b/configure.ac index ba25521..fbd535c 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,11 @@ AC_PREREQ([2.69]) AC_INIT([Game], [0.0.1], [wytau@sdf.org]) AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADERS([config.h]) + +# This is actually defined in Makefile.am +# But this stops intellisense like software from complaining +AC_DEFINE_UNQUOTED([DATAPATH], ["$pkgdatadir"],"DData Directory Path") + AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/src/container.jpg b/data/container.jpg similarity index 100% rename from src/container.jpg rename to data/container.jpg diff --git a/src/fragment.glsl b/data/shaders/fragment.glsl similarity index 100% rename from src/fragment.glsl rename to data/shaders/fragment.glsl diff --git a/src/vertex.glsl b/data/shaders/vertex.glsl similarity index 100% rename from src/vertex.glsl rename to data/shaders/vertex.glsl diff --git a/src/main.cpp b/src/main.cpp index b612c7e..c65a7df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,7 +66,7 @@ int main(int argc, char **argv) { // Create event handling struct SDL_Event input; - ShaderLoader shader("src/vertex.glsl", "src/fragment.glsl"); + ShaderLoader shader(DATADIR "/vertex.glsl", DATADIR "/fragment.glsl"); float vertices[] = { // positions // texture Co-ords @@ -121,7 +121,7 @@ int main(int argc, char **argv) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Load texture image - SDL_Surface *image = IMG_Load("src/container.jpg"); + SDL_Surface *image = IMG_Load(DATADIR "/container.jpg"); if (image == nullptr) { error.crash("SDL2_image was unable to load a texture", IMG_GetError()); } @@ -142,8 +142,6 @@ int main(int argc, char **argv) { GL_UNSIGNED_BYTE, image->pixels); glGenerateMipmap(GL_TEXTURE_2D); - error.log(std::to_string(image->h)); - // remove image surface now it's no longer needed to create texture SDL_FreeSurface(image); image = nullptr;