什么是glUseProgram(0)呢? [英] What does glUseProgram(0) do?

查看:4797
本文介绍了什么是glUseProgram(0)呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL的文档为 glUseProgram 声称具有的参数调用它的的会造成着色器执行的结果是未定义

The OpenGL docs for glUseProgram claim that calling it with an argument of zero will cause the results of shader execution to be undefined.

不过,一些搜索后,我已经看到了使用 glUseProgram 人几个例子的卸载的当前着色器程序。

However, after a little searching I've seen a couple examples of people using glUseProgram to uninstall the current shader program.

这种行为是可靠的?如果不是,那么究竟是什么 glUseProgram(0)吗?

Is this behavior reliable? If not, then what exactly does glUseProgram(0) do?

推荐答案

glUseProgram 意味着,给定的程序对象是将用于使用程序当前事物的计划( glUniform ,渲染命令等)。 0很像 NULL 对OpenGL的对象。它重新presents 不是一个对象(大多数对象)。因此, glUseProgram 表示的没有的程序是最新的,因此没有程序将被用于使用程序的东西。

glUseProgram means that the given program object is the current program that will be used for things that use programs (glUniform, rendering commands, etc). 0 is a lot like NULL for OpenGL objects. It represents not an object (for most objects). Therefore, glUseProgram means that no program is current, and therefore no program will be used for things that use programs.

如果您尝试调用 glUniform 函数时没有程序是最新的,他们将失败,出现错误。如果试图渲染时没有程序是最新的,两件事情之一会发生。

If you attempt to call the glUniform functions when no program is current, they will fail with an error. If you attempt to render when no program is current, one of two things will happen.


  • 的OpenGL 3.1以上版本,核心配置文件后,您将获得 GL_INVALID_OPERATION 错误,因为核心的OpenGL的必须的渲染与程序。

  • 兼容性配置文件或版本3.0或更低后,您将获得固定功能的渲染。

  • In OpenGL 3.1+, core profile, you will get a GL_INVALID_OPERATION error, because core OpenGL must render with a program.
  • In compatibility profiles or version 3.0 or less, you will get fixed-function rendering.

这篇关于什么是glUseProgram(0)呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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