Updates
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
namespace sophia {
|
||||
|
||||
class Camera2D {
|
||||
public:
|
||||
glm::vec2 position{0.f, 0.f};
|
||||
|
||||
void setProjection(float left, float right, float bottom, float top) {
|
||||
projection = glm::ortho(left, right, bottom, top);
|
||||
}
|
||||
|
||||
const glm::mat4& getProjection() const { return projection; }
|
||||
|
||||
glm::mat4 getView() const {
|
||||
return glm::translate(glm::mat4(1.f), glm::vec3(-position, 0.f));
|
||||
}
|
||||
|
||||
glm::mat4 getViewProjection() const { return projection * getView(); }
|
||||
|
||||
private:
|
||||
glm::mat4 projection{1.f};
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <sophia/frame_info.hpp>
|
||||
#include <vector>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace sophia {
|
||||
|
||||
class Application;
|
||||
|
||||
struct CanvasVertex {
|
||||
glm::vec2 position;
|
||||
glm::vec3 color;
|
||||
};
|
||||
|
||||
class Canvas {
|
||||
public:
|
||||
Canvas(const Canvas&) = delete;
|
||||
Canvas& operator=(const Canvas&) = delete;
|
||||
|
||||
~Canvas();
|
||||
|
||||
void triangle(glm::vec2 a, glm::vec2 b, glm::vec2 c,
|
||||
glm::vec3 color = {1.0f, 1.0f, 1.0f});
|
||||
void quad(glm::vec2 position, glm::vec2 size,
|
||||
glm::vec3 color = {1.0f, 1.0f, 1.0f});
|
||||
void clear();
|
||||
|
||||
private:
|
||||
friend class Application;
|
||||
|
||||
Canvas(Application* application);
|
||||
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <sophia/camera_2d.hpp>
|
||||
#include <sophia/types.hpp>
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
@@ -13,6 +14,7 @@ struct FrameInfo {
|
||||
double elapsedTime;
|
||||
double deltaTime;
|
||||
glm::vec2 currentFramebufferExtent;
|
||||
const Camera2D& camera;
|
||||
};
|
||||
|
||||
} // namespace sophia
|
||||
|
||||
Reference in New Issue
Block a user