From b12678f45145cbb9e98682e9256d0d21a94156e7 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 16 Dec 2003 23:21:09 +0000 Subject: Fixed crash on exit. git-svn-id: http://svn.leocad.org/trunk@351 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/project.cpp | 19 +++++++++++-------- common/project.h | 44 ++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 30 deletions(-) (limited to 'common') diff --git a/common/project.cpp b/common/project.cpp index bc04775..dacfae9 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -28,6 +28,7 @@ #include "mainwnd.h" #include "view.h" #include "library.h" +#include "texfont.h" // FIXME: temporary function, replace the code !!! void SystemUpdateFocus (void* p) @@ -110,6 +111,7 @@ Project::Project() m_pClipboard[i] = NULL; m_pLibrary = new PiecesLibrary (); + m_pScreenFont = new TexFont(); } Project::~Project() @@ -131,6 +133,7 @@ Project::~Project() delete m_pTerrain; delete m_pBackground; + delete m_pScreenFont; delete m_pLibrary; } @@ -2055,7 +2058,7 @@ void Project::RenderScene(bool bShaded, bool bDrawViewports) m.SetTranslation(0,0,0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - m_ScreenFont.MakeCurrent(); + m_pScreenFont->MakeCurrent(); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); @@ -2063,7 +2066,7 @@ void Project::RenderScene(bool bShaded, bool bDrawViewports) glTranslatef(1.4f*ds, 0, 0); glMultMatrixf(m.m); glBegin(GL_QUADS); - m_ScreenFont.PrintCharScaled (0.025f * ds, 'X'); + m_pScreenFont->PrintCharScaled (0.025f * ds, 'X'); glEnd(); glPopMatrix(); @@ -2071,7 +2074,7 @@ void Project::RenderScene(bool bShaded, bool bDrawViewports) glTranslatef(0, 1.4f*ds, 0); glMultMatrixf(m.m); glBegin(GL_QUADS); - m_ScreenFont.PrintCharScaled (0.025f * ds, 'Y'); + m_pScreenFont->PrintCharScaled (0.025f * ds, 'Y'); glEnd(); glPopMatrix(); @@ -2079,7 +2082,7 @@ void Project::RenderScene(bool bShaded, bool bDrawViewports) glTranslatef(0, 0, 1.4f*ds); glMultMatrixf(m.m); glBegin(GL_QUADS); - m_ScreenFont.PrintCharScaled (0.025f * ds, 'Z'); + m_pScreenFont->PrintCharScaled (0.025f * ds, 'Z'); glEnd(); glPopMatrix(); @@ -2442,7 +2445,7 @@ void Project::RenderViewports(bool bBackground, bool bLines) if (!bBackground) glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - m_ScreenFont.MakeCurrent(); + m_pScreenFont->MakeCurrent(); glEnable(GL_ALPHA_TEST); glBegin(GL_QUADS); @@ -2453,7 +2456,7 @@ void Project::RenderViewports(bool bBackground, bool bLines) w = viewports[m_nViewportMode].dim[vp][2] * (float)(m_nViewX - 1); h = viewports[m_nViewportMode].dim[vp][3] * (float)(m_nViewY - 1); - m_ScreenFont.PrintText (x + 3, y + h - 6, m_pViewCameras[vp]->GetName ()); + m_pScreenFont->PrintText (x + 3, y + h - 6, m_pViewCameras[vp]->GetName ()); } glEnd(); @@ -2592,7 +2595,7 @@ void Project::RenderInitialize() glDisable (GL_FOG); // Load font - if (!m_ScreenFont.IsLoaded ()) + if (!m_pScreenFont->IsLoaded ()) { char filename[LC_MAXPATH]; FileDisk file; @@ -2601,7 +2604,7 @@ void Project::RenderInitialize() strcat (filename, "sysfont.txf"); if (file.Open (filename, "rb")) - m_ScreenFont.FileLoad (file); + m_pScreenFont->FileLoad (file); } glAlphaFunc(GL_GREATER, 0.0625); diff --git a/common/project.h b/common/project.h index c06a591..8026e25 100644 --- a/common/project.h +++ b/common/project.h @@ -5,13 +5,12 @@ #include "defines.h" #include "typedefs.h" #include "opengl.h" -#include "texfont.h" #include "array.h" typedef enum { - LC_TRACK_NONE, LC_TRACK_START_LEFT, LC_TRACK_LEFT, - LC_TRACK_START_RIGHT, LC_TRACK_RIGHT + LC_TRACK_NONE, LC_TRACK_START_LEFT, LC_TRACK_LEFT, + LC_TRACK_START_RIGHT, LC_TRACK_RIGHT } LC_MOUSE_TRACK; class Piece; @@ -25,6 +24,7 @@ class Matrix; class View; class Image; class PiecesLibrary; +class TexFont; // Undo support @@ -32,10 +32,10 @@ class PiecesLibrary; typedef struct LC_UNDOINFO { - FileMem file; - char strText[21]; - LC_UNDOINFO* pNext; - LC_UNDOINFO() { pNext = NULL; }; + FileMem file; + char strText[21]; + LC_UNDOINFO* pNext; + LC_UNDOINFO() { pNext = NULL; }; } LC_UNDOINFO; class Project @@ -52,19 +52,19 @@ public: { return m_bModified; } void SetModifiedFlag(bool bModified) { m_bModified = bModified; } - + // Access to protected members unsigned char GetLastStep(); bool IsAnimation() { return m_bAnimation; } unsigned short GetCurrentTime () - { return m_bAnimation ? m_nCurFrame : m_nCurStep; } + { return m_bAnimation ? m_nCurFrame : m_nCurStep; } void SetCurrentPiece(PieceInfo* pInfo) { m_pCurPiece = pInfo; } int GetCurrentColor () const { return m_nCurColor; } - int GetCurrentGroup () const - { return m_nCurGroup; } + int GetCurrentGroup () const + { return m_nCurGroup; } float* GetBackgroundColor() { return m_fBackground; } Camera* GetCamera(int i); @@ -73,8 +73,8 @@ public: *from = m_bAnimation ? m_nCurFrame : m_nCurStep; *to = m_bAnimation ? m_nTotalFrames : 255; } - unsigned short GetTotalFrames () const - { return m_nTotalFrames; } + unsigned short GetTotalFrames () const + { return m_nTotalFrames; } void GetArrays(Piece** ppPiece, Camera** ppCamera, Light** ppLight) { @@ -83,8 +83,8 @@ public: *ppLight = m_pLights; } - PiecesLibrary* GetPiecesLibrary () const - { return m_pLibrary; } + PiecesLibrary* GetPiecesLibrary () const + { return m_pLibrary; } void SetPathName (const char* lpszPathName, bool bAddToMRU); void SetTitle (const char* lpszTitle); @@ -99,11 +99,11 @@ public: void CheckAutoSave(); void GetFocusPosition(float* pos); Object* GetFocusObject() const; - Group* AddGroup (const char* name, Group* pParent, float x, float y, float z); + Group* AddGroup (const char* name, Group* pParent, float x, float y, float z); - void AddView (View* pView); - void RemoveView (View* pView); - void UpdateAllViews (View* pSender = NULL); + void AddView (View* pView); + void RemoveView (View* pView); + void UpdateAllViews (View* pSender = NULL); // Implementation protected: @@ -112,7 +112,7 @@ protected: char m_strPathName[LC_MAXPATH]; bool m_bModified; // changed since last saved - PtrArray m_ViewList; + PtrArray m_ViewList; char m_strAuthor[101]; char m_strDescription[101]; @@ -120,8 +120,8 @@ protected: // Piece library char m_AppPath[LC_MAXPATH]; // path to the LeoCAD executable - TexFont m_ScreenFont; - PiecesLibrary* m_pLibrary; + TexFont* m_pScreenFont; + PiecesLibrary* m_pLibrary; // Undo support LC_UNDOINFO* m_pUndoList; -- cgit v1.2.3