This commit is contained in:
parent
5c730d9614
commit
0cdff1e9c9
7 changed files with 1684 additions and 52 deletions
1361
Utils/MapEdit/GLEnabledView.cpp
Normal file
1361
Utils/MapEdit/GLEnabledView.cpp
Normal file
File diff suppressed because it is too large
Load diff
248
Utils/MapEdit/GLEnabledView.h
Normal file
248
Utils/MapEdit/GLEnabledView.h
Normal file
|
@ -0,0 +1,248 @@
|
|||
#if !defined(AFX_GLENABLEDVIEW_H__59CED13F_E584_11D1_ACB3_E52ED8AC9002__INCLUDED_)
|
||||
#define AFX_GLENABLEDVIEW_H__59CED13F_E584_11D1_ACB3_E52ED8AC9002__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGLEnabledView.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Global type definitions
|
||||
enum ColorsNumber{INDEXED,THOUSANDS,MILLIONS,MILLIONS_WITH_TRANSPARENCY};
|
||||
enum ZAccuracy{NORMAL,ACCURATE};
|
||||
struct GLInfoStruct
|
||||
{
|
||||
CString vendor;
|
||||
CString renderer;
|
||||
CString acceleration;
|
||||
CString glextensions;
|
||||
CString glversion;
|
||||
CString gluextensions;
|
||||
CString gluversion;
|
||||
int max_lights;
|
||||
int max_clip_planes;
|
||||
int max_model_stack_depth;
|
||||
int max_proj_stack_depth;
|
||||
int max_txtr_stack_depth;
|
||||
int max_name_stack_depth;
|
||||
int max_attrib_stack_depth;
|
||||
int max_texture_size;
|
||||
int max_list_nesting;
|
||||
int max_eval_order;
|
||||
CSize max_viewport_dims;
|
||||
int auxiliary_buffers;
|
||||
int max_smooth_point_size;
|
||||
int min_smooth_point_size;
|
||||
float smooth_point_granularity;
|
||||
int max_smooth_line_size;
|
||||
int min_smooth_line_size;
|
||||
float smooth_line_granularity;
|
||||
int red_bits;
|
||||
int blue_bits;
|
||||
int green_bits;
|
||||
int alpha_bits;
|
||||
int depth_bits;
|
||||
int stencil_bits;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGLEnabledView view
|
||||
|
||||
class CGLEnabledView : public CView
|
||||
{
|
||||
protected:
|
||||
CGLEnabledView();// protected constructor used by dynamic creation
|
||||
DECLARE_DYNCREATE(CGLEnabledView)
|
||||
/** CGLDispList
|
||||
DESC:-this is an helper class which let you create "display list objects",
|
||||
use these objects to define the key elements in your scene (a disp.
|
||||
list is faster than the corresponding GL commands).
|
||||
-Through the class members functions you have total control on a
|
||||
single display list.
|
||||
-An isolated display list save OGL parameters before execution
|
||||
(so it's not affected by preceding transformations or settings).
|
||||
*******/
|
||||
class CGLDispList
|
||||
{
|
||||
friend class CGLEnabledView;
|
||||
private:
|
||||
BOOL m_bIsolated;
|
||||
int m_glListId;
|
||||
public:
|
||||
CGLDispList(); // constructor
|
||||
~CGLDispList(); // destructor
|
||||
void StartDef(BOOL bImmediateExec=FALSE);// enclose a disp.list def.
|
||||
void EndDef();
|
||||
void Draw();// execute disp list GL commands
|
||||
void SetIsolation(BOOL bValue) {m_bIsolated=bValue;}; // set isolation property
|
||||
};
|
||||
|
||||
/** CGLTesselator
|
||||
DESC:-this is a wrapper class which let you create "tesselator objects",
|
||||
use these objects to create concave or self intersecting polygons.
|
||||
-OGL tessellation objects converts a vertices list describing a convex
|
||||
or self-intersecting polygon in one or more GL primitives.Read the
|
||||
docs to understand the callbacks mechanism.
|
||||
-The callbacks have been defined as a simple and direct mapping to
|
||||
corresponding GL primitive (no per vertex color or texture information).
|
||||
-The callbacks have to be global functions.
|
||||
-A very simple garbage collection list has been implemented to manage new
|
||||
vertices create by combine callback.
|
||||
-Elaboration and drawing occur after EndDef().
|
||||
*******/
|
||||
class CGLTesselator
|
||||
{
|
||||
public:
|
||||
CGLTesselator(); // constructor
|
||||
~CGLTesselator(); // destructor
|
||||
// properties functions
|
||||
void SetFilling(BOOL bFill=TRUE);
|
||||
BOOL GetFilling();
|
||||
void SetWindingRule(GLdouble which);
|
||||
GLdouble GetWindingRule();
|
||||
// definition functions
|
||||
void StartDef();
|
||||
void AddVertexArray(GLdouble arr[][3],int size);
|
||||
void AddVertex(GLdouble vertData[3]);
|
||||
void ContourSeparator();
|
||||
void EndDef();// here occur drawing
|
||||
|
||||
private:
|
||||
GLUtesselator* m_tessObj;
|
||||
};
|
||||
|
||||
/** CGLQuadric
|
||||
DESC:-This is a wrapper class which let you create "quadric objects",
|
||||
use these objects to create spheres, disks and cylinders.
|
||||
-All GL commands related to quadrics have been wrapped hiding the
|
||||
quadric object parameter.
|
||||
*******/
|
||||
class CGLQuadric
|
||||
{
|
||||
public:
|
||||
CGLQuadric(GLenum drwStyle=GLU_FILL, // constructor
|
||||
GLenum normals=GLU_FLAT,
|
||||
GLenum side=GLU_OUTSIDE,
|
||||
BOOL bGenerateTxtrCoords=FALSE);
|
||||
~CGLQuadric(); // destructor
|
||||
// properties functions
|
||||
void SetDrawStyle(GLenum style);
|
||||
void SetOrientation(GLenum type);
|
||||
void SetTextureCoordsGen(BOOL flag);
|
||||
void SetNormals(GLenum type);
|
||||
// drawing functions
|
||||
void DrawPartialDisk(GLdouble innerRadius,GLdouble outerRadius,int slices,int loops,GLdouble startAngle,GLdouble sweepAngle);
|
||||
void DrawDisk(GLdouble innerRadius,GLdouble outerRadius,int slices,int loops);
|
||||
void DrawCylinder(GLdouble baseRadius,GLdouble topRadius,GLdouble height,int slices,int stacks);
|
||||
void DrawSphere(GLdouble radius,int longitudeSubdiv,int latitudeSubdiv);
|
||||
|
||||
private:
|
||||
GLUquadricObj* m_quadrObj;
|
||||
};
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
/* Stock Display lists functions
|
||||
DESC.: these display lists are internally organized in a vector (20 max),
|
||||
you have control on definition and redrawing only.
|
||||
use them for background elements which are to be drawn everytime
|
||||
all together.
|
||||
NOTE: between BeginStockDispList and EndStockDispList should be present OpenGL calls only (see documentation for which are allowed and how are them treated)
|
||||
*/
|
||||
void StartStockDListDef(); // allocates a new stock display list entry and opens a display list definition
|
||||
void EndStockListDef(); // closes a stock display list definition
|
||||
void DrawStockDispLists(); // executes all the stock display lists
|
||||
void ClearStockDispLists(); // deletes all the stock display lists
|
||||
// Information retrieval function
|
||||
GLInfoStruct GetInformation();
|
||||
// Mouse cursor function
|
||||
void SetMouseCursor(HCURSOR mcursor=NULL);
|
||||
// Attribute retrieval function
|
||||
double GetAspectRatio() {return m_dAspectRatio;};
|
||||
// Text functions
|
||||
void PrepareCharset3D(CString fontname,float extrusion,BOOL boldface=FALSE,BOOL italicface=FALSE,BOOL uselines=false,float precision=0.01f);// prepare a 3D charset to be used by successive Text3D calls
|
||||
void PrepareCharset3D(const LOGFONT* pLF,float extrusion,BOOL uselines=false,float precision=0.01f);// alternate method to prepare a 3D charset
|
||||
void PrepareCharset2D(CString fontname,int height=10,BOOL boldface=FALSE,BOOL italicface=FALSE);// prepare a 2D charset to be used by successive Text2D calls
|
||||
void PrepareCharset2D(const LOGFONT* pLF);// alternate method to prepare a 2D charset
|
||||
float Text3D(CString text);// draw a 3D text string
|
||||
void Text2D(CString text);// draw a bitmapped text string at the current raster position
|
||||
// Rendering Context switching
|
||||
void BeginGLCommands();// use to issue GL commands outside Overridables
|
||||
void EndGLCommands();// i.e: in menu event handlers, button events handler etc.
|
||||
// Overridables
|
||||
virtual void OnCreateGL(); // override to set bg color, activate z-buffer, and other global settings
|
||||
virtual void OnSizeGL(int cx, int cy); // override to adapt the viewport to the window
|
||||
virtual void OnDrawGL(); // override to issue drawing functions
|
||||
virtual void VideoMode(ColorsNumber &c,ZAccuracy &z,BOOL &dbuf); // override to specify some video mode parameters
|
||||
|
||||
// Overrides
|
||||
// NOTE: these have been declared private because they shouldn't be
|
||||
// overridden, use the provided virtual functions instead.
|
||||
private:
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CGLEnabledView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
protected:
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
int m_glErrorCode;
|
||||
virtual ~CGLEnabledView();
|
||||
CRect m_ClientRect; // client area size
|
||||
double m_dAspectRatio; // aspect
|
||||
GLYPHMETRICSFLOAT* m_gmfvector;
|
||||
const int m_numchars;
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
// NOTE: these have been declared private because they shouldn't be
|
||||
// overridden, use the provided virtual functions instead.
|
||||
private:
|
||||
//{{AFX_MSG(CGLEnabledView)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
// member variables
|
||||
private:
|
||||
CDC* m_pCDC; // WinGDI Device Context
|
||||
HGLRC m_hRC; // OpenGL Rendering Context
|
||||
HCURSOR m_hMouseCursor; // mouse cursor handle for the view
|
||||
CPalette m_CurrentPalette; // palettes
|
||||
CPalette* m_pOldPalette;
|
||||
int m_DispListVector[20]; // Internal stock display list vector
|
||||
BOOL m_bInsideDispList; // Disp List definition semaphore
|
||||
BOOL m_bExternGLCall;
|
||||
BOOL m_bExternDispListCall;
|
||||
int m_charsetDListBase;
|
||||
// initialization helper functions
|
||||
unsigned char ComponentFromIndex(int i, UINT nbits, UINT shift);
|
||||
void CreateRGBPalette();
|
||||
BOOL bSetupPixelFormat();
|
||||
|
||||
CDC* GetCDC() {return m_pCDC;};
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_GLENABLEDVIEW_H__59CED13F_E584_11D1_ACB3_E52ED8AC9002__INCLUDED_)
|
|
@ -51,7 +51,7 @@ HeaderFile=MapEditView.h
|
|||
ImplementationFile=MapEditView.cpp
|
||||
Filter=W
|
||||
LastObject=CMapEditView
|
||||
BaseClass=CView
|
||||
BaseClass=CGLEnabledView
|
||||
VirtualFilter=VWC
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ Type=0
|
|||
HeaderFile=ChildFrm.h
|
||||
ImplementationFile=ChildFrm.cpp
|
||||
Filter=M
|
||||
LastObject=IDC_LAYERBAR_LIST
|
||||
LastObject=CChildFrame
|
||||
|
||||
|
||||
[CLS:CAboutDlg]
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
// MapEdit.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MapEdit.h"
|
||||
#include "stdafx.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "ChildFrm.h"
|
||||
#include "MapEditDoc.h"
|
||||
#include "MapEditView.h"
|
||||
#include "MapEdit.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "ChildFrm.h"
|
||||
#include "MapEditDoc.h"
|
||||
#include "MapEditView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
|
|
@ -85,6 +85,21 @@ LINK32=link.exe
|
|||
|
||||
# Name "MapEdit - Win32 Release"
|
||||
# Name "MapEdit - Win32 Debug"
|
||||
# Begin Group "MapEditor"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Core.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Core.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
|
@ -94,7 +109,19 @@ SOURCE=.\ChildFrm.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Core.cpp
|
||||
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
|
||||
|
||||
|
@ -135,7 +162,19 @@ SOURCE=.\ChildFrm.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Core.h
|
||||
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
|
||||
|
||||
|
@ -186,9 +225,6 @@ SOURCE=.\res\MapEditDoc.ico
|
|||
SOURCE=.\res\Toolbar.bmp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ReadMe.txt
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
// MapEditView.cpp : implementation of the CMapEditView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MapEdit.h"
|
||||
#include "stdafx.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include "GLEnabledView.h"
|
||||
|
||||
#include "MapEditDoc.h"
|
||||
#include "MapEditView.h"
|
||||
#include "MapEdit.h"
|
||||
|
||||
#include "MapEditDoc.h"
|
||||
#include "MapEditView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
@ -16,16 +21,16 @@ static char THIS_FILE[] = __FILE__;
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMapEditView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMapEditView, CView)
|
||||
IMPLEMENT_DYNCREATE(CMapEditView, CGLEnabledView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMapEditView, CView)
|
||||
BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
|
||||
//{{AFX_MSG_MAP(CMapEditView)
|
||||
ON_WM_SETFOCUS()
|
||||
//}}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)
|
||||
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()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -33,6 +38,7 @@ END_MESSAGE_MAP()
|
|||
|
||||
CMapEditView::CMapEditView()
|
||||
{
|
||||
TRACE0("Here");
|
||||
// TODO: add construction code here
|
||||
|
||||
}
|
||||
|
@ -41,24 +47,6 @@ CMapEditView::~CMapEditView()
|
|||
{
|
||||
}
|
||||
|
||||
BOOL CMapEditView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMapEditView drawing
|
||||
|
||||
void CMapEditView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CMapEditDoc* pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
// TODO: add draw code for native data here
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMapEditView printing
|
||||
|
||||
|
@ -84,12 +72,12 @@ void CMapEditView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
|||
#ifdef _DEBUG
|
||||
void CMapEditView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
CGLEnabledView::AssertValid();
|
||||
}
|
||||
|
||||
void CMapEditView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
CGLEnabledView::Dump(dc);
|
||||
}
|
||||
|
||||
CMapEditDoc* CMapEditView::GetDocument() // non-debug version is inline
|
||||
|
@ -104,12 +92,10 @@ CMapEditDoc* CMapEditView::GetDocument() // non-debug version is inline
|
|||
|
||||
void CMapEditView::OnSetFocus(CWnd* pOldWnd)
|
||||
{
|
||||
|
||||
CMapEditDoc *CurDoc=GetDocument();
|
||||
CView::OnSetFocus(pOldWnd);
|
||||
CGLEnabledView::OnSetFocus(pOldWnd);
|
||||
theApp.SetCurrent(CurDoc);
|
||||
|
||||
CurDoc->UpdateAll(); // woohoo, that was easy
|
||||
|
||||
// TODO: Add your message handler code here
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
class CMapEditView : public CView
|
||||
class CMapEditView : public CGLEnabledView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMapEditView();
|
||||
|
@ -26,9 +25,6 @@ public:
|
|||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMapEditView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
protected:
|
||||
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
|
||||
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue