Skip to content

Commit

Permalink
added needed shaders for a game
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriiKoniushenko committed Oct 16, 2023
1 parent 76eb276 commit eb71bd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/core/camera/source/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
void Camera::setSize(const Utils::ISize2D& size)
{
size_ = size;
GetWindow().viewport(0,0, size.width, size.height);
}

const Utils::ISize2D& Camera::getSize() const
Expand Down
11 changes: 6 additions & 5 deletions lib/core/shapes/source/Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

#include "Widget.h"

#include "Camera.h"
#include "Image.h"
#include "Mouse.h"
#include "Texture.h"
#include "WidgetCollector.h"
#include "Window.h"
#include "WorldVariables.h"
#include "Camera.h"

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
Expand All @@ -44,7 +44,7 @@ Widget::~Widget()
getWidgetCollector().remove(this);
}

void Widget::draw(ShaderPack& shaderPack, Camera* camera/* = nullptr*/)
void Widget::draw(ShaderPack& shaderPack, Camera* camera /* = nullptr*/)
{
if (!isPrepared)
{
Expand Down Expand Up @@ -75,9 +75,9 @@ void Widget::draw(ShaderPack& shaderPack, Camera* camera/* = nullptr*/)
}

glm::mat4 trans = glm::mat4(1.0f);
auto translateOffset = glm::vec3(
fakePosition / glm::vec2(static_cast<float>(GetWindow().getSize().width) / 2.f,
static_cast<float>(GetWindow().getSize().height) / 2.f),0.f);
auto translateOffset = glm::vec3(fakePosition / glm::vec2(static_cast<float>(GetWindow().getSize().width) / 2.f,
static_cast<float>(GetWindow().getSize().height) / 2.f),
0.f);

trans = glm::translate(trans, translateOffset);
trans = glm::rotate(trans, rotation_, glm::vec3(0.0f, 0.0f, 1.0f));
Expand All @@ -86,6 +86,7 @@ void Widget::draw(ShaderPack& shaderPack, Camera* camera/* = nullptr*/)
shaderProgram.use();
shaderProgram.uniform("uHasTexture", static_cast<bool>(texture_));
shaderProgram.uniform("uTransform", false, trans);
shaderProgram.uniform("uCameraMatrix", false, trans);
shaderProgram.uniform(
"uResolution", static_cast<float>(GetWindow().getSize().width), static_cast<float>(GetWindow().getSize().height));
shaderProgram.uniform("uGamma", shaderProgram.lightning.gamma);
Expand Down

0 comments on commit eb71bd0

Please sign in to comment.