Push - Texte sur écran ajusté au window size. Clean up gun01 image.
This commit is contained in:
@@ -181,13 +181,11 @@ void Engine::DisplayHud() {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
unsigned int x = Width() / 20;
|
||||
unsigned int y = Height() - (Height() - 85);
|
||||
float scale = 1.5f;
|
||||
float scale = GetScale();
|
||||
m_textureFont.Bind();
|
||||
std::ostringstream ss;
|
||||
ss << m_player.GetUsername();
|
||||
PrintText(x, y, scale, ss.str());
|
||||
PrintText(fPosX, fPosY, scale, ss.str());
|
||||
}
|
||||
|
||||
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
@@ -195,26 +193,26 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
m_textureFont.Bind();
|
||||
std::ostringstream ss;
|
||||
|
||||
float scale = 1.0f;
|
||||
float scale = GetScale();
|
||||
unsigned int x = Width() / 25;
|
||||
|
||||
ss << " Fps : " << GetFps(elapsedTime);
|
||||
PrintText(x, Height() - 25, scale, ss.str());
|
||||
PrintText(x, Height() - (Height() / 19.2), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Rendered Chunks : " << m_renderCount;
|
||||
PrintText(x, Height() - 35, scale, ss.str());
|
||||
PrintText(x, Height() - (Height() / 13.7), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
||||
PrintText(x, Height() - 45, scale, ss.str());
|
||||
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
|
||||
PrintText(x, 10, scale, ss.str());
|
||||
PrintText(x, Height() / 48, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Direction : " << m_player.GetDirection();
|
||||
PrintText(x, 20, scale, ss.str());
|
||||
PrintText(x, Height() / 24, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Position : " << m_player.GetPosition();
|
||||
PrintText(x, 30, scale, ss.str());
|
||||
PrintText(x, Height() / 16, scale, ss.str());
|
||||
ss.str("");
|
||||
ss << " Block : ";
|
||||
|
||||
@@ -222,7 +220,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||
ss << "Weapon.";
|
||||
else ss << (int)bloc;
|
||||
|
||||
PrintText(x, 40, scale, ss.str());
|
||||
PrintText(x, Height() / 12, scale, ss.str());
|
||||
}
|
||||
|
||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
@@ -269,7 +267,7 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Engine::PrintText(unsigned int x, unsigned int y, float scale, const std::string& t) {
|
||||
void Engine::PrintText(float x, float y, float scale, const std::string& t) {
|
||||
glLoadIdentity();
|
||||
glTranslated(x, y, 0);
|
||||
|
||||
@@ -280,15 +278,22 @@ void Engine::PrintText(unsigned int x, unsigned int y, float scale, const std::s
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(12, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12, 12);
|
||||
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12);
|
||||
glTexCoord2f(left + .0625f, 1.f - top - .0625f); glVertex2f(12 * scale, 0);
|
||||
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12 * scale, 12 * scale);
|
||||
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12 * scale);
|
||||
glEnd();
|
||||
|
||||
glTranslated(8, 0, 0);
|
||||
glTranslated(8 * scale, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
float Engine::GetScale() const {
|
||||
float widthRatio = Width() / BASE_WIDTH;
|
||||
float heightRatio = Height() / BASE_HEIGHT;
|
||||
|
||||
return (widthRatio + heightRatio) / 2.0f;
|
||||
}
|
||||
|
||||
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
||||
|
||||
void Engine::Render(float elapsedTime) {
|
||||
@@ -412,7 +417,8 @@ void Engine::KeyPressEvent(unsigned char key) {
|
||||
}
|
||||
break;
|
||||
case 94: // F10 - Plein <20>cran
|
||||
SetFullscreen(!IsFullscreen());
|
||||
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
||||
//SetFullscreen(!IsFullscreen());
|
||||
break;
|
||||
case 2: // C - Ignorer
|
||||
break;
|
||||
|
Reference in New Issue
Block a user