// Floor.cpp: implementation of the CFloor class.
//
//////////////////////////////////////////////////////////////////////
#include "Floor.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFloor::CFloor()
{
// load texture
pTexture = new CTexture();
if (!pTexture->LoadGLTexture("Data/c19.bmp"))
//if (!pTexture->LoadGLTexture("Data/mud.bmp"))
pApp->pLog->Log("Loading of texture for floor failed!");
bTexture = true;
}
CFloor::~CFloor()
{
delete pTexture;
}
void CFloor::Draw()
{
const GLfloat EDGE = 12.0;
const GLfloat TEX_OFFSET = 10.0;
/* Draw the floor. */
glEnable(GL_BLEND);
glPushMatrix();
glTranslatef(pos_x, pos_y, pos_z);
if (bTexture)
{
glBindTexture(GL_TEXTURE_2D, pTexture->texture2d);
glDepthMask(GL_FALSE);
glEnable(GL_TEXTURE_2D);
glColor3f(1.0, 1.0, 1.0);
}
else
{
glColor3f(0.2f, 0.2f, 0.2f);
}
glBegin(GL_QUADS);
glTexCoord2f(TEX_OFFSET, TEX_OFFSET);
glVertex3f(-EDGE, -0.05f, -EDGE);
glTexCoord2f(0.0, TEX_OFFSET);
glVertex3f(EDGE, -0.05f, -EDGE);
glTexCoord2f(0.0, 0.0);
glVertex3f(EDGE, -0.05f, EDGE);
glTexCoord2f(TEX_OFFSET, 0.0);
glVertex3f(-EDGE, -0.05f, EDGE);
glEnd(); /* Allow particles to blend with each other. */
// Draw floor now, note the texture for the floor must be loaded
glPopMatrix();
glDisable(GL_BLEND);
if (bTexture)
{
glDepthMask(GL_TRUE);
glDisable(GL_TEXTURE_2D);
}
}