Просмотр исходного кода

Merge pull request #96 from dariomanesku/master

mtxOrthoLh
Branimir Karadžić 9 лет назад
Родитель
Сommit
f8c8a522cf
1 измененных файлов с 27 добавлено и 3 удалено
  1. 27 3
      include/bx/fpumath.h

+ 27 - 3
include/bx/fpumath.h

@@ -640,8 +640,8 @@ namespace bx
 		memset(_result, 0, sizeof(float)*16);
 		memset(_result, 0, sizeof(float)*16);
 		_result[ 0] = _width;
 		_result[ 0] = _width;
 		_result[ 5] = _height;
 		_result[ 5] = _height;
-		_result[ 8] =  _x;
-		_result[ 9] = -_y;
+		_result[ 8] = -_x;
+		_result[ 9] =  _y;
 		_result[10] = aa;
 		_result[10] = aa;
 		_result[11] = 1.0f;
 		_result[11] = 1.0f;
 		_result[14] = -bb;
 		_result[14] = -bb;
@@ -720,7 +720,26 @@ namespace bx
 		mtxProjRh(_result, _fovy, _aspect, _near, _far, _oglNdc);
 		mtxProjRh(_result, _fovy, _aspect, _near, _far, _oglNdc);
 	}
 	}
 
 
-	inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
+	inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
+	{
+		const float aa = 2.0f/(_right - _left);
+		const float bb = 2.0f/(_top - _bottom);
+		const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
+		const float dd = (_left + _right)/(_left - _right);
+		const float ee = (_top + _bottom)/(_bottom - _top);
+		const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
+
+		memset(_result, 0, sizeof(float)*16);
+		_result[ 0] = aa;
+		_result[ 5] = bb;
+		_result[10] = -cc;
+		_result[12] = dd + _offset;
+		_result[13] = ee;
+		_result[14] = ff;
+		_result[15] = 1.0f;
+	}
+
+	inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
 	{
 	{
 		const float aa = 2.0f/(_right - _left);
 		const float aa = 2.0f/(_right - _left);
 		const float bb = 2.0f/(_top - _bottom);
 		const float bb = 2.0f/(_top - _bottom);
@@ -739,6 +758,11 @@ namespace bx
 		_result[15] = 1.0f;
 		_result[15] = 1.0f;
 	}
 	}
 
 
+	inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
+	{
+	    return mtxOrthoRh(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
+	}
+
 	inline void mtxRotateX(float* _result, float _ax)
 	inline void mtxRotateX(float* _result, float _ax)
 	{
 	{
 		const float sx = fsin(_ax);
 		const float sx = fsin(_ax);