SBSPSS/Utils/MapEdit/MapEditView.cpp

151 lines
4.1 KiB
C++
Raw Normal View History

2000-09-22 17:11:29 +02:00
// MapEditView.cpp : implementation of the CMapEditView class
//
2000-09-22 18:56:20 +02:00
#include "stdafx.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include "GLEnabledView.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
#include "MapEditView.h"
2000-09-25 17:43:52 +02:00
#include "MainFrm.h"
2000-09-22 17:11:29 +02:00
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMapEditView
2000-09-22 18:56:20 +02:00
IMPLEMENT_DYNCREATE(CMapEditView, CGLEnabledView)
2000-09-22 17:11:29 +02:00
2000-09-22 18:56:20 +02:00
BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
2000-09-22 17:11:29 +02:00
//{{AFX_MSG_MAP(CMapEditView)
2000-09-22 23:19:46 +02:00
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEWHEEL()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
2000-09-25 17:43:52 +02:00
ON_WM_MOUSEMOVE()
2001-02-14 23:35:47 +01:00
ON_WM_SETFOCUS()
2000-09-22 17:11:29 +02:00
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMapEditView construction/destruction
CMapEditView::CMapEditView()
{
}
CMapEditView::~CMapEditView()
{
}
/////////////////////////////////////////////////////////////////////////////
2000-09-22 23:19:46 +02:00
void CMapEditView::VideoMode(ColorsNumber & c, ZAccuracy & z, BOOL & dbuf)
2000-09-22 17:11:29 +02:00
{
2000-12-29 23:20:38 +01:00
c=MILLIONS;
z=NORMAL;
dbuf=TRUE;
2000-09-22 17:11:29 +02:00
}
2000-09-22 23:19:46 +02:00
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnCreateGL()
2000-09-22 17:11:29 +02:00
{
2000-11-17 22:36:13 +01:00
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Background Color
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
2000-11-28 00:07:07 +01:00
glEnable(GL_BLEND); // Enable Alpha Channel
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
2000-09-22 17:11:29 +02:00
}
2000-11-03 23:40:41 +01:00
2000-10-30 22:16:48 +01:00
/////////////////////////////////////////////////////////////////////////////
2000-11-06 21:24:11 +01:00
2000-09-22 23:19:46 +02:00
void CMapEditView::OnDrawGL()
2000-09-22 17:11:29 +02:00
{
2001-02-14 23:35:47 +01:00
GetDocument()->Render();
2000-09-22 17:11:29 +02:00
}
2000-11-03 23:40:41 +01:00
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnSizeGL(int cx, int cy)
{
2000-12-29 23:20:38 +01:00
// cy=cx/1.5f;
2000-11-03 23:40:41 +01:00
glViewport(0,0,cx,cy);
2000-11-28 00:07:07 +01:00
2000-11-03 23:40:41 +01:00
// update the camera
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
SetupPersMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
2001-02-14 23:35:47 +01:00
GetDocument()->UpdateView();
2000-11-03 23:40:41 +01:00
}
/////////////////////////////////////////////////////////////////////////////
2000-11-06 21:24:11 +01:00
void CMapEditView::SetupPersMatrix()
2000-11-03 23:40:41 +01:00
{
2000-11-28 00:07:07 +01:00
gluPerspective(40.0,m_dAspectRatio,0.1f, 100.0f);
2000-12-29 23:20:38 +01:00
glTranslatef(0.0f,0.0f,-1.f);
2000-11-03 23:40:41 +01:00
}
2000-11-06 21:24:11 +01:00
2000-09-22 17:11:29 +02:00
/////////////////////////////////////////////////////////////////////////////
// CMapEditView diagnostics
#ifdef _DEBUG
void CMapEditView::AssertValid() const
{
2000-09-22 18:56:20 +02:00
CGLEnabledView::AssertValid();
2000-09-22 17:11:29 +02:00
}
void CMapEditView::Dump(CDumpContext& dc) const
{
2000-09-22 18:56:20 +02:00
CGLEnabledView::Dump(dc);
2000-09-22 17:11:29 +02:00
}
CMapEditDoc* CMapEditView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMapEditDoc)));
return (CMapEditDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMapEditView message handlers
2001-02-14 23:35:47 +01:00
void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(nFlags,point,TRUE);}
void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {GetDocument()->LButtonControl(nFlags,point,FALSE);}
void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(nFlags,point,TRUE);}
void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {GetDocument()->MButtonControl(nFlags,point,FALSE);}
BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {GetDocument()->MouseWheel(nFlags,zDelta,pt) ;return(0);}
void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(nFlags,point,TRUE);}
void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {GetDocument()->RButtonControl(nFlags,point,FALSE);}
void CMapEditView::OnMouseMove(UINT nFlags, CPoint point) {GetDocument()->MouseMove(nFlags, point);}
void CMapEditView::OnSetFocus(CWnd* pOldWnd)
{
CGLEnabledView::OnSetFocus(pOldWnd);
theApp.SetCurrent(GetDocument());
}
void CMapEditView::OnInitialUpdate()
2001-02-09 22:17:01 +01:00
{
2001-02-14 23:35:47 +01:00
CGLEnabledView::OnInitialUpdate();
GetDocument()->SetView(this);
2001-02-09 22:17:01 +01:00
}
2001-02-14 23:35:47 +01:00