aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp48
-rw-r--r--src/windowClass.cpp40
2 files changed, 42 insertions, 46 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 71b6595..61920e7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,13 +7,12 @@ SDL_GLContext mainGLContext = NULL;
bool gameRunning = true;
UIClass ui;
-Window win;
int main(int argc,char **argv){
//runs start-up procedures
if(!SDL_Init(SDL_INIT_VIDEO)){
atexit(SDL_Quit);
- if(!(IMG_Init(IMG_INIT_PNG)&IMG_INIT_PNG)){
+ if(!(IMG_Init(IMG_INIT_PNG|IMG_INIT_JPG)&(IMG_INIT_PNG|IMG_INIT_JPG))){
std::cout<<"Could not init image libraries!\n"<<std::endl;
return -1;
}
@@ -41,22 +40,59 @@ int main(int argc,char **argv){
return -1;
}
+ glClearColor(.3,.5,.8,0);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
/**************************
**** GAMELOOP ****
**************************/
- win.setupRender();
+ World *w=new World("res/dirt.jpg",
+ "res/dirt.jpg",
+ "res/dirt.jpg",
+ "res/dirt.jpg");
+
while(gameRunning){
- ui.handleEvents();
- win.render();
+ ui.handleEvents(); // Handle events
+ //a matrix is a blank canvas for the computer to draw on, the matrices are stored in a "stack"
+ //GL_PROJECTION has 2 matrices
+ //GL_MODELVIEW has 32 matrices
+ glMatrixMode(GL_PROJECTION); //set the matrix mode as projection so we can set the ortho size and the camera settings later on
+ glPushMatrix(); //push the matrix to the top of the matrix stack
+ glLoadIdentity(); //replace the entire matrix stack with the updated GL_PROJECTION mode
+ //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(); //push the matrix to the top of the matrix stack
+ glLoadIdentity(); //replace the entire matrix stack with the updated GL_MODELVIEW mode
+ glPushMatrix(); //basically here we put a blank canvas (new matrix) on the screen to draw on
+ glClear(GL_COLOR_BUFFER_BIT); //clear the matrix on the top of the stack
+
+ /**************************
+ **** RENDER STUFF HERE ****
+ **************************/
+
+ /*glColor3f(1.0f, 0.0f, 0.0f); //color to red
+ glRectf(0,0, 50,50); //draw a test rectangle
+ glColor3f(0.0f, 1.0f, 0.0f); //color to blue
+ glRectf(50,0, 100,50); //draw a test rectangle
+ glColor3f(0.0f, 0.0f, 1.0f); //color to green
+ glRectf(100,0,150,50); //draw a test rectangle*/
+
+ w->draw();
+
+ /**************************
+ **** CLOSE THE LOOP ****
+ **************************/
+
+ glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer
+ SDL_GL_SwapWindow(window); //give the stack to SDL to render it
}
/**************************
**** CLOSE PROGRAM ****
**************************/
-
//closes the window and frees resources
SDL_GL_DeleteContext(mainGLContext);
SDL_DestroyWindow(window);
diff --git a/src/windowClass.cpp b/src/windowClass.cpp
deleted file mode 100644
index e0e3840..0000000
--- a/src/windowClass.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <windowClass.h>
-
-void Window::setupRender(){
- glClearColor(0,0,0,0); //set the background color
-
-}
-
-void Window::render(){
- //a matrix is a blank canvas for the computer to draw on, the matrices are stored in a "stack"
- //GL_PROJECTION has 2 matrices
- //GL_MODELVIEW has 32 matrices
- glMatrixMode(GL_PROJECTION); //set the matrix mode as projection so we can set the ortho size and the camera settings later on
- glPushMatrix(); //push the matrix to the top of the matrix stack
- glLoadIdentity(); //replace the entire matrix stack with the updated GL_PROJECTION mode
-
- 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(); //push the matrix to the top of the matrix stack
- glLoadIdentity(); //replace the entire matrix stack with the updated GL_MODELVIEW mode
-
- glPushMatrix(); //basically here we put a blank canvas (new matrix) on the screen to draw on
- glClear(GL_COLOR_BUFFER_BIT); //clear the matrix on the top of the stack
-
- /**************************
- **** RENDER STUFF HERE ****
- **************************/
- glColor3f(1.0f, 0.0f, 0.0f); //color to red
- glRectf(0,0, 50,50); //draw a test rectangle
- glColor3f(0.0f, 1.0f, 0.0f); //color to blue
- glRectf(50,0, 100,50); //draw a test rectangle
- glColor3f(0.0f, 0.0f, 1.0f); //color to green
- glRectf(100,0,150,50); //draw a test rectangle
- /**************************
- **** CLOSE THE LOOP ****
- **************************/
-
- glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer
- SDL_GL_SwapWindow(window); //give the stack to SDL to render it
-} \ No newline at end of file