summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorleo2000-08-24 21:24:42 +0000
committerleo2000-08-24 21:24:42 +0000
commit31a1d493ed4ca5d263244a8a3231111a58bdc5c4 (patch)
tree9963c933eb4fe42f257db26c7938009c4a88b0f4
parente54d0ecfb00132cb4eeafb7d909f89c93a7b3ca6 (diff)
Updated the Windows version with the new Minifig Wizard.
Fixed some OpenGL problems on the Windows version. git-svn-id: http://svn.leocad.org/trunk@106 c7d43263-9d01-0410-8a33-9dba5d9f93d6
-rw-r--r--README.txt5
-rw-r--r--common/defines.h2
-rwxr-xr-xcommon/library.cpp1
-rwxr-xr-xcommon/object.cpp3
-rw-r--r--common/project.cpp5
-rw-r--r--docs/CHANGES.txt4
-rw-r--r--win/Cadview.cpp47
-rw-r--r--win/Figdlg.cpp169
-rw-r--r--win/LeoCAD.dsp110
-rw-r--r--win/Leocad.cpp29
-rw-r--r--win/Mfwnd.cpp88
-rw-r--r--win/Mfwnd.h5
-rw-r--r--win/Moddlg.cpp6
-rw-r--r--win/Pieceprv.cpp32
-rw-r--r--win/Print.cpp28
-rw-r--r--win/Stdafx.h3
-rw-r--r--win/System.cpp148
-rw-r--r--win/Terrwnd.cpp36
-rwxr-xr-xwin/win_gl.cpp1
19 files changed, 277 insertions, 445 deletions
diff --git a/README.txt b/README.txt
index 7b4da71..32bc56a 100644
--- a/README.txt
+++ b/README.txt
@@ -1,6 +1,3 @@
-README.txt
-$Id$
-
We lack documentation :(
@@ -8,7 +5,7 @@ However, there are several mailing lists:
http://gerf.org/mailman/listinfo
And a new website:
-http://leocad.gerf.org/
+http://www.leocad.org/
And CVS access:
http://gerf.org/cgi-bin/cvsweb
diff --git a/common/defines.h b/common/defines.h
index f08cb40..9cb8391 100644
--- a/common/defines.h
+++ b/common/defines.h
@@ -85,7 +85,7 @@ unsigned long SwapLONG(unsigned long x)
#define ABS(a) (((a) > 0) ? (a) : -(a))
#endif
-#ifndef RGB
+#ifndef LC_WINDOWS
#define RGB(r, g, b) ((unsigned long)(((unsigned char) (r) | ((unsigned short) (g) << 8))|(((unsigned long) (unsigned char) (b)) << 16)))
#endif
diff --git a/common/library.cpp b/common/library.cpp
index af110c5..df7ab29 100755
--- a/common/library.cpp
+++ b/common/library.cpp
@@ -4,6 +4,7 @@
#include <malloc.h>
#include <string.h>
+#include <stdlib.h>
#include <math.h>
#include "defines.h"
#include "globals.h"
diff --git a/common/object.cpp b/common/object.cpp
index 2d75341..a26d2d5 100755
--- a/common/object.cpp
+++ b/common/object.cpp
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <float.h>
+#include <math.h>
#include "object.h"
#include "matrix.h"
#include "vector.h"
@@ -26,7 +27,7 @@ static void GetPolyCoeffs (float x1, float y1, float z1, float x2, float y2, flo
double LC_CLICKLINE::PointDistance (float *point)
{
- Vector op (point[0] - a1, point[1] - b1, point[2] - c1);
+ Vector op ((float)(point[0] - a1), (float)(point[1] - b1), (float)(point[2] - c1));
Vector d ((float)a2, (float)b2, (float)c2);
float len = d.Length ();
d.Normalize ();
diff --git a/common/project.cpp b/common/project.cpp
index 2b070ab..06efabe 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -289,7 +289,10 @@ bool Project::Initialize(int argc, char *argv[], char* binpath, char* libpath)
if (!loaded)
{
#ifdef LC_WINDOWS
- SystemDoMessageBox("Cannot load piece library.", LC_MB_OK|LC_MB_ICONERROR);
+ // let's hope this message helps the users
+ SystemDoMessageBox("Cannot load piece library.\n"
+ "Make sure that you have the PIECES.IDX file in the same "
+ "folder where you installed the program.", LC_MB_OK|LC_MB_ICONERROR);
#else
printf("Cannot load piece library !\n");
#endif
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index f3a7a4a..72e5b2f 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -1,5 +1,9 @@
This is a changelog for developers only, not for ordinary users.
+24/08/2000
+ - Updated the Windows version with the new Minifig Wizard.
+ - Fixed OpenGL problems on the Windows version.
+
21/08/2000
- New options for the Minifig Wizard, now each piece can be rotated.
diff --git a/win/Cadview.cpp b/win/Cadview.cpp
index 8d3349d..8bc2e29 100644
--- a/win/Cadview.cpp
+++ b/win/Cadview.cpp
@@ -141,7 +141,7 @@ void CCADView::OnDraw(CDC* /*pDC*/)
else
pDoc->Render(FALSE);
- SwapBuffers(wglGetCurrentDC());
+ pfnwglSwapBuffers (pfnwglGetCurrentDC());
*/
}
@@ -284,7 +284,7 @@ void CCADView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
bi.bmiHeader.biXPelsPerMeter = 2925;
bi.bmiHeader.biYPelsPerMeter = 2925;
- HBITMAP hBm = CreateDIBSection(hMemDC, &bi, DIB_RGB_COLORS, (void **)&lpbi, NULL, (DWORD)0);
+ HBITMAP hBm = CreateDIBSection(hMemDC, &bi, DIB_RGB_COLORS, (void **)&lpbi, NULL, (DWORD)0);
HBITMAP hBmOld = (HBITMAP)SelectObject(hMemDC, hBm);
// Setting up a Pixel format for the DIB surface
@@ -292,14 +292,14 @@ void CCADView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
- int pixelformat = ChoosePixelFormat(hMemDC, &pfd);
- DescribePixelFormat(hMemDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
- SetPixelFormat(hMemDC, pixelformat, &pfd);
+ int pixelformat = pfnwglChoosePixelFormat(hMemDC, &pfd);
+ pfnwglDescribePixelFormat (hMemDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ pfnwglSetPixelFormat (hMemDC, pixelformat, &pfd);
// Creating OpenGL context
- HGLRC hmemrc = wglCreateContext(hMemDC);
- wglMakeCurrent(hMemDC, hmemrc);
-// if (!wglShareLists(m_hglRC, hmemrc))
+ HGLRC hmemrc = pfnwglCreateContext(hMemDC);
+ pfnwglMakeCurrent(hMemDC, hmemrc);
+// if (!pfnwglShareLists(m_hglRC, hmemrc))
// pDoc->RebuildDisplayLists(TRUE);
project->RenderInitialize();
@@ -421,8 +421,8 @@ void CCADView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
project->m_nViewX = oldSizex;
project->m_nViewY = oldSizey;
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(hmemrc);
+ pfnwglMakeCurrent(NULL, NULL);
+ pfnwglDeleteContext(hmemrc);
SelectObject(hMemDC, hBmOld);
DeleteObject(hBm);
DeleteDC(hMemDC);
@@ -431,7 +431,7 @@ void CCADView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
SelectObject(pDC->m_hDC, OldFont);
DeleteObject(font);
glFinish();
-// wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+// pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC);
lf.lfHeight = -MulDiv(12, pDC->GetDeviceCaps(LOGPIXELSY), 72);
lf.lfWeight = FW_REGULAR;
@@ -544,7 +544,7 @@ void CCADView::PrintHeader(BOOL bFooter, HDC hDC, CRect rc, UINT page, BOOL bCat
void CCADView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
- wglMakeCurrent(m_pDC->GetSafeHdc(), m_hglRC);
+ pfnwglMakeCurrent(m_pDC->GetSafeHdc(), m_hglRC);
}
void CCADView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewViewEx* pView)
@@ -582,9 +582,9 @@ void CCADView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPrev
///
- wglMakeCurrent(NULL, NULL);
+ pfnwglMakeCurrent(NULL, NULL);
- if (GetPixelFormat(m_pDC->GetSafeHdc()) == 0)
+ if (pfnwglGetPixelFormat(m_pDC->GetSafeHdc()) == 0)
{
delete m_pDC;
m_pDC = new CClientDC(this);
@@ -594,19 +594,19 @@ void CCADView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPrev
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
- int pixelformat = ChoosePixelFormat(m_pDC->GetSafeHdc(), &pfd);
+ int pixelformat = pfnwglChoosePixelFormat(m_pDC->GetSafeHdc(), &pfd);
if (pixelformat == 0)
{
AfxMessageBox("ChoosePixelFormat failed");
}
- if (SetPixelFormat(m_pDC->m_hDC, pixelformat, &pfd) == FALSE)
+ if (pfnwglSetPixelFormat(m_pDC->m_hDC, pixelformat, &pfd) == FALSE)
{
AfxMessageBox("SetPixelFormat failed");
}
}
- if (wglMakeCurrent(m_pDC->m_hDC, m_hglRC) == FALSE)
+ if (pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC) == FALSE)
{
LPTSTR lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
@@ -772,14 +772,14 @@ int CCADView::OnCreate(LPCREATESTRUCT lpCreateStruct)
0, 0, // no stencil & auxiliary buffer
PFD_MAIN_PLANE, 0, 0, 0, 0 }; // layer masks ignored
- int pixelformat = ChoosePixelFormat(m_pDC->GetSafeHdc(), &pfd);
+ int pixelformat = pfnwglChoosePixelFormat(m_pDC->GetSafeHdc(), &pfd);
if (pixelformat == 0)
{
AfxMessageBox("ChoosePixelFormat failed");
return -1;
}
- if (SetPixelFormat(m_pDC->m_hDC, pixelformat, &pfd) == FALSE)
+ if (pfnwglSetPixelFormat(m_pDC->m_hDC, pixelformat, &pfd) == FALSE)
{
AfxMessageBox("SetPixelFormat failed");
return -1;
@@ -797,9 +797,10 @@ int CCADView::OnCreate(LPCREATESTRUCT lpCreateStruct)
m_pPalette = NULL;
}
- m_hglRC = wglCreateContext(m_pDC->m_hDC);
- wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+ m_hglRC = pfnwglCreateContext(m_pDC->m_hDC);
+ pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+ GL_InitializeExtensions ();
SetTimer (IDT_LC_SAVETIMER, 5000, NULL);
return 0;
@@ -829,10 +830,10 @@ BOOL CCADView::OnQueryNewPalette()
void CCADView::OnDestroy()
{
- wglMakeCurrent(NULL, NULL);
+ pfnwglMakeCurrent(NULL, NULL);
if (m_hglRC)
- wglDeleteContext(m_hglRC);
+ pfnwglDeleteContext(m_hglRC);
if (m_pPalette)
{
diff --git a/win/Figdlg.cpp b/win/Figdlg.cpp
index f819fca..27baa93 100644
--- a/win/Figdlg.cpp
+++ b/win/Figdlg.cpp
@@ -5,9 +5,7 @@
#include "LeoCAD.h"
#include "FigDlg.h"
#include "MFWnd.h"
-#include "pieceinf.h"
-#include "project.h"
-#include "globals.h"
+#include "minifig.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -73,60 +71,28 @@ BOOL CMinifigDlg::OnInitDialog()
ScreenToClient (&r);
m_pMFWnd = new CMinifigWnd;
- m_pMFWnd->m_pFig = (LC_MINIFIGDLG_OPTS*)m_pParam;
+ m_pMFWnd->m_pFig = (MinifigWizard*)m_pParam;
m_pMFWnd->Create (NULL, NULL, WS_BORDER | WS_CHILD | WS_VISIBLE, r, this, 501);
m_pMFWnd->InitGL();
- for (int i = 0; i < 15; i++)
- ((CColorPicker*)GetDlgItem (IDC_MF_HATCOLOR+i))->SetColorIndex (m_pMFWnd->m_pFig->colors[i]);
+ for (int i = 0; i < LC_MFW_NUMITEMS; i++)
+ ((CColorPicker*)GetDlgItem (IDC_MF_HATCOLOR+i))->SetColorIndex (m_pMFWnd->m_pFig->m_Colors[i]);
- for (i = 0; i < MFW_PIECES; i++)
+ for (i = 0; i < LC_MFW_NUMITEMS; i++)
{
- PieceInfo* pInfo = project->FindPieceInfo(mfwpieceinfo[i].name);
- if (pInfo != NULL)
- {
- UINT id = 0;
- switch (mfwpieceinfo[i].type)
- {
- case MF_HAT: id = IDC_MF_HAT; break;
- case MF_HEAD: id = IDC_MF_HEAD; break;
- case MF_TORSO: id = IDC_MF_TORSO; break;
- case MF_NECK: id = IDC_MF_NECK; break;
- case MF_ARML: id = IDC_MF_ARML; break;
- case MF_ARMR: id = IDC_MF_ARMR; break;
- case MF_HAND: id = IDC_MF_HANDL; break;
- case MF_TOOL: id = IDC_MF_TOOLL; break;
- case MF_HIPS: id = IDC_MF_HIPS; break;
- case MF_LEGL: id = IDC_MF_LEGL; break;
- case MF_LEGR: id = IDC_MF_LEGR; break;
- case MF_SHOE: id = IDC_MF_SHOEL; break;
- }
+ CComboBox* pCombo = (CComboBox*)GetDlgItem(i+IDC_MF_HAT);
+ char **names;
+ int j, count;
- CComboBox* pCombo = (CComboBox*)GetDlgItem(id);
- int pos;
- if (i != 29)
- {
- pos = pCombo->AddString(mfwpieceinfo[i].description);
- pCombo->SetItemDataPtr(pos, pInfo);
- }
+ m_pMFWnd->m_pFig->GetDescriptions (i, &names, &count);
- if (id == IDC_MF_HANDL || id == IDC_MF_TOOLL || id == IDC_MF_SHOEL)
- {
- pCombo = (CComboBox*)GetDlgItem(id+1);
- pos = pCombo->AddString(mfwpieceinfo[i].description);
- pCombo->SetItemDataPtr(pos, pInfo);
- }
- if (i == 6) i++;
- }
- }
+ for (j = 0; j < count; j++)
+ pCombo->AddString (names[j]);
+ free (names);
- UINT nid[6] = { IDC_MF_HAT, IDC_MF_NECK, IDC_MF_TOOLL, IDC_MF_TOOLR, IDC_MF_SHOEL, IDC_MF_SHOER };
- for (i = 0; i < 6; i++)
- {
- CComboBox* pCombo = (CComboBox*)GetDlgItem(nid[i]);
- pCombo->InsertString(0, "None");
- pCombo->SetItemData (0, 0);
+ if (i == 6) i++;
}
+
for (i = IDC_MF_NECK; i <= IDC_MF_SHOER; i++)
((CComboBox*)GetDlgItem(i))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_MF_HAT))->SetCurSel(6);
@@ -147,7 +113,7 @@ BOOL CMinifigDlg::DestroyWindow()
LONG CMinifigDlg::OnColorSelEndOK(UINT lParam, LONG wParam)
{
- m_pMFWnd->m_pFig->colors[wParam-IDC_MF_HATCOLOR] = lParam;
+ m_pMFWnd->m_pFig->ChangeColor (wParam-IDC_MF_HATCOLOR, lParam);
m_pMFWnd->PostMessage(WM_PAINT);
return TRUE;
@@ -155,108 +121,9 @@ LONG CMinifigDlg::OnColorSelEndOK(UINT lParam, LONG wParam)
void CMinifigDlg::OnPieceSelEndOK(UINT nID)
{
- CComboBox* pCombo = (CComboBox*)GetDlgItem(nID);
- PieceInfo* pInfo = (PieceInfo*)pCombo->GetItemDataPtr(pCombo->GetCurSel());
-
- if (m_pMFWnd->m_pFig->info[nID-IDC_MF_HAT])
- m_pMFWnd->m_pFig->info[nID-IDC_MF_HAT]->DeRef();
- m_pMFWnd->m_pFig->info[nID-IDC_MF_HAT] = pInfo;
- if (pInfo)
- pInfo->AddRef();
-
- if (nID == IDC_MF_NECK)
- {
- if (m_pMFWnd->m_pFig->info[3] != NULL)
- {
- m_pMFWnd->m_pFig->pos[0][2] = 3.92f;
- m_pMFWnd->m_pFig->pos[1][2] = 3.92f;
-
- if (strcmp (pInfo->m_strName,"4498") == 0)
- m_pMFWnd->m_pFig->rot[3][2] = 180.0f;
- }
- else
- {
- m_pMFWnd->m_pFig->pos[0][2] = 3.84f;
- m_pMFWnd->m_pFig->pos[1][2] = 3.84f;
- }
- }
-
- if (nID == IDC_MF_SHOEL)
- {
- if (pCombo->GetCurSel() == 1)
- m_pMFWnd->m_pFig->pos[13][1] = 0;
- else
- m_pMFWnd->m_pFig->pos[13][1] = -0.12f;
- }
-
- if (nID == IDC_MF_SHOER)
- {
- if (pCombo->GetCurSel() == 1)
- m_pMFWnd->m_pFig->pos[14][1] = 0;
- else
- m_pMFWnd->m_pFig->pos[14][1] = -0.12f;
- }
-
- if ((nID == IDC_MF_TOOLL) || (nID == IDC_MF_TOOLR))
- if (pCombo->GetItemData(pCombo->GetCurSel()) != 0)
- {
- float rx = 45, ry = 0, rz = 0, x = 0.92f, y = -0.62f, z = 1.76f;
-
- if (strcmp (pInfo->m_strName,"4529") == 0)
- { rx = -45; y = -1.14f; z = 2.36f; }
- if (strcmp (pInfo->m_strName,"3899") == 0)
- { y = -1.64f; z = 1.38f; }
- if (strcmp (pInfo->m_strName,"4528") == 0)
- { rx = -45; y = -1.26f; z = 2.36f; }
- if (strcmp (pInfo->m_strName,"4479") == 0)
- { rz = 90; y = -1.22f; z = 2.44f; }
- if (strcmp (pInfo->m_strName,"3962") == 0)
- { rz = 90; y = -0.7f; z = 1.62f; }
- if (strcmp (pInfo->m_strName,"4360") == 0)
- { rz = -90; y = -1.22f; z = 2.44f; }
- if (strncmp (pInfo->m_strName,"6246",4) == 0)
- { y = -1.82f; z = 2.72f; rz = 90; }
- if (strcmp (pInfo->m_strName,"4349") == 0)
- { y = -1.16f; z = 2.0f; }
- if (strcmp (pInfo->m_strName,"4479") == 0)
- { y = -1.42f; z = 2.26f; }
- if (strcmp (pInfo->m_strName,"3959") == 0)
- { y = -1.0f; z = 1.88f; }
- if (strcmp (pInfo->m_strName,"4522") == 0)
- { y = -1.64f; z = 2.48f; }
- if (strcmp (pInfo->m_strName,"194") == 0)
- { rz = 180; y = -1.04f; z = 1.94f; }
- if (strcmp (pInfo->m_strName,"4006") == 0)
- { rz = 180; y = -1.24f; z = 2.18f; }
- if (strcmp (pInfo->m_strName,"6246C") == 0)
- { rx = 35; rz = 0; y = -2.36f; z = 1.08f; }
- if (strcmp (pInfo->m_strName,"4497") == 0)
- { y = -2.16f; z = 3.08f; rz = 90; }
- if (strcmp (pInfo->m_strName,"30092") == 0)
- { x = 0; rz = 180; }
- if (strcmp (pInfo->m_strName,"37") == 0)
- { z = 1.52f; y = -0.64f; }
- if (strcmp (pInfo->m_strName,"38") == 0)
- { z = 1.24f; y = -0.34f; }
- if (strcmp (pInfo->m_strName,"3841") == 0)
- { z = 2.24f; y = -1.34f; rz = 180; }
- if (strcmp (pInfo->m_strName,"4499") == 0)
- { rz = 10; z = 1.52f; }
- if (strcmp (pInfo->m_strName,"3852") == 0)
- { rz = -90; x = 0.90f; y = -0.8f; z = 1.84f; }
- if (strcmp (pInfo->m_strName,"30152") == 0)
- { z = 3.06f; y = -2.16f; }
-
- if (nID == IDC_MF_TOOLR)
- x = -x;
-
- m_pMFWnd->m_pFig->pos[nID-IDC_MF_HAT][0] = x;
- m_pMFWnd->m_pFig->pos[nID-IDC_MF_HAT][1] = y;
- m_pMFWnd->m_pFig->pos[nID-IDC_MF_HAT][2] = z;
- m_pMFWnd->m_pFig->rot[nID-IDC_MF_HAT][0] = rx;
- m_pMFWnd->m_pFig->rot[nID-IDC_MF_HAT][1] = ry;
- m_pMFWnd->m_pFig->rot[nID-IDC_MF_HAT][2] = rz;
- }
+ char tmp[65];
+ GetDlgItem(nID)->GetWindowText (tmp, 65);
+ m_pMFWnd->m_pFig->ChangePiece (nID-IDC_MF_HAT, tmp);
m_pMFWnd->PostMessage(WM_PAINT);
}
diff --git a/win/LeoCAD.dsp b/win/LeoCAD.dsp
index 5cb4d8d..b4ab015 100644
--- a/win/LeoCAD.dsp
+++ b/win/LeoCAD.dsp
@@ -52,7 +52,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
-# ADD LINK32 vfw32.lib glu32.lib opengl32.lib jpeglib.lib 3dsftk.lib libpng.lib zlib.lib /nologo /subsystem:windows /map /machine:I386 /libpath:"./jpeglib/release" /libpath:"./3dsftk/release" /libpath:"./libpng/release" /libpath:"./zlib/release"
+# ADD LINK32 vfw32.lib jpeglib.lib 3dsftk.lib libpng.lib zlib.lib /nologo /subsystem:windows /map /machine:I386 /libpath:"./jpeglib/release" /libpath:"./3dsftk/release" /libpath:"./libpng/release" /libpath:"./zlib/release"
!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug"
@@ -78,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 vfw32.lib glu32.lib opengl32.lib jpeglib.lib 3dsftk.lib libpng.lib zlib.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:"./jpeglib/debug" /libpath:"./3dsftk/debug" /libpath:"./libpng/debug" /libpath:"./zlib/debug"
+# ADD LINK32 vfw32.lib jpeglib.lib 3dsftk.lib libpng.lib zlib.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:"./jpeglib/debug" /libpath:"./3dsftk/debug" /libpath:"./libpng/debug" /libpath:"./zlib/debug"
# SUBTRACT LINK32 /profile
!ENDIF
@@ -174,42 +174,20 @@ SOURCE=.\Leocad.cpp
SOURCE=.\hlp\LeoCAD.hpj
USERDEP__LEOCA="$(ProjDir)\hlp\AfxCore.rtf" "$(ProjDir)\hlp\AfxPrint.rtf"
+# End Source File
+# Begin Source File
-!IF "$(CFG)" == "LeoCAD - Win32 Release"
-
-# Begin Custom Build - Making help file...
-OutDir=.\Release
-ProjDir=.
-TargetName=LeoCAD
-InputPath=.\hlp\LeoCAD.hpj
-
-"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- call "$(ProjDir)\makehelp.bat"
+SOURCE=.\Leocad.rc
-# End Custom Build
+!IF "$(CFG)" == "LeoCAD - Win32 Release"
!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug"
-# Begin Custom Build - Making help file...
-OutDir=.\Debug
-ProjDir=.
-TargetName=LeoCAD
-InputPath=.\hlp\LeoCAD.hpj
-
-"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- call "$(ProjDir)\makehelp.bat"
-
-# End Custom Build
-
!ENDIF
# End Source File
# Begin Source File
-SOURCE=.\Leocad.rc
-# End Source File
-# Begin Source File
-
SOURCE=.\Libdlg.cpp
# End Source File
# Begin Source File
@@ -337,6 +315,10 @@ SOURCE=.\Transbar.cpp
SOURCE=.\Wheelwnd.cpp
# End Source File
+# Begin Source File
+
+SOURCE=.\win_gl.cpp
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -527,10 +509,6 @@ SOURCE=.\StepPop.h
# End Source File
# Begin Source File
-SOURCE=.\system.h
-# End Source File
-# Begin Source File
-
SOURCE=.\TerOpDlg.h
# End Source File
# Begin Source File
@@ -561,6 +539,10 @@ SOURCE=.\Transbar.h
SOURCE=.\WheelWnd.h
# End Source File
+# Begin Source File
+
+SOURCE=.\win_gl.h
+# End Source File
# End Group
# Begin Group "Resource Files"
@@ -947,15 +929,6 @@ SOURCE=.\hlp\Scmin.bmp
# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\Common\boundbox.cpp
-# SUBTRACT CPP /YX /Yc /Yu
-# End Source File
-# Begin Source File
-
-SOURCE=..\Common\boundbox.h
-# End Source File
-# Begin Source File
-
SOURCE=..\Common\camera.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -1044,6 +1017,57 @@ SOURCE=..\Common\matrix.h
# End Source File
# Begin Source File
+SOURCE=..\common\minifig.cpp
+
+!IF "$(CFG)" == "LeoCAD - Win32 Release"
+
+!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\minifig.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\object.cpp
+
+!IF "$(CFG)" == "LeoCAD - Win32 Release"
+
+!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\object.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\opengl.cpp
+
+!IF "$(CFG)" == "LeoCAD - Win32 Release"
+
+!ELSEIF "$(CFG)" == "LeoCAD - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\common\opengl.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\piece.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -1080,6 +1104,10 @@ SOURCE=..\Common\quant.h
# End Source File
# Begin Source File
+SOURCE=..\common\system.h
+# End Source File
+# Begin Source File
+
SOURCE=..\Common\terrain.cpp
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
diff --git a/win/Leocad.cpp b/win/Leocad.cpp
index 7ddecbe..f792a43 100644
--- a/win/Leocad.cpp
+++ b/win/Leocad.cpp
@@ -91,6 +91,9 @@ BOOL CCADApp::InitInstance()
SetRegistryKey(_T("BT Software"));
// LoadStdProfileSettings(); // Load standard INI file options (including MRU)
+ if (!GL_Initialize (NULL))
+ return FALSE;
+
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
@@ -111,19 +114,13 @@ BOOL CCADApp::InitInstance()
m_nCmdShow = SW_HIDE;
pDocTemplate->OpenDocumentFile(NULL);
- // Try to find the piece library.
- char* envp = ::getenv("LEOCAD_LIB");
- if (envp == NULL)
- {
- static char app[LC_MAXPATH], *ptr;
- GetModuleFileName (NULL, app, LC_MAXPATH);
- ptr = strrchr(app,'\\');
- if (ptr)
- *(++ptr) = 0;
- envp = app;
- }
+ char app[LC_MAXPATH], *ptr;
+ GetModuleFileName (NULL, app, LC_MAXPATH);
+ ptr = strrchr(app,'\\');
+ if (ptr)
+ *(++ptr) = 0;
- if (!project->Initialize(__argc, __targv, envp))
+ if (!project->Initialize(__argc, __targv, app, NULL))
return false;
@@ -264,7 +261,9 @@ int CCADApp::ExitInstance()
if (__hStdOut != NULL)
FreeConsole();
#endif
-
+
+ GL_Shutdown ();
+
return CWinApp::ExitInstance();
}
@@ -281,7 +280,7 @@ void CCADApp::OnHelpUpdates()
DWORD dwBytesRead;
CString Contents;
- HINTERNET hHttpFile = InternetOpenUrl(session, "http://www.geocities.com/Colosseum/3479/updates.txt", NULL, 0, 0, 0);
+ HINTERNET hHttpFile = InternetOpenUrl(session, "http://www.leocad.org", NULL, 0, 0, 0);
if (hHttpFile)
{
@@ -323,7 +322,7 @@ void CCADApp::OnHelpUpdates()
void CCADApp::OnHelpHomePage()
{
- ShellExecute(::GetDesktopWindow(), _T("open"), _T("http://www.geocities.com\\Colosseum\\3479\\leocad.htm"), NULL, NULL, SW_NORMAL);
+ ShellExecute(::GetDesktopWindow(), _T("open"), _T("http://www.leocad.org"), NULL, NULL, SW_NORMAL);
}
void CCADApp::OnHelpEmail()
diff --git a/win/Mfwnd.cpp b/win/Mfwnd.cpp
index 258e9a9..753fc4b 100644
--- a/win/Mfwnd.cpp
+++ b/win/Mfwnd.cpp
@@ -5,10 +5,7 @@
#include "LeoCAD.h"
#include "MFWnd.h"
#include "Tools.h"
-#include "project.h"
-#include "globals.h"
-#include "Matrix.h"
-#include "pieceinf.h"
+#include "minifig.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -46,22 +43,22 @@ int CMinifigWnd::InitGL()
ASSERT(m_pDC != NULL);
// Fill in the Pixel Format Descriptor
- PIXELFORMATDESCRIPTOR pfd;
+ PIXELFORMATDESCRIPTOR pfd;
memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR));
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1;
+ pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
+ pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
+ pfd.cColorBits = 24;
pfd.cDepthBits = 24;
- pfd.iLayerType = PFD_MAIN_PLANE;
+ pfd.iLayerType = PFD_MAIN_PLANE;
- int nPixelFormat = ChoosePixelFormat(m_pDC->m_hDC, &pfd);
+ int nPixelFormat = pfnwglChoosePixelFormat(m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0)
return -1 ;
- if (!SetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
+ if (!pfnwglSetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
return -1 ;
m_pPal = new CPalette;
@@ -78,37 +75,16 @@ int CMinifigWnd::InitGL()
}
// Create a rendering context.
- m_hrc = wglCreateContext(m_pDC->m_hDC);
+ m_hrc = pfnwglCreateContext(m_pDC->m_hDC);
if (!m_hrc)
return -1;
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
- wglShareLists(oldRC, m_hrc);
- wglMakeCurrent (m_pDC->m_hDC, m_hrc);
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
+ pfnwglShareLists(oldRC, m_hrc);
+ pfnwglMakeCurrent (m_pDC->m_hDC, m_hrc);
- CRect rc;
- GetClientRect (&rc);
-
- double aspect = (float)rc.right/(float)rc.bottom;
- glViewport(0, 0, rc.right, rc.bottom);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(30.0f, aspect, 1.0f, 50.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- gluLookAt (0, -9, 4, 0, 5, 1, 0, 0, 1);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- float *bg = project->GetBackgroundColor();
- glClearColor(bg[0], bg[1], bg[2], bg[3]);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDisable (GL_DITHER);
- glShadeModel (GL_FLAT);
-
- wglMakeCurrent (oldDC, oldRC);
+ pfnwglMakeCurrent (oldDC, oldRC);
return 0;
}
@@ -129,14 +105,14 @@ void CMinifigWnd::OnDestroy()
{
if (m_pPal)
{
- CPalette palDefault;
+ CPalette palDefault;
palDefault.CreateStockObject(DEFAULT_PALETTE);
m_pDC->SelectPalette(&palDefault, FALSE);
delete m_pPal;
}
if (m_hrc)
- wglDeleteContext(m_hrc);
+ pfnwglDeleteContext(m_hrc);
if (m_pDC)
delete m_pDC;
@@ -151,28 +127,16 @@ void CMinifigWnd::DrawScene()
m_pDC->RealizePalette();
}
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
- wglMakeCurrent (m_pDC->m_hDC, m_hrc);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
+ pfnwglMakeCurrent (m_pDC->m_hDC, m_hrc);
- for (int i = 0; i < 15; i++)
- {
- if (m_pFig->info[i] == NULL)
- continue;
-
- glPushMatrix();
- Matrix mat;
- float rot[4];
- mat.CreateOld(0,0,0, m_pFig->rot[i][0], m_pFig->rot[i][1], m_pFig->rot[i][2]);
- mat.ToAxisAngle(rot);
- glTranslatef(m_pFig->pos[i][0], m_pFig->pos[i][1], m_pFig->pos[i][2]);
- glRotatef(rot[3], rot[0], rot[1], rot[2]);
- m_pFig->info[i]->RenderPiece(m_pFig->colors[i]);
- glPopMatrix();
- }
+ RECT rc;
+ GetClientRect (&rc);
+
+ m_pFig->Resize (rc.right, rc.bottom);
+ m_pFig->Redraw ();
- glFinish();
- SwapBuffers(m_pDC->m_hDC);
- wglMakeCurrent (oldDC, oldRC);
+ pfnwglSwapBuffers (m_pDC->m_hDC);
+ pfnwglMakeCurrent (oldDC, oldRC);
}
diff --git a/win/Mfwnd.h b/win/Mfwnd.h
index c047f5f..e14245a 100644
--- a/win/Mfwnd.h
+++ b/win/Mfwnd.h
@@ -4,7 +4,8 @@
// MFWind.h : header file
//
-#include "system.h"
+//#include "system.h"
+class MinifigWizard;
/////////////////////////////////////////////////////////////////////////////
// CMinifigWnd window
@@ -25,7 +26,7 @@ protected:
public:
void DrawScene();
int InitGL();
- LC_MINIFIGDLG_OPTS* m_pFig;
+ MinifigWizard* m_pFig;
// Overrides
// ClassWizard generated virtual function overrides
diff --git a/win/Moddlg.cpp b/win/Moddlg.cpp
index 52fec77..9d12db1 100644
--- a/win/Moddlg.cpp
+++ b/win/Moddlg.cpp
@@ -198,15 +198,15 @@ void CModifyDialog::UpdateInfo(void* pObject, BYTE nType)
{
float tmp[3];
Camera* pCamera = (Camera*)m_pObject;
- pCamera->GetEye(tmp);
+ pCamera->GetEyePos(tmp);
m_fPosX = tmp[0];
m_fPosY = tmp[1];
m_fPosZ = tmp[2];
- pCamera->GetTarget(tmp);
+ pCamera->GetTargetPos(tmp);
m_fRotX = tmp[0];
m_fRotY = tmp[1];
m_fRotZ = tmp[2];
- pCamera->GetUp(tmp);
+ pCamera->GetUpVec(tmp);
m_fUpX = tmp[0];
m_fUpY = tmp[1];
m_fUpZ = tmp[2];
diff --git a/win/Pieceprv.cpp b/win/Pieceprv.cpp
index da4c814..ea39638 100644
--- a/win/Pieceprv.cpp
+++ b/win/Pieceprv.cpp
@@ -64,8 +64,8 @@ void CPiecePreview::OnPaint()
if (!IsWindowEnabled() || (m_pPieceInfo == NULL))
return;
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
if (m_pPalette)
{
@@ -73,7 +73,7 @@ void CPiecePreview::OnPaint()
m_pDC->RealizePalette();
}
- wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+ pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC);
double aspect = (float)m_szView.cx/(float)m_szView.cy;
glViewport(0, 0, m_szView.cx, m_szView.cy);
@@ -95,9 +95,9 @@ void CPiecePreview::OnPaint()
m_pPieceInfo->RenderPiece(project->GetCurrentColor());
- glFinish();
- SwapBuffers(m_pDC->m_hDC);
- wglMakeCurrent (oldDC, oldRC);
+ glFinish();
+ pfnwglSwapBuffers (m_pDC->m_hDC);
+ pfnwglMakeCurrent (oldDC, oldRC);
}
void CPiecePreview::OnSize(UINT nType, int cx, int cy)
@@ -129,11 +129,11 @@ int CPiecePreview::OnCreate(LPCREATESTRUCT lpCreateStruct)
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
- int nPixelFormat = ChoosePixelFormat(m_pDC->m_hDC, &pfd);
+ int nPixelFormat = pfnwglChoosePixelFormat(m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0)
return 0;
- if (!SetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
+ if (!pfnwglSetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
return 0;
m_pPalette = new CPalette;
@@ -150,17 +150,17 @@ int CPiecePreview::OnCreate(LPCREATESTRUCT lpCreateStruct)
}
// Create a rendering context.
- m_hglRC = wglCreateContext(m_pDC->m_hDC);
+ m_hglRC = pfnwglCreateContext(m_pDC->m_hDC);
if (!m_hglRC)
return 0;
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
- wglMakeCurrent (m_pDC->m_hDC, m_hglRC);
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
+ pfnwglMakeCurrent (m_pDC->m_hDC, m_hglRC);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
+ glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.5f, 0.1f);
@@ -172,8 +172,8 @@ int CPiecePreview::OnCreate(LPCREATESTRUCT lpCreateStruct)
glDisable (GL_DITHER);
glShadeModel (GL_FLAT);
- wglMakeCurrent(oldDC, oldRC);
- wglShareLists(oldRC, m_hglRC);
+ pfnwglMakeCurrent (oldDC, oldRC);
+ pfnwglShareLists (oldRC, m_hglRC);
return 0;
}
@@ -190,7 +190,7 @@ void CPiecePreview::OnDestroy()
}
if (m_hglRC)
- wglDeleteContext(m_hglRC);
+ pfnwglDeleteContext(m_hglRC);
if (m_pDC)
delete m_pDC;
diff --git a/win/Print.cpp b/win/Print.cpp
index 158a0ab..2c62f80 100644
--- a/win/Print.cpp
+++ b/win/Print.cpp
@@ -179,15 +179,15 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWnd* pMainFrame)
1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
- int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd);
- DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
- SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
+ int pixelformat = pfnwglChoosePixelFormat(pMemDC->m_hDC, &pfd);
+ pfnwglDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ pfnwglSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
// Creating a OpenGL context
- HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc());
+ HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc());
// Setting up the current OpenGL context
- wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
+ pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
double aspect = (float)w/(float)h;
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, w, h);
@@ -372,8 +372,8 @@ static void PrintCatalogThread (CWnd* pParent, CFrameWnd* pMainFrame)
free(previous);
}
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(hmemrc);
+ pfnwglMakeCurrent(NULL, NULL);
+ pfnwglDeleteContext(hmemrc);
SelectObject(pMemDC->GetSafeHdc(), hBmOld);
DeleteObject(hBm);
delete pMemDC;
@@ -563,11 +563,11 @@ static void PrintPiecesThread(void* pv)
PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
- int pixelformat = ChoosePixelFormat(pMemDC->m_hDC, &pfd);
- DescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
- SetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
- HGLRC hmemrc = wglCreateContext(pMemDC->GetSafeHdc());
- wglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
+ int pixelformat = pfnwglChoosePixelFormat(pMemDC->m_hDC, &pfd);
+ pfnwglDescribePixelFormat(pMemDC->m_hDC, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ pfnwglSetPixelFormat(pMemDC->m_hDC, pixelformat, &pfd);
+ HGLRC hmemrc = pfnwglCreateContext(pMemDC->GetSafeHdc());
+ pfnwglMakeCurrent(pMemDC->GetSafeHdc(), hmemrc);
double aspect = (float)picw/(float)h;
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, picw, h);
@@ -770,8 +770,8 @@ static void PrintPiecesThread(void* pv)
free(previous);
}
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(hmemrc);
+ pfnwglMakeCurrent(NULL, NULL);
+ pfnwglDeleteContext(hmemrc);
SelectObject(pMemDC->GetSafeHdc(), hBmOld);
DeleteObject(hBm);
delete pMemDC;
diff --git a/win/Stdafx.h b/win/Stdafx.h
index 3053a07..a9c6b96 100644
--- a/win/Stdafx.h
+++ b/win/Stdafx.h
@@ -23,8 +23,7 @@
//#include <afxadv.h> // CSharedFile
-#include <gl\gl.h>
-#include <gl\glu.h>
+#include "opengl.h"
#define IDT_LC_SAVETIMER (WM_USER+200)
#define IDT_LC_WHEELTIMER (WM_USER+201)
diff --git a/win/System.cpp b/win/System.cpp
index 8cc5c46..d3d6e23 100644
--- a/win/System.cpp
+++ b/win/System.cpp
@@ -308,29 +308,39 @@ void SystemDoWaitCursor(int nCode)
}
}
+void Sys_BeginWait ()
+{
+ SystemDoWaitCursor (1);
+}
+
+void Sys_EndWait ()
+{
+ SystemDoWaitCursor (-1);
+}
+
/////////////////////////////////////////////////////////////////////////////
// Profile Access
// returns the store value or default
-int SystemGetProfileInt(const char* section, const char* entry, const int defaultvalue)
+int Sys_ProfileLoadInt(const char* section, const char* entry, const int defaultvalue)
{
return theApp.GetProfileInt(section, entry, defaultvalue);
}
// returns true if successful
-bool SystemSetProfileInt(const char* section, const char* entry, const int value)
+bool Sys_ProfileSaveInt(const char* section, const char* entry, const int value)
{
return theApp.WriteProfileInt(section, entry, value) ? true : false;
}
-const char* SystemGetProfileString(const char* section, const char* entry, const char* defaultvalue)
+char* Sys_ProfileLoadString(const char* section, const char* entry, const char* defaultvalue)
{
static CString str;
str = theApp.GetProfileString(section, entry, defaultvalue);
- return (LPCSTR)str;
+ return (char*)(LPCSTR)str;
}
-bool SystemSetProfileString(const char* section, const char* entry, const char* value)
+bool Sys_ProfileSaveString(const char* section, const char* entry, const char* value)
{
return theApp.WriteProfileString(section, entry, value) ? true : false;
}
@@ -1019,6 +1029,11 @@ int SystemDoMessageBox(char* prompt, int nMode)
return AfxMessageBox(prompt, nMode);
}
+int Sys_MessageBox (const char* text, const char* caption, int type)
+{
+ return AfxMessageBox(text, type);
+}
+
extern BOOL AFXAPI AfxFullPath(LPTSTR lpszPathOut, LPCTSTR lpszFileIn);
bool SystemDoDialog(int nMode, void* param)
@@ -1360,7 +1375,7 @@ bool SystemDoDialog(int nMode, void* param)
case LC_DLG_ABOUT:
{
CAboutDlg dlg;
- dlg.m_hViewDC = wglGetCurrentDC();
+ dlg.m_hViewDC = pfnwglGetCurrentDC();
dlg.DoModal();
} break;
}
@@ -1381,14 +1396,14 @@ typedef struct
HBITMAP oldhbm;
} LC_RENDER;
-void* SystemStartRender(int width, int height)
+void* Sys_StartMemoryRender(int width, int height)
{
LC_RENDER* render = (LC_RENDER*)malloc(sizeof(LC_RENDER));
CFrameWnd* pFrame = (CFrameWnd*)AfxGetMainWnd();
CView* pView = pFrame->GetActiveView();
CDC* pDC = pView->GetDC();
- render->oldhdc = wglGetCurrentDC();
- render->oldhrc = wglGetCurrentContext();
+ render->oldhdc = pfnwglGetCurrentDC();
+ render->oldhrc = pfnwglGetCurrentContext();
render->hdc = CreateCompatibleDC(pDC->m_hDC);
// Preparing bitmap header for DIB section
@@ -1414,101 +1429,27 @@ void* SystemStartRender(int width, int height)
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
- int pixelformat = ChoosePixelFormat(render->hdc, &pfd);
- DescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
- SetPixelFormat(render->hdc, pixelformat, &pfd);
- render->hrc = wglCreateContext(render->hdc);
- wglMakeCurrent(render->hdc, render->hrc);
+ int pixelformat = pfnwglChoosePixelFormat(render->hdc, &pfd);
+ pfnwglDescribePixelFormat(render->hdc, pixelformat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ pfnwglSetPixelFormat(render->hdc, pixelformat, &pfd);
+ render->hrc = pfnwglCreateContext(render->hdc);
+ pfnwglMakeCurrent(render->hdc, render->hrc);
return render;
}
-void SystemFinishRender(void* param)
+void Sys_FinishMemoryRender(void* param)
{
LC_RENDER* render = (LC_RENDER*)param;
- wglMakeCurrent (render->oldhdc, render->oldhrc);
- wglDeleteContext(render->hrc);
+ pfnwglMakeCurrent (render->oldhdc, render->oldhrc);
+ pfnwglDeleteContext(render->hrc);
SelectObject(render->hdc, render->oldhbm);
DeleteObject(render->hbm);
DeleteDC(render->hdc);
free(render);
}
-LC_IMAGE* SystemGetRenderImage(void* param)
-{
- LC_RENDER* render = (LC_RENDER*)param;
- HANDLE hdib;
- HDC hdc;
- BITMAP bitmap;
- UINT wLineLen;
- DWORD dwSize, wColSize;
- LPBITMAPINFOHEADER lpbi;
- LPBYTE lpBits;
-
- glFinish();
- GetObject(render->hbm, sizeof(BITMAP), &bitmap);
-
- // DWORD align the width of the DIB
- // Figure out the size of the colour table
- // Calculate the size of the DIB
- wLineLen = (bitmap.bmWidth*24+31)/32 * 4;
- wColSize = sizeof(RGBQUAD)*((24 <= 8) ? 1 << 24 : 0);
- dwSize = sizeof(BITMAPINFOHEADER) + wColSize +
- (DWORD)(UINT)wLineLen*(DWORD)(UINT)bitmap.bmHeight;
-
- // Allocate room for a DIB and set the LPBI fields
- hdib = GlobalAlloc(GHND, dwSize);
- if (!hdib)
- return NULL;
-
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(hdib);
- lpbi->biSize = sizeof(BITMAPINFOHEADER);
- lpbi->biWidth = bitmap.bmWidth;
- lpbi->biHeight = bitmap.bmHeight;
- lpbi->biPlanes = 1;
- lpbi->biBitCount = (WORD)24;
- lpbi->biCompression = BI_RGB;
- lpbi->biSizeImage = dwSize - sizeof(BITMAPINFOHEADER) - wColSize;
- lpbi->biXPelsPerMeter = 0;
- lpbi->biYPelsPerMeter = 0;
- lpbi->biClrUsed = (24 <= 8) ? 1 << 24 : 0;
- lpbi->biClrImportant = 0;
-
- // Get the bits from the bitmap and stuff them after the LPBI
- lpBits = (LPBYTE)(lpbi+1)+wColSize;
- hdc = CreateCompatibleDC(NULL);
- GetDIBits(hdc, render->hbm, 0, bitmap.bmHeight,
- lpBits, (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
-
- // Fix this if GetDIBits messed it up....
- lpbi->biClrUsed = (24 <= 8) ? 1 << 24 : 0;
-
- DeleteDC(hdc);
-
- LC_IMAGE* image = (LC_IMAGE*)malloc(bitmap.bmWidth*bitmap.bmHeight*3+sizeof(LC_IMAGE));
- image->width = (unsigned short)bitmap.bmWidth;
- image->height = (unsigned short)bitmap.bmHeight;
- image->bits = (char*)image + sizeof(LC_IMAGE);
-
- for (int i = 0; i < image->height; i++)
- {
- unsigned char* out = (unsigned char*)image->bits + (image->height-i-1)*image->width*3;
- unsigned char* in = lpBits + i*wLineLen;
- for (int j = 0; j < image->width*3; j += 3)
- {
- out[j] = in[j+2];
- out[j+1] = in[j+1];
- out[j+2] = in[j];
- }
- }
-
- GlobalUnlock(hdib);
- GlobalFree(hdib);
-
- return image;
-}
-
/////////////////////////////////////////////////////////////////////////////
// Main window functions
@@ -1597,3 +1538,28 @@ bool Sys_KeyDown (int key)
{
return GetKeyState (KEY_CONTROL) < 0;
}
+
+void SystemPumpMessages()
+{
+ MSG msg;
+ while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+long SystemGetTicks()
+{
+ return GetTickCount();
+}
+
+void SystemSwapBuffers()
+{
+ pfnwglSwapBuffers (pfnwglGetCurrentDC());
+}
+
+void SystemSetGroup(int group)
+{
+ AfxGetMainWnd()->PostMessage (WM_LC_UPDATE_LIST, group+2, 0);
+}
diff --git a/win/Terrwnd.cpp b/win/Terrwnd.cpp
index 68b706c..2708cc7 100644
--- a/win/Terrwnd.cpp
+++ b/win/Terrwnd.cpp
@@ -63,8 +63,8 @@ void CTerrainWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
if (m_pPalette)
{
@@ -72,7 +72,7 @@ void CTerrainWnd::OnPaint()
m_pDC->RealizePalette();
}
- wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+ pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -83,9 +83,9 @@ void CTerrainWnd::OnPaint()
m_pTerrain->Render(m_pCamera, aspect);
- glFlush();
- SwapBuffers(dc.m_hDC);
- wglMakeCurrent (oldDC, oldRC);
+ glFlush();
+ pfnwglSwapBuffers (dc.m_hDC);
+ pfnwglMakeCurrent (oldDC, oldRC);
}
void CTerrainWnd::OnSize(UINT nType, int cx, int cy)
@@ -109,7 +109,7 @@ void CTerrainWnd::OnDestroy()
}
if (m_hglRC)
- wglDeleteContext(m_hglRC);
+ pfnwglDeleteContext(m_hglRC);
if (m_pDC)
delete m_pDC;
@@ -136,11 +136,11 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
- int nPixelFormat = ChoosePixelFormat(m_pDC->m_hDC, &pfd);
+ int nPixelFormat = pfnwglChoosePixelFormat(m_pDC->m_hDC, &pfd);
if (nPixelFormat == 0)
return -1;
- if (!SetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
+ if (!pfnwglSetPixelFormat(m_pDC->m_hDC, nPixelFormat, &pfd))
return -1;
m_pPalette = new CPalette;
@@ -156,13 +156,13 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
}
// Create a rendering context.
- m_hglRC = wglCreateContext(m_pDC->m_hDC);
+ m_hglRC = pfnwglCreateContext(m_pDC->m_hDC);
if (!m_hglRC)
return -1;
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
- wglMakeCurrent (m_pDC->m_hDC, m_hglRC);
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
+ pfnwglMakeCurrent (m_pDC->m_hDC, m_hglRC);
// Initialize OpenGL the way we want it.
float ambient [] = {0.0f, 0.0f, 0.0f, 1.0f};
@@ -184,19 +184,19 @@ int CTerrainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
- wglMakeCurrent(oldDC, oldRC);
+ pfnwglMakeCurrent(oldDC, oldRC);
return 0;
}
void CTerrainWnd::LoadTexture(bool linear)
{
- HDC oldDC = wglGetCurrentDC();
- HGLRC oldRC = wglGetCurrentContext();
+ HDC oldDC = pfnwglGetCurrentDC();
+ HGLRC oldRC = pfnwglGetCurrentContext();
- wglMakeCurrent(m_pDC->m_hDC, m_hglRC);
+ pfnwglMakeCurrent(m_pDC->m_hDC, m_hglRC);
m_pTerrain->LoadTexture(linear);
- wglMakeCurrent(oldDC, oldRC);
+ pfnwglMakeCurrent(oldDC, oldRC);
}
void CTerrainWnd::OnLButtonDown(UINT nFlags, CPoint point)
diff --git a/win/win_gl.cpp b/win/win_gl.cpp
index b23bb55..4310c55 100755
--- a/win/win_gl.cpp
+++ b/win/win_gl.cpp
@@ -2,6 +2,7 @@
// Windows OpenGL functions
//
+#include "stdafx.h"
#include "opengl.h"
static HMODULE gl_module;