Setup Open GL Environment with GLUT freeglut 2010
- Slides: 23
Setup Open. GL Environment with GLUT / freeglut 2010. 09. 16 I-Cheng Yeh
Resource l This slides and resource l l http: //vslab. csie. ncku. edu. tw/course/CG/ Super Bible 4 th l http: //www. starstonesoftware. com/Open. GL/four th. Edition. htm l l NEHE : l http: //nehe. gamedev. net/ l http: //vision. csie. ncku. edu. tw/~ichenyeh/public/nehe/ Game Tutorial : l http: //www. gametutorials. com/
About GLUT l The Open. GL Utility Toolkit (GLUT) l l Latest version l l l originally written by Mark Kilgard, Kilgard ported to Win 32 (Windows 95, 98, Me, NT, 2000, XP) by Nate Robins. http: //www. xmission. com/~nate/glut. html glut-3. 7. 6 -bin. zip (117 KB) GLUT for Win 32 dll, lib and header file (everything you need to get started programming with GLUT). Ours
Setup GLUT in Visual Studio 2005 l l Global setting glut. h l l l glut. lib l l Precompiled versions of the import library $(MSDev. Dir)VCPlatform. SDKLib glut. dll l l Header file of GLUT $(MSDev. Dir)VCPlatform. SDKIncludegl Precompiled versions of the DLL l %Win. Dir%System or %Win. Dir%System 32 $(MSDev. Dir) = C: Program FilesMicrosoft Visual Studio 8 %Win. Dir%= C: WINDOWS Global Version
Setup GLUT in Visual Studio 2005 cont l Global setting – open “options” page Global Version
Setup GLUT in Visual Studio 2005 cont l Global setting – edit include files C: open. GLOpen. GLSDKinclude Global Version
Setup GLUT in Visual Studio 2005 cont l Global setting – edit library files C: open. GLOpen. GLSDKlib Global Version
Setup GLUT in Visual Studio 2005 cont l Local setting – Properties page Local Version
Setup GLUT in Visual Studio 2005 cont l Local setting – additional include directories Local Version
Setup GLUT in Visual Studio 2005 cont l Local setting – additional library directories Local Version
ERROR l Compiler message l l error C 2381: 'exit' : redefinition; __declspec(noreturn) differs $(MSDev. Dir)VCincludestdlib. h 406 Solution 1 l l Open glut. h in Line 146 Change l extern _CRTIMP void __cdecl exit(int); To l l extern _CRTIMP __declspec(noreturn) void __cdecl exit(int); Solution 2 l Correct the order of including list l l #include <stdlib. h> #include <GL/glut. h>
Attention l Local setting – additional library directories
Setup GLUT in Visual Studio 6 l l Extract Open. GLSDK. zip to Disk (e. q. : c: Open. GLSDK) Copy glut. dll (in C: Open. GLSDKLIB) to %Win. Dir%System or %Win. Dir%System 32 l l Get in “VC 6 ->Tool->Option” Select page: ”Directory” l Select ”Include file” , and add two path l l l C: open. GLOpen. GLSDKincludegl Select page: ”Library file” l Add path l C: open. GLOpen. GLSDKLIB
About freeglut ? ? l The “freeglut” l l l Open Sourced alternative to the Open. GL Utility Toolkit (GLUT) Originally written by Pawel W. Olszta with contributions from Andreas Umbach and Steve Baker. Steve is now the official owner/maintainer of freeglut. Latest version l http: //freeglut. sourceforge. net/ (ver. 2. 6)
Getting Start l #include <GL/glut. h> l # pragma comment (lib, "opengl 32. lib") l l # pragma comment (lib, "glu 32. lib") l l /* link with Microsoft Open. GL lib */ /* link with Microsoft Open. GL Utility lib */ # pragma comment (lib, "glut 32. lib") l /* link with Win 32 GLUT lib */
Program 1 (double) l Left Click l Active l Rotation Function Right Click l Disable Rotation Function
glut. Mouse. Func(mouse); //put this line into main() function void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) glut. Idle. Func(spin. Display); break; case GLUT_MIDDLE_BUTTON: case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) glut. Idle. Func(NULL); break; default: break; } } l
glut. Keyboard. Func(keyboard); //put this line into main() function void keyboard (unsigned char key, int x, int y) { switch (key) { case 'x': case 'X': glut. Idle. Func(rot. Display. X); break; case 'y': case 'Y': glut. Idle. Func(rot. Display. Y); break; case 'z': case 'Z': glut. Idle. Func(rot. Display. Z); break; default: break; } } l
Draw Triangle void displays(void) { //Clear color gl. Clear (GL_COLOR_BUFFER_BIT); //Draw 2 D Rectangle gl. Rectf (-25. 0, 25. 0); //Draw 2 D Triangle gl. Begin(GL_TRIANGLES); gl. Vertex 3 d(-25. 0, 0. 0); gl. Vertex 3 d(0. 0, 0. 0); gl. Vertex 3 d(-25. 0, 0. 0); gl. End(); gl. Flush(); //Refresh } (-25, 0, 0) (0, 0, 0) CCW = Counterclockwise (-25, 0)
Exercise ! (double)
Exercise 2! (gasket 3)
Exercise 2! (gasket 3) l Press Z l Rotate l Z Press X l Rotate l by Z-Axis by X-Axis Mouse Click l Stop ALL X
DEMO, Q&A ?
- Open innovation open science open to the world
- Financial environment of business
- Homeostasis ejemplos
- Glut piruvát transzamináz
- Gl/glut.h
- Glut timer
- Glut 種類
- Glut init
- Glut menu example
- Glut draw text
- Glut thy sorrow on a morning rose
- Lenhinger
- Kata polyhedral bersal dari kata?
- Glucosa
- Glut solid torus
- Glut is ours
- Glbitmap
- Glut keyboard
- Glut dependiente de insulina
- Glut
- Dyned install
- Glutsolid
- Glutwire
- Glut primitives