The data files are now installed with the game

This commit is contained in:
Warwick 2021-05-19 17:45:36 +01:00
parent 59e32663a1
commit 928efe501c
6 changed files with 18 additions and 4 deletions

View file

@ -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)\"

View file

@ -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])

View file

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

View file

@ -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;