This commit is contained in:
Daveo 2000-09-22 21:19:46 +00:00
parent 0cdff1e9c9
commit e04ad09c18
5 changed files with 196 additions and 51 deletions

View File

@ -4,8 +4,18 @@
#include "stdafx.h"
#include "gl3d.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
#include "GLEnabledView.h"
#include "MapEditDoc.h"
#include "MapEditView.h"
#include "Core.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
@ -18,6 +28,110 @@ CCore::~CCore()
{
}
/*****************************************************************************/
void CCore::Init(CMapEditView *Wnd)
{
ParentWindow=Wnd;
// TestLayer.Init();
// UpdateView();
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CCore::Render()
{
// if (RenderMode & RENDER_MODE_GFX) TestLayer.Render();
// if (RenderMode & RENDER_MODE_POS) TestLayer.UpdateCursor(this);
// RenderMode=0;
}
/*****************************************************************************/
void CCore::UpdateView(float XOfs,float YOfs,float ZOfs)
{
// RenderMode|= RENDER_MODE_POS;
// RenderMode|= RENDER_MODE_GFX;
// ViewPos=ViewPos+Vec(XOfs,YOfs,ZOfs);
// if (ViewPos.z>-1) ViewPos.z=-1;
// ParentWindow->Redraw();
}
/*****************************************************************************/
/*** Control *****************************************************************/
/*****************************************************************************/
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.LButtonControl(nFlags,point,DownFlag);
}
/*****************************************************************************/
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
if (DownFlag)
{
LastMousePos=point;
ParentWindow->SetCapture();
}
else
{
ReleaseCapture();
}
}
/*****************************************************************************/
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
{
// TestLayer.RButtonControl(nFlags,point,DownFlag);
}
/*****************************************************************************/
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
{
if (zDelta<0)
{
UpdateView(0,0,+1.0f);
}
if (zDelta>0)
{
UpdateView(0,0,-1.0f);
}
}
/*****************************************************************************/
void CCore::MouseMove(UINT nFlags, CPoint &Point,BOOL CaptureFlag)
{
float XOfs=0;
float YOfs=0;
CurrentMousePos=Point;
if (CaptureFlag)
{
float XS,YS;
RECT ThisRect;
ParentWindow->GetWindowRect(&ThisRect);
XS=ViewPos.z/((ThisRect.right-ThisRect.left));
YS=ViewPos.z/((ThisRect.bottom-ThisRect.top));
XOfs=LastMousePos.x-CurrentMousePos.x;
YOfs=LastMousePos.y-CurrentMousePos.y;
LastMousePos=Point;
XOfs*=XS;
YOfs*=YS;
}
UpdateView(-XOfs,-YOfs,0);
if (nFlags & MK_LBUTTON) LButtonControl(nFlags,Point,TRUE);
if (nFlags & MK_RBUTTON) RButtonControl(nFlags,Point,TRUE);
}
/*****************************************************************************/
/*** Layer Code **************************************************************/
/*****************************************************************************/

View File

@ -6,6 +6,7 @@
#define __CORE_HEADER__
#include <Vector>
#include "gl3d.h"
/*****************************************************************************/
@ -17,11 +18,24 @@ struct sLayer
};
/*****************************************************************************/
class CMapEditView;
class CCore
{
public:
CCore();
~CCore();
// Control
void LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
void MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
void RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag);
void MouseWheel(UINT nFlags, short zDelta, CPoint &pt);
void MouseMove(UINT nFlags, CPoint &point, BOOL CaptureFlag);
// Blah
void Init(CMapEditView *Wnd);
void Render();
void UpdateView(float XOfs,float YOfs,float ZOfs);
// Layers
void LayerAdd(char *Name=0);
@ -36,9 +50,14 @@ public:
private:
CMapEditView *ParentWindow;
CPoint CurrentMousePos,LastMousePos;
Vec ViewPos;
std::vector<sLayer> Layers;
int ActiveLayer;
std::vector<sLayer> Layers;
int ActiveLayer;
};
/*****************************************************************************/

View File

@ -65,6 +65,7 @@ LINK32=link.exe
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
@ -77,7 +78,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 opengl32.lib glu32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
@ -96,8 +97,12 @@ SOURCE=.\Core.cpp
SOURCE=.\Core.h
# End Source File
# Begin Source File
SOURCE=.\gl3d.h
# End Source File
# End Group
# Begin Group "Windows"
# Begin Group "Shell"
# PROP Default_Filter ""
# Begin Group "Source Files"
@ -109,22 +114,10 @@ SOURCE=.\ChildFrm.cpp
# End Source File
# Begin Source File
SOURCE=.\gl3d.cpp
# End Source File
# Begin Source File
SOURCE=.\glcam.cpp
# End Source File
# Begin Source File
SOURCE=.\GLEnabledView.cpp
# End Source File
# Begin Source File
SOURCE=.\glfrust.cpp
# End Source File
# Begin Source File
SOURCE=.\LayerBar.cpp
# End Source File
# Begin Source File
@ -162,22 +155,10 @@ SOURCE=.\ChildFrm.h
# End Source File
# Begin Source File
SOURCE=.\gl3d.h
# End Source File
# Begin Source File
SOURCE=.\glcam.h
# End Source File
# Begin Source File
SOURCE=.\GLEnabledView.h
# End Source File
# Begin Source File
SOURCE=.\glfrust.h
# End Source File
# Begin Source File
SOURCE=.\LayerBar.h
# End Source File
# Begin Source File

View File

@ -6,7 +6,6 @@
#include <gl\glu.h>
#include <gl\glut.h>
#include "GLEnabledView.h"
#include "MapEdit.h"
#include "MapEditDoc.h"
@ -26,11 +25,14 @@ IMPLEMENT_DYNCREATE(CMapEditView, CGLEnabledView)
BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
//{{AFX_MSG_MAP(CMapEditView)
ON_WM_SETFOCUS()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEWHEEL()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CGLEnabledView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CGLEnabledView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CGLEnabledView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@ -38,9 +40,6 @@ END_MESSAGE_MAP()
CMapEditView::CMapEditView()
{
TRACE0("Here");
// TODO: add construction code here
}
CMapEditView::~CMapEditView()
@ -48,22 +47,35 @@ CMapEditView::~CMapEditView()
}
/////////////////////////////////////////////////////////////////////////////
// CMapEditView printing
BOOL CMapEditView::OnPreparePrinting(CPrintInfo* pInfo)
void CMapEditView::VideoMode(ColorsNumber & c, ZAccuracy & z, BOOL & dbuf)
{
// default preparation
return DoPreparePrinting(pInfo);
c=THOUSANDS; // ask for 65355 colors...
z=NORMAL; // ...16 bit Z-buffer...
dbuf=TRUE; // ...double-buffering
}
void CMapEditView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnCreateGL()
{
// TODO: add extra initialization before printing
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is SetUp)
glEnable(GL_LIGHTING); // Enable Lighting
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
//Core.Init(this);
}
void CMapEditView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
/////////////////////////////////////////////////////////////////////////////
void CMapEditView::OnDrawGL()
{
// TODO: add cleanup after printing
// Core.Render();
}
/////////////////////////////////////////////////////////////////////////////
@ -99,3 +111,17 @@ CMapEditDoc *CurDoc=GetDocument();
CurDoc->UpdateAll(); // woohoo, that was easy
}
/*********************************************************************************/
/*********************************************************************************/
/*********************************************************************************/
void CMapEditView::OnLButtonDown(UINT nFlags, CPoint point) {}
void CMapEditView::OnLButtonUp(UINT nFlags, CPoint point) {}
void CMapEditView::OnMButtonDown(UINT nFlags, CPoint point) {}
void CMapEditView::OnMButtonUp(UINT nFlags, CPoint point) {}
BOOL CMapEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) {return(0);}
void CMapEditView::OnRButtonDown(UINT nFlags, CPoint point) {}
void CMapEditView::OnRButtonUp(UINT nFlags, CPoint point) {}
/*********************************************************************************/

View File

@ -5,6 +5,7 @@
#if !defined(AFX_MAPEDITVIEW_H__DBE61BE7_547C_43E9_BC46_E55636495066__INCLUDED_)
#define AFX_MAPEDITVIEW_H__DBE61BE7_547C_43E9_BC46_E55636495066__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
@ -18,17 +19,14 @@ protected: // create from serialization only
// Attributes
public:
CMapEditDoc* GetDocument();
void OnCreateGL();
void OnDrawGL();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMapEditView)
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
@ -40,11 +38,18 @@ public:
#endif
protected:
void VideoMode(ColorsNumber &c,ZAccuracy &z,BOOL &dbuf);
// Generated message map functions
protected:
//{{AFX_MSG(CMapEditView)
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};