kinda 3d
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include "misc/Time.h"
|
||||
#include "misc/Easing.h"
|
||||
#include "misc/Maths.h"
|
||||
|
||||
namespace td {
|
||||
namespace render {
|
||||
@@ -35,8 +36,6 @@ void Renderer::InitShaders() {
|
||||
m_WorldShader->LoadShader();
|
||||
m_EntityShader = std::make_unique<shader::EntityShader>();
|
||||
m_EntityShader->LoadShader();
|
||||
SetIsometricView(true);
|
||||
UpdateIsometricView();
|
||||
}
|
||||
|
||||
// TODO : change loader check
|
||||
@@ -69,7 +68,7 @@ void Renderer::RenderVAO(const GL::VertexArray& vao) {
|
||||
|
||||
void Renderer::RenderModel(const Model& model) {
|
||||
m_EntityShader->Start();
|
||||
//m_EntityShader->SetModelPos(model.positon);
|
||||
m_EntityShader->SetModelPos(model.positon);
|
||||
m_EntityShader->SetColorEffect(model.color);
|
||||
model.vao->Bind();
|
||||
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(model.vao->GetVertexCount()));
|
||||
@@ -99,10 +98,11 @@ void Renderer::Prepare() {
|
||||
}
|
||||
|
||||
void Renderer::Resize(int width, int height) {
|
||||
maths::Mat4f projectionMatrix = maths::Perspective(80.0f / 180.0f * M_PI, static_cast<float>(width) / height, 0.1f, 160.0f);
|
||||
m_WorldShader->Start();
|
||||
//m_WorldShader->SetAspectRatio(static_cast<float>(width) / height);
|
||||
m_WorldShader->SetProjectionMatrix(projectionMatrix);
|
||||
m_EntityShader->Start();
|
||||
//m_EntityShader->SetAspectRatio(static_cast<float>(width) / height);
|
||||
m_WorldShader->SetProjectionMatrix(projectionMatrix);
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
@@ -114,17 +114,18 @@ void Renderer::SetZoom(float zoom) {
|
||||
}
|
||||
|
||||
void Renderer::SetCamMovement(const Vec2f& mov) {
|
||||
m_CamPos.x += mov.x * (1 - m_IsometricView) + (0.5 * mov.x - mov.y) * m_IsometricView;
|
||||
m_CamPos.y += -mov.y * (1 - m_IsometricView) + (-0.5 * mov.x - mov.y) * m_IsometricView;
|
||||
m_CamPos.x += mov.x;
|
||||
m_CamPos.y += -mov.y;
|
||||
SetCamPos(m_CamPos);
|
||||
}
|
||||
|
||||
void Renderer::SetCamPos(const Vec2f& newPos) {
|
||||
m_CamPos = newPos;
|
||||
maths::Mat4f viewMatrix = maths::LookAt({m_CamPos.x, 50, m_CamPos.y}, {m_CamPos.x, -1, m_CamPos.y}, {0, 1, 0});
|
||||
m_WorldShader->Start();
|
||||
//m_WorldShader->SetCamPos(newPos);
|
||||
m_WorldShader->SetViewMatrix(viewMatrix);
|
||||
m_EntityShader->Start();
|
||||
//m_EntityShader->SetCamPos(newPos);
|
||||
m_EntityShader->SetViewMatrix(viewMatrix);
|
||||
}
|
||||
|
||||
void Renderer::SetIsometricView(bool isometric) {
|
||||
|
||||
Reference in New Issue
Block a user