SQCSimulator2023/SQCSim2021/engine.cpp

581 lines
16 KiB
C++
Raw Normal View History

#include "engine.h"
Engine::Engine() {}
Engine::~Engine() {
2021-12-06 21:41:50 -05:00
m_world.CleanUpWorld(m_renderCount, true);
2021-12-07 18:59:50 -05:00
for (int x = 0; x < WORLD_SIZE_X; ++x)
2021-12-06 21:41:50 -05:00
for (int y = 0; y < WORLD_SIZE_Y; ++y)
if (m_world.GetChunks().Get(x, y))
m_world.GetChunks().Get(x, y)->~Chunk();
}
2021-11-30 19:55:11 -05:00
void Engine::Init() {
2021-10-11 11:37:58 -04:00
GLenum glewErr = glewInit();
2021-10-12 15:58:54 -04:00
if (glewErr != GLEW_OK) {
2021-10-11 11:37:58 -04:00
std::cerr << " ERREUR GLEW : " << glewGetErrorString(glewErr) << std::endl;
abort();
}
//glDisable(GL_FRAMEBUFFER_SRGB);
//glEnable(GL_DEPTH_TEST);
//glEnable(GL_STENCIL_TEST);
//glEnable(GL_POINT_SMOOTH);
//glEnable(GL_BLEND);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (float)Width() / (float)Height(), 0.1f, VIEW_DISTANCE);
glShadeModel(GL_SMOOTH);
2021-11-30 19:55:11 -05:00
//glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//glDisable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendEquation(GL_FUNC_SUBTRACT);
//
2021-10-12 15:58:54 -04:00
// Objet de skybox avec sa propre texture et son propre shader!
2021-12-06 09:45:51 -05:00
m_skybox.Init(0.2f);
2021-10-04 12:29:10 -04:00
2021-10-19 10:27:59 -04:00
// Objet de musique!
m_audio.ToggleMusicState();
2021-11-15 20:58:13 -05:00
2021-12-07 18:59:50 -05:00
// Array pour les balles.
for (int x = 0; x < MAX_BULLETS; ++x)
m_bullets[x] = nullptr;
2023-09-25 08:23:52 -04:00
uint64_t seed = 12345;
std::string playname = "John Test";
const char srvaddr[] = "127.0.0.1";
if (NETWORK_TEST) { // Test connexion r<>seau.
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(SRV_PORT);
addr.sin_addr.s_addr = inet_addr(srvaddr);
if (!m_conn->Init(addr)) {
if (m_conn->Connect(playname)) {
// setup jeu en r<>seau.
seed = m_conn->getSeed();
std::cout << "ID re<72>u du serveur: " << std::to_string(m_conn->getId()) << "!" << std::endl;
}
else std::cout << "Erreur de connexion." << std::endl;
}
else std::cout << "Erreur de cr<63>ation de socket." << std::endl;
}
m_world.SetSeed(seed);
2021-11-16 20:48:52 -05:00
// Init Chunks
2021-11-19 11:11:08 -05:00
m_world.GetChunks().Reset(nullptr);
2021-11-02 18:01:06 -04:00
2021-10-31 00:31:08 -04:00
// Gestion de souris.
CenterMouse();
HideCursor();
}
void Engine::DeInit() {}
2021-09-27 11:30:18 -04:00
void Engine::LoadResource() {
LoadTexture(m_skybox.GetTexture(), TEXTURE_PATH "skybox.png", true);
LoadTexture(m_textureCrosshair, TEXTURE_PATH "cross.bmp", true);
LoadTexture(m_textureFont, TEXTURE_PATH "font.bmp", true);
LoadTexture(m_textureGun, TEXTURE_PATH "gun01.png", false);
2021-10-31 00:31:08 -04:00
TextureAtlas::TextureIndex texDirtIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal3.png");
TextureAtlas::TextureIndex texIceIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "metal2.png");
2021-10-31 00:31:08 -04:00
TextureAtlas::TextureIndex texGrassIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "grass.png");
2021-12-06 09:45:51 -05:00
TextureAtlas::TextureIndex texMetalIndex = m_textureAtlas.AddTexture(TEXTURE_PATH "dirt.png");
2021-10-26 17:28:37 -04:00
2021-12-06 10:58:40 -05:00
if (!m_textureAtlas.Generate(TEXTURE_SIZE, false)) {
2021-10-26 17:28:37 -04:00
std::cout << " Unable to generate texture atlas ..." << std::endl;
abort();
}
2021-10-11 11:37:58 -04:00
2021-10-31 00:31:08 -04:00
float u, v, s;
m_textureAtlas.TextureIndexToCoord(texDirtIndex, u, v, s, s);
m_blockinfo[BTYPE_DIRT] = new BlockInfo(BTYPE_DIRT, "Dirt", u, v, s, 1);
m_textureAtlas.TextureIndexToCoord(texGrassIndex, u, v, s, s);
m_blockinfo[BTYPE_GRASS] = new BlockInfo(BTYPE_GRASS, "Grass", u, v, s, 1);
m_textureAtlas.TextureIndexToCoord(texMetalIndex, u, v, s, s);
m_blockinfo[BTYPE_METAL] = new BlockInfo(BTYPE_METAL, "Metal", u, v, s, 1);
m_textureAtlas.TextureIndexToCoord(texIceIndex, u, v, s, s);
m_blockinfo[BTYPE_ICE] = new BlockInfo(BTYPE_ICE, "Ice", u, v, s, 1);
2021-10-11 11:37:58 -04:00
std::cout << " Loading and compiling shaders ..." << std::endl;
2021-10-12 15:58:54 -04:00
if (!m_shader01.Load(SHADER_PATH "shader01.vert", SHADER_PATH "shader01.frag", true)) {
2021-10-11 11:37:58 -04:00
std::cout << " Failed to load shader " << std::endl;
exit(1);
}
2021-10-12 15:58:54 -04:00
if (!m_skybox.GetShader().Load(SHADER_PATH "skybox.vert", SHADER_PATH "skybox.frag", true)) {
std::cout << " Failed to load shader " << std::endl;
exit(1);
}
}
2021-11-15 20:58:13 -05:00
void Engine::UnloadResource() {}
2021-10-12 15:58:54 -04:00
void Engine::DisplayCrosshair() {
m_textureCrosshair.Bind();
static const int crossSize = 32;
glLoadIdentity();
glTranslated(Width() / 2 - crossSize / 2, Height() / 2 - crossSize / 2, 0);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2i(0, 0);
glTexCoord2f(1, 0);
glVertex2i(crossSize, 0);
glTexCoord2f(1, 1);
glVertex2i(crossSize, crossSize);
glTexCoord2f(0, 1);
glVertex2i(0, crossSize);
glEnd();
}
void Engine::DisplayCurrentItem() {
}
void Engine::DisplayHud() {
glBindTexture(GL_TEXTURE_2D, 0);
glLoadIdentity();
glDisable(GL_BLEND);
// Barre HP
float fBarWidth = Width() / 4;
float fBarHeight = Height() / 25;
float fPosX = Width() / 20;
float fPosY = Height() - (Height() - (fBarHeight * 4));
float playerHp = m_player.GetHP();
float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f;
// Arri<72>re-plan (Barre HP)
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
glBegin(GL_QUADS);
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
glVertex2f(fPosX + fBarWidth, fPosY - fBarHeight); // Bas-Droite
glVertex2f(fPosX + fBarWidth, fPosY); // Haut-Droite
glVertex2f(fPosX, fPosY); // Haut-Gauche
glEnd();
//TODO: Associer avec m<>chanique de vie du joueur
// Barre HP
glColor3f(0.0f * facteurOmbrage, 1.0f * facteurOmbrage, 0.0f * facteurOmbrage);
glBegin(GL_QUADS);
glVertex2f(fPosX, fPosY - fBarHeight); // Bas-Gauche
glVertex2f(fPosX + fBarWidth * playerHp, fPosY - fBarHeight); // Bas-Droite
glVertex2f(fPosX + fBarWidth * playerHp, fPosY); // Haut-Droite
glVertex2f(fPosX, fPosY); // Haut-Gauche
glEnd();
// Barre <20>quip
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor3f(1.0f * facteurOmbrage, 1.0f * facteurOmbrage, 1.0f * facteurOmbrage);
m_textureGun.Bind();
float margin = Width() * 0.05;
float itemWidth = Width() * 0.33;
float itemHeight = itemWidth / 2.208;
float startX = Width() - itemWidth - margin;
float startY = margin;
glTranslated(startX, startY, 0);
glBegin(GL_QUADS);
glTexCoord2f(1, 0); glVertex2i(0, 0);
glTexCoord2f(0, 0); glVertex2i(itemWidth, 0);
glTexCoord2f(0, 1); glVertex2i(itemWidth, itemHeight);
glTexCoord2f(1, 1); glVertex2i(0, itemHeight);
glEnd();
glDisable(GL_BLEND);
// Username
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor3f(1.0f, 1.0f, 1.0f);
float scale = GetScale();
m_textureFont.Bind();
std::ostringstream ss;
ss << m_player.GetUsername();
PrintText(fPosX, fPosY, scale, ss.str());
}
void Engine::DisplayInfo(float elapsedTime, BlockType bloc) {
2021-10-26 17:28:37 -04:00
// Bind de la texture pour le font
m_textureFont.Bind();
std::ostringstream ss;
float scale = GetScale();
unsigned int x = Width() / 25;
2021-10-26 17:28:37 -04:00
ss << " Fps : " << GetFps(elapsedTime);
PrintText(x, Height() - (Height() / 19.2), scale, ss.str());
2021-10-26 17:28:37 -04:00
ss.str("");
2021-11-26 11:59:02 -05:00
ss << " Rendered Chunks : " << m_renderCount;
PrintText(x, Height() - (Height() / 13.7), scale, ss.str());
2021-11-26 11:59:02 -05:00
ss.str("");
ss << " To-Be-Deleted Chunks : " << m_world.GettbDeleted();
PrintText(x, Height() - (Height() / 10.7), scale, ss.str());
ss.str("");
2021-10-26 17:28:37 -04:00
ss << " Velocity : " << m_player.GetVelocity(); // IMPORTANT : on utilise l <20> operateur << pour afficher la position
PrintText(x, Height() / 48, scale, ss.str());
2021-10-26 17:28:37 -04:00
ss.str("");
ss << " Direction : " << m_player.GetDirection();
PrintText(x, Height() / 24, scale, ss.str());
2021-10-26 17:28:37 -04:00
ss.str("");
ss << " Position : " << m_player.GetPosition();
PrintText(x, Height() / 16, scale, ss.str());
2021-12-07 18:59:50 -05:00
ss.str("");
ss << " Block : ";
2021-12-07 18:59:50 -05:00
if (bloc == BTYPE_LAST)
ss << "Weapon.";
else ss << (int)bloc;
PrintText(x, Height() / 12, scale, ss.str());
}
void Engine::DrawHud(float elapsedTime, BlockType bloc) {
// Setter le blend function, tout ce qui sera noir sera transparent
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, Width(), 0, Height(), -1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (m_displayInfo) {
DisplayInfo(elapsedTime, bloc);
}
if (m_displayHud) {
DisplayHud();
}
if (m_displayCrosshair) {
DisplayCrosshair();
}
// Reset du blend function
2021-12-06 11:08:34 -05:00
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR);
glBlendEquation(GL_FUNC_SUBTRACT);
2021-12-06 11:08:34 -05:00
glEnable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
2021-10-26 17:28:37 -04:00
glMatrixMode(GL_PROJECTION);
glPopMatrix();
2021-10-26 17:28:37 -04:00
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
void Engine::PrintText(float x, float y, float scale, const std::string& t) {
2021-10-26 17:28:37 -04:00
glLoadIdentity();
glTranslated(x, y, 0);
2021-10-26 17:28:37 -04:00
for (unsigned int i = 0; i < t.length(); ++i) {
float left = (float)((t[i] - 32) % 16) / 16.f;
float top = (float)((t[i] - 32) / 16) / 16.f;
top += .5f;
2021-10-26 17:28:37 -04:00
glBegin(GL_QUADS);
glTexCoord2f(left, 1.f - top - .0625f); glVertex2f(0, 0);
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);
2021-10-26 17:28:37 -04:00
glEnd();
glTranslated(8 * scale, 0, 0);
2021-10-26 17:28:37 -04:00
}
}
float Engine::GetScale() const {
float widthRatio = Width() / BASE_WIDTH;
float heightRatio = Height() / BASE_HEIGHT;
return (widthRatio + heightRatio) / 2.0f;
}
2021-10-26 17:28:37 -04:00
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
void Engine::Render(float elapsedTime) {
2022-04-06 23:07:24 -04:00
//static float gameTime = elapsedTime;
static float pollTime = 0;
2021-12-07 18:59:50 -05:00
static float bulletTime = 0;
static BlockType bloc = 1;
2021-11-15 20:58:13 -05:00
if (elapsedTime > 0.1f) return;
2022-04-06 23:07:24 -04:00
//gameTime += elapsedTime;
pollTime += elapsedTime;
2021-09-27 13:15:57 -04:00
Transformation all;
2021-09-27 13:56:29 -04:00
Transformation skybox;
2021-12-06 09:45:51 -05:00
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// Transformations initiales
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
2021-12-07 18:59:50 -05:00
if (bulletTime > 0.f) bulletTime -= elapsedTime;
if (bulletTime < 0.f) bulletTime = 0.f;
if (pollTime >= .005f) {
m_player.ApplyPhysics(m_player.GetInput(m_keyW, m_keyS, m_keyA, m_keyD, m_keySpace, (bloc == BTYPE_LAST && bulletTime <= 0.f && m_mouseL), elapsedTime), &m_world, elapsedTime, &m_audio);
m_audio.Update3DAudio(m_player.GetPOV(), m_player.GetDirection(), m_player.GetVelocity()); // Ajustement du positionnement 3D avec les coordonn<6E>es du joueur et
// son vecteur de v<>locit<69> (pour l'effet Doppler)
pollTime = 0;
}
2021-09-27 13:15:57 -04:00
m_player.ApplyTransformation(all);
2021-10-06 21:33:56 -04:00
m_player.ApplyTransformation(skybox, false); // Version d'ApplyTransformation qui ne tient compte que de la rotation
// (donc l'objet ne bouge pas relativement au joueur, ce qui est pratique pour une skybox!).
if (m_mouseWU) bloc++;
else if (m_mouseWD) bloc--;
2021-12-07 18:59:50 -05:00
if (bloc == BTYPE_LAST + 1) bloc = BTYPE_AIR + 1;
else if (bloc == BTYPE_AIR) bloc = BTYPE_LAST; // La selection de BTYPE_LAST <20>quipe l'arme.
m_mouseWU = m_mouseWD = false;
2021-12-07 18:59:50 -05:00
if (m_mouseL) {
if (bloc != BTYPE_LAST)
m_world.ChangeBlockAtCursor(bloc, m_player, m_block);
else if (bulletTime <= 0.f) {
for (int x = 0; x < MAX_BULLETS; ++x) // Ajouter une balle dans l'array (aussi connu sous le nom de "faire pow pow").
if (!m_bullets[x]) {
m_bullets[x] = new Bullet(m_player);
break;
}
else if (x == MAX_BULLETS - 1) { // S'il y a pas d'espace dans l'array, prendre la place de la premi<6D>re balle de l'array.
m_bullets[0]->~Bullet();
m_bullets[0] = new Bullet(m_player);
}
bulletTime = .1f;
m_audio.Create3DAudioObj(m_powpow, AUDIO_PATH "windowsaccount.wav", m_player.GetPOV(), m_player.GetDirection() * 10, .5f);
2021-12-07 18:59:50 -05:00
if (m_flash) { // Coupe le rendering et affiche un frame blanc, pour simuler un flash.
glClearColor(.8f, .8f, .8f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glClearColor(0.f, 0.f, 0.f, 1.f);
return;
}
}
}
2021-11-30 19:55:11 -05:00
else if (m_mouseR)
2021-12-02 18:12:35 -05:00
m_world.ChangeBlockAtCursor(BTYPE_AIR, m_player, m_block);
2021-12-07 18:59:50 -05:00
for (int x = 0; x < MAX_BULLETS; ++x) // Array de bullets en jeu.
if (m_bullets[x])
if (m_bullets[x]->Update(&m_world, all, elapsedTime)) {
m_bullets[x]->~Bullet();
m_bullets[x] = nullptr;
}
m_world.Update(m_renderCount, m_bullets, m_player, all, m_shader01, m_textureAtlas, m_blockinfo);
2021-11-26 11:59:02 -05:00
2021-12-06 09:45:51 -05:00
if (m_isSkybox) m_skybox.Render(skybox);
DrawHud(elapsedTime, bloc);
2021-12-08 16:29:36 -05:00
static bool fell = false;
2021-12-07 18:59:50 -05:00
if (m_player.GetPosition().y < 1.7f && !fell) {
m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), 1.f);
fell = true;
}
else if (m_player.GetPosition().y < -20.f) {
m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde.
2021-12-07 18:59:50 -05:00
fell = false;
}
}
2021-12-02 18:12:35 -05:00
void Engine::KeyPressEvent(unsigned char key) {
2021-10-11 11:37:58 -04:00
switch (key) {
case 0: // A - Gauche
if (!m_keyA) {
m_keyA = true;
}
break;
case 3: // D - Droite
if (!m_keyD) {
m_keyD = true;
}
break;
case 18: // S - Reculer
if (!m_keyS) {
m_keyS = true;
}
break;
case 22: // W - Avancer
if (!m_keyW) {
m_keyW = true;
}
break;
case 36: // ESC - Quitter
Stop();
2021-10-04 12:29:10 -04:00
break;
case 57: // Space - Sauter
2021-10-01 10:52:33 -04:00
if (!m_keySpace) {
m_keySpace = true;
}
break;
case 94: // F10 - Plein <20>cran
IsFullscreen() ? SetFullscreen(false) : SetFullscreen(true);
//SetFullscreen(!IsFullscreen());
break;
case 2: // C - Ignorer
break;
2021-12-07 18:59:50 -05:00
case 5: // F - Ignorer
break;
2021-10-19 10:27:59 -04:00
case 12: // M - Ignorer
break;
case 7: // H - Ignorer
break;
case 8: // I - Ignorer
break;
2021-11-26 11:59:02 -05:00
case 17: // R - Ignorer
break;
case 24: // Y - Ignorer
break;
case 255: // Fn - Ignorer
break;
default:
std::cout << "Unhandled key: " << (int)key << std::endl;
}
}
2021-12-02 18:12:35 -05:00
void Engine::KeyReleaseEvent(unsigned char key) {
2021-10-11 11:37:58 -04:00
switch (key) {
case 0: // A - Stop gauche
m_keyA = false;
break;
case 2: // C - Toggle crosshair
m_displayCrosshair = !m_displayCrosshair;
std::cout << "DISPLAY CROSSHAIR " << (m_displayCrosshair ? "enabled" : "disabled") << std::endl;
break;
case 3: // D - Stop droite
m_keyD = false;
break;
case 5: // F - Toggle flash
2021-12-07 18:59:50 -05:00
m_flash = !m_flash;
break;
case 7: // H - Toggle HUD
m_displayHud = !m_displayHud;
std::cout << "DISPLAY HUD " << (m_displayHud ? "enabled" : "disabled") << std::endl;
break;
case 8: // I - Toggle render data
m_displayInfo = !m_displayInfo;
std::cout << "DISPLAY INFO " << (m_displayInfo ? "enabled" : "disabled") << std::endl;
break;
case 12: // M - Toggle music
2021-10-25 10:50:08 -04:00
m_audio.ToggleMusicState();
2021-10-19 10:27:59 -04:00
break;
case 17: // R - Toggle skybox
2021-12-01 21:21:45 -05:00
m_isSkybox = !m_isSkybox;
2021-11-26 11:59:02 -05:00
break;
case 18: // S - Stop reculer
m_keyS = false;
break;
case 22: // W - Stop avancer
m_keyW = false;
break;
case 24: // Y - Wireframe
m_wireframe = !m_wireframe;
if (m_wireframe)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
break;
case 57: // Espace - Stop sauter
2021-10-01 10:52:33 -04:00
m_keySpace = false;
break;
}
}
2021-12-02 18:12:35 -05:00
void Engine::MouseMoveEvent(int x, int y) {
2021-10-04 12:29:10 -04:00
m_player.TurnLeftRight(x - (Width() / 2));
m_player.TurnTopBottom(y - (Height() / 2));
2021-09-27 13:15:57 -04:00
// Centrer la souris seulement si elle n'est pas d<>j<EFBFBD> centr<74>e
// Il est n<>cessaire de faire la v<>rification pour <20>viter de tomber
// dans une boucle infinie o<> l'appel <20> CenterMouse g<>n<EFBFBD>re un
// MouseMoveEvent, qui rapelle CenterMouse qui rapelle un autre
// MouseMoveEvent, etc
if (x == (Width() / 2) && y == (Height() / 2))
return;
CenterMouse();
}
2021-11-26 11:59:02 -05:00
void Engine::MousePressEvent(const MOUSE_BUTTON& button, int x, int y) {
switch (button) {
case MOUSE_BUTTON_LEFT:
m_mouseL = true;
break;
case MOUSE_BUTTON_RIGHT:
m_mouseR = true;
break;
case MOUSE_BUTTON_MIDDLE:
m_mouseC = true;
break;
case MOUSE_BUTTON_WHEEL_UP:
m_mouseWU = true;
break;
case MOUSE_BUTTON_WHEEL_DOWN:
m_mouseWD = true;
break;
case MOUSE_BUTTON_NONE: break;
}
}
2021-11-26 11:59:02 -05:00
void Engine::MouseReleaseEvent(const MOUSE_BUTTON& button, int x, int y) {
switch (button) {
case MOUSE_BUTTON_LEFT:
m_mouseL = false;
2021-11-27 13:35:39 -05:00
m_block = false;
2021-11-26 11:59:02 -05:00
break;
case MOUSE_BUTTON_RIGHT:
m_mouseR = false;
2021-11-27 13:35:39 -05:00
m_block = false;
2021-11-26 11:59:02 -05:00
break;
case MOUSE_BUTTON_MIDDLE:
m_mouseC = false;
break;
case MOUSE_BUTTON_WHEEL_UP:
m_mouseWU = false;
break;
case MOUSE_BUTTON_WHEEL_DOWN:
m_mouseWD = false;
break;
case MOUSE_BUTTON_NONE: break;
}
}
bool Engine::LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps, bool stopOnError) {
texture.Load(filename, useMipmaps);
if (!texture.IsValid()) {
std::cerr << "Unable to load texture (" << filename << ")" << std::endl;
if (stopOnError)
Stop();
return false;
}
return true;
}