I m trying to implement orthographic camera. When I used DirectX, orthographic projection matrix could be determined in some way. An ordinary textured rectangle might be represented as follows:
auto l = -screenWidth / 2 + rectPosition.X;
auto r = l + rectWidth;
auto t = screenHeight / 2 - rectPosition.Y;
auto b = t - rectHeight;
float vx [] =
{
l, t, 0, 1, 0, 0, // x y z w u v
r, b, 0, 1, 1, 1,
l, b, 0, 1, 0, 1,
l, t, 0, 1, 0, 0,
r, t, 0, 1, 1, 0,
r, b, 0, 1, 1, 1,
};
And ortho matrix could be set this way:
ortho(screenWidth,screenHeight,0.1f,1000.f);
I could get visible image by setting camera's projection matrix as ortho matrix without changing camera's update code. So, I think this approach must work. But all I see is black screen. What's to be done?
use glutOrtho2d. Refer the link if you have any doubts
单位投影矩阵将视口的左上和右下范围放在(-1,+1)和(+1,-1)且没有透视效果,因此“默认情况下” OpenGL为您提供正交投影,其中屏幕的左上角是(-1,+1),右下角是(+1,-1)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.