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
|
# Ignore Cmake build files
|
||||||
build/
|
.cache/
|
||||||
|
.cmake/
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
Game
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
# Ignore autoconf cruft for now
|
# Ignore Cmake'd files
|
||||||
Makefile.in
|
src/helpers/RootDir.h
|
||||||
aclocal.m4
|
|
||||||
autom4te.cache/
|
|
||||||
autoscan.log
|
|
||||||
compile
|
|
||||||
config.h.in
|
|
||||||
configure
|
|
||||||
depcomp
|
|
||||||
install-sh
|
|
||||||
missing
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#define ROOT_DIR "/"
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#pragma once
|
#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"
|
#include "ShaderLoader.h"
|
||||||
// Camera
|
// Camera
|
||||||
#include "PlayerCamera.h"
|
#include "PlayerCamera.h"
|
||||||
|
#include "helpers/RootDir.h"
|
||||||
|
|
||||||
// Include error class
|
// Include error class
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
|
@ -68,10 +69,8 @@ int main(int argc, char **argv) {
|
||||||
// Create event handling struct
|
// Create event handling struct
|
||||||
SDL_Event input;
|
SDL_Event input;
|
||||||
|
|
||||||
ShaderLoader shader("./data/shaders"
|
ShaderLoader shader(ROOT_DIR "data/shaders/vertex.glsl",
|
||||||
"/vertex.glsl",
|
ROOT_DIR "data/shaders/fragment.glsl");
|
||||||
"./data/shaders"
|
|
||||||
"/fragment.glsl");
|
|
||||||
|
|
||||||
float vertices[] = {
|
float vertices[] = {
|
||||||
// positions // texture Co-ords
|
// positions // texture Co-ords
|
||||||
|
|
@ -126,8 +125,7 @@ int main(int argc, char **argv) {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
// Load texture image
|
// Load texture image
|
||||||
SDL_Surface *image = IMG_Load("./data"
|
SDL_Surface *image = IMG_Load(ROOT_DIR "data/container.jpg");
|
||||||
"/container.jpg");
|
|
||||||
if (image == nullptr) {
|
if (image == nullptr) {
|
||||||
error.crash("SDL2_image was unable to load a texture", IMG_GetError());
|
error.crash("SDL2_image was unable to load a texture", IMG_GetError());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue