From 905cb8cbbe9a2c59784d95899df948dd9e50c069 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 1 Jan 2000 21:11:39 +0000 Subject: Changes to help porting to other platforms git-svn-id: http://svn.leocad.org/trunk@44 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/camera.cpp | 5 ++-- common/defines.h | 8 +++--- common/file.cpp | 10 +++---- common/group.cpp | 4 +-- common/image.cpp | 2 +- common/light.cpp | 2 +- common/piece.cpp | 77 +++++++++++++++++++++++++++-------------------------- common/pieceinf.cpp | 33 +++++++++++------------ common/project.cpp | 47 ++++++++++++++++---------------- common/terrain.cpp | 5 ++-- common/texture.cpp | 24 ++++++++--------- common/tr.cpp | 36 ++++++++++++++----------- common/tr.h | 2 +- 13 files changed, 126 insertions(+), 129 deletions(-) (limited to 'common') diff --git a/common/camera.cpp b/common/camera.cpp index e78d9d0..34893e8 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -1,10 +1,9 @@ // Camera object. -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else -#include "GL/glu.h" #endif +#include "GL/glu.h" #include #include #include diff --git a/common/defines.h b/common/defines.h index 25366a8..59676ae 100644 --- a/common/defines.h +++ b/common/defines.h @@ -7,11 +7,11 @@ ///////////////////////////////////////////////////////////////////////////// // System specific -#if ! ( defined( _WINDOWS ) || defined( _LINUX ) ) +#if ! ( defined( LC_WINDOWS ) || defined( LC_LINUX ) || defined( LC_MACINTOSH )) #error YOU NEED TO DEFINE YOUR OS #endif -#ifdef _WINDOWS +#ifdef LC_WINDOWS #define LC_MAXPATH _MAX_PATH #define KEY_SHIFT VK_SHIFT #define KEY_CONTROL VK_CONTROL @@ -29,7 +29,7 @@ #define KEY_MINUS VK_SUBTRACT #endif -#ifdef _LINUX +#ifdef LC_LINUX #define LC_MAXPATH 1024 //FILENAME_MAX #define KEY_SHIFT 0x01 #define KEY_CONTROL 0x02 @@ -52,7 +52,7 @@ char* strlwr(char* string); #endif // Endianess handling (files are little endian). -#ifdef _BIG_ENDIAN +#ifdef LC_BIG_ENDIAN unsigned short SwapSHORT(unsigned short x) { return (x>>8) | (x<<8); } unsigned long SwapLONG(unsigned long x) diff --git a/common/file.cpp b/common/file.cpp index ad7372a..06838cf 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -32,7 +32,7 @@ unsigned long File::ReadShort(void* pBuf, unsigned long nCount) read = Read(pBuf, nCount*2)/2; -#ifdef _BIG_ENDIAN +#ifdef LC_BIG_ENDIAN unsigned long i; unsigned short* val = (unsigned short*)pBuf, x; @@ -54,7 +54,7 @@ unsigned long File::ReadLong(void* pBuf, unsigned long nCount) read = Read(pBuf, nCount*4)/4; -#ifdef _BIG_ENDIAN +#ifdef LC_BIG_ENDIAN unsigned long i; unsigned long* val = (unsigned long*)pBuf, x; @@ -76,7 +76,7 @@ unsigned long File::WriteByte(const void* pBuf, unsigned long nCount) unsigned long File::WriteShort(const void* pBuf, unsigned long nCount) { -#ifdef _BIG_ENDIAN +#ifdef LC_BIG_ENDIAN unsigned long wrote = 0, i; unsigned short* val = (unsigned short*)pBuf, x; @@ -95,7 +95,7 @@ unsigned long File::WriteShort(const void* pBuf, unsigned long nCount) unsigned long File::WriteLong(const void* pBuf, unsigned long nCount) { -#ifdef _BIG_ENDIAN +#ifdef LC_BIG_ENDIAN unsigned long wrote = 0, i; unsigned long* val = (unsigned long*)pBuf, x; @@ -112,7 +112,7 @@ unsigned long File::WriteLong(const void* pBuf, unsigned long nCount) #endif } -// ======================================================== +// ========================================================= FileMem::FileMem() { diff --git a/common/group.cpp b/common/group.cpp index e20a1f5..89c6299 100644 --- a/common/group.cpp +++ b/common/group.cpp @@ -52,7 +52,7 @@ void Group::FileLoad(File* file) file->Read(&version, 1); file->Read(m_strName, 65); file->Read(m_fCenter, 12); - file->Read(&i, 4); + file->ReadLong(&i, 1); m_pGroup = (Group*)i; } @@ -75,5 +75,5 @@ void Group::FileSave(File* file, Group* pGroups) else i++; } - file->Write(&i, 4); + file->WriteLong(&i, 1); } diff --git a/common/image.cpp b/common/image.cpp index 9d7fe50..950f211 100644 --- a/common/image.cpp +++ b/common/image.cpp @@ -1028,7 +1028,7 @@ static bool SaveGIF(File* file, LC_IMAGE* image, bool transparent, bool interlac return true; } -#ifdef _WINDOWS +#ifdef LC_WINDOWS //#include //#include diff --git a/common/light.cpp b/common/light.cpp index f634822..b546e4b 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -1,6 +1,6 @@ // Light object. -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" #endif #include diff --git a/common/piece.cpp b/common/piece.cpp index b63c401..c0c29c3 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -1,7 +1,7 @@ // A piece object in the LeoCAD world. // -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" #endif #include @@ -99,19 +99,20 @@ inline static void SetCurrentColor(unsigned char nColor, bool* bTrans, bool bLig static bool lockarrays = false; -#ifdef _WINDOWS +#ifdef LC_WINDOWS typedef void (APIENTRY * GLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); typedef void (APIENTRY * GLUNLOCKARRAYSEXTPROC) (); static GLLOCKARRAYSEXTPROC glLockArraysEXT = NULL; static GLUNLOCKARRAYSEXTPROC glUnlockArraysEXT = NULL; #else +// TODO: get the entry point under different OS's #define glLockArraysEXT(a,b) {} #define glUnlockArraysEXT() {} #endif Piece::Piece(PieceInfo* pPieceInfo) { -#ifdef _WINDOWS +#ifdef LC_WINDOWS static bool first_time = true; if (first_time) @@ -198,13 +199,13 @@ void Piece::FileLoad(File* file, char* name) PIECE_KEY *node; unsigned char version, ch; - file->Read(&version, 1); + file->ReadByte(&version, 1); if (version > 5) { unsigned long keys; - file->Read(&keys, 4); + file->ReadLong(&keys, 1); for (node = NULL; keys--;) { if (node == NULL) @@ -216,11 +217,11 @@ void Piece::FileLoad(File* file, char* name) node = AddNode(node, 1, PK_POSITION); file->Read(node->param, 16); - file->Read(&node->time, 2); - file->Read(&node->type, 1); + file->ReadShort(&node->time, 1); + file->ReadByte(&node->type, 1); } - file->Read(&keys, 4); + file->ReadLong(&keys, 1); for (node = NULL; keys--;) { if (node == NULL) @@ -232,8 +233,8 @@ void Piece::FileLoad(File* file, char* name) node = AddNode(node, 1, PK_POSITION); file->Read(node->param, 16); - file->Read(&node->time, 2); - file->Read(&node->type, 1); + file->ReadShort(&node->time, 1); + file->ReadByte(&node->type, 1); } } else @@ -268,14 +269,14 @@ void Piece::FileLoad(File* file, char* name) } unsigned char b; - file->Read(&b, 1); + file->ReadByte(&b, 1); node->time = b; mat.GetTranslation(&node->param[0], &node->param[1], &node->param[2]); node = AddNode(node, b, PK_ROTATION); mat.ToAxisAngle(node->param); int bl; - file->Read(&bl, 4); + file->ReadLong(&bl, 1); } } else @@ -300,7 +301,7 @@ void Piece::FileLoad(File* file, char* name) // Common to all versions. file->Read(name, 9); - file->Read(&m_nColor, 1); + file->ReadByte(&m_nColor, 1); if (version < 5) { @@ -308,28 +309,28 @@ void Piece::FileLoad(File* file, char* name) m_nColor = conv[m_nColor]; } - file->Read(&m_nStepShow, 1); + file->ReadByte(&m_nStepShow, 1); if (version > 1) - file->Read(&m_nStepHide, 1); + file->ReadByte(&m_nStepHide, 1); else m_nStepHide = 255; if (version > 5) { - file->Read(&m_nFrameShow, 2); - file->Read(&m_nFrameHide, 2); + file->ReadShort(&m_nFrameShow, 1); + file->ReadShort(&m_nFrameHide, 1); if (version > 7) { - file->Read(&m_nState, 1); + file->ReadByte(&m_nState, 1); UnSelect(); - file->Read(&ch, 1); + file->ReadByte(&ch, 1); file->Read(m_strName, ch); } else { int hide; - file->Read(&hide, 4); + file->ReadLong(&hide, 1); if (hide != 0) m_nState |= LC_PIECE_HIDDEN; file->Read(m_strName, 81); @@ -338,7 +339,7 @@ void Piece::FileLoad(File* file, char* name) // 7 (0.64) int i = -1; if (version > 6) - file->Read(&i, 4); + file->ReadLong(&i, 1); m_pGroup = (Group*)i; } else @@ -346,13 +347,13 @@ void Piece::FileLoad(File* file, char* name) m_nFrameShow = 1; m_nFrameHide = 65535; - file->Read(&ch, 1); + file->ReadByte(&ch, 1); if (ch == 0) m_pGroup = (Group*)-1; else m_pGroup = (Group*)ch; - file->Read(&ch, 1); + file->ReadByte(&ch, 1); if (ch & 0x01) m_nState |= LC_PIECE_HIDDEN; } @@ -364,42 +365,42 @@ void Piece::FileSave(File* file, Group* pGroups) unsigned char ch = 8; // LeoCAD 0.70 unsigned long n; - file->Write(&ch, 1); + file->WriteByte(&ch, 1); for (n = 0, node = m_pInstructionKeys; node; node = node->next) n++; - file->Write(&n, 4); + file->WriteLong(&n, 1); for (node = m_pInstructionKeys; node; node = node->next) { file->Write(node->param, 16); - file->Write(&node->time, 2); - file->Write(&node->type, 1); + file->WriteShort(&node->time, 1); + file->WriteByte(&node->type, 1); } for (n = 0, node = m_pAnimationKeys; node; node = node->next) n++; - file->Write(&n, 4); + file->WriteLong(&n, 1); for (node = m_pAnimationKeys; node; node = node->next) { file->Write(node->param, 16); - file->Write(&node->time, 2); - file->Write(&node->type, 1); + file->WriteShort(&node->time, 1); + file->WriteByte(&node->type, 1); } file->Write(m_pPieceInfo->m_strName, 9); - file->Write(&m_nColor, 1); - file->Write(&m_nStepShow, 1); - file->Write(&m_nStepHide, 1); - file->Write(&m_nFrameShow, 2); - file->Write(&m_nFrameHide, 2); + file->WriteByte(&m_nColor, 1); + file->WriteByte(&m_nStepShow, 1); + file->WriteByte(&m_nStepHide, 1); + file->WriteShort(&m_nFrameShow, 1); + file->WriteShort(&m_nFrameHide, 1); // version 8 - file->Write(&m_nState, 1); + file->WriteByte(&m_nState, 1); ch = strlen(m_strName); - file->Write(&ch, 1); + file->WriteByte(&ch, 1); file->Write(m_strName, ch); // version 7 @@ -415,7 +416,7 @@ void Piece::FileSave(File* file, Group* pGroups) } else i = -1; - file->Write(&i, 4); + file->WriteLong(&i, 1); } void Piece::Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame, unsigned char nColor) diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index b44c833..7cd9b6c 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -1,12 +1,11 @@ // Information about how to draw a piece and some more stuff. // -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else +#endif #include #include -#endif #include #include #include @@ -207,7 +206,6 @@ void PieceInfo::LoadIndex(File* file) init = true; } - // TODO: don't change ref. if we're reloading ? m_nRef = 0; m_nVertexCount = 0; @@ -221,11 +219,11 @@ void PieceInfo::LoadIndex(File* file) file->Read(m_strName, 8); file->Read(m_strDescription, 64); - file->Read(sh, sizeof(sh)); - file->Read(&m_nFlags, sizeof(m_nFlags)); - file->Read(&m_nGroups, sizeof(m_nGroups)); - file->Read(&m_nOffset, sizeof(m_nOffset)); - file->Read(&m_nSize, sizeof(m_nSize)); + file->ReadShort(sh, 6); + file->ReadByte(&m_nFlags, 1); + file->ReadLong(&m_nGroups, 1); + file->ReadLong(&m_nOffset, 1); + file->ReadLong(&m_nSize, 1); scale = 100; if (m_nFlags & LC_PIECE_MEDIUM) scale = 1000; @@ -265,7 +263,7 @@ void PieceInfo::DeRef() void PieceInfo::LoadInformation() { - FILE* bin; + FileDisk bin; char filename[LC_MAXPATH]; void* buf; unsigned long verts, *longs, fixverts; @@ -318,14 +316,13 @@ void PieceInfo::LoadInformation() // Open pieces.bin and buffer the information we need. strcpy(filename, project->GetLibraryPath()); strcat(filename, "pieces.bin"); - bin = fopen(filename, "rb"); - if (bin == NULL) + if (!bin.Open(filename, "rb")) return; buf = malloc(m_nSize); - fseek(bin, m_nOffset, SEEK_SET); - fread(buf, 1, m_nSize, bin); - fclose(bin); + bin.Seek(m_nOffset, SEEK_SET); + bin.Read(buf, m_nSize); + bin.Close(); shift = 1.0f/(1<<14); scale = 0.01f; @@ -1491,10 +1488,10 @@ void PieceInfo::ZoomExtents() { // TODO: Calculate this in the right way bool out = false; - double modelMatrix[16], projMatrix[16]; - double obj1x, obj1y, obj1z, obj2x, obj2y, obj2z; + GLdouble modelMatrix[16], projMatrix[16]; + GLdouble obj1x, obj1y, obj1z, obj2x, obj2y, obj2z; double View[3] = { -5, -5, 3 }; - int viewport[4]; + GLint viewport[4]; float v[24] = { m_fDimensions[0], m_fDimensions[1], m_fDimensions[5], m_fDimensions[3], m_fDimensions[1], m_fDimensions[5], diff --git a/common/project.cpp b/common/project.cpp index d77c8f3..68abbd5 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1,12 +1,11 @@ // Everything that is a part of a LeoCAD project goes here. // -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else +#endif #include #include -#endif #include #include #include @@ -261,7 +260,7 @@ bool Project::Initialize(int argc, char *argv[], char* libpath) if (LoadPieceLibrary() == false) { -#ifdef _WINDOWS +#ifdef LC_WINDOWS SystemDoMessageBox("Cannot load piece library.", LC_MB_OK|LC_MB_ICONERROR); #else printf("Cannot load piece library !\n"); @@ -1676,7 +1675,7 @@ void Project::Render(bool bToMemory) // return; #ifdef _DEBUG -#ifdef _WINDOWS +#ifdef LC_WINDOWS #define BENCHMARK #endif #endif @@ -1931,8 +1930,8 @@ glLightfv(GL_LIGHT0, GL_SPECULAR, one); // There's got to be an easier way... if (m_nSnap & LC_DRAW_AXIS) { - double model[16], proj[16], obj1x, obj1y, obj1z, obj2x, obj2y, obj2z; - int viewport[4]; + GLdouble model[16], proj[16], obj1x, obj1y, obj1z, obj2x, obj2y, obj2z; + GLint viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, model); glGetDoublev(GL_PROJECTION_MATRIX, proj); @@ -3186,7 +3185,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) case LC_FILE_3DS: { -#ifdef _WINDOWS +#ifdef LC_WINDOWS Export3DStudio(); #endif } break; @@ -3747,7 +3746,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (opts.render) { -#ifdef _WINDOWS +#ifdef LC_WINDOWS // TODO: Linux support char buf[600]; char tmp[LC_MAXPATH], out[LC_MAXPATH]; @@ -5056,10 +5055,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (m_pPieces == 0) break; bool bControl = IsKeyDown(KEY_CONTROL); - double modelMatrix[16], projMatrix[16]; + GLdouble modelMatrix[16], projMatrix[16]; float up[3], eye[3], target[3]; float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 }; - int viewport[4], out, x, y, w, h; + GLint viewport[4], out, x, y, w, h; for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext) if (pPiece->IsVisible(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation)) @@ -5734,9 +5733,9 @@ PieceInfo* Project::FindPieceInfo(char* name) BoundingBox* Project::FindObjectFromPoint(int x, int y) { - double px, py, pz, rx, ry, rz; - double modelMatrix[16], projMatrix[16]; - int viewport[4]; + GLdouble px, py, pz, rx, ry, rz; + GLdouble modelMatrix[16], projMatrix[16]; + GLint viewport[4]; Piece* pPiece; Camera* pCamera; Light* pLight; @@ -6405,9 +6404,9 @@ bool Project::OnKeyDown(char nKey, bool bControl, bool bShift) } break; } - double modelMatrix[16], projMatrix[16], p1[3], p2[3], p3[3]; + GLdouble modelMatrix[16], projMatrix[16], p1[3], p2[3], p3[3]; float ax, ay; - int viewport[4]; + GLint viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); @@ -6465,8 +6464,8 @@ bool Project::OnKeyDown(char nKey, bool bControl, bool bShift) void Project::OnLeftButtonDown(int x, int y) { - double modelMatrix[16], projMatrix[16], point[3]; - int viewport[4]; + GLdouble modelMatrix[16], projMatrix[16], point[3]; + GLint viewport[4]; if (IsDrawing()) return; @@ -6741,8 +6740,8 @@ void Project::OnLeftButtonDown(int x, int y) void Project::OnLeftButtonDoubleClick(int x, int y) { - double modelMatrix[16], projMatrix[16], point[3]; - int viewport[4]; + GLdouble modelMatrix[16], projMatrix[16], point[3]; + GLint viewport[4]; if (IsDrawing()) return; @@ -6817,8 +6816,8 @@ void Project::OnLeftButtonUp(int x, int y) void Project::OnRightButtonDown(int x, int y) { - double modelMatrix[16], projMatrix[16], point[3]; - int viewport[4]; + GLdouble modelMatrix[16], projMatrix[16], point[3]; + GLint viewport[4]; if (StopTracking(false)) return; @@ -6906,8 +6905,8 @@ void Project::OnMouseMove(int x, int y) if (IsDrawing()) return; - double modelMatrix[16], projMatrix[16], tmp[3]; - int viewport[4]; + GLdouble modelMatrix[16], projMatrix[16], tmp[3]; + GLint viewport[4]; float ptx, pty, ptz; LoadViewportProjection(); diff --git a/common/terrain.cpp b/common/terrain.cpp index 771cce0..a1c9b2a 100644 --- a/common/terrain.cpp +++ b/common/terrain.cpp @@ -1,11 +1,10 @@ // Terrain: a Bezier surface. // -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else -#include #endif +#include #include #include #include diff --git a/common/texture.cpp b/common/texture.cpp index febaf9e..066fa6a 100644 --- a/common/texture.cpp +++ b/common/texture.cpp @@ -1,11 +1,10 @@ // Texture object. // -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else -#include "GL/glu.h" #endif +#include "GL/glu.h" #include #include #include "file.h" @@ -58,9 +57,9 @@ void Texture::LoadIndex(File* idx) m_nID = 0; idx->Read(m_strName, 8); - idx->Read(&m_nWidth, sizeof(m_nWidth)); - idx->Read(&m_nHeight, sizeof(m_nHeight)); - idx->Read(&bt, sizeof(bt)); + idx->ReadShort(&m_nWidth, 1); + idx->ReadShort(&m_nHeight, 1); + idx->ReadByte(&bt, 1); switch (bt) { @@ -69,7 +68,7 @@ void Texture::LoadIndex(File* idx) case LC_RGBA: m_nType = GL_RGBA; break; } - idx->Read(&m_nOffset, sizeof(m_nOffset)); + idx->ReadLong(&m_nOffset, 1); } void Texture::Unload() @@ -84,13 +83,12 @@ void Texture::Load(bool bFilter) { unsigned char* bits; char filename[LC_MAXPATH]; - FILE* bin; + FileDisk bin; int size; strcpy(filename, project->GetLibraryPath()); strcat(filename, "textures.bin"); - bin = fopen(filename, "rb"); - if (bin == NULL) + if (!bin.Open(filename, "rb")) return; size = m_nWidth*m_nHeight; @@ -100,9 +98,9 @@ void Texture::Load(bool bFilter) size *= 4; bits = (unsigned char*)malloc(size); - fseek(bin, m_nOffset, SEEK_SET); - fread(bits, 1, size, bin); - fclose(bin); + bin.Seek(m_nOffset, SEEK_SET); + bin.Read(bits, size); + bin.Close(); if (m_nID == 0) glGenTextures(1, &m_nID); diff --git a/common/tr.cpp b/common/tr.cpp index c39087f..9aa82f5 100644 --- a/common/tr.cpp +++ b/common/tr.cpp @@ -2,12 +2,11 @@ // ////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS +#ifdef LC_WINDOWS #include "stdafx.h" -#else +#endif #include #include -#endif #include "tr.h" #include @@ -144,7 +143,7 @@ void TiledRender::Perspective(double fovy, double aspect, double zNear, double z void TiledRender::BeginTile() { - int matrixMode; + GLint matrixMode; int tileWidth, tileHeight, tileWidthNB, tileHeightNB, border; double left, right, bottom, top; @@ -158,7 +157,7 @@ void TiledRender::BeginTile() glGetIntegerv(GL_VIEWPORT, m_ViewportSave); } - /* which tile (by row and column) we're about to render */ + // which tile (by row and column) we're about to render if (m_RowOrder == TR_BOTTOM_TO_TOP) { m_CurrentRow = m_CurrentTile / m_Columns; @@ -172,7 +171,7 @@ void TiledRender::BeginTile() border = m_TileBorder; - /* Compute actual size of this tile with border */ + // Compute actual size of this tile with border if (m_CurrentRow < m_Rows-1) tileHeight = m_TileHeight; else @@ -183,22 +182,22 @@ void TiledRender::BeginTile() else tileWidth = m_ImageWidth - (m_Columns-1) * (m_TileWidthNB) + 2 * border; - /* tile size with No Border */ + // tile size with No Border tileWidthNB = tileWidth - 2 * border; tileHeightNB = tileHeight - 2 * border; - /* Save tile size, with border */ + // Save tile size, with border m_CurrentTileWidth = tileWidth; m_CurrentTileHeight = tileHeight; - glViewport(0, 0, tileWidth, tileHeight); /* tile size including border */ + glViewport(0, 0, tileWidth, tileHeight); // tile size including border - /* save current matrix mode */ + // save current matrix mode glGetIntegerv(GL_MATRIX_MODE, &matrixMode); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - /* compute projection parameters */ + // compute projection parameters left = m_Left + (m_Right - m_Left) * (m_CurrentColumn * m_TileWidthNB - border) / m_ImageWidth; right = left + (m_Right - m_Left) * tileWidth / m_ImageWidth; @@ -211,13 +210,13 @@ void TiledRender::BeginTile() else glOrtho(left, right, bottom, top, m_Near, m_Far); - /* restore user's matrix mode */ + // restore user's matrix mode glMatrixMode((GLenum)matrixMode); } int TiledRender::EndTile() { - int prevRowLength, prevSkipRows, prevSkipPixels; + GLint prevRowLength, prevSkipRows, prevSkipPixels; // be sure OpenGL rendering is finished glFlush(); @@ -284,9 +283,9 @@ void TiledRender::RasterPos3f(float x, float y, float z) } else { - double modelview[16], proj[16]; - int viewport[4]; - double winX, winY, winZ; + GLdouble modelview[16], proj[16]; + GLint viewport[4]; + GLdouble winX, winY, winZ; // Get modelview, projection and viewport glGetDoublev(GL_MODELVIEW_MATRIX, modelview); @@ -323,3 +322,8 @@ void TiledRender::RasterPos3f(float x, float y, float z) } } } + + + + + diff --git a/common/tr.h b/common/tr.h index 024adaf..f1394c6 100644 --- a/common/tr.h +++ b/common/tr.h @@ -69,7 +69,7 @@ public: int m_CurrentTileWidth, m_CurrentTileHeight; int m_CurrentRow, m_CurrentColumn; - int m_ViewportSave[4]; + GLint m_ViewportSave[4]; }; #endif // _TR_H_ -- cgit v1.2.3