added error class. (need better method of class discovery)

This commit is contained in:
Warwick 2021-02-08 12:35:57 +00:00
parent 16d54ea956
commit b091a1a637
5 changed files with 30 additions and 2 deletions

View file

@ -1,8 +1,13 @@
# Allow directory manangement of source
AUTOMAKE_OPTIONS = subdir-objects
# Use m4 directory (modern best practice)
ACLOCAL_AMFLAGS = -I m4 --install
bin_PROGRAMS = Game
Game_SOURCES = \
src/main.cpp
src/main.cpp \
src/Error.h \
src/Error.cpp
Game_CPPFLAGS = @sdl2_CFLAGS@ @glew_CFLAGS@ @opengl_CFLAGS@
Game_LDFLAGS = @sdl2_LIBS@ @glew_LIBS@ @opengl_LIBS@

View file

@ -6,6 +6,7 @@ AC_INIT([Game], [0.0.1], [wytau@sdf.org])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_CXX

4
src/Error.cpp Normal file
View file

@ -0,0 +1,4 @@
#include "Error.h"
#include <string>
Error::Error(std::string location) { object = location; }

11
src/Error.h Normal file
View file

@ -0,0 +1,11 @@
#pragma once
#include <string>
class Error {
private:
// this string gives us the name of the object the error occured in
std::string object;
public:
Error(std::string location);
};

View file

@ -14,13 +14,20 @@ const char *fragmentShaderSource =
" FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\0";
//#include <iostream>
// Include Config header generated by GNU autotools
#include "../config.h"
#include <GL/glew.h>
// Make sure Glew is loaded first
#include <GL/gl.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
// Include error class
#include "Error.h"
#include <string>
// TODO: Remove check that error class was included properly
Error error("main");
// TODO: Create Error handling class
int main(int argc, char **argv) {