CPPGPGPU Library - Reference (Doxygen)

Main Page | General Use | Reference | Examples Info | Get/Download CPPGPGPU | SF.net Page

example.cpp

Go to the documentation of this file.
00001 #include "GLUTCore.h"
00002 #include "OGLParts.h"
00003 #include <stdio.h>
00004 
00005 void MyDraw();
00006 
00007 Texture T1;
00008 
00009 int main (int argc, char * const argv[]) {
00010     printf("Hello, World!\n");
00011     //This must be set before init.
00012     GLUT.SetDrawFunct( MyDraw );
00013 
00014     GLUT.Init( argc, (char**)argv, 640, 480, "Hello World" );
00015 
00016     //For display purposes, we should depth test all of our surfaces.
00017     glEnable(GL_DEPTH_TEST);
00018 
00019     //Load a texture from a file (PPMs are all that's supported)
00020     T1.LoadTextureFile( "Basic.ppm" );
00021 
00022     GLUT.DrawAndDoMainLoop();
00023     return 0;
00024 }
00025 
00026 
00027 void MyDraw()
00028 {
00029     //Clear the screen.
00030     glClearColor( .1f, .1f, .2f, 0.0f );
00031     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00032 
00033     T1.ActivateTexture( 0 );
00034     //Draw a square textured with Texture 0.
00035     DrawSquare();
00036     T1.DeactivateTexture( 0 );
00037 
00038     //Update FPS, print if its time.
00039     GLUT.TackFPS();
00040 
00041     //You need these last two lines.
00042     glutSwapBuffers();
00043     glutPostRedisplay();
00044 }

© 2005-2007 Charles Lohr, Joshua Allen, David Chapman, Andrew Lohr. All material including documentation under the MIT/X11 license.