資源簡介
很好的3D魔方游戲源代碼,趕快下起,下載運行就能玩,讓你過把癮!!
代碼片段和文件信息
//?FScreen.c
//?OpenGL?SuperBible?Chapter?17
//?Program?by?Richard?S.?Wright?Jr.
//?This?program?shows?a?how?to?create?a?full?screen
//?window?and?render?into?it?with?OpenGL.
#include?
#include?
#include?
#include?
#include?
#include?
#include?“cubemanage.h“
#include?“wcgcube.h“
static?GLfloat?PI=3.1415f;
//?Rotation?amounts
static?GLfloat?xRot?=?0.0f;
static?GLfloat?yRot?=?0.0f;
static?GLfloat?rotate=0.0f;
static?int?rotateType=0;
static?int?rotateOK=0;
static?int?rotateRate=100;
static?GLfloat?rotateStep=5*PI/180;
CubeManage?cm;
HPALETTE?hPalette?=?NULL;
//?Keep?track?of?windows?changing?width?and?height
GLfloat?windowWidth;
GLfloat?windowHeight;
static?LPCTSTR?lpszAppName?=?“WcgCube“;
void?exitGame(HWND?hWndHDC?hDCHGLRC?hRC);
//?Declaration?for?Window?procedure
LRESULT?CALLBACK?WndProc( HWND? hWnd
UINT message
WPARAM wParam
LPARAM lParam);
//?Set?Pixel?Format?function?-?forward?declaration
void?SetDCPixelFormat(HDC?hDC);
void?ChangeSize(GLsizei?w?GLsizei?h)
{
GLfloat?nRange?=?350.0f;
//?Prevent?a?divide?by?zero
if(h?==?0)
h?=?1;
//?Set?Viewport?to?window?dimensions
????glViewport(0?0?w?h);
//?Reset?coordinate?system
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//?Establish?clipping?volume?(left?right?bottom?top?near?far)
????if?(w?<=?h)?
glOrtho?(-nRange?nRange?-nRange*h/w?nRange*h/w?-nRange?nRange);
????else?
glOrtho?(-nRange*w/h?nRange*w/h?-nRange?nRange?-nRange?nRange);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//?Called?by?timer?routine?to?effect?movement?of?the?rectangle.
void?IdleFunction(void)
{
if?(rotate>=PI/2)?{
cm.turn(rotateType);
rotateType=0;
rotateOK=0;
rotate=0.0f;
//?Refresh?the?Window
// glutPostRedisplay();
return;
}
rotate+=rotateStep;
//?Refresh?the?Window
// glutPostRedisplay();
}
//?Called?by?AUX?library?to?draw?scene
void?RenderScene(void)
{
//?Clear?the?window?with?current?clearing?color
glClear(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT);
??glPushMatrix();
??glRotatef(xRot?1.0f?0.0f?0.0f);
glRotatef(yRot?0.0f?1.0f?0.0f);
cm.draw(rotateTyperotate);
??glPopMatrix();
//?Show?the?graphics
// glutSwapBuffers();
}
//?If?necessary?creates?a?3-3-2?palette?for?the?device?context?listed.
HPALETTE?GetOpenGLPalette(HDC?hDC)
{
HPALETTE?hRetPal?=?NULL; //?Handle?to?palette?to?be?created
PIXELFORMATDEscriptOR?pfd; //?Pixel?Format?Descriptor
LOGPALETTE?*pPal; //?Pointer?to?memory?for?logical?palette
int?nPixelFormat; //?Pixel?format?index
int?nColors; //?Number?of?entries?in?palette
int?i; //?Counting?variable
BYTE?RedRangeGreenRangeBlueRange;
//?Range?for?each?color?entry?(77and?3)
//?Get?the?pixel?format?index?and?retrieve?the?pixel?format?description
nPixelFormat?=?GetP
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13805??2001-11-11?11:36??3D魔方游戲源代碼\CubeGame.cpp
?????文件??????13868??2001-11-10?20:26??3D魔方游戲源代碼\cubemanage.cpp
?????文件???????1756??2001-11-11?10:34??3D魔方游戲源代碼\cubemanage.h
?????文件???????4326??2001-11-10?20:23??3D魔方游戲源代碼\main.cpp
?????文件???????5515??2001-11-08?23:53??3D魔方游戲源代碼\wcgcube.cpp
?????文件???????4240??2001-11-11?11:02??3D魔方游戲源代碼\WcgCube.dsp
?????文件????????537??2001-11-11?11:02??3D魔方游戲源代碼\WcgCube.dsw
?????文件???????1657??2001-11-11?10:34??3D魔方游戲源代碼\wcgcube.h
?????文件??????41984??2001-11-11?11:41??3D魔方游戲源代碼\WcgCube.ncb
?????文件??????52736??2001-11-11?11:41??3D魔方游戲源代碼\WcgCube.opt
?????文件???????1146??2001-11-11?11:36??3D魔方游戲源代碼\WcgCube.plg
?????目錄??????????0??2009-01-01?22:59??3D魔方游戲源代碼
-----------?---------??----------?-----??----
???????????????141570????????????????????12
評論
共有 條評論