void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); }
#endif //_DEBUG
// CMainFrame message handlers void CMainFrame::OnPaint() { CPaintDC dc(this); // device context for painting }
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { if (!m_wndSplitter.CreateStatic(this, 1, 2,WS_CHILD | WS_VISIBLE)) { TRACE(\ return FALSE; } // First splitter pane if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CRenderView), CSize(600,500), pContext)) { TRACE(\ return FALSE; } if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CFormCommandView), CSize(0,0), pContext)) { TRACE(\ return FALSE; } // Second splitter pane return TRUE; }
4、RenderView.cpp
11
#include \#include \#include
#include \#include \
#ifdef _DEBUG
#define new DEBUG_NEW #undef THIS_FILE
static char THIS_FILE[] = __FILE__; #endif
extern void Render(void);
// This is the holding space for the landscape colours.
int WinWidth, WinHeigth;
unsigned short int comp = 32; // Scale modifier.
unsigned short int temp, texture_mapping = FALSE,
land_fogging = TRUE, flat_shading = TRUE;
float angle, Near, ex, ey, ez, cx, cy, cz;
// Initial eye position and vector of sight. static GLfloat speed = 0;
// The following code for mouse routines was contributed. // These are used for the motion function. #define FORWARD 1 #define UP 2
#define TURNLEFT 3 #define LOOKUP 5
// Mouse position and button.
12
int oldmx = 0, oldmy = 0, mb;
// CRenderView
IMPLEMENT_DYNCREATE(CRenderView, CView)
BEGIN_MESSAGE_MAP(CRenderView, CView) //{{AFX_MSG_MAP(CRenderView) ON_WM_DESTROY() ON_WM_SIZE()
ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() ON_WM_PAINT() ON_WM_CREATE() //}}AFX_MSG_MAP // Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP()
// CRenderView construction/destruction
CRenderView::CRenderView() {
// OpenGL
m_hGLContext = NULL; m_GLPixelIndex = 0;
// Mouse
m_LeftButtonDown = FALSE; m_RightButtonDown = FALSE;
m_CursorRotation = AfxGetApp()->LoadCursor(IDC_CURSOR_ROTATION);
// Colors
CToolApp *pApp = (CToolApp *)AfxGetApp();
m_ClearColorRed = GetRValue(pApp->m_OptionColorGlBack); m_ClearColorGreen = GetGValue(pApp->m_OptionColorGlBack); m_ClearColorBlue = GetBValue(pApp->m_OptionColorGlBack);
13
ReadData();
WinWidth=1000; WinHeigth=800; LoadAllTexture(); InitLookAt(); }
//============================================ // InitGeometry
//============================================ void CRenderView::InitGeometry(void) {
GLfloat fogColor[4] = {0.75, 0.75, 1.0, 1.0};
speed = 0;
srand(224);
srand((unsigned)time(NULL));
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glEnable(GL_DEPTH_TEST); glShadeModel(GL_FLAT);
glFogi(GL_FOG_MODE, GL_LINEAR); glFogfv(GL_FOG_COLOR, fogColor); glFogf(GL_FOG_DENSITY, 0.8f); glFogf(GL_FOG_START, 400.0f); glFogf(GL_FOG_END, 500.0f); glClearColor(0.75f, 0.75f, 1.0f, 1.0f); }
CRenderView::~CRenderView() { FreeAllTexture(); freelist(); }
BOOL CRenderView::PreCreateWindow(CREATESTRUCT& cs) {
return CView::PreCreateWindow(cs);
14
}
// CRenderView drawing
void CRenderView::OnDraw(CDC* pDC) { }
BOOL CRenderView::OnPreparePrinting(CPrintInfo* pInfo) {
return DoPreparePrinting(pInfo); }
void CRenderView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { }
void CRenderView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { }
// CRenderView diagnostics #ifdef _DEBUG
void CRenderView::AssertValid() const {
CView::AssertValid(); }
void CRenderView::Dump(CDumpContext& dc) const {
CView::Dump(dc); }
CToolDoc* CRenderView::GetDocument() // non-debug version is inline {
if (m_pDocument){
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CToolDoc))); return (CToolDoc*)m_pDocument; }
else return NULL;
15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库研究生计算机图形学课程室内场景OpenGL--实验报告(3)在线全文阅读。
相关推荐: