在opengl中混合固定功能管道和可编程管道 [英] Mixing fixed function pipeline and programmable pipeline in opengl

查看:198
本文介绍了在opengl中混合固定功能管道和可编程管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这里是我的问题。我有一个框架用于我的学校的可视化,我一直在试图设置它做3d图形。问题是,框架目前只使用固定函数管道来绘制。没有搞砸,我一直在试图解决旧的代码,仍然需要使用固定的函数管道,我已经设置了设施,允许创建着色器和着色器程序。我有一个简单的颜色着色器来编译,我也做了一个测试顶点数组(一个绿色三角形)。

Okay, so here is my problem. I have a framework used by my school for visualizations, and I've been trying to set it up to do 3d graphics. Problem is, the framework currently only uses the fixed function pipeline to draw. Without messing that up, i've been trying to work around the old code which still needs to use the fixed function pipeline, and i have been setting up facilities to allow for the creation of shaders and shader programs. I've got a simple color shader to compile and i've also made a test vertex array (a green triangle).

现在当我试图渲染它,屏幕变黑了。之前,有很多2d精灵和什么不在屏幕上移动,但逐步通过代码我添加到渲染功能,我发现,在我调用glUseProgram的时候,屏幕变黑。如果我注释掉glUseProgram,和我设置制服和绘制的部分,一切正常工作。 glUseProgram是否禁用固定功能管道?

Now when i tried to render it, the screen went black. Before hand, there was a lot of 2d sprites and what not moving about the screen, but stepping through the code i added to the render function, I found that the screen goes black the moment I call glUseProgram. If i comment out the glUseProgram, and the parts where i set the uniforms and draw, everything works normally. Does glUseProgram disable the fixed function pipeline? if so, is there anyway to reactivate it, per se?

推荐答案

当你使用 glUseProgram 固定功能管道由可编程管道替代。你不能同时拥有固定功能+可编程管道。例如假设您的场景包含雾。但如果你没有照顾你的片段着色器,你不会看到它在最终的输出。

The moment you use glUseProgram fixed function pipeline is replaced by programmable pipeline. You can't have like fixed function + programmable pipeline at the same time. For example suppose your scene contains fog. But if you haven't taken care of that in your fragment shader you wont see it in final output.

虽然在渲染/绘制函数中你可以这样做

Though in your render/draw function you can do something like this

draw
{
  glUseProgram(program);
  // render stuff with shader
  glUseProgram(0)
  // render stuff with fixed pipeline
}

这篇关于在opengl中混合固定功能管道和可编程管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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