OpenGL:使用不同的参数重复使用相同的纹理 [英] OpenGL: Reusing the same texture with different parameters

查看:75
本文介绍了OpenGL:使用不同的参数重复使用相同的纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,我有一个在不同情况下多次使用的纹理.在每种情况下,我都需要应用一组特定的参数.

In my program I have a texture which is used several times in different situations. In each situation I need to apply a certain set of parameters.

我想避免创建额外的缓冲区,而本质上是每次需要将纹理用于其他用途时都创建纹理的副本,所以我想知道是否有更好的方法?

I want to avoid having to create an additional buffer and essentially creating a copy of the texture for every time I need to use it for something else, so I'd like to know if there's a better way?

推荐答案

这是采样器对象的用途(可用从3.3版开始,或使用ARB_sampler_objects).采样器对象将纹理图像与其参数分开,因此您可以将一个纹理与多个参数集一起使用.该功能的创建正是考虑到您的问题.

This is what sampler objects are for (available in core since version 3.3, or using ARB_sampler_objects). Sampler objects separate the texture image from its parameters, so you can use one texture with several parameter sets. That functionality was created with exactly your problem in mind.

引文来自ARB_sampler_objects扩展规范:

在未扩展的OpenGL中,纹理被视为图像数据集(Mip链,数组,立方体贴图面集等)和采样状态(采样模式,Mip映射状态,坐标换行和钳位规则等). .)合并为一个对象.通常,应用程序使用许多纹理,并且它们之间具有相同的有限采样状态集.为了以这种方式使用纹理,应用程序必须生成并配置许多纹理名称,这会增加应用程序和实现的开销.此外,如果应用程序希望以一种以上的方式(例如有无mip映射)从纹理中采样,则它必须修改纹理的状态或创建两个纹理,每个纹理均具有相同的图像数据副本.这可能会给应用程序带来运行时和内存成本.

In unextended OpenGL textures are considered to be sets of image data (mip-chains, arrays, cube-map face sets, etc.) and sampling state (sampling mode, mip-mapping state, coordinate wrapping and clamping rules, etc.) combined into a single object. It is typical for an application to use many textures with a limited set of sampling states that are the same between them. In order to use textures in this way, an application must generate and configure many texture names, adding overhead both to applications and to implementations. Furthermore, should an application wish to sample from a texture in more than one way (with and without mip-mapping, for example) it must either modify the state of the texture or create two textures, each with a copy of the same image data. This can introduce runtime and memory costs to the application.

这篇关于OpenGL:使用不同的参数重复使用相同的纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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