3

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()?

genpfault
  • 51,148
  • 11
  • 85
  • 139
seal
  • 1,122
  • 5
  • 19
  • 37

1 Answers1

3

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
genpfault
  • 51,148
  • 11
  • 85
  • 139