以重复模式绑定纹理
我正在尝试在 OpenGL 中的 3D 纹理中存储八叉树,以便使用 Cg 在 GPU 上使用,来自此处找到的 GPU Gems 2 中的一章 http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter37.html。但是我得到的结果是不正确的。我认为这是因为我创建八叉树的方式。
在该章的附录中,它说“如果我们以重复模式(GL_REPEAT)绑定间接池纹理(八叉树纹理)......”。
这是否仅仅意味着将过滤器和包装设置为重复,还是我需要做其他事情?这是我到目前为止的代码
glGenTextures(1, &octree_texture);
glBindTexture(GL_TEXTURE_3D, octree_texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, WIDTH, HEIGHT, DEPTH, 0, GL_RGBA, GL_UNSIGNED_BYTE, octreeData);
感谢您的帮助:)
I am trying to store an octree in a 3D texture in OpenGL for use on the GPU using Cg, from a chapter in GPU Gems 2 found here http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter37.html. However the results I am getting are incorrect. I think this is because of how I create the octree.
In the appendix of that chapter, it says "If we bind the indirection pool texture (octree texture) in repeat mode (GL_REPEAT)...".
Does this simply mean set the the filters and wrapping to repeat, or do I need to do something else? This is my code so far
glGenTextures(1, &octree_texture);
glBindTexture(GL_TEXTURE_3D, octree_texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, WIDTH, HEIGHT, DEPTH, 0, GL_RGBA, GL_UNSIGNED_BYTE, octreeData);
Thanks for the help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
过滤器不能重复,这会产生GL错误,只有换行模式可以是GL_REPEAT,这可能就是书上的意思。
The filters can't be repeat, that will generate a GL error, only the wrap mode can be GL_REPEAT, and that's probably what the book means.