Commits

Marc Lepage  committed 1c7da82 Draft

Implement glOrthof.

  • Participants
  • Parent commits 7b496e3
  • Branches gles

Comments (0)

Files changed (2)

File src/modules/graphics/opengl/GLES.cpp

 
 void glTranslatef(float x, float y, float z)
 {
-	// TODO support z?
+	// NOTE z ignored
 	stack[mode].back().translate(x, y);
 }
 
 void glScalef(float x, float y, float z)
 {
-	// TODO support z?
+	// NOTE z ignored
 	stack[mode].back().scale(x, y);
 }
 
 void glRotatef(float angle, float x, float y, float z)
 {
-	// TODO support arbitrary angles?
+	// NOTE xyz ignored
 	stack[mode].back().rotate(LOVE_TORAD(angle));
 }
 
-void glOrtho(double left, double right, double bottom, double top, double nearVal, double farVal)
+void glOrthof(float left, float right, float bottom, float top, float near, float far)
 {
-	// TODO
+	float m[16];
+	memset(m, 0, sizeof(float)*16);
+
+	m[0]  = 2.0f / (right-left);
+	m[5]  = 2.0f / (top-bottom);
+	m[10] = 2.0f / (far-near);
+
+	m[12] = - (right+left) / (right-left);
+	m[13] = - (top+bottom) / (top-bottom);
+	m[14] = - (far+near)   / (far-near);
+	m[15] = 1;
+
+	Matrix t;
+	t.setElements(m);
+	stack[mode].back() *= t;
 }
 
 void glPushAttrib(unsigned int mask)

File src/modules/graphics/opengl/GLES.h

 #define GL_VIEWPORT_BIT 0
 #define GL_TRANSFORM_BIT 1
 
+// Name tweaks
+#define glOrtho glOrthof
+
 void glesGetColorfv(float* params);
 
 void glColor4fv(const float* v);
 void glScalef(float x, float y, float z);
 void glRotatef(float angle, float x, float y, float z);
 
-void glOrtho(double left, double right, double bottom, double top, double nearVal, double farVal);
+void glOrthof(float left, float right, float bottom, float top, float near, float far);
 
 void glPushAttrib(unsigned int mask);
 void glPopAttrib(void);