禁用 opengl es 纹理 ios

发布于 2024-12-26 20:20:05 字数 183 浏览 1 评论 0原文

如何在渲染函数中暂时禁用 opengl es 2.x for ios 上的纹理? 我正在实施颜色选择。

我没有使用 glkit。我正在使用着色器,因此 glDisable(GL_TEXTURE_2D) 不起作用,glBindTexture(GL_TEXTURE_2D,0) 也不起作用

How do i temporarily disable textures on opengl es 2.x for ios in the render function?
I am implementing color selection.

I am not using glkit. I am using shaders, so glDisable(GL_TEXTURE_2D) doesn't work, nor did glBindTexture(GL_TEXTURE_2D,0)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2025-01-02 20:20:05

取决于您想要实现什么目标。如果禁用纹理,您希望渲染中出现什么?

如果你的着色器根据纹理样本计算片段的颜色,如果你没有绑定任何纹理,它应该使用什么来代替纹理?一种颜色?

我看到 2 个选项:

A - 使用 2 个着色器,一个支持纹理,一个使用固定颜色(如果加载属性,则使用顶点颜色)

B - 使用单个着色器并使用统一来试行渲染(纹理或颜色)。

选项 B 提供了更高的性能。

编辑关于如何做到这一点的第一个问题:

if (Texture == 0) {
    gl_FragColor = vec4(1.0,0.0,0.0,0.0);  //red color
} else{
    gl_FragColor = texture2D(Texture, TexCoordOut);
}

Depends on what you want to achieve. If you disable a texture what do you expect to have in your rendering?

If your shader calculates the color of a fragment based on a Texture sample, if you do not bind any texture, what should it use in place of the texture? A color?

I see 2 options:

A - use 2 shaders, one supporting textures, one using fixed colors (or vertex colors if you load the attribute)

B - use a single shader and pilot the rendering (texture or colors) using uniforms.

The option B offers much more performance.

Edit to first question on how to do it:

if (Texture == 0) {
    gl_FragColor = vec4(1.0,0.0,0.0,0.0);  //red color
} else{
    gl_FragColor = texture2D(Texture, TexCoordOut);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文