reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofMatrixStack.h
Go to the documentation of this file.
1/*
2 * ofMatrixStack.h
3 *
4 * Created on: Apr 3, 2013
5 * Author: arturo
6 */
7
8#ifndef OFMATRIXSTACK_H_
9#define OFMATRIXSTACK_H_
10
11#include "ofRectangle.h"
12#include "ofGraphicsConstants.h"
13#include "ofConstants.h"
14#include "glm/mat4x4.hpp"
15#include <stack>
16
17class ofBaseDraws;
18class ofAppBaseWindow;
19class ofFbo;
20enum ofOrientation: short;
21
23public:
24 ofMatrixStack(const ofAppBaseWindow * window);
25
26 void setRenderSurface(const ofBaseDraws & fbo);
28 void setRenderSurface(const ofAppBaseWindow & window);
29
30 void setOrientation(ofOrientation orientation, bool vFlip);
32
33 void viewport(float x, float y, float width, float height, bool vflip);
38
39 const glm::mat4 & getProjectionMatrix() const;
40 const glm::mat4 & getViewInverse() const;
41 const glm::mat4 & getViewMatrix() const;
42 const glm::mat4 & getModelMatrix() const;
43 const glm::mat4 & getModelViewMatrix() const;
44 const glm::mat4 & getModelViewProjectionMatrix() const;
45 const glm::mat4 & getTextureMatrix() const;
46 const glm::mat4 & getCurrentMatrix() const;
47 const glm::mat4 & getProjectionMatrixNoOrientation() const;
48 const glm::mat4 & getOrientationMatrix() const;
49 const glm::mat4 & getOrientationMatrixInverse() const;
50
52
54
55 bool isVFlipped() const;
56 bool customMatrixNeedsFlip() const;
57
58 void pushView();
59 void popView();
60
61 void pushMatrix();
62 void popMatrix();
63 void translate(float x, float y, float z = 0);
64 void scale(float xAmnt, float yAmnt, float zAmnt = 1);
65 void rotateRad(float radians, float vecX, float vecY, float vecZ);
66 void matrixMode(ofMatrixMode mode);
67 void loadIdentityMatrix (void);
68
69 void loadMatrix (const glm::mat4 & m);
70 void multMatrix (const glm::mat4 & m);
71
72 void loadViewMatrix(const glm::mat4 & matrix);
73 void multViewMatrix(const glm::mat4 & matrix);
74
75 void clearStacks();
76 bool doesHardwareOrientation() const;
77
78private:
79 bool vFlipped;
80 ofOrientation orientation;
81 ofRectangle currentViewport;
82 ofHandednessType handedness;
83 ofBaseDraws * currentRenderSurface;
84 ofAppBaseWindow * currentWindow;
85
86 ofMatrixMode currentMatrixMode;
87
88 glm::mat4 * currentMatrix;
89 bool flipRenderSurfaceMatrix;
90 glm::mat4 modelMatrix;
91 glm::mat4 viewMatrix;
92 glm::mat4 viewInverse;
93 glm::mat4 modelViewMatrix;
94 glm::mat4 projectionMatrix;
95 glm::mat4 textureMatrix;
96 glm::mat4 modelViewProjectionMatrix;
97 glm::mat4 orientedProjectionMatrix;
98 glm::mat4 orientationMatrix;
99 glm::mat4 orientationMatrixInverse;
100
101 std::stack <ofRectangle> viewportHistory;
102 std::stack <glm::mat4> viewMatrixStack;
103 std::stack <glm::mat4> modelViewMatrixStack;
104 std::stack <glm::mat4> projectionMatrixStack;
105 std::stack <glm::mat4> textureMatrixStack;
106 std::stack <std::pair<ofOrientation,bool> > orientationStack;
107
108 int getRenderSurfaceWidth() const;
109 int getRenderSurfaceHeight() const;
110 bool doesHWOrientation() const;
111 inline void updatedRelatedMatrices();
112
113};
114
115#endif /* OFMATRIXSTACK_H_ */
Definition ofAppBaseWindow.h:21
Definition ofGraphicsBaseTypes.h:139
Definition ofFbo.h:46
Definition ofMatrixStack.h:22
bool customMatrixNeedsFlip() const
Definition ofMatrixStack.cpp:112
void viewport(float x, float y, float width, float height, bool vflip)
Definition ofMatrixStack.cpp:149
void clearStacks()
Definition ofMatrixStack.cpp:321
ofHandednessType getHandedness() const
Definition ofMatrixStack.cpp:140
ofOrientation getOrientation() const
Definition ofMatrixStack.cpp:104
const glm::mat4 & getModelMatrix() const
Definition ofMatrixStack.cpp:199
const glm::mat4 & getViewInverse() const
Definition ofMatrixStack.cpp:207
const glm::mat4 & getCurrentMatrix() const
Definition ofMatrixStack.cpp:227
void pushMatrix()
Definition ofMatrixStack.cpp:290
const glm::mat4 & getProjectionMatrix() const
Definition ofMatrixStack.cpp:211
void loadIdentityMatrix(void)
Definition ofMatrixStack.cpp:407
const glm::mat4 & getProjectionMatrixNoOrientation() const
Definition ofMatrixStack.cpp:231
ofMatrixMode getCurrentMatrixMode() const
Definition ofMatrixStack.cpp:136
void setOrientation(ofOrientation orientation, bool vFlip)
Definition ofMatrixStack.cpp:62
void rotateRad(float radians, float vecX, float vecY, float vecZ)
Definition ofMatrixStack.cpp:387
const glm::mat4 & getModelViewMatrix() const
Definition ofMatrixStack.cpp:215
void popMatrix()
Definition ofMatrixStack.cpp:304
ofRectangle getCurrentViewport() const
Definition ofMatrixStack.cpp:168
void setRenderSurface(const ofBaseDraws &fbo)
Definition ofMatrixStack.cpp:44
const glm::mat4 & getTextureMatrix() const
Definition ofMatrixStack.cpp:223
const glm::mat4 & getOrientationMatrix() const
Definition ofMatrixStack.cpp:235
void translate(float x, float y, float z=0)
Definition ofMatrixStack.cpp:377
void multMatrix(const glm::mat4 &m)
Definition ofMatrixStack.cpp:417
void pushView()
Definition ofMatrixStack.cpp:243
void multViewMatrix(const glm::mat4 &matrix)
Definition ofMatrixStack.cpp:431
void scale(float xAmnt, float yAmnt, float zAmnt=1)
Definition ofMatrixStack.cpp:382
const glm::mat4 & getViewMatrix() const
Definition ofMatrixStack.cpp:203
void loadViewMatrix(const glm::mat4 &matrix)
Definition ofMatrixStack.cpp:422
void popView()
Definition ofMatrixStack.cpp:261
bool isVFlipped() const
Definition ofMatrixStack.cpp:108
ofRectangle getNativeViewport() const
Definition ofMatrixStack.cpp:181
const glm::mat4 & getOrientationMatrixInverse() const
Definition ofMatrixStack.cpp:239
void loadMatrix(const glm::mat4 &m)
Definition ofMatrixStack.cpp:412
ofRectangle getFullSurfaceViewport() const
Definition ofMatrixStack.cpp:185
void matrixMode(ofMatrixMode mode)
Definition ofMatrixStack.cpp:392
const glm::mat4 & getModelViewProjectionMatrix() const
Definition ofMatrixStack.cpp:219
bool doesHardwareOrientation() const
Definition ofMatrixStack.cpp:456
void nativeViewport(ofRectangle viewport)
Definition ofMatrixStack.cpp:195
void setRenderSurfaceNoMatrixFlip(const ofBaseDraws &fbo)
Definition ofMatrixStack.cpp:50
A class representing a 2D rectangle.
Definition ofRectangle.h:87
unsigned int height
Definition ofAppEGLWindow.cpp:125
unsigned int width
Definition ofAppEGLWindow.cpp:124
ofMatrixMode
represents the available matrix types used internally in ofMatrixStack.
Definition ofGraphicsConstants.h:119
ofHandednessType
represents the available matrix coordinate system handednesses.
Definition ofGraphicsConstants.h:116
ofOrientation
Used to represent the available screen orientations.
Definition ofWindowSettings.h:25