1 / 27

Windows Programming Basic & OpengGL Under Win32

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

hagen
Download Presentation

Windows Programming Basic & OpengGL Under Win32

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 要學會Windows程式設計,最快需要花上六個月的時間要學會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 3.Enter project name 2.Specify project location 1.choose “Win32 Application”

  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 Toolbars Code Edit Window Fileview Resourceview Classview Debug and other window

  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 5th 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.

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

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

  26. Any Questions?

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

More Related