Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenGL Open a Win32 Console Application in Microsoft Visual C++.

Similar presentations


Presentation on theme: "OpenGL Open a Win32 Console Application in Microsoft Visual C++."— Presentation transcript:

1 OpenGL Open a Win32 Console Application in Microsoft Visual C++.
A Console Application basically has the starting point configured and hence less work for you. Also this way you don’t have change project settings

2 OpenGl These are the include files you need apart from any others you might use for regular algorithms etc. #include <GL/gl.h> #include <GL/glu.h> #include<windows.h> #include <GL/glut.h>

3 Int main() Now although you are used to having no parameters passed to int main(), C++ allows parameters to be passed to a program. int main(int *NUM_PARAMETERS, char ** ACT_PARAMETERS){ return 0; }

4 Step 1 to initialize your window
glutInit(int *argc, char **argv) initializes GLUT and processes any command line arguments glutInit() should be called before any other GLUT routine.

5 Step 1 to initialize your window
glutInitDisplayMode(unsigned int mode) specifies whether to use an RGBA or color-index color model. You can alsospecify whether you want a single- or double-buffered window. You can use this routine to indicate that you want the window to have an associated depth, stencil, and/or accumulation buffer. Example: if you want a window with double buffering, the RGBA color model, and a depth buffer, you might call glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH).

6 Callbacks a callback is executable code that is passed as an argument to other code.

7 Step 3 to initialize your window
glutInitWindowPosition(int x, int y) specifies the screen location for the upper-left corner of your window. glutInitWindowSize(int width, int size) specifies the size, in pixels, of your window.

8 Step 3 to initialize your window
int glutCreateWindow(char *string) creates a window with an OpenGL context. Be warned: Until glutMainLoop() is called the window is not yet displayed.

9 Display glutDisplayFunc(void (*func)(void)) is the first and most important event callback function you will see. Whenever GLUT determines the contents of the window need to be redisplayed, the callback function registered by glutDisplayFunc() is executed. You should put all the routines you need to redraw the scene in the display callback function.

10 Execute! The very last thing you must do is call glutMainLoop(void).
All windows that have been created are now shown, and rendering to those windows is now effective. Event processing begins, and the registered display callback is triggered. Once this loop is entered, it is never exited!


Download ppt "OpenGL Open a Win32 Console Application in Microsoft Visual C++."

Similar presentations


Ads by Google