A
download Floor.cpp
Language: C++
LOC: 48
Project Info
TableHockey3D(tablehockey)
Server: SourceForge
Type: cvs
...ey\CVSROOT\tablehockey\src\
   Application.cpp
   Application.h
   Camera.cpp
   Camera.h
   Cube.cpp
   Cube.h
   Data.cpp
   Data.h
   Disk.cpp
   Disk.h
   FloatingText.cpp
   FloatingText.h
   Floor.cpp
   Floor.h
   Input.cpp
   Input.h
   Light.cpp
   Light.h
   log.cpp
   log.h
   main.cpp
   mmgr.cpp
   mmgr.h
   Model.cpp
   Model.h
   nommgr.h
   Puck.cpp
   Puck.h
   Pyramid.cpp
   Pyramid.h
   scene.cpp
   scene.h
   SmartPtr.h
   Sound.cpp
   Sound.h
   TableHockey.dsp
   TableHockey.dsw
   TestScene.cpp
   TestScene.h
   text.cpp
   text.h
   TextHelp.cpp
   TextHelp.h
   texture.cpp
   texture.h
   TexturedCube.cpp
   TexturedCube.h
   timer.cpp
   timer.h
   View.cpp
   View.h

// 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);
	}
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us