1 #ifndef INCLUDE_AL_RENDER_MANAGER_HPP
2 #define INCLUDE_AL_RENDER_MANAGER_HPP
4 #include <unordered_map>
6 #include "al/graphics/al_EasyFBO.hpp"
7 #include "al/graphics/al_EasyVAO.hpp"
8 #include "al/graphics/al_FBO.hpp"
9 #include "al/graphics/al_Shader.hpp"
10 #include "al/graphics/al_VAOMesh.hpp"
11 #include "al/graphics/al_Viewpoint.hpp"
12 #include "al/math/al_Matrix4.hpp"
13 #include "al/math/al_Quat.hpp"
14 #include "al/math/al_Vec.hpp"
34 std::vector<Matrix4f> stack;
48 void set(
int left,
int bottom,
int width,
int height);
51 std::vector<Viewport> stack;
59 unsigned int get()
const;
60 void set(
unsigned int id);
63 std::vector<unsigned int> stack;
105 void multViewMatrix(
const Matrix4f &m) {
109 void multProjMatrix(
const Matrix4f &m) {
114 Matrix4f modelMatrix()
const {
return mModelStack.get(); }
115 Matrix4f viewMatrix()
const {
return mViewStack.get(); }
116 Matrix4f projMatrix()
const {
return mProjStack.get(); }
118 void modelMatrix(
const Matrix4f &m) {
122 void viewMatrix(
const Matrix4f &m) {
126 void projMatrix(
const Matrix4f &m) {
131 void pushModelMatrix() { mModelStack.push(); }
132 void pushViewMatrix() { mViewStack.push(); }
133 void pushProjMatrix() { mProjStack.push(); }
135 void pushModelMatrix(
const Matrix4f &m) {
139 void pushViewMatrix(
const Matrix4f &m) {
143 void pushProjMatrix(
const Matrix4f &m) {
148 void popModelMatrix() {
152 void popViewMatrix() {
156 void popProjMatrix() {
161 void resetModelMatrixStack() {
162 mModelStack.pop_all();
165 void resetViewMatrixStack() {
166 mViewStack.pop_all();
169 void resetProjMatrixStack() {
170 mProjStack.pop_all();
173 void resetMatrixStack() {
174 resetModelMatrixStack();
175 resetViewMatrixStack();
176 resetProjMatrixStack();
193 translate(
float(v[0]),
float(v[1]),
float(v[2]));
205 void rotate(
float angle,
float x = 0.,
float y = 0.,
float z = 1.);
218 void scale(
float x,
float y,
float z = 1.);
227 void viewport(
int left,
int bottom,
int width,
int height);
229 Viewport viewport() {
return mViewportStack.get(); }
232 void pushViewport(
int l,
int b,
int w,
int h) {
234 viewport(l, b, w, h);
236 void pushViewport(
const Viewport &v) {
240 void pushViewport(
int w,
int h) {
245 void framebuffer(EasyFBO &easyFBO) { framebuffer(easyFBO.fbo().id()); }
246 void framebuffer(FBO &fbo) { framebuffer(fbo.id()); }
247 void framebuffer(
unsigned int id);
249 unsigned int framebuffer() {
return mFBOStack.get(); }
250 void pushFramebuffer();
251 void popFramebuffer();
252 void pushFramebuffer(EasyFBO &f) {
256 void pushFramebuffer(FBO &f) {
260 void pushFramebuffer(
unsigned int f) {
265 void shader(ShaderProgram &s);
266 ShaderProgram &shader() {
return *mShaderPtr; }
267 ShaderProgram *shaderPtr() {
return mShaderPtr; }
269 virtual void camera(Viewpoint
const &v);
270 virtual void camera(Viewpoint::SpecialType v);
273 void pushCamera(Viewpoint
const &v) {
277 void pushCamera(Viewpoint::SpecialType v) {
282 virtual void update();
283 void draw(VAOMesh &mesh);
284 void draw(EasyVAO &vao);
285 void draw(
const Mesh &mesh);
286 void draw(Mesh &&mesh);
289 ShaderProgram *mShaderPtr =
nullptr;
290 std::unordered_map<unsigned int, int> modelviewLocs;
291 std::unordered_map<unsigned int, int> projLocs;
292 bool mShaderChanged =
false;
295 MatrixStack mViewStack;
296 MatrixStack mProjStack;
297 MatrixStack mModelStack;
298 bool mMatChanged =
false;
300 ViewportStack mViewportStack;
301 EasyVAO mInternalVAO;
void translate(const Vec< 3, T > &v)
Translate current matrix.
void rotate(float angle, const Vec< 3, T > &axis)
void viewport(int left, int bottom, int width, int height)
Set viewport.
void rotate(float angle, float x=0., float y=0., float z=1.)
void scale(float x, float y, float z=1.)
Scale current matrix along each dimension.
void rotate(const Quatd &q)
Rotate current matrix.
void multModelMatrix(const Matrix4f &m)
Multiply current matrix.
void scale(float s)
Scale current matrix uniformly.
void scale(const Vec< 2, T > &v)
Scale current matrix along each dimension.
void scale(const Vec< 3, T > &v)
Scale current matrix along each dimension.
void translate(float x, float y, float z=0.)
Translate current matrix.
void translate(const Vec< 2, T > &v)
Translate current matrix.
void popMatrix()
Pop current matrix stack.
void pushMatrix()
Push current matrix stack.
void rotate(const Quatf &q)
Rotate current matrix.
void loadIdentity()
Set current matrix to identity.
Matrix4< float > Matrix4f
Single-precision 4-by-4 matrix.
T angle(const Vec< N, T > &a, const Vec< N, T > &b)
Returns angle, in interval [0, pi], between two vectors.
int h
left, bottom, width, height