Some Rendering Stuff.

Se ha añadido un método para cambiar el color de clear.
Se ha abstraido la cámara del renderer para más versatilidad a futuro.
Nota: La implementación de la cámara no es nada segura. Tocará revisarlo
This commit is contained in:
2022-08-29 17:54:34 +02:00
parent 692812a710
commit 132f24720e
8 changed files with 109 additions and 34 deletions
+10 -9
View File
@@ -116,7 +116,7 @@ void Loop()
}
if (eventHandler.type == SDL_WINDOWEVENT && eventHandler.window.event == SDL_WINDOWEVENT_RESIZED)
{
//GAME_LOG_CRITICAL("Window Size chaged {0}x{1}", eventHandler.window.data1, eventHandler.window.data2);
GAME_LOG_INFO("Window Size chaged {0}x{1}", eventHandler.window.data1, eventHandler.window.data2);
UE_Renderer->SetScreenSize(eventHandler.window.data1, eventHandler.window.data2);
}
if (eventHandler.type == SDL_KEYDOWN)
@@ -146,29 +146,30 @@ void Loop()
}
UE::Camera* cam = UE_Renderer->GetCamera();
if (keyStates[SDL_SCANCODE_W])
{
glm::ivec2 camPos = UE_Renderer->GetCamPosition();
glm::ivec2 camPos = cam->GetCamPosition();
camPos.y -= 5;
UE_Renderer->SetCamPosition(camPos.x, camPos.y);
cam->SetCamPosition(camPos.x, camPos.y);
}
if (keyStates[SDL_SCANCODE_S])
{
glm::ivec2 camPos = UE_Renderer->GetCamPosition();
glm::ivec2 camPos = cam->GetCamPosition();
camPos.y += 5;
UE_Renderer->SetCamPosition(camPos.x, camPos.y);
cam->SetCamPosition(camPos.x, camPos.y);
}
if (keyStates[SDL_SCANCODE_D])
{
glm::ivec2 camPos = UE_Renderer->GetCamPosition();
glm::ivec2 camPos = cam->GetCamPosition();
camPos.x += 5;
UE_Renderer->SetCamPosition(camPos.x, camPos.y);
cam->SetCamPosition(camPos.x, camPos.y);
}
if (keyStates[SDL_SCANCODE_A])
{
glm::ivec2 camPos = UE_Renderer->GetCamPosition();
glm::ivec2 camPos = cam->GetCamPosition();
camPos.x -= 5;
UE_Renderer->SetCamPosition(camPos.x, camPos.y);
cam->SetCamPosition(camPos.x, camPos.y);
}
currentScene->SceneUpdate();
+8
View File
@@ -1,6 +1,7 @@
//#include "UberEngine.h"
#pragma once
#include "Engine.h"
#include "Scene/Scene.h"
#include "Render/Renderer.h"
#include "Assets/AssetManager.h"
@@ -33,6 +34,13 @@ public:
{
UE_LOG_INFO("Escena {0} ha sido cargada", _sceneName);
//Configuramos las cosas del Renderer.
//UE::Engine::GetRenderer()->SetCamPosition(150, 25);
SDL_Color newColor{40, 160, 195, 255};
UE::Engine::GetRenderer()->SetDrawingColor(newColor);
UE::AssetManager* as = UE::Engine::GetAssetManager();
UE::Texture* test1Texture = as->getTexture("test1");