我是OpenGL的新手,仍在尝试基本形状。我有时会发现许多函数(如“ glend”等)在OpenGL 3+文档中没有提到。它们被其他函数取代了吗?还是我必须手动编写它们?是否有在线教程使用OpenGL 3+?
至于“ gluPerspective”,我读到它在OpenGL 3+中不再使用。它不应该是GLUT中的一个单独函数吗?它与OpenGL 3+有什么关系?最后,“ Transform(Width,Height)”是干什么用的呢?(我在下载的一些示例代码中找到了它,但在GLUT或OpenGL中找不到它。)
以下是代码:
至于“ gluPerspective”,我读到它在OpenGL 3+中不再使用。它不应该是GLUT中的一个单独函数吗?它与OpenGL 3+有什么关系?最后,“ Transform(Width,Height)”是干什么用的呢?(我在下载的一些示例代码中找到了它,但在GLUT或OpenGL中找不到它。)
以下是代码:
GLvoid Transform(GLfloat Width, GLfloat Height)
{
glViewport(00, 00, Width, Height); /* Set the viewport */
glMatrixMode(GL_PROJECTION); /* Select the projection matrix */
glLoadIdentity(); /* Reset The Projection Matrix */
gluPerspective(20.0,Width/Height,0.1,100.0); /* Calculate The Aspect Ratio Of The Window */
glMatrixMode(GL_MODELVIEW); /* Switch back to the modelview matrix */
}
/* A general OpenGL initialization function. Sets all of the initial parameters. */
GLvoid InitGL(GLfloat Width, GLfloat Height)
{
glClearColor(0.0, 0.0, 0.0, 0.0); /* This Will Clear The Background Color To Black */
glLineWidth(2.0); /* Add line width, ditto */
Transform( Width, Height ); /* Perform the transformation */
}
/* The function called when our window is resized */
GLvoid ReSizeGLScene(GLint Width, GLint Height)
{
if (Height==0) Height=1; /* Sanity checks */
if (Width==0) Width=1;
Transform( Width, Height ); /* Perform the transformation */
}