資源簡介
open gl圖形編程案例,是最為經典的學習資料,適合入門

代碼片段和文件信息
/*
?* This?Code?Was?Created?By?Jeff?Molofee?2000
?* A?HUGE?Thanks?To?Fredric?Echols?For?Cleaning?Up
?* And?Optimizing?This?Code?Making?It?More?Flexible!
?* If?You‘ve?Found?This?Code?Useful?Please?Let?Me?Know.
?* Visit?My?Site?At?nehe.gamedev.net
?*/
#include? //?Header?File?For?Windows
#include? //?Header?File?For?The?OpenGL32?Library
#include? //?Header?File?For?The?GLu32?Library
#include? //?Header?File?For?The?Glaux?Library
HDC hDC=NULL; //?Private?GDI?Device?Context
HGLRC hRC=NULL; //?Permanent?Rendering?Context
HWND hWnd=NULL; //?Holds?Our?Window?Handle
HINSTANCE hInstance; //?Holds?The?Instance?Of?The?Application
bool keys[256]; //?Array?Used?For?The?Keyboard?Routine
bool active=TRUE; //?Window?Active?Flag?Set?To?TRUE?By?Default
bool fullscreen=TRUE; //?Fullscreen?Flag?Set?To?Fullscreen?Mode?By?Default
LRESULT CALLBACK?WndProc(HWND?UINT?WPARAM?LPARAM); //?Declaration?For?WndProc
GLvoid?ReSizeGLScene(GLsizei?width?GLsizei?height) //?Resize?And?Initialize?The?GL?Window
{
if?(height==0) //?Prevent?A?Divide?By?Zero?By
{
height=1; //?Making?Height?Equal?One
}
glViewport(00widthheight); //?Reset?The?Current?Viewport
glMatrixMode(GL_PROJECTION); //?Select?The?Projection?Matrix
glLoadIdentity(); //?Reset?The?Projection?Matrix
//?Calculate?The?Aspect?Ratio?Of?The?Window
gluPerspective(45.0f(GLfloat)width/(GLfloat)height0.1f100.0f);
glMatrixMode(GL_MODELVIEW); //?Select?The?Modelview?Matrix
glLoadIdentity(); //?Reset?The?Modelview?Matrix
}
int?InitGL(GLvoid) //?All?Setup?For?OpenGL?Goes?Here
{
glShadeModel(GL_SMOOTH); //?Enable?Smooth?Shading
glClearColor(0.0f?0.0f?0.0f?0.5f); //?Black?Background
glClearDepth(1.0f); //?Depth?Buffer?Setup
glEnable(GL_DEPTH_TEST); //?Enables?Depth?Testing
glDepthFunc(GL_LEQUAL); //?The?Type?Of?Depth?Testing?To?Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT?GL_NICEST); //?Really?Nice?Perspective?Calculations
return?TRUE; //?Initialization?Went?OK
}
int?DrawGLScene(GLvoid) //?Here‘s?Where?We?Do?All?The?Drawing
{
glClear(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT); //?Clear?Screen?And?Depth?Buffer
glLoadIdentity(); //?Reset?The?Current?Modelview?Matrix
return?TRUE; //?Everything?Went?OK
}
GLvoid?KillGLWindow(GLvoid) //?Properly?Kill?The?Window
{
if?(fullscreen) //?Are?We?In?Fullscreen?Mode?
{
ChangeDisplaySettings(NULL0); //?If?So?Switch?Back?To?The?Desktop
ShowCursor(TRUE); //?Show?Mouse?Pointer
}
if?(hRC) //?Do?We?Have?A?Rendering?Context?
{
if?(!wglMakeCurrent(NULLNULL)) //?Are?We?Able?To?Release?The?DC?And?RC?Contexts?
{
MessageBox(NULL“Release?Of?DC?And?RC?Failed.““SHUTDOWN?ERROR“MB_OK?|?MB_ICONINFORMATION);
}
if?(!wglDeleteContext(hRC)) //?Are
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-10-17?21:42??Lesson01\
?????目錄???????????0??2013-10-17?21:41??Lesson01\Debug\
?????文件?????????608??2013-10-17?21:41??Lesson01\Debug\cl.command.1.tlog
?????文件???????13304??2013-10-17?21:41??Lesson01\Debug\CL.read.1.tlog
?????文件?????????136??2013-10-17?21:41??Lesson01\Debug\CL.write.1.tlog
?????文件??????200779??2011-10-31?20:39??Lesson01\Debug\lesson1.exe
?????文件??????236140??2011-10-31?20:39??Lesson01\Debug\lesson1.ilk
?????文件??????????55??2013-10-17?21:41??Lesson01\Debug\Lesson1.lastbuildstate
?????文件?????????932??2013-10-17?21:41??Lesson01\Debug\Lesson1.log
?????文件???????????0??2013-10-17?21:41??Lesson01\Debug\Lesson1.unsuccessfulbuild
?????文件?????????713??2013-10-17?21:41??Lesson01\Debug\Lesson1.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2013-10-17?21:41??Lesson01\Debug\Lesson1.write.1.tlog
?????文件??????216064??2013-10-17?21:41??Lesson01\Debug\vc100.idb
?????文件???????53248??2013-10-17?21:41??Lesson01\Debug\vc100.pdb
?????文件??????132096??2011-10-31?20:39??Lesson01\Debug\vc60.idb
?????文件???????77824??2011-10-31?20:39??Lesson01\Debug\vc60.pdb
?????目錄???????????0??2013-10-17?21:41??Lesson01\ipch\
?????目錄???????????0??2013-10-17?21:41??Lesson01\ipch\lesson1-614b0551\
?????文件???????15241??2000-10-08?17:04??Lesson01\Lesson1.cpp
?????文件????????4056??2000-12-24?04:06??Lesson01\Lesson1.dsp
?????文件?????????539??1999-09-29?22:50??Lesson01\Lesson1.dsw
?????文件???????32768??2000-10-08?17:04??Lesson01\Lesson1.exe
?????文件???????41984??2012-03-28?23:20??Lesson01\Lesson1.ncb
?????文件???????48640??2012-03-28?23:20??Lesson01\Lesson1.opt
?????文件????????1199??2011-10-31?20:39??Lesson01\lesson1.plg
?????文件????24137728??2013-10-17?21:42??Lesson01\Lesson1.sdf
?????文件????????2560??2013-10-17?21:42??Lesson01\Lesson1.suo
?????文件????????6698??2013-10-17?21:41??Lesson01\Lesson1.vcxproj
?????文件?????????903??2013-10-17?21:41??Lesson01\Lesson1.vcxproj.filters
?????文件?????????143??2013-10-17?21:41??Lesson01\Lesson1.vcxproj.user
?????文件?????????766??2003-09-22?22:44??Lesson01\NeHe‘s?Readme.txt
............此處省略0個文件信息
- 上一篇:c編寫的旅游管理信息系統
- 下一篇:網口相機連接Demo
評論
共有 條評論