Starting matricies, etc...
This commit is contained in:
BIN
VulkanTest
BIN
VulkanTest
Binary file not shown.
Binary file not shown.
38
cve_game_object.hpp
Normal file
38
cve_game_object.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "cve_model.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace cve {
|
||||
|
||||
struct Transform2dComponent {
|
||||
glm::vec2 translation{}; // Position offset
|
||||
glm::mat2 mat2() { return glm::mat2{1.f}; };
|
||||
};
|
||||
|
||||
class CveGameObject {
|
||||
public:
|
||||
using id_t = unsigned int;
|
||||
|
||||
static CveGameObject createGameObject() {
|
||||
static id_t currentId = 0;
|
||||
return CveGameObject{currentId++};
|
||||
}
|
||||
|
||||
CveGameObject(const CveGameObject &) = delete;
|
||||
CveGameObject &operator=(const CveGameObject &) = delete;
|
||||
CveGameObject(CveGameObject &&) = default;
|
||||
CveGameObject &operator=(CveGameObject &&) = default;
|
||||
|
||||
const id_t getId() { return id; }
|
||||
|
||||
std::shared_ptr<CveModel> model{};
|
||||
glm::vec3 color;
|
||||
Transform2dComponent transform2d{};
|
||||
|
||||
private:
|
||||
CveGameObject(id_t objID) : id{objID} {}
|
||||
id_t id;
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace cve {
|
||||
struct SimplePushConstantData{
|
||||
glm::mat2 transform{1.f}; // Identity matrix
|
||||
glm::vec2 offset;
|
||||
alignas(16) glm::vec3 color;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "cve_device.hpp"
|
||||
#include "cve_swap_chain.hpp"
|
||||
#include "cve_model.hpp"
|
||||
#include "cve_game_object.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat2 transform;
|
||||
vec2 offset;
|
||||
vec3 color;
|
||||
} push;
|
||||
|
||||
Binary file not shown.
@@ -4,10 +4,11 @@ layout(location = 0) in vec2 position;
|
||||
layout(location = 1) in vec3 color;
|
||||
|
||||
layout(push_constant) uniform Push {
|
||||
mat2 transform;
|
||||
vec2 offset;
|
||||
vec3 color;
|
||||
} push;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position + push.offset, 0.0, 1.0);
|
||||
gl_Position = vec4(push.transform * position + push.offset, 0.0, 1.0);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user