Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Programming Basic & OpengGL Under Win32 戴明仁 20040517.

Similar presentations


Presentation on theme: "Windows Programming Basic & OpengGL Under Win32 戴明仁 20040517."— Presentation transcript:

1 Windows Programming Basic & OpengGL Under Win32 戴明仁 20040517

2 要學會 Windows 程式設計, 最快需要花上六個月的時間 -- Charles Petzold (author of Programming Windows)

3 Win32 API Programming  An event driven system model  Only requires basic skills of C language programming  The bottom layer of MFC,VCL…etc. Let’s begin Win32 programming using MSVC6.0!

4 Win32 Program Overview

5 Step 1 : Create a New Project

6 Step 2 : Set Project Properties 1.choose “Win32 Application” 2.Specify project location 3.Enter project name

7 Step 3 : Choose Project Template We choose this in our tutorial Then choose Finish and OK….A new project has been created!

8 Step 4 : VC 6.0 IDE Overview Classview Resourceview Fileview Debug and other window Code Edit Window Toolbars

9 Step 5 : The WinMain() Function  The entry point of a Win32 program, such as main() in a console mode program.  Do windows initializations here.  A message loop is in the function, grabbing messages and send it to message dispatcher -- WndProc( Window Procedure )

10 Step 6 : Message Dispatcher– WndProc()  Every Windows message comes to here  We write codes here to perform some tasks to achieve our goals.  For Example : –If user presses a key, then a WM_KEYDOWN message will be received.  Check references to see more details about win32 programming.

11 References  Programming Windows 5 th edition by Charles Petzold. Microsoft Press.  Windows 程式設計實務 by 施威銘 旗標

12 Using OpenGL under Windows-1  Install OpenGL library Check OpenGL website for latest version of OpenGL library,download and install it. http://www.opengl.org/documentation/implementations.html

13 Using OpenGL under Windows-2  Setup VC environment.

14 Using OpenGL under Windows-3  Link your program with OpenGL libraries. Congratulations!You now can write OpenGL programs!

15 Reference  Official OpenGL website http://www.opengl.org  NeHe -- Very good OpenGL tutorials http://nehe.gamedev.net/  NeHe Chinese version http://www.geocities.com/SiliconValley/Vista/8177/tutorial/nehe.htm  OpenGL Programming Guide 3th edition  OpenGL 超級手冊 ( 碁峰 )

16 Why use Win32 instead of GLUT  Win32 applications is faster.  Win32 is the base of GLUT.  Under Win32,user can manipulate any messages very easily and efficiently.  We can integrate other useful stuff (such as DirectX ) into Win32 applications.

17 Let’s see how to use kgl to write a OpenGL program.

18 What is kglApp?  A framework for Win32 and OpenGL  A simplest kglApp contains these files: Double click the workspace file to open kglApp project

19 What’s in kglApp? 1)Open kglWinGL.h 2)Some configurations that user can modify 3)The main rendering function that user must override itself.

20 OpenGL Initial Function Put OpenGL initialization code here.

21 OpenGL Resize Function  Called when user resize the window.

22 Keyboard Message Manipulate  Place code here to do some thing when some key is pressed

23 Windows Virtual Key Codes  In the above example, VK_F1 is virtual key code defined in Win32 API which represents the F1 key in the keyboard.  You can check MSDN ( http://msdn.microsoft.com ) for more information about Win32 virtual key codes.http://msdn.microsoft.com

24 Custom Setup Function  Put any initialize code other then OpenGL here

25 The Main Rendering Loop 1)Open main.cpp 2)The rendering loop.Draw anything you like here.

26 Any Questions?

27 Hope there will be another Quake 3 from you... Goodbye….XD!


Download ppt "Windows Programming Basic & OpengGL Under Win32 戴明仁 20040517."

Similar presentations


Ads by Google