diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-08 18:29:24 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-08 18:29:24 -0400 |
commit | f135a4a380b5ea56a876dcfef1448e01f1bebdec (patch) | |
tree | 0519d8e3507f2b439ef220413e10fca37fcd6971 | |
parent | 9e842f5cb8a2ab5f3774333bfa868e9982ec4bd6 (diff) | |
parent | 2a0df74f8a73427b1fe2b96ec7840e7f39178569 (diff) |
Merge branch 'master' of https://github.com/tcsullivan/gamedev
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | include/common.h | 1 | ||||
-rw-r--r-- | include/windowClass.h | 13 | ||||
-rw-r--r-- | src/main.cpp | 7 | ||||
-rw-r--r-- | src/windowClass.cpp | 38 |
5 files changed, 57 insertions, 6 deletions
@@ -3,10 +3,10 @@ FLAGS_WIN32 = -lopengl32 -lmingw32 #-lSDL2_Image FLAGS = -m32 -Iinclude -Wall -Werror -lSDL2main -lSDL2 all: - @g++ src/main.cpp src/UIClass.cpp src/Quest.cpp -o main $(FLAGS_LINUX) $(FLAGS) + @g++ src/main.cpp src/UIClass.cpp src/windowClass.cpp src/Quest.cpp -o main $(FLAGS_LINUX) $(FLAGS) win32: - @g++ -L lib/ src/main.cpp src/UIClass.cpp -o main.exe $(FLAGS_WIN32) $(FLAGS) + @g++ -L lib/ src/main.cpp src/UIClass.cpp src/windowClass.cpp src/Quest.cpp -o main.exe $(FLAGS_WIN32) $(FLAGS) clean: rm main* diff --git a/include/common.h b/include/common.h index db0824b..4b05e5d 100644 --- a/include/common.h +++ b/include/common.h @@ -8,6 +8,7 @@ #include <SDL2/SDL.h> #include <SDL2/SDL_opengl.h> #include <UIClass.h> +#include <windowClass.h> #define SCREEN_WIDTH 1280 #define SCREEN_HEIGHT 720 diff --git a/include/windowClass.h b/include/windowClass.h new file mode 100644 index 0000000..1aaae98 --- /dev/null +++ b/include/windowClass.h @@ -0,0 +1,13 @@ +#ifndef WINDOWCLASS_H +#define WINDOWCLASS_H + +#include <common.h> + +class Window{ +public: + void setupRender(); + void render(); + +}; + +#endif //WINDOWCLASS_H
\ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 78163db..9ce98a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ SDL_GLContext mainGLContext = NULL; bool gameRunning = true; UIClass ui; +Window win; int main(int argc,char **argv){ //runs start-up procedures @@ -38,12 +39,10 @@ int main(int argc,char **argv){ **** GAMELOOP **** **************************/ - glClearColor(1,1,1,0); + win.setupRender(); while(gameRunning){ - glClear(GL_COLOR_BUFFER_BIT); - SDL_GL_SwapWindow(window); - ui.handleEvents(); + win.render(); } /************************** diff --git a/src/windowClass.cpp b/src/windowClass.cpp new file mode 100644 index 0000000..942ba86 --- /dev/null +++ b/src/windowClass.cpp @@ -0,0 +1,38 @@ +#include <windowClass.h> + +void Window::setupRender(){ + glClearColor(0,0,0,0); //set the background color + +} + +void Window::render(){ + + glMatrixMode(GL_PROJECTION); //set the matrix mode as projection so we can set the ortho size and the camera settings later on + glPushMatrix(); //load the settings into the matrix + glLoadIdentity(); //save the matrix + + glOrtho(0,SCREEN_WIDTH, 0,SCREEN_HEIGHT, -1,1); //set the the size of the screen + + glMatrixMode(GL_MODELVIEW); //set the matrix to modelview so we can draw objects + glPushMatrix(); //load + glLoadIdentity(); //save + + glPushMatrix(); //start a new matrix + glClear(GL_COLOR_BUFFER_BIT); //clear the screen + + /************************** + **** RENDER STUFF HERE **** + **************************/ + glColor3f(1.0f, 0.0f, 0.0f); + glRectf(0,0, 50,50); //draw a test rectangle + glColor3f(0.0f, 1.0f, 0.0f); + glRectf(50,0, 100,50); + glColor3f(0.0f, 0.0f, 1.0f); + glRectf(100,0,150,50); + /************************** + **** CLOSE THE LOOP **** + **************************/ + + glPopMatrix(); //see ya' matrix + SDL_GL_SwapWindow(window); //give the render to SDL to display it +}
\ No newline at end of file |