ChildView.cpp in snowworld.rar
Sponsored links
// 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(CChildView,CWnd )
//{{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();
re
...
...
... to be continued.
This is a preview. To get the complete source file,
please click here to download the whole source code package.