游戏开发论坛

 找回密码
 立即注册
搜索
查看: 7633|回复: 4

关于 glClearDepth(参数) 的疑问

[复制链接]

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
发表于 2008-1-25 14:20:00 | 显示全部楼层 |阅读模式
在 NEHE 的教程中,用的是 glClearDepth(1.0)。
资料上写着,这个参数可以是 0.0到1.0 的数。

问题:
①如果参数不同,那会对显示效果有什么影响?

②如果我用的投影矩阵是
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f),
那么 glClearDepth()里的参数应该写 0.1好呢?还是0.01好呢?还是仍然写 1.0呢?
如果是仍然都要写 1.0,那为什么还需要这个参数呢?直接在OpenGL内部隐藏掉不就行了吗?
为什么还让我们自己输入?
[em5]

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
 楼主| 发表于 2008-1-25 14:26:00 | 显示全部楼层

Re:关于 glClearDepth(参数) 的疑问

以下是我在BAIDU上找到的英文资料

glClearDepth
glClearDepth
NAME
glClearDepth - specify the clear value for the depth buffer

C SPECIFICATION
void glClearDepth( GLclampd depth )

PARAMETERS
depth ? Specifies the depth value used when the depth buffer is cleared.


DESCRIPTION
glClearDepth specifies the depth value used by glClear to clear the depth buffer. Values specified by glClearDepth are clamped to the range [0,1].

ERRORS
GL_INVALID_OPERATION is generated if glClearDepth is called between a call to glBegin and the corresponding call to glEnd.

ASSOCIATED GETS
glGet with argument GL_DEPTH_CLEAR_VALUE

SEE ALSO
"glClear"

32

主题

1259

帖子

1351

积分

金牌会员

Rank: 6Rank: 6

积分
1351
发表于 2008-1-25 15:47:00 | 显示全部楼层

Re:关于 glClearDepth(参数) 的疑问

如果是0.5, 将有后面一半的深度不会清除掉。

180

主题

3511

帖子

3520

积分

论坛元老

Rank: 8Rank: 8

积分
3520
 楼主| 发表于 2008-1-25 16:44:00 | 显示全部楼层

Re: Re:关于 glClearDepth(参数) 的疑问

Devil: Re:关于 glClearDepth(参数) 的疑问

如果是0.5, 将有后面一半的深度不会清除掉。

什么叫“后面一半”?

gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f)里的
从 50.05f 到 100.0f 之间,不会被清楚?

3

主题

121

帖子

121

积分

注册会员

Rank: 2

积分
121
QQ
发表于 2008-1-25 17:53:00 | 显示全部楼层

Re:关于 glClearDepth(参数) 的疑问

glClearDepth(0.5f);
只是将所有的片断的深度清为0.5.

gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f)
0.1f处的片断的深度为0.0, 100.0f处的片断的深度为1.0.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-19 23:50

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表