• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef sw_MatrixStack_hpp
16 #define sw_MatrixStack_hpp
17 
18 #include "Renderer/Matrix.hpp"
19 
20 namespace sw
21 {
22 	class MatrixStack
23 	{
24 	public:
25 		MatrixStack(int size = 2);
26 
27 		~MatrixStack();
28 
29 		void identity();
30 		void load(const Matrix &M);
31 		void load(const float *M);
32 		void load(const double *M);
33 
34 		void translate(float x, float y, float z);
35 		void translate(double x, double y, double z);
36 		void rotate(float angle, float x, float y, float z);
37 		void rotate(double angle, double x, double y, double z);
38 		void scale(float x, float y, float z);
39 		void scale(double x, double y, double z);
40 		void multiply(const float *M);
41 		void multiply(const double *M);
42 
43 		void frustum(float left, float right, float bottom, float top, float zNear, float zFar);
44 		void ortho(double left, double right, double bottom, double top, double zNear, double zFar);
45 
46 		bool push();   // False on overflow
47 		bool pop();    // False on underflow
48 
49 		const Matrix &current();
50 		bool isIdentity() const;
51 
52 	private:
53 		int top;
54 		int size;
55 		Matrix *stack;
56 	};
57 }
58 
59 #endif   // sw_MatrixStack_hpp
60