資源簡介
全套教程中文版供48課,html網頁版,附所有源代碼

代碼片段和文件信息
/*
?* 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
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????107??2007-02-28?13:43??Pic\bc.gif
?????文件????????293??2007-02-28?13:43??Pic\bc.png
?????文件???????6638??2007-02-28?13:43??Pic\big_glow.jpg
?????文件????????305??2007-02-28?13:43??Pic\bl.gif
?????文件????????720??2007-02-28?13:43??Pic\bl.png
?????文件?????????42??2007-02-28?13:43??Pic\blank(1).gif
?????文件????????305??2007-02-28?13:43??Pic\br.gif
?????文件????????641??2007-02-28?13:43??Pic\br.png
?????文件???????1549??2007-02-28?13:43??Pic\curve1.gif
?????文件???????5124??2007-02-28?13:43??Pic\curve2.jpg
?????文件???????4494??2007-02-28?13:43??Pic\curve3.jpg
?????文件???????4367??2007-02-28?13:43??Pic\figure1.jpg
?????文件???????8330??2007-02-28?13:43??Pic\figure2.jpg
?????文件???????5083??2007-02-28?13:43??Pic\figure3.jpg
?????文件???????9134??2007-02-28?13:43??Pic\figure4.jpg
?????文件???????1378??2007-02-28?13:43??Pic\foo_foo.gif
?????文件???????2753??2007-02-28?13:43??Pic\free.gif
?????文件???????5654??2007-02-28?13:43??Pic\glow.jpg
?????文件???????6505??2007-02-28?13:43??Pic\halo.jpg
?????文件??????40281??2007-02-28?13:43??Pic\illustration.jpg
?????文件????????888??2007-02-28?13:43??Pic\image002.jpg
?????文件???????2358??2007-02-28?13:43??Pic\image004.jpg
?????文件???????1368??2007-02-28?13:43??Pic\image006.jpg
?????文件??????15285??2007-02-28?13:43??Pic\image008.jpg
?????文件????????124??2007-02-28?13:43??Pic\l.gif
?????文件????????308??2007-02-28?13:43??Pic\l.png
?????文件???????5070??2007-02-28?13:43??Pic\lesson01.jpg
?????文件???????1586??2007-02-28?13:43??Pic\lesson02.jpg
?????文件???????1842??2007-02-28?13:43??Pic\lesson03.jpg
?????文件???????1891??2007-02-28?13:43??Pic\lesson04.jpg
............此處省略604個文件信息
評論
共有 條評論