How to texture of a glutSolidTorus in OpenGL? [closed]

Deadly 提交于 2020-08-25 04:08:39

问题


I am trying to texture a glutSolidTorus().

Here is my code:

glColor3f(1.0f, 1.0f, 1.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tiring);
glutSolidTorus(.55, 1.8, 25, 25);           
glDisable(GL_TEXTURE_2D);

But it does not work. How can I texture glutSolidTorus()?


回答1:


Except for glut*Teapot() none of the GLUT geometry primitives provide texture coordinates:

11 Geometric Object Rendering

GLUT includes a number of routines for generating easily recognizable 3D geometric objects. These routines reflect functionality available in the aux toolkit described in the OpenGL Programmer's Guide and are included in GLUT to allow the construction of simple GLUT programs that render recognizable objects. These routines can be implemented as pure OpenGL rendering routines. The routines do not generate display lists for the objects they create.

The routines generate normals appropriate for lighting but do not generate texture coordinates (except for the teapot).

You have several options:

  1. Fixed-function texcoord generation
  2. Shader-based texcoord generation
  3. Reimplement glutSolidTorus() to add texture coordinates


来源:https://stackoverflow.com/questions/29953874/how-to-texture-of-a-glutsolidtorus-in-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!