我正在努力实现这种效果: https://www.youtube.com/watch?v=HuARqqMuHE8
我有框架更新:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left, right, bottom, top); //Window dimensions: 800x600
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
我需要在左侧,右侧,下方,顶部放置哪些值才能在上面的视频中实现效果?
答案 0 :(得分:0)
根据您要将相机放置在与船舶相关的位置,将确定顶部和左侧位置。我知道OpenGL中的坐标系会发生一些奇怪的事情,但这应该有效:
这将始终将船放在屏幕的中央:
left = shipPos.x - (screenWidth/2.0); // in your case this would be x - 400
top = shipPos.y - (screenHeigh/2.0); // and this would be y - 300
right = left + screenWidth;
bottom = top + screenHeight;