]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
mhm
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Sep 2015 16:31:29 +0000 (12:31 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Sep 2015 16:31:29 +0000 (12:31 -0400)
Makefile
include/common.h
include/windowClass.h [deleted file]
src/main.cpp
src/windowClass.cpp [deleted file]

index bfb410020ff4f98129c40fb7773e711a0751a503..60d784fb4bf8e3193df9edefc71112899b6ea533 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
-FLAGS_LINUX = -lGL                 -lSDL_image
+FLAGS_LINUX = -lGL                 -lSDL2_image
 FLAGS_WIN32 = -lopengl32 -lmingw32 -lSDL2_Image
 FLAGS = -m32 -Iinclude -Wall -Werror -lSDL2main -lSDL2
 
 all:
-       @g++ src/main.cpp src/UIClass.cpp src/windowClass.cpp src/Quest.cpp -o main $(FLAGS_LINUX) $(FLAGS)
+       @g++ src/*.cpp -o main $(FLAGS_LINUX) $(FLAGS)
 
 win32:
        @g++ -L lib/ src/main.cpp src/UIClass.cpp src/windowClass.cpp src/Quest.cpp -o main.exe $(FLAGS_WIN32) $(FLAGS)
index 56bbe3ff0695d85524754d2ecd78b42dbc2625ac..816de5ad2aeae49086e5e86e4ff595db7e3b9159 100644 (file)
@@ -9,10 +9,10 @@
 #include <SDL2/SDL_image.h>
 #include <SDL2/SDL_opengl.h>
 #include <UIClass.h>
-#include <windowClass.h>
+#include <World.h>
 
-#define SCREEN_WIDTH 1280
-#define SCREEN_HEIGHT 720
+#define SCREEN_WIDTH  640
+#define SCREEN_HEIGHT 480
 //#define FULLSCREEN
 
 //SDL VARIABLES
diff --git a/include/windowClass.h b/include/windowClass.h
deleted file mode 100644 (file)
index 1aaae98..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#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
index 71b6595f09dc783e80cc0230174a9c18ece675af..61920e7cf49c3d497c7b549e5a0c7e6d7f70ee7b 100644 (file)
@@ -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 (file)
index e0e3840..0000000
+++ /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