资源简介
很绚丽的雪花飞舞场景。使用openGL完成。
代码片段和文件信息
// 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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 10745 2006-08-31 00:04 SnowWorld\ChildView.cpp
文件 2404 2006-08-31 00:00 SnowWorld\ChildView.h
文件 40734 2007-11-23 12:20 SnowWorld\Debug\ChildView.obj
文件 23641 2007-11-23 12:20 SnowWorld\Debug\MainFrm.obj
文件 540763 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.exe
文件 295564 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.ilk
文件 26977 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.obj
文件 5502316 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.pch
文件 328704 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.pdb
文件 351800 2007-11-23 12:20 SnowWorld\Debug\SnowWorld.res
文件 105842 2007-11-23 12:20 SnowWorld\Debug\StdAfx.obj
文件 214016 2007-11-23 12:20 SnowWorld\Debug\vc60.idb
文件 380928 2007-11-23 12:20 SnowWorld\Debug\vc60.pdb
目录 0 2007-11-23 12:21 SnowWorld\Debug
文件 2558 2006-08-22 23:15 SnowWorld\MainFrm.cpp
文件 1639 2006-08-20 00:48 SnowWorld\MainFrm.h
文件 3590 2006-08-20 00:48 SnowWorld\ReadMe.txt
文件 196662 1999-12-21 20:20 SnowWorld\res\Data\SnowFloor.bmp
文件 12342 1999-12-21 22:25 SnowWorld\res\Data\SnowLarge.bmp
文件 12342 1999-12-21 22:26 SnowWorld\res\Data\SnowMiddle.bmp
文件 12342 1999-12-21 22:26 SnowWorld\res\Data\SnowSmall.bmp
目录 0 2007-11-23 12:21 SnowWorld\res\Data
文件 115119 1997-06-03 05:03 SnowWorld\res\Music.WAV
文件 1078 2006-08-20 00:48 SnowWorld\res\SnowWorld.ico
文件 401 2006-08-20 00:48 SnowWorld\res\SnowWorld.rc2
目录 0 2007-11-23 12:21 SnowWorld\res
文件 657 2006-08-30 22:31 SnowWorld\Resource.h
文件 3910 2006-08-30 22:21 SnowWorld\SnowWorld.cpp
文件 4457 2006-08-30 22:51 SnowWorld\SnowWorld.dsp
文件 541 2006-08-20 00:48 SnowWorld\SnowWorld.dsw
............此处省略12个文件信息
- 上一篇:串口温度数据采集系统并实时显示曲线
- 下一篇:商城网站模板包括管理后台
评论
共有 条评论