summaryrefslogtreecommitdiff
path: root/common/terrain.cpp
diff options
context:
space:
mode:
authorLeo2009-02-23 07:47:54 +0000
committerLeo2009-02-23 07:47:54 +0000
commit281dfd75faafc8a0806cb43649a07833d9209d07 (patch)
treebc1bd02d9df9100acb9d1aa217d1f514dc5e8e9c /common/terrain.cpp
parent27815f2cce37721ae1c524669c3e19cff8a50894 (diff)
Replaced immediate mode calls with vertex buffers.
git-svn-id: http://svn.leocad.org/tags/leocad-0.75@742 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/terrain.cpp')
-rw-r--r--common/terrain.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/common/terrain.cpp b/common/terrain.cpp
index 4e24a93..1e817cd 100644
--- a/common/terrain.cpp
+++ b/common/terrain.cpp
@@ -581,6 +581,15 @@ void Terrain::Render(Camera* pCam, float aspect)
glTranslatef(eye[0], eye[1], 0);
glScalef(pCam->m_zFar, pCam->m_zFar, 1);
+ float verts[4][2] =
+ {
+ { -1, -1 }, { 1, -1 },
+ { 1, 1 }, { -1, 1 }
+ };
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(2, GL_FLOAT, 0, verts);
+
if (m_nOptions & LC_TERRAIN_TEXTURE)
{
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -595,30 +604,30 @@ float tx, ty;
tx = (tw*eye[0])/(2*pCam->m_zFar);
ty = (th*eye[1])/(2*pCam->m_zFar);
- glBegin(GL_QUADS);
- glTexCoord2f(tx, ty);
- glVertex2f(-1, -1);
- glTexCoord2f(tx+tw, ty);
- glVertex2f(1, -1);
- glTexCoord2f(tx+tw, ty+th);
- glVertex2f(1, 1);
- glTexCoord2f(tx, ty+th);
- glVertex2f(-1, 1);
- glEnd();
+ float coords[4][2] =
+ {
+ { tx, ty }, { tx+tw, ty },
+ { tx+tw, ty+th }, { tx, ty+th }
+ };
+
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2, GL_FLOAT, 0, coords);
+
+ glDrawArrays(GL_QUADS, 0, 4);
+
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
else
{
glColor3fv(m_fColor);
- glBegin(GL_QUADS);
- glVertex2f(-1, -1);
- glVertex2f(1, -1);
- glVertex2f(1, 1);
- glVertex2f(-1, 1);
- glEnd();
+
+ glDrawArrays(GL_QUADS, 0, 4);
}
+ glDisableClientState(GL_VERTEX_ARRAY);
+
glPopMatrix();
}
else