glTexGen

glTexGen

  Rather than having to explicitly provide a texture coordinate for each vertex, we can use texture coordinate generation (texgen) functions to have OpenGL automatically compute texture coordinates.

  This uses the function glTexGen, and the glEnable modes GL_TEXTURE_GEN_S & GL_TEXTURE_GEN_T.

planeCoefficients = [ 1, 0, 0, 0 ]

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR)

glTexGenfv(GL_S, GL_OBJECT_PLANE, planeCoefficients)

glEnable(GL_TEXTURE_GEN_S)



glBegin(GL_QUADS)

glVertex3f(-3.25, -1, 0)

glVertex3f(-1.25, -1, 0)

glVertex3f(-1.25, 1, 0)

glVertex3f(-3.25, 1, 0)

glEnd()

  glTexGen

API说明

  glTexGen

  coord:Specifies a texture coordinate. Must be one of GL_SGL_TGL_R, or GL_Q.

  pname:Specifies the symbolic name of the texture-coordinate generation function. Must be GL_TEXTURE_GEN_MODE.

  param:Specifies a single-valued texture generation parameter, one of GL_OBJECT_LINEARGL_EYE_LINEARGL_SPHERE_MAPGL_NORMAL_MAP, or GL_REFLECTION_MAP.

参考:

1、http://resumbrae.com/ub/dms424_s05/10/print.html

2、https://www.opengl.org/sdk/docs/man2/xhtml/glTexGen.xml

你可能感兴趣的:(T)