OpenGL中的2D游戏 - 坐标

时间:2012-12-22 09:41:20

标签: android opengl-es

如何在2D游戏中进行坐标(所以X = 0 Y = 0在右上角)? 左边有这样的东西: enter image description here

1 个答案:

答案 0 :(得分:1)

您只需使用一些公式在两个坐标系之间进行转换。

openGL_x = (screen_x - width/2)/(width/2)   == a*x + b;
openGL_y = (height/2 - screenY)/(height/2)  == c*y + d;

使用openGL,您可以将这两个线性方程式嵌入到ViewMatrix中,并使用像素坐标。

相关问题