aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Belle-Isle <abelleisle@roadrunner.com>2015-09-08 19:10:31 -0400
committerAndy Belle-Isle <abelleisle@roadrunner.com>2015-09-08 19:10:36 -0400
commit1da594bc86e524b0a5e919149a865508fcbfbb23 (patch)
tree2f2ed196323884f1edef94dfcccd29a0b070e927
parentcffb8fbcef2edf15c80423c6b26f55c84b746b6f (diff)
Re-Documented the render loop
-rw-r--r--src/windowClass.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/windowClass.cpp b/src/windowClass.cpp
index 942ba86..e0e3840 100644
--- a/src/windowClass.cpp
+++ b/src/windowClass.cpp
@@ -6,33 +6,35 @@ void Window::setupRender(){
}
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(); //load the settings into the matrix
- glLoadIdentity(); //save the matrix
+ 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(); //load
- glLoadIdentity(); //save
+ glPushMatrix(); //push the matrix to the top of the matrix stack
+ glLoadIdentity(); //replace the entire matrix stack with the updated GL_MODELVIEW mode
- glPushMatrix(); //start a new matrix
- glClear(GL_COLOR_BUFFER_BIT); //clear the screen
+ 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);
+ 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);
- glRectf(50,0, 100,50);
- glColor3f(0.0f, 0.0f, 1.0f);
- glRectf(100,0,150,50);
+ 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(); //see ya' matrix
- SDL_GL_SwapWindow(window); //give the render to SDL to display it
+ 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