From 6a0c59cd1ef3362a486e9261a000020ce8aacc9c Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 24 Feb 2009 05:54:16 +0000 Subject: Removed display lists. git-svn-id: http://svn.leocad.org/tags/leocad-0.75@743 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/camera.cpp | 104 +++++++--------- common/camera.h | 2 - common/light.cpp | 338 +++++++++++++++++++++++++--------------------------- common/light.h | 6 +- common/piece.cpp | 4 +- common/pieceinf.cpp | 14 +-- common/pieceinf.h | 9 +- common/project.cpp | 14 +-- common/project.h | 2 +- 9 files changed, 214 insertions(+), 279 deletions(-) (limited to 'common') diff --git a/common/camera.cpp b/common/camera.cpp index a73fe60..3713939 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -14,8 +14,6 @@ #define LC_CAMERA_SAVE_VERSION 6 // LeoCAD 0.73 -GLuint Camera::m_nTargetList = 0; - static LC_OBJECT_KEY_INFO camera_key_info[LC_CK_COUNT] = { { "Camera Position", 3, LC_CK_EYE }, @@ -194,9 +192,6 @@ Camera::Camera (float ex, float ey, float ez, float tx, float ty, float tz, Came Camera::~Camera() { - if (m_nList != 0) - glDeleteLists (m_nList, 1); - delete m_pTarget; } @@ -208,9 +203,7 @@ void Camera::Initialize() m_pNext = NULL; m_nState = 0; - m_nList = 0; m_nType = LC_CAMERA_USER; - m_nList = 0; m_pTR = NULL; for (unsigned char i = 0 ; i < sizeof(m_strName) ; i++ ) @@ -546,11 +539,28 @@ void Camera::UpdateBoundingBox() mat.SetTranslation (m_fTarget[0], m_fTarget[1], m_fTarget[2]); m_pTarget->BoundingBoxCalculate (&mat); mat.SetTranslation (0, 0, 0); +} - if (!m_nList) - return; +void Camera::Render(float fLineWidth) +{ + // Fix the up vector + Vector frontvec(m_fEye[0]-m_fTarget[0], m_fEye[1]-m_fTarget[1], m_fEye[2]-m_fTarget[2]); + float len = frontvec.Length(); - glNewList(m_nList, GL_COMPILE); + Matrix mat; + mat.CreateLookat (m_fEye, m_fTarget, m_fUp); + mat.Invert (); + mat.SetTranslation (0, 0, 0); + + if (IsEyeSelected()) + { + glLineWidth(fLineWidth*2); + glColor3ubv(FlatColorArray[(m_nState & LC_CAMERA_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); + } + else + { + glColor4f(0.5f, 0.8f, 0.5f, 1.0f); + } glPushMatrix(); glTranslatef(m_fEye[0], m_fEye[1], m_fEye[2]); @@ -578,73 +588,41 @@ void Camera::UpdateBoundingBox() glVertexPointer (3, GL_FLOAT, 0, verts); glDrawArrays(GL_LINES, 0, 24); glDrawArrays(GL_LINE_STRIP, 24, 10); + glLineWidth(fLineWidth); glTranslatef(0, 0, -len); - glEndList(); - - if (m_nTargetList == 0) - { - m_nTargetList = glGenLists(1); - glNewList (m_nTargetList, GL_COMPILE); - - glEnableClientState(GL_VERTEX_ARRAY); - float box[24][3] = { - { 0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, 0.2f }, - { -0.2f, 0.2f, 0.2f }, { -0.2f, -0.2f, 0.2f }, - { -0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, 0.2f }, - { 0.2f, -0.2f, 0.2f }, { 0.2f, 0.2f, 0.2f }, - { 0.2f, 0.2f, -0.2f }, { -0.2f, 0.2f, -0.2f }, - { -0.2f, 0.2f, -0.2f }, { -0.2f, -0.2f, -0.2f }, - { -0.2f, -0.2f, -0.2f }, { 0.2f, -0.2f, -0.2f }, - { 0.2f, -0.2f, -0.2f }, { 0.2f, 0.2f, -0.2f }, - { 0.2f, 0.2f, 0.2f }, { 0.2f, 0.2f, -0.2f }, - { -0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, -0.2f }, - { -0.2f, -0.2f, 0.2f }, { -0.2f, -0.2f, -0.2f }, - { 0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, -0.2f } }; - glVertexPointer (3, GL_FLOAT, 0, box); - glDrawArrays(GL_LINES, 0, 24); - glPopMatrix(); - glEndList(); - } -} - -void Camera::Render(float fLineWidth) -{ - // Create the display lists if this is the first time we're rendered. - if (!m_nList) - { - m_nList = glGenLists(1); - UpdateBoundingBox(); - } - - if (IsEyeSelected()) - { - glLineWidth(fLineWidth*2); - glColor3ubv(FlatColorArray[(m_nState & LC_CAMERA_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); - glCallList(m_nList); - glLineWidth(fLineWidth); - } - else - { - glColor4f(0.5f, 0.8f, 0.5f, 1.0f); - glCallList(m_nList); - } - if (IsTargetSelected()) { glLineWidth(fLineWidth*2); glColor3ubv(FlatColorArray[(m_nState & LC_CAMERA_TARGET_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); - glCallList(m_nTargetList); - glLineWidth(fLineWidth); } else { glColor3f(0.5f, 0.8f, 0.5f); - glCallList(m_nTargetList); } glEnableClientState(GL_VERTEX_ARRAY); + float box[24][3] = + { + { 0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, 0.2f }, + { -0.2f, 0.2f, 0.2f }, { -0.2f, -0.2f, 0.2f }, + { -0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, 0.2f }, + { 0.2f, -0.2f, 0.2f }, { 0.2f, 0.2f, 0.2f }, + { 0.2f, 0.2f, -0.2f }, { -0.2f, 0.2f, -0.2f }, + { -0.2f, 0.2f, -0.2f }, { -0.2f, -0.2f, -0.2f }, + { -0.2f, -0.2f, -0.2f }, { 0.2f, -0.2f, -0.2f }, + { 0.2f, -0.2f, -0.2f }, { 0.2f, 0.2f, -0.2f }, + { 0.2f, 0.2f, 0.2f }, { 0.2f, 0.2f, -0.2f }, + { -0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, -0.2f }, + { -0.2f, -0.2f, 0.2f }, { -0.2f, -0.2f, -0.2f }, + { 0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, -0.2f } + }; + glVertexPointer (3, GL_FLOAT, 0, box); + glDrawArrays(GL_LINES, 0, 24); + glPopMatrix(); + + glLineWidth(fLineWidth); float Line[2][3] = { diff --git a/common/camera.h b/common/camera.h index 060086b..2476471 100644 --- a/common/camera.h +++ b/common/camera.h @@ -181,8 +181,6 @@ protected: char m_strName[81]; unsigned char m_nState; unsigned char m_nType; - GLuint m_nList; - static GLuint m_nTargetList; // Current position and orientation. float m_fEye[3]; diff --git a/common/light.cpp b/common/light.cpp index a6f7dea..cdd0536 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -10,9 +10,6 @@ #include "vector.h" #include "matrix.h" -GLuint Light::m_nSphereList = 0; -GLuint Light::m_nTargetList = 0; - static LC_OBJECT_KEY_INFO light_key_info[LC_LK_COUNT] = { { "Light Position", 3, LC_LK_POSITION }, @@ -112,7 +109,6 @@ void Light::Initialize () m_pNext = NULL; m_nState = 0; m_pTarget = NULL; - m_nList = 0; memset (m_strName, 0, sizeof (m_strName)); m_fAmbient[3] = 1.0f; @@ -147,9 +143,6 @@ void Light::Initialize () Light::~Light () { - if (m_nList != 0) - glDeleteLists (m_nList, 1); - delete m_pTarget; } @@ -271,172 +264,7 @@ void Light::UpdatePosition (unsigned short nTime, bool bAnimation) BoundingBoxCalculate (m_fPos); if (m_pTarget != NULL) - { m_pTarget->BoundingBoxCalculate (m_fTarget); - - if (m_nList == 0) - m_nList = glGenLists(1); - - glNewList (m_nList, GL_COMPILE); - - glPushMatrix (); - glTranslatef (m_fPos[0], m_fPos[1], m_fPos[2]); - - Vector frontvec (m_fTarget[0]-m_fPos[0], m_fTarget[1]-m_fPos[1], m_fTarget[2]-m_fPos[2]); - float len = frontvec.Length (), up[3] = { 1, 1, 1 }; - - if (fabs (frontvec[0]) < fabs (frontvec[1])) - { - if (fabs (frontvec[0]) < fabs (frontvec[2])) - up[0] = -(up[1]*frontvec[1] + up[2]*frontvec[2]); - else - up[2] = -(up[0]*frontvec[0] + up[1]*frontvec[1]); - } - else - { - if (fabs (frontvec[1]) < fabs (frontvec[2])) - up[1] = -(up[0]*frontvec[0] + up[2]*frontvec[2]); - else - up[2] = -(up[0]*frontvec[0] + up[1]*frontvec[1]); - } - - Matrix mat; - mat.CreateLookat (m_fPos, m_fTarget, up); - mat.Invert (); - mat.SetTranslation (0, 0, 0); - - glMultMatrixf (mat.m); - - glEnableClientState (GL_VERTEX_ARRAY); - float verts[16*3]; - for (int i = 0; i < 8; i++) - { - verts[i*6] = verts[i*6+3] = (float)cos ((float)i/4 * PI) * 0.3f; - verts[i*6+1] = verts[i*6+4] = (float)sin ((float)i/4 * PI) * 0.3f; - verts[i*6+2] = 0.3f; - verts[i*6+5] = -0.3f; - } - glVertexPointer (3, GL_FLOAT, 0, verts); - glDrawArrays (GL_LINES, 0, 16); - glVertexPointer (3, GL_FLOAT, 6*sizeof(float), verts); - glDrawArrays (GL_LINE_LOOP, 0, 8); - glVertexPointer (3, GL_FLOAT, 6*sizeof(float), &verts[3]); - glDrawArrays (GL_LINE_LOOP, 0, 8); - - float Lines[4][3] = - { - { -0.5f, -0.5f, -0.3f }, - { 0.5f, -0.5f, -0.3f }, - { 0.5f, 0.5f, -0.3f }, - { -0.5f, 0.5f, -0.3f } - }; - - glVertexPointer(3, GL_FLOAT, 0, Lines); - glDrawArrays(GL_LINE_LOOP, 0, 4); - - glTranslatef(0, 0, -len); - glEndList(); - - if (m_nTargetList == 0) - { - m_nTargetList = glGenLists (1); - glNewList (m_nTargetList, GL_COMPILE); - - glEnableClientState (GL_VERTEX_ARRAY); - float box[24][3] = { - { 0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, 0.2f }, - { -0.2f, 0.2f, 0.2f }, { -0.2f, -0.2f, 0.2f }, - { -0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, 0.2f }, - { 0.2f, -0.2f, 0.2f }, { 0.2f, 0.2f, 0.2f }, - { 0.2f, 0.2f, -0.2f }, { -0.2f, 0.2f, -0.2f }, - { -0.2f, 0.2f, -0.2f }, { -0.2f, -0.2f, -0.2f }, - { -0.2f, -0.2f, -0.2f }, { 0.2f, -0.2f, -0.2f }, - { 0.2f, -0.2f, -0.2f }, { 0.2f, 0.2f, -0.2f }, - { 0.2f, 0.2f, 0.2f }, { 0.2f, 0.2f, -0.2f }, - { -0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, -0.2f }, - { -0.2f, -0.2f, 0.2f }, { -0.2f, -0.2f, -0.2f }, - { 0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, -0.2f } }; - glVertexPointer (3, GL_FLOAT, 0, box); - glDrawArrays (GL_LINES, 0, 24); - glPopMatrix (); - glEndList (); - } - } - else - { - if (m_nSphereList == 0) - m_nSphereList = glGenLists (1); - glNewList (m_nSphereList, GL_COMPILE); - glEnableClientState (GL_VERTEX_ARRAY); - - const float radius = 0.2f; - const int slices = 6, stacks = 6; - float rho, drho, theta, dtheta; - int i, j, imin, imax; - drho = 3.1415926536f/(float)stacks; - dtheta = 2.0f*3.1415926536f/(float)slices; - - // draw +Z end as a triangle fan - float Cap[slices+2][3]; - - Cap[0][0] = 0.0f; - Cap[0][1] = 0.0f; - Cap[0][2] = radius; - - for (j = 0; j <= slices; j++) - { - theta = (j == slices) ? 0.0f : j * dtheta; - Cap[j+1][0] = (float)(-sin(theta) * sin(drho)) * radius; - Cap[j+1][1] = (float)(cos(theta) * sin(drho)) * radius; - Cap[j+1][2] = (float)(cos(drho)) * radius; - } - - glVertexPointer(3, GL_FLOAT, 0, Cap); - glDrawArrays(GL_TRIANGLE_FAN, 0, slices+2); - - imin = 1; - imax = stacks-1; - - float Center[(slices+1)*2][3]; - glVertexPointer(3, GL_FLOAT, 0, Center); - - for (i = imin; i < imax; i++) - { - rho = i * drho; - - for (j = 0; j <= slices; j++) - { - theta = (j == slices) ? 0.0f : j * dtheta; - Center[j*2][0] = (float)(-sin(theta) * sin(rho)) * radius; - Center[j*2][1] = (float)(cos(theta) * sin(rho)) * radius; - Center[j*2][2] = (float)(cos(rho)) * radius; - Center[j*2+1][0] = (float)(-sin(theta) * sin(rho+drho)) * radius; - Center[j*2+1][1] = (float)(cos(theta) * sin(rho+drho)) * radius; - Center[j*2+1][2] = (float)(cos(rho+drho)) * radius; - } - - glDrawArrays(GL_TRIANGLE_STRIP, 0, (slices+1)*2); - } - - // draw -Z end as a triangle fan - Cap[0][0] = 0.0f; - Cap[0][1] = 0.0f; - Cap[0][2] = -radius; - - rho = 3.1415926536f - drho; - for (j = slices; j >= 0; j--) - { - theta = (j==slices) ? 0.0f : j * dtheta; - Cap[j+1][0] = (float)(-sin(theta) * sin(rho)) * radius; - Cap[j+1][1] = (float)(cos(theta) * sin(rho)) * radius; - Cap[j+1][2] = (float)(cos(rho)) * radius; - } - - glVertexPointer(3, GL_FLOAT, 0, Cap); - glDrawArrays(GL_TRIANGLE_FAN, 0, slices+2); - - glEndList (); - } } void Light::Render (float fLineWidth) @@ -447,26 +275,26 @@ void Light::Render (float fLineWidth) { glLineWidth(fLineWidth*2); glColor3ubv(FlatColorArray[(m_nState & LC_LIGHT_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); - glCallList(m_nList); + DrawCone(); glLineWidth(fLineWidth); } else { glColor3f(0.5f, 0.8f, 0.5f); - glCallList(m_nList); + DrawCone(); } if (IsTargetSelected()) { glLineWidth(fLineWidth*2); glColor3ubv(FlatColorArray[(m_nState & LC_LIGHT_TARGET_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); - glCallList(m_nTargetList); + DrawTarget(); glLineWidth(fLineWidth); } else { glColor3f(0.5f, 0.8f, 0.5f); - glCallList(m_nTargetList); + DrawTarget(); } glColor3f(0.5f, 0.8f, 0.5f); @@ -550,13 +378,13 @@ void Light::Render (float fLineWidth) { glLineWidth (fLineWidth*2); glColor3ubv (FlatColorArray[(m_nState & LC_LIGHT_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); - glCallList (m_nSphereList); + DrawSphere(); glLineWidth (fLineWidth); } else { glColor3f (0.5f, 0.8f, 0.5f); - glCallList (m_nSphereList); + DrawSphere(); } glPopMatrix (); @@ -565,6 +393,160 @@ void Light::Render (float fLineWidth) glDisableClientState(GL_VERTEX_ARRAY); } +void Light::DrawCone() +{ + glPushMatrix (); + glTranslatef (m_fPos[0], m_fPos[1], m_fPos[2]); + + Vector frontvec (m_fTarget[0]-m_fPos[0], m_fTarget[1]-m_fPos[1], m_fTarget[2]-m_fPos[2]); + float len = frontvec.Length (), up[3] = { 1, 1, 1 }; + + if (fabs (frontvec[0]) < fabs (frontvec[1])) + { + if (fabs (frontvec[0]) < fabs (frontvec[2])) + up[0] = -(up[1]*frontvec[1] + up[2]*frontvec[2]); + else + up[2] = -(up[0]*frontvec[0] + up[1]*frontvec[1]); + } + else + { + if (fabs (frontvec[1]) < fabs (frontvec[2])) + up[1] = -(up[0]*frontvec[0] + up[2]*frontvec[2]); + else + up[2] = -(up[0]*frontvec[0] + up[1]*frontvec[1]); + } + + Matrix mat; + mat.CreateLookat (m_fPos, m_fTarget, up); + mat.Invert (); + mat.SetTranslation (0, 0, 0); + + glMultMatrixf (mat.m); + + glEnableClientState (GL_VERTEX_ARRAY); + float verts[16*3]; + for (int i = 0; i < 8; i++) + { + verts[i*6] = verts[i*6+3] = (float)cos ((float)i/4 * PI) * 0.3f; + verts[i*6+1] = verts[i*6+4] = (float)sin ((float)i/4 * PI) * 0.3f; + verts[i*6+2] = 0.3f; + verts[i*6+5] = -0.3f; + } + glVertexPointer (3, GL_FLOAT, 0, verts); + glDrawArrays (GL_LINES, 0, 16); + glVertexPointer (3, GL_FLOAT, 6*sizeof(float), verts); + glDrawArrays (GL_LINE_LOOP, 0, 8); + glVertexPointer (3, GL_FLOAT, 6*sizeof(float), &verts[3]); + glDrawArrays (GL_LINE_LOOP, 0, 8); + + float Lines[4][3] = + { + { -0.5f, -0.5f, -0.3f }, + { 0.5f, -0.5f, -0.3f }, + { 0.5f, 0.5f, -0.3f }, + { -0.5f, 0.5f, -0.3f } + }; + + glVertexPointer(3, GL_FLOAT, 0, Lines); + glDrawArrays(GL_LINE_LOOP, 0, 4); + + glTranslatef(0, 0, -len); +} + +void Light::DrawTarget() +{ + glEnableClientState (GL_VERTEX_ARRAY); + float box[24][3] = + { + { 0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, 0.2f }, + { -0.2f, 0.2f, 0.2f }, { -0.2f, -0.2f, 0.2f }, + { -0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, 0.2f }, + { 0.2f, -0.2f, 0.2f }, { 0.2f, 0.2f, 0.2f }, + { 0.2f, 0.2f, -0.2f }, { -0.2f, 0.2f, -0.2f }, + { -0.2f, 0.2f, -0.2f }, { -0.2f, -0.2f, -0.2f }, + { -0.2f, -0.2f, -0.2f }, { 0.2f, -0.2f, -0.2f }, + { 0.2f, -0.2f, -0.2f }, { 0.2f, 0.2f, -0.2f }, + { 0.2f, 0.2f, 0.2f }, { 0.2f, 0.2f, -0.2f }, + { -0.2f, 0.2f, 0.2f }, { -0.2f, 0.2f, -0.2f }, + { -0.2f, -0.2f, 0.2f }, { -0.2f, -0.2f, -0.2f }, + { 0.2f, -0.2f, 0.2f }, { 0.2f, -0.2f, -0.2f } + }; + glVertexPointer (3, GL_FLOAT, 0, box); + glDrawArrays (GL_LINES, 0, 24); + glPopMatrix (); +} + +void Light::DrawSphere() +{ + glEnableClientState (GL_VERTEX_ARRAY); + + const float radius = 0.2f; + const int slices = 6, stacks = 6; + float rho, drho, theta, dtheta; + int i, j, imin, imax; + drho = 3.1415926536f/(float)stacks; + dtheta = 2.0f*3.1415926536f/(float)slices; + + // draw +Z end as a triangle fan + float Cap[slices+2][3]; + + Cap[0][0] = 0.0f; + Cap[0][1] = 0.0f; + Cap[0][2] = radius; + + for (j = 0; j <= slices; j++) + { + theta = (j == slices) ? 0.0f : j * dtheta; + Cap[j+1][0] = (float)(-sin(theta) * sin(drho)) * radius; + Cap[j+1][1] = (float)(cos(theta) * sin(drho)) * radius; + Cap[j+1][2] = (float)(cos(drho)) * radius; + } + + glVertexPointer(3, GL_FLOAT, 0, Cap); + glDrawArrays(GL_TRIANGLE_FAN, 0, slices+2); + + imin = 1; + imax = stacks-1; + + float Center[(slices+1)*2][3]; + glVertexPointer(3, GL_FLOAT, 0, Center); + + for (i = imin; i < imax; i++) + { + rho = i * drho; + + for (j = 0; j <= slices; j++) + { + theta = (j == slices) ? 0.0f : j * dtheta; + Center[j*2][0] = (float)(-sin(theta) * sin(rho)) * radius; + Center[j*2][1] = (float)(cos(theta) * sin(rho)) * radius; + Center[j*2][2] = (float)(cos(rho)) * radius; + Center[j*2+1][0] = (float)(-sin(theta) * sin(rho+drho)) * radius; + Center[j*2+1][1] = (float)(cos(theta) * sin(rho+drho)) * radius; + Center[j*2+1][2] = (float)(cos(rho+drho)) * radius; + } + + glDrawArrays(GL_TRIANGLE_STRIP, 0, (slices+1)*2); + } + + // draw -Z end as a triangle fan + Cap[0][0] = 0.0f; + Cap[0][1] = 0.0f; + Cap[0][2] = -radius; + + rho = 3.1415926536f - drho; + for (j = slices; j >= 0; j--) + { + theta = (j==slices) ? 0.0f : j * dtheta; + Cap[j+1][0] = (float)(-sin(theta) * sin(rho)) * radius; + Cap[j+1][1] = (float)(cos(theta) * sin(rho)) * radius; + Cap[j+1][2] = (float)(cos(rho)) * radius; + } + + glVertexPointer(3, GL_FLOAT, 0, Cap); + glDrawArrays(GL_TRIANGLE_FAN, 0, slices+2); +} + void Light::Setup (int index) { GLenum light = (GLenum)(GL_LIGHT0+index); diff --git a/common/light.h b/common/light.h index da1cdb6..65a63f7 100644 --- a/common/light.h +++ b/common/light.h @@ -118,9 +118,9 @@ protected: char m_strName[81]; bool m_bEnabled; - GLuint m_nList; - static GLuint m_nSphereList; - static GLuint m_nTargetList; + void DrawCone(); + void DrawTarget(); + void DrawSphere(); // Temporary parameters float m_fPos[4]; diff --git a/common/piece.cpp b/common/piece.cpp index 98e539b..4bf9471 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -1143,14 +1143,14 @@ void Piece::RenderBox(bool bHilite, float fLineWidth) glLineWidth(2*fLineWidth); glPushAttrib(GL_POLYGON_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glCallList(m_pPieceInfo->GetBoxDisplayList()); + m_pPieceInfo->RenderBox(); glPopAttrib(); glLineWidth(fLineWidth); } else { glColor3ubv(FlatColorArray[m_nColor]); - glCallList(m_pPieceInfo->GetBoxDisplayList()); + m_pPieceInfo->RenderBox(); } glPopMatrix(); } diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index bb84695..39e5a9b 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -217,7 +217,6 @@ void PieceInfo::LoadIndex (File& file) m_pGroups = NULL; m_nTextureCount = 0; m_pTextures = NULL; - m_nBoxList = 0; file.Read (m_strName, 8); m_strName[8] = '\0'; @@ -267,14 +266,8 @@ void PieceInfo::DeRef() FreeInformation(); } -void PieceInfo::CreateBoxDisplayList() +void PieceInfo::RenderBox() { - if (m_nBoxList) - return; - - // Create a display for the bounding box. - m_nBoxList = glGenLists(1); - glNewList(m_nBoxList, GL_COMPILE); glEnableClientState(GL_VERTEX_ARRAY); float box[24][3] = @@ -307,7 +300,6 @@ void PieceInfo::CreateBoxDisplayList() glVertexPointer(3, GL_FLOAT, 0, box); glDrawArrays(GL_QUADS, 0, 24); - glEndList(); } void PieceInfo::LoadInformation() @@ -1503,10 +1495,6 @@ void PieceInfo::LoadInformation() void PieceInfo::FreeInformation() { - if (m_nBoxList != 0) - glDeleteLists(m_nBoxList, 1); - m_nBoxList = 0; - if (m_fVertexArray != NULL) { free(m_fVertexArray); diff --git a/common/pieceinf.h b/common/pieceinf.h index 56892c8..cb574c6 100644 --- a/common/pieceinf.h +++ b/common/pieceinf.h @@ -84,15 +84,10 @@ class PieceInfo void ZoomExtents(float Fov, float Aspect, float* EyePos = NULL) const; void RenderOnce(int nColor); void RenderPiece(int nColor); + void RenderBox(); void WriteWavefront(FILE* file, unsigned char color, unsigned long* start); // Implementation - GLuint GetBoxDisplayList() - { - if (!m_nBoxList) - CreateBoxDisplayList(); - return m_nBoxList; - }; void LoadIndex(File& file); void AddRef(); void DeRef(); @@ -118,11 +113,9 @@ public: protected: int m_nRef; - GLuint m_nBoxList; void LoadInformation(); void FreeInformation(); - void CreateBoxDisplayList(); }; #endif // _PIECEINF_H_ diff --git a/common/project.cpp b/common/project.cpp index 01f775a..3c35cf7 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -96,7 +96,6 @@ Project::Project() m_pGroups = NULL; m_pUndoList = NULL; m_pRedoList = NULL; - m_nGridList = 0; m_pTrackFile = NULL; m_nCurClipboard = 0; m_nCurAction = 0; @@ -1916,7 +1915,7 @@ void Project::RenderScene(bool bShaded, bool bDrawViewports) glColor3f(1.0f - m_fBackground[0], 1.0f - m_fBackground[1], 1.0f - m_fBackground[2]); if (m_nSnap & LC_DRAW_GRID) - glCallList (m_nGridList); + DrawGrid(); if ((bShaded) && (m_nDetail & LC_DET_LIGHTING)) glEnable(GL_LIGHTING); @@ -3026,7 +3025,6 @@ void Project::RenderBoxes(bool bHilite) // Initialize OpenGL void Project::RenderInitialize() { - int i; glLineStipple (1, 65280); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -3123,13 +3121,12 @@ void Project::RenderInitialize() // Set the perspective correction hint to fastest or nicest... // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); +} - // Grid display list - if (m_nGridList == 0) - m_nGridList = glGenLists(1); - glNewList (m_nGridList, GL_COMPILE); +void Project::DrawGrid() +{ glEnableClientState(GL_VERTEX_ARRAY); - i = 2*(4*m_nGridSize+2); // verts needed (2*lines) + int i = 2*(4*m_nGridSize+2); // verts needed (2*lines) float *grid = (float*)malloc(i*sizeof(float[3])); float x = m_nGridSize*0.8f; @@ -3151,7 +3148,6 @@ void Project::RenderInitialize() } glVertexPointer(3, GL_FLOAT, 0, grid); glDrawArrays(GL_LINES, 0, i); - glEndList(); free(grid); } diff --git a/common/project.h b/common/project.h index af59d7f..de951ce 100644 --- a/common/project.h +++ b/common/project.h @@ -190,6 +190,7 @@ protected: void RenderOverlays(int Viewport); void RenderBoxes(bool bHilite); void RenderInitialize(); + void DrawGrid(); void CreateHTMLPieceList(FILE* f, int nStep, bool bImages, char* ext); inline bool IsDrawing() @@ -277,7 +278,6 @@ protected: char m_strFooter[256]; char m_strHeader[256]; - GLuint m_nGridList; unsigned long m_nAutosave; unsigned long m_nSaveTimer; char m_strModelsPath[LC_MAXPATH]; -- cgit v1.2.3