Allow the game to be run from any directory
This commit is contained in:
parent
5811e13f55
commit
f42740d8cc
4 changed files with 16 additions and 22 deletions
24
.gitignore
vendored
24
.gitignore
vendored
|
|
@ -1,14 +1,12 @@
|
|||
# Ignore Builds
|
||||
build/
|
||||
# Ignore Cmake build files
|
||||
.cache/
|
||||
.cmake/
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
Game
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
compile_commands.json
|
||||
|
||||
# Ignore autoconf cruft for now
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
autoscan.log
|
||||
compile
|
||||
config.h.in
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
missing
|
||||
# Ignore Cmake'd files
|
||||
src/helpers/RootDir.h
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
#pragma once
|
||||
#define ROOT_DIR "/"
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
#pragma once
|
||||
#define ROOT_DIR "@SMAKE_SOURCE_DIR@/"
|
||||
#define ROOT_DIR "@CMAKE_SOURCE_DIR@/"
|
||||
|
|
|
|||
10
src/main.cpp
10
src/main.cpp
|
|
@ -16,6 +16,7 @@
|
|||
#include "ShaderLoader.h"
|
||||
// Camera
|
||||
#include "PlayerCamera.h"
|
||||
#include "helpers/RootDir.h"
|
||||
|
||||
// Include error class
|
||||
#include "Error.h"
|
||||
|
|
@ -68,10 +69,8 @@ int main(int argc, char **argv) {
|
|||
// Create event handling struct
|
||||
SDL_Event input;
|
||||
|
||||
ShaderLoader shader("./data/shaders"
|
||||
"/vertex.glsl",
|
||||
"./data/shaders"
|
||||
"/fragment.glsl");
|
||||
ShaderLoader shader(ROOT_DIR "data/shaders/vertex.glsl",
|
||||
ROOT_DIR "data/shaders/fragment.glsl");
|
||||
|
||||
float vertices[] = {
|
||||
// positions // texture Co-ords
|
||||
|
|
@ -126,8 +125,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("./data"
|
||||
"/container.jpg");
|
||||
SDL_Surface *image = IMG_Load(ROOT_DIR "data/container.jpg");
|
||||
if (image == nullptr) {
|
||||
error.crash("SDL2_image was unable to load a texture", IMG_GetError());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue