44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <frostbite2D/types/type_math.h>
|
|
|
|
namespace frostbite2D {
|
|
|
|
class Camera {
|
|
public:
|
|
Camera();
|
|
|
|
void setPosition(const Vec2& pos);
|
|
void setZoom(float zoom);
|
|
void setViewport(int width, int height);
|
|
void setFlipY(bool flip) { flipY_ = flip; } // Debug Y-axis flip.
|
|
void setPixelSnapEnabled(bool enabled) { pixelSnapEnabled_ = enabled; }
|
|
|
|
const Vec2& getPosition() const { return position_; }
|
|
Vec2 getRenderPosition() const;
|
|
Vec2 snapWorldPosition(const Vec2& position) const;
|
|
float getZoom() const { return zoom_; }
|
|
int getViewportWidth() const { return viewportWidth_; }
|
|
int getViewportHeight() const { return viewportHeight_; }
|
|
float getVisibleWidth() const;
|
|
float getVisibleHeight() const;
|
|
bool isPixelSnapEnabled() const { return pixelSnapEnabled_; }
|
|
|
|
void lookAt(const Vec2& target);
|
|
void move(const Vec2& delta);
|
|
void zoomAt(float factor, const Vec2& screenPos);
|
|
|
|
glm::mat4 getViewMatrix() const;
|
|
glm::mat4 getProjectionMatrix() const;
|
|
|
|
private:
|
|
Vec2 position_;
|
|
float zoom_ = 1.0f;
|
|
int viewportWidth_ = 1280;
|
|
int viewportHeight_ = 720;
|
|
bool flipY_ = false; // Debug Y-axis flip.
|
|
bool pixelSnapEnabled_ = false;
|
|
};
|
|
|
|
} // namespace frostbite2D
|