www.pudn.com > Gimcrack-v0.0051-Source.zip > minimap.cpp


#include "minimap.h" 
 
 
////////////////////////////////////////////////////////////////////////////////// 
 
void GcMinimap::Load(GcTexture * land, uint mapWidth, int scale) 
{ 
	// Save the pointer the the terrain's land texture 
	minimap = land; 
 
	// Calculate the scale multiplier 
	scaler = (float)MINIMAP_WIDTH / (scale * mapWidth); 
} 
 
////////////////////////////////////////////////////////////////////////////////// 
 
void GcMinimap::Draw(float sx, float sy) 
{ 
	float x = sy * scaler; 
	float y = sx * scaler; 
 
	glPushMatrix(); 
 
		// Move to the correct palce 
		glTranslatef(GcSettings::ScreenWidth() - 128, GcSettings::ScreenHeight() - 128, 0.0f); 
 
		glColor3f(1.0f, 1.0f, 1.0f); 
 
		// Set the correct texture 
		minimap->Bind(); 
 
		// Draw the minimap 
		glBegin(GL_QUADS); 
			glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f); 
			glTexCoord2f(0.0f, 0.0f); glVertex3f(MINIMAP_WIDTH, 0.0f, 0.0f); 
			glTexCoord2f(1.0f, 0.0f); glVertex3f(MINIMAP_WIDTH, MINIMAP_WIDTH, 0.0f); 
			glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, MINIMAP_WIDTH, 0.0f); 
		glEnd(); 
 
		glColor3f(1.0f, 0.0f, 0.0f); 
 
		glPointSize(5.0f); 
 
		// No texture bound 
		glBindTexture(GL_TEXTURE_2D, NULL); 
 
		// Draw the location point 
		glBegin(GL_POINTS); 
			glVertex3f(x, y, 0.0f); 
		glEnd(); 
 
	glPopMatrix(); 
} 
 
//////////////////////////////////////////////////////////////////////////////////