Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何将GlorTo2D与移动位置一起使用?_C++_Opengl_Glut_Opengl 1.x - Fatal编程技术网

C++ 如何将GlorTo2D与移动位置一起使用?

C++ 如何将GlorTo2D与移动位置一起使用?,c++,opengl,glut,opengl-1.x,C++,Opengl,Glut,Opengl 1.x,我试图根据玩家(简单正方形)的位置(x,y)移动相机。比例相对较小,字符为0.5f乘0.5f 如何使用glOrtho2D将相机聚焦在播放器的x和y坐标上 我真的被你如何使用左、右、下和上感到困惑。它完全没有意义,它显然定义了屏幕比例以及它绘制的位置 非常感谢您的帮助 我从3d版本(gluLookAt)切换到以下版本: gluLookAt(jake.px, 0.0f, jake.pz + 20, jake.px, 7.0f, jake.pz, 0.0f, 1.0f, 0.0f ); 然后重新调整

我试图根据玩家(简单正方形)的位置(x,y)移动相机。比例相对较小,字符为0.5f乘0.5f

如何使用glOrtho2D将相机聚焦在播放器的x和y坐标上

我真的被你如何使用左、右、下和上感到困惑。它完全没有意义,它显然定义了屏幕比例以及它绘制的位置

非常感谢您的帮助

我从3d版本(gluLookAt)切换到以下版本:

gluLookAt(jake.px, 0.0f, jake.pz + 20, jake.px, 7.0f, jake.pz, 0.0f, 1.0f, 0.0f );
然后重新调整大小

gluPerspective(45.0f, ratio, 0.1f, 100.0f);

gluOrtho2D(player.x-screenWidth/2,player.x+screenWidth/2,player.y-screenHeight/2,player.y+screenHeight/2)
?@user2802841仍然没有任何内容:/n您可以用一些虚构的值替换screenWidth/Height(只需保持纵横比与分辨率相同),例如,如果您的角色为0.5x0.5,则类似于32.0x18.0(对于16:9纵横比)应使其可见。根据经验,投影矩阵(由
glOrtho
glperspective
等设置)应独立于相机移动。其功能类似于相机上的镜头。传统OpenGL中的相机移动是通过
glTranslate
/
glRotate
(不要忘记
glMatrixMode(GL_MODELVIEW);glLoadIdentity();