Push - Texte sur écran ajusté au window size. Clean up gun01 image.
This commit is contained in:
parent
54ae0b087a
commit
e546de57c9
@ -33,6 +33,9 @@
|
|||||||
#define VIEW_DISTANCE 256
|
#define VIEW_DISTANCE 256
|
||||||
#define TEXTURE_SIZE 128
|
#define TEXTURE_SIZE 128
|
||||||
#define MAX_BULLETS 64
|
#define MAX_BULLETS 64
|
||||||
|
|
||||||
|
#define BASE_WIDTH 640
|
||||||
|
#define BASE_HEIGHT 480
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
@ -181,13 +181,11 @@ void Engine::DisplayHud() {
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor3f(1.0f, 1.0f, 1.0f);
|
||||||
unsigned int x = Width() / 20;
|
float scale = GetScale();
|
||||||
unsigned int y = Height() - (Height() - 85);
|
|
||||||
float scale = 1.5f;
|
|
||||||
m_textureFont.Bind();
|
m_textureFont.Bind();
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << m_player.GetUsername();
|
ss << m_player.GetUsername();
|
||||||
PrintText(x, y, scale, ss.str());
|
PrintText(fPosX, fPosY, scale, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
||||||
@ -195,26 +193,26 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
|||||||
m_textureFont.Bind();
|
m_textureFont.Bind();
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
|
|
||||||
float scale = 1.0f;
|
float scale = GetScale();
|
||||||
unsigned int x = Width() / 25;
|
unsigned int x = Width() / 25;
|
||||||
|
|
||||||
ss << " Fps : " << GetFps(elapsedTime);
|
ss << " Fps : " << GetFps(elapsedTime);
|
||||||
PrintText(x, Height() - 25, scale, ss.str());
|
PrintText(x, Height() - (Height() / 19.2), scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Rendered Chunks : " << m_renderCount;
|
ss << " Rendered Chunks : " << m_renderCount;
|
||||||
PrintText(x, Height() - 35, scale, ss.str());
|
PrintText(x, Height() - (Height() / 13.7), scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
|
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.str("");
|
||||||
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l ’ operateur << pour afficher la position
|
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l ’ operateur << pour afficher la position
|
||||||
PrintText(x, 10, scale, ss.str());
|
PrintText(x, Height() / 48, scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Direction : " << m_player.GetDirection();
|
ss << " Direction : " << m_player.GetDirection();
|
||||||
PrintText(x, 20, scale, ss.str());
|
PrintText(x, Height() / 24, scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Position : " << m_player.GetPosition();
|
ss << " Position : " << m_player.GetPosition();
|
||||||
PrintText(x, 30, scale, ss.str());
|
PrintText(x, Height() / 16, scale, ss.str());
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << " Block : ";
|
ss << " Block : ";
|
||||||
|
|
||||||
@ -222,7 +220,7 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
|
|||||||
ss << "Weapon.";
|
ss << "Weapon.";
|
||||||
else ss << (int)bloc;
|
else ss << (int)bloc;
|
||||||
|
|
||||||
PrintText(x, 40, scale, ss.str());
|
PrintText(x, Height() / 12, scale, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
||||||
@ -269,7 +267,7 @@ void Engine::DrawHud(float elapsedTime, BlockType bloc) {
|
|||||||
glPopMatrix();
|
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();
|
glLoadIdentity();
|
||||||
glTranslated(x, y, 0);
|
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);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
|
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 - .0625f); glVertex2f(12 * scale, 0);
|
||||||
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12, 12);
|
glTexCoord2f(left + .0625f, 1.f - top); glVertex2f(12 * scale, 12 * scale);
|
||||||
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12);
|
glTexCoord2f(left, 1.f - top); glVertex2f(0, 12 * scale);
|
||||||
glEnd();
|
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; }
|
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
||||||
|
|
||||||
void Engine::Render(float elapsedTime) {
|
void Engine::Render(float elapsedTime) {
|
||||||
@ -412,7 +417,8 @@ void Engine::KeyPressEvent(unsigned char key) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 94: // F10 - Plein écran
|
case 94: // F10 - Plein écran
|
||||||
SetFullscreen(!IsFullscreen());
|
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
|
||||||
|
//SetFullscreen(!IsFullscreen());
|
||||||
break;
|
break;
|
||||||
case 2: // C - Ignorer
|
case 2: // C - Ignorer
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#ifndef ENGINE_H__
|
#ifndef ENGINE_H__
|
||||||
#define ENGINE_H__
|
#define ENGINE_H__
|
||||||
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "openglcontext.h"
|
#include "openglcontext.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
@ -31,19 +32,18 @@ public:
|
|||||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
float GetScale() const;
|
||||||
|
|
||||||
|
int GetFps(float elapsedTime) const;
|
||||||
|
|
||||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||||
|
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
void DisplayHud();
|
void DisplayHud();
|
||||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||||
void DrawHud(float elapsedTime, BlockType bloc);
|
void DrawHud(float elapsedTime, BlockType bloc);
|
||||||
void PrintText(unsigned int x, unsigned int y, float scale, const std::string& t);
|
void PrintText(float x, float y, float scale, const std::string& t);
|
||||||
int GetFps(float elapsedTime) const;
|
|
||||||
|
|
||||||
bool m_wireframe = false;
|
|
||||||
bool m_isSkybox = true;
|
|
||||||
|
|
||||||
int m_renderCount = 0;
|
|
||||||
|
|
||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
BlockInfo* m_blockinfo[BTYPE_LAST];
|
BlockInfo* m_blockinfo[BTYPE_LAST];
|
||||||
@ -66,6 +66,18 @@ private:
|
|||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
|
float m_scale;
|
||||||
|
|
||||||
|
int m_renderCount = 0;
|
||||||
|
|
||||||
|
bool m_wireframe = false;
|
||||||
|
bool m_isSkybox = true;
|
||||||
|
bool m_block = false;
|
||||||
|
bool m_flash = true;
|
||||||
|
bool m_displayCrosshair = true;
|
||||||
|
bool m_displayHud = true;
|
||||||
|
bool m_displayInfo = false;
|
||||||
|
|
||||||
bool m_keyW = false;
|
bool m_keyW = false;
|
||||||
bool m_keyA = false;
|
bool m_keyA = false;
|
||||||
bool m_keyS = false;
|
bool m_keyS = false;
|
||||||
@ -76,13 +88,6 @@ private:
|
|||||||
bool m_mouseC = false;
|
bool m_mouseC = false;
|
||||||
bool m_mouseWU = false;
|
bool m_mouseWU = false;
|
||||||
bool m_mouseWD = false;
|
bool m_mouseWD = false;
|
||||||
|
|
||||||
bool m_block = false;
|
|
||||||
bool m_flash = true;
|
|
||||||
bool m_displayCrosshair = true;
|
|
||||||
bool m_displayHud = true;
|
|
||||||
bool m_displayInfo = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // ENGINE_H__
|
#endif // ENGINE_H__
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
int main() {
|
int main() {
|
||||||
Engine engine;
|
Engine engine;
|
||||||
engine.SetMaxFps(60);
|
engine.SetMaxFps(60);
|
||||||
engine.Start("Syndicat Quebecois de la Construction Simulator 2023", 640, 480, false);
|
engine.Start("Syndicat Quebecois de la Construction Simulator 2023", BASE_WIDTH, BASE_HEIGHT, false);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 76 KiB |
Loading…
x
Reference in New Issue
Block a user