Skip to content
Browse files

program now actually uses opengl. Also, no window comes up and nothin…

…g renders
  • Loading branch information...
1 parent 9f328e5 commit ba41688e829ef0d2e32e65b133b16d3f13ee0470 Jeremy M committed Oct 8, 2012
Showing with 71 additions and 1 deletion.
  1. +71 −1 glintro/glintro.cpp
View
72 glintro/glintro.cpp
@@ -1,17 +1,65 @@
#include "SDL/SDL.h"
+#include "SDL/SDL_opengl.h"
+
+void render()
+{
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glBegin( GL_QUADS);
+ glVertex2f(-15.f, -15.f);
+ glVertex2f(-15.f, 15.f);
+ glVertex2f(15.f, -15.f);
+ glVertex2f(15.f, 15.f);
+ glEnd();
+
+ SDL_GL_SwapBuffers();
+}
+
int main (int argc, char* args[])
{
+
+ SDL_Surface* screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL | SDL_FULLSCREEN );
+
+ if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
+ printf("Unable to initialize SDL: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // *new*
+
+ SDL_WM_SetCaption( "GIRAFFE", NULL);
+
+ glEnable( GL_TEXTURE_2D );
+
+ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
+
+ glViewport( 0, 0, 640, 480 );
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+
+ glOrtho(0.0f, 640, 480, 0.0f, -1.0f, 1.0f);
+
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+/*
SDL_Surface* jraf = NULL;
SDL_Surface* screen = NULL;
SDL_Surface* loadImage = NULL;
+
SDL_Init(SDL_INIT_EVERYTHING);
//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
SDL_WM_SetCaption( "GIRAFFE", NULL);
+
//Load image
loadImage = SDL_LoadBMP( "jraf.bmp" );
@@ -31,9 +79,24 @@ int main (int argc, char* args[])
offset.y = 0;
offset.x = 640;
+ int y = 0;
- for(int i = 640; i > -640; i--)
+ int state = 1;
+
+ for(int i = 640; i > -640; i-=5)
{
+
+ y += 3*state;
+ if(y > 5)
+ {
+ state = -1;
+ }
+ if(y < -5)
+ {
+ state = 1;
+ }
+
+ offset.y = y;
offset.x = i;
SDL_FillRect(screen, NULL, bgcolor);
@@ -50,9 +113,16 @@ int main (int argc, char* args[])
//Free the loaded image
SDL_FreeSurface( jraf );
+*/
+ int h = 0;
+ while(h++ < 50000000){
+ render();
+ }
//Quit SDL
SDL_Quit();
return 0;
}
+
+

0 comments on commit ba41688

Please sign in to comment.
Something went wrong with that request. Please try again.