OpenGL gluLookAt
OpenGL gluLookAt
我试图画一个茶壶并以3D形式查看它,但是当我运行程序时,什么也没显示。窗户里什么都没有。我知道它与我的gluLookAt((函数有关,但我不确定如何解决它。
// helloteapot.cc
//#include <GLUT/gl.h>
#include <GLUT/glut.h>
#include "GL/glui.h"
void display () {
/* clear window */
glClear(GL_COLOR_BUFFER_BIT);
/* draw scene */
glColor3f(1.0, 0.0, 0.0);
glTranslatef(0.0, 0.5, 0.0);
glutSolidTeapot(0.15);
/* flush drawing routines to the window */
glFlush();
}
int main ( int argc, char * argv[] ) {
glutInit(&argc,argv);
/* setup the size, position, and display mode for new windows */
glutInitWindowSize(800,600);
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_RGB);
/* create and set up a window */
glutCreateWindow("hello, teapot!");
glutDisplayFunc(display);
/*GLfloat width = 800;
GLfloat height = 600;
GLfloat aspect = (GLfloat)width / (GLfloat)height;
// Set the viewport to cover the new window
glViewport(0, 0, width, height);*/
// Set the aspect ratio of the clipping volume to match the
viewport
glMatrixMode(GL_PROJECTION); // To operate on the Projection
matrix
glLoadIdentity(); // Reset
// Enable perspective projection with fovy, aspect, zNear and zFar
//luPerspective(45.0f, aspect, -100.0f, 100.0f);
gluLookAt(0, 0, 0, 0, 0.5, 0, 0, -1, 0);
/* tell GLUT to wait for events */
glutMainLoop();
}
您要求 GL 将相机定位在原点,将相机向上对准点 (0, 0.5, 0(,并且还(错误地(将向上矢量指定为 0, -1, 0。问题是相机的前进方向是 (0, 1, 0( [由您的眼睛和瞄准位置指定],并且此方向与向上矢量或 (0, -1, 0( 冲突。尝试使用与前进方向成直角的矢量!(例如 [1
, 0, 0], [0, 0, 1](gluLookAt(
0, 0, 0, //< camera location
0, 0.5, 0, //< looking towards point
1, 0, 0); //< which direction is up?
相关文章:
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 了解 GLM- openGL 中的相机转换
- 如何在全屏模式下(在OpenGL中)使背景透明
- 为什么我不能使用 EGL 创建无头 OpenGl 上下文?
- 如何使用gluLookAt围绕OpenGL中的点旋转相机视图
- OpenGL gluLookAt
- gluLookAt() 在 OpenGL 中没有效果
- OpenGL Glulookat不与着色器一起使用
- 意外的glulookat行为,点在opengl上抽出
- LWJGL:gluLookAt在opengl 3+中返回Matrix4f
- 两个 Sphere 和 gluLookAt 函数之间的 OpenGL 碰撞
- gluLookAt似乎产生了错误的观点,OpenGL
- 使用 OpenGL 和 gluLookAt 围绕球体旋转
- Opengl鼠标相机问题(gluLookAt)
- openGL-使用gluLookAt在对象上方和下方旋转
- glulookat()-使用键盘移动相机(OpenGL)
- glulookat() usage-opengl and C++
- C++ OpenGL gluLookAt
- gluLookAt的c ++ OpenGL显示问题
- C++ OpenGL gluLookAt help