資源簡(jiǎn)介
應(yīng)用VS2010及opengl編寫(xiě)的雪花動(dòng)畫(huà)。底部的大雪花可以旋轉(zhuǎn),并伴隨空中有旋轉(zhuǎn)的雪花飄落。
代碼片段和文件信息
//?ChildView.cpp?:?implementation?of?the?CChildView?class
//
#include?“stdafx.h“
#include?“SnowWorld.h“
#include?“ChildView.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
GLfloat?LightAmbient??[]?=?{?0.5f?0.5f?0.5f?1.0f?};
GLfloat?LightDiffuse??[]?=?{?1.0f?1.0f?1.0f?1.0f?};
GLfloat?LightPosition?[]?=?{?0.0f?0.0f?2.0f?1.0f?};
/////////////////////////////////////////////////////////////////////////////
//?CChildView
CChildView::CChildView()
{
m_pClientDC?=?NULL;
m_lpThread??=?NULL;
m_nFloorIndex?=?0;
}
CChildView::~CChildView()
{
if?(?m_lpThread?!=?NULL?)
{
delete?m_lpThread;
m_lpThread?=?NULL;
}
}
BEGIN_MESSAGE_MAP(CChildViewCWnd?)
//{{AFX_MSG_MAP(CChildView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CChildView?message?handlers
BOOL?CChildView::PreCreateWindow(CREATESTRUCT&?cs)?
{
if?(?!?CWnd::PreCreateWindow(?cs?)?)
return?FALSE;
cs.dwExstyle?|=?WS_EX_CLIENTEDGE;
cs.style?&=?~WS_BORDER;
cs.lpszClass?=?AfxRegisterWndClass(?CS_HREDRAW?|?CS_VREDRAW?|?CS_DBLCLKS?
::LoadCursor(?NULL?IDC_ARROW?)?HBRUSH(?COLOR_WINDOW?+?1?)?NULL?);
return?TRUE;
}
BOOL?CChildView::PreTranslateMessage(?MSG*?pMsg?)
{
if?(?pMsg->message?==?WM_KEYDOWN?&&?(?pMsg->wParam?==?VK_RETURN?||?pMsg->wParam?==?VK_SPACE?)?)
{
if?(?++m_nFloorIndex?>=?3?)
m_nFloorIndex?=?0;
}
return?CWnd::PreTranslateMessage(?pMsg?);
}
int?CChildView::OnCreate(?LPCREATESTRUCT?lpCreateStruct?)
{
if?(?CWnd::OnCreate(?lpCreateStruct?)?==?-1?)
{
TRACE0(?“Failed?to?create?the?CChildView“?);
return?-1;
}
m_lpThread?=?AfxBeginThread(?Thread?NULL?THREAD_PRIORITY_NORMAL?0?CREATE_SUSPENDED?);
ASSERT(?m_lpThread?);
InitOpenGL();
SetTimer(?1?50?NULL?);
m_lpThread->ResumeThread();
return?0;
}
void?CChildView::OnSize(?UINT?nType?int?cx?int?cy?)
{
CWnd::OnSize(?nType?cx?cy?);
if?(?cy?==?0?)
cy?=?1;
glViewport(?0?0?cx?cy?); //?Reset?The?Current?View-port
glMatrixMode(?GL_PROJECTION?); //?Select?The?Projection?Matrix
glLoadIdentity(); //?Reset?The?Projection?Matrix
//?Calculate?The?Aspect?Ratio?Of?The?Window
gluPerspective(?45.0f?(?GLfloat?)?cx?/?(?GLfloat?)?cy?0.1f?400.0f?);
glMatrixMode(?GL_MODELVIEW?); //?Select?The?Model-view?Matrix
glLoadIdentity();
}
void?CChildView::OnPaint()?
{
CPaintDC?dc(this);?//?device?context?for?painting
CBitmap?bitmap;
bitmap.LoadBitmap(?IDB_SNOW_FLOOR?);
//?TODO:?Add?your?message?handler?code?here
DrawOpenGLScene();
//?Do?not?call?CWnd::OnPaint()?for?painting?messages
}
BOOL?CChildView::OnEraseBkgnd(?CDC*?pDC?)
{
UNREFERENCED_PARAMETER(?pDC?);
return?TRUE;
}
void?CChildView::OnDestroy()
{
HGLRC?hrc?=?NU
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????10745??2006-08-31?00:04??ChildView.cpp
?????文件????????2404??2012-02-27?14:37??ChildView.h
?????目錄???????????0??2012-04-02?08:29??ipch\
?????目錄???????????0??2012-04-02?08:29??ipch\snowworld-8858a476\
?????文件????69861376??2012-04-02?08:29??ipch\snowworld-8858a476\snowworld-45f7a5.ipch
?????文件????????2558??2006-08-22?23:15??MainFrm.cpp
?????文件????????1639??2006-08-20?00:48??MainFrm.h
?????文件????????3590??2006-08-20?00:48??ReadMe.txt
?????目錄???????????0??2012-02-27?14:24??res\
?????文件?????????657??2006-08-30?22:31??Resource.h
?????目錄???????????0??2012-02-27?14:24??res\Data\
?????文件??????196662??1999-12-21?20:20??res\Data\SnowFloor.bmp
?????文件???????12342??1999-12-21?22:25??res\Data\SnowLarge.bmp
?????文件???????12342??1999-12-21?22:26??res\Data\SnowMiddle.bmp
?????文件???????12342??1999-12-21?22:26??res\Data\SnowSmall.bmp
?????文件??????115119??1997-06-03?05:03??res\Music.WAV
?????文件????????1078??2006-08-20?00:48??res\SnowWorld.ico
?????文件?????????401??2006-08-20?00:48??res\SnowWorld.rc2
?????文件??????372756??2012-04-02?08:45??SnowWorld.aps
?????文件????????3910??2006-08-30?22:21??SnowWorld.cpp
?????文件????????4461??2006-11-27?12:59??SnowWorld.dsp
?????文件?????????541??2006-08-20?00:48??SnowWorld.dsw
?????文件????????1400??2006-08-20?00:48??SnowWorld.h
?????文件???????58368??2012-02-27?13:55??SnowWorld.ncb
?????文件??????162304??2012-02-27?13:55??SnowWorld.opt
?????文件????????3602??2006-11-27?12:55??SnowWorld.plg
?????文件?????????148??2006-09-22?08:49??SnowWorld.positions
?????文件????????6617??2006-08-31?00:13??SnowWorld.rc
?????文件????56971264??2012-04-02?10:29??SnowWorld.sdf
?????文件?????????884??2012-02-27?14:36??SnowWorld.sln
?????文件???????12800??2012-04-02?10:29??SnowWorld.suo
............此處省略6個(gè)文件信息
評(píng)論
共有 條評(píng)論