1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef GL_MATRIX_STACK_H
#define GL_MATRIX_STACK_H
#define CHECK_MATRIX_STACK_UNDERFLOW
#ifdef CHECK_MATRIX_STACK_UNDERFLOW
#include <cassert>
#endif
#include <vector>
#include "System/Matrix44f.h"
namespace GL {
struct MatrixState {
private:
std::vector<CMatrix44f> stacks[3] = {{CMatrix44f::Identity()}, {CMatrix44f::Identity()}, {CMatrix44f::Identity()}};
std::vector<CMatrix44f>* stack = &stacks[0];
CMatrix44f dummy;
public:
const CMatrix44f& Top(unsigned int mode) const;
CMatrix44f& Top(unsigned int mode);
const CMatrix44f& Top() const { return (Top(GetMode())); }
CMatrix44f& Top() { return (Top(GetMode())); }
void SetMode(unsigned int mode) { stack = &stacks[mode]; }
unsigned int GetMode() const { return (stack - &stacks[0]); }
void Push(const CMatrix44f& m);
void Push();
void Pop();
void Mult(const CMatrix44f& m);
void Load(const CMatrix44f& m);
void Translate(const float3& v);
void Translate(float x, float y, float z);
void Scale(const float3& s);
void Scale(float x, float y, float z);
void RotateX(float a);
void RotateY(float a);
void RotateZ(float a);
void Rotate(float a, float x, float y, float z);
};
MatrixState* SetMatrixStatePointer(bool mainThread);
MatrixState* GetMatrixStatePointer();
void MatrixMode(unsigned int glMode);
int GetMatrixMode();
const CMatrix44f& GetMatrix();
const CMatrix44f& GetMatrix(unsigned int glMode);
void PushMatrix(const CMatrix44f& m);
void PushMatrix();
void PopMatrix();
// inlined to avoid multiple definitions
inline void PushIdentityMatrix() { PushMatrix(CMatrix44f::Identity()); }
void MultMatrix(const CMatrix44f& m);
void LoadMatrix(const CMatrix44f& m);
void LoadIdentity();
void Translate(const float3& v);
void Translate(float x, float y, float z);
void Scale(const float3& s);
void Scale(float x, float y, float z);
void Rotate(float a, float x, float y, float z);
void RotateX(float a);
void RotateY(float a);
void RotateZ(float a);
}
#define glMatrixStatePtr GL::GetMatrixStatePointer()
#endif
|