如何在OpenGL中构造glutSolidTorus的纹理? [英] How to texture of a glutSolidTorus in OpenGL?

查看:452
本文介绍了如何在OpenGL中构造glutSolidTorus的纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试纹理glutSolidTorus().

这是我的代码:

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);

但是它不起作用.如何纹理glutSolidTorus()?

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

推荐答案

除了glut*Teapot()

11个几何对象渲染

GLUT包含许多用于生成易于识别的3D几何对象的例程.这些例程反映了《 OpenGL程序员指南》中所述的aux工具包中可用的功能,并且包含在GLUT中,以允许构造呈现可识别对象的简单GLUT程序.这些例程可以实现为纯OpenGL渲染例程.例程不会为其创建的对象生成显示列表.

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).

您有几种选择:

  1. 固定功能 texcoord生成
  2. 基于着色器的texcoord生成
  3. 重新实现glutSolidTorus() 添加纹理坐标
  1. Fixed-function texcoord generation
  2. Shader-based texcoord generation
  3. Reimplement glutSolidTorus() to add texture coordinates

这篇关于如何在OpenGL中构造glutSolidTorus的纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆