Upload
hagen
View
64
Download
1
Embed Size (px)
DESCRIPTION
Windows Programming Basic& OpengGL Under Win32. 戴明仁200 40517. 要學會 Windows 程式設計,最快需要花上六個月的時間 -- Charles Petzold (author of Programming Windows). Win32 API Programming. An event driven system model Only requires basic skills of C language programming - PowerPoint PPT Presentation
Citation preview
Windows Programming Basic&
OpengGL Under Win32
戴明仁20040517
要學會Windows程式設計,最快需要花上六個月的時間
-- Charles Petzold
(author of Programming Windows)
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!
Win32 Program Overview
W in M ain ( )
I n it ia liza tio n
W in d o w sP r o c ed u r e
P r o g r amT er m in a ted
Us er I n te r r u p ted
M es s ag e L o o p
Step 1 : Create a New Project
Step 2 : Set Project Properties
1.choose “Win32 Application”
2.Specify project location
3.Enter project name
Step 3 : Choose Project Template
We choose this in our tutorial
Then choose Finish and OK….A new project has been created!
Step 4 : VC 6.0 IDE Overview
Classview
Resourceview
Fileview
Debug and other window
Code Edit Window
Toolbars
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 )
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.
References
Programming Windows 5th editionby Charles
Petzold.
Microsoft Press. Windows 程式設計實務
by 施威銘旗標
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
Using OpenGL under Windows-2 Setup VC environment.
Using OpenGL under Windows-3 Link your program with OpenGL libraries.
Congratulations!You now can write OpenGL programs!
Reference
Official OpenGL websitehttp://www.opengl.org
NeHe -- Very good OpenGL tutorialshttp://nehe.gamedev.net/
NeHe Chinese versionhttp://www.geocities.com/SiliconValley/Vista/8177/tutorial/nehe.htm
OpenGL Programming Guide 3th edition OpenGL 超級手冊 (碁峰 )
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.
Let’s see how to use kgl to write a OpenGL program.
What is kglApp?
A framework for Win32 and OpenGL A simplest kglApp contains these files:
Double click the workspace file to open kglApp project
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.
OpenGL Initial Function
Put OpenGL initialization code here.
OpenGL Resize Function
Called when user resize the window.
Keyboard Message Manipulate Place code here to do some thing when some key is pressed
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.
Custom Setup Function
Put any initialize code other then OpenGL here
The Main Rendering Loop
1)Open main.cpp
2)The rendering loop.Draw anything you like here.
Any Questions?
Hope there will be another Quake 3 from you... Goodbye….XD!