From a05319c8417b5bad66458baefa0cbf8dffa66291 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 20 Jan 2006 06:14:06 +0000 Subject: Made the Windows piece preview use the common preview code. git-svn-id: http://svn.leocad.org/trunk@458 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/preview.cpp | 92 +++++++++++++++++++++++++++--------------------------- common/preview.h | 16 +++++----- 2 files changed, 55 insertions(+), 53 deletions(-) (limited to 'common') diff --git a/common/preview.cpp b/common/preview.cpp index 8317104..12a7986 100644 --- a/common/preview.cpp +++ b/common/preview.cpp @@ -7,68 +7,68 @@ #include "project.h" #include "pieceinf.h" -PiecePreview::PiecePreview (GLWindow *share) - : GLWindow (share) +PiecePreview::PiecePreview(GLWindow *share) + : GLWindow(share) { - m_pPieceInfo = NULL; + m_PieceInfo = NULL; } -PiecePreview::~PiecePreview () +PiecePreview::~PiecePreview() { } -void PiecePreview::OnDraw () +void PiecePreview::OnDraw() { - if (m_pPieceInfo == NULL) - return; + if (m_PieceInfo == NULL) + return; - if (!MakeCurrent ()) - return; + if (!MakeCurrent()) + return; - glEnable (GL_LIGHT0); - glEnable (GL_LIGHTING); - glEnable (GL_DEPTH_TEST); - glDepthFunc (GL_LEQUAL); - glEnable (GL_POLYGON_OFFSET_FILL); - glPolygonOffset (0.5f, 0.1f); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - glEnable (GL_COLOR_MATERIAL); - glDisable (GL_DITHER); - glShadeModel (GL_FLAT); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0.5f, 0.1f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + glDisable(GL_DITHER); + glShadeModel(GL_FLAT); - double aspect = (float)m_nWidth/(float)m_nHeight; - glViewport (0, 0, m_nWidth, m_nHeight); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - gluPerspective (30.0f, aspect, 1.0f, 100.0f); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - m_pPieceInfo->ZoomExtents (30.0f, aspect); + float aspect = (float)m_nWidth/(float)m_nHeight; + glViewport(0, 0, m_nWidth, m_nHeight); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(30.0f, aspect, 1.0f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + m_PieceInfo->ZoomExtents(30.0f, aspect); - float pos[4] = { 0, 0, 10, 0 }, *bg = project->GetBackgroundColor (); - glLightfv (GL_LIGHT0, GL_POSITION, pos); - glClearColor (bg[0], bg[1], bg[2], bg[3]); - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_pPieceInfo->RenderPiece (project->GetCurrentColor ()); + float pos[4] = { 0, 0, 10, 0 }, *bg = project->GetBackgroundColor (); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glClearColor(bg[0], bg[1], bg[2], bg[3]); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_PieceInfo->RenderPiece(project->GetCurrentColor ()); - glFinish (); - SwapBuffers (); + glFinish(); + SwapBuffers(); } -void PiecePreview::SetCurrentPiece (PieceInfo *pInfo) +void PiecePreview::SetCurrentPiece(PieceInfo *pInfo) { - MakeCurrent (); + MakeCurrent(); - if (m_pPieceInfo != NULL) - m_pPieceInfo->DeRef(); + if (m_PieceInfo != NULL) + m_PieceInfo->DeRef(); - m_pPieceInfo = pInfo; + m_PieceInfo = pInfo; - if (m_pPieceInfo != NULL) - { - m_pPieceInfo->AddRef (); - project->SetCurrentPiece (m_pPieceInfo); - Redraw (); - } + if (m_PieceInfo != NULL) + { + m_PieceInfo->AddRef(); + project->SetCurrentPiece(m_PieceInfo); + Redraw(); + } } diff --git a/common/preview.h b/common/preview.h index 21ff3a8..13d6f27 100644 --- a/common/preview.h +++ b/common/preview.h @@ -7,16 +7,18 @@ class PieceInfo; class PiecePreview : public GLWindow { - public: - PiecePreview (GLWindow *share); - virtual ~PiecePreview (); +public: + PiecePreview(GLWindow *share); + virtual ~PiecePreview(); - void OnDraw (); + void OnDraw(); - void SetCurrentPiece (PieceInfo *pInfo); + PieceInfo* GetCurrentPiece() const + { return m_PieceInfo; } + void SetCurrentPiece(PieceInfo* Info); - private: - PieceInfo* m_pPieceInfo; +protected: + PieceInfo* m_PieceInfo; }; #endif // _PREVIEW_H_ -- cgit v1.2.3