Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing fixed function pipeline and programmable pipeline in opengl

Tags:

c++

opengl

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).

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?

like image 213
FatalCatharsis Avatar asked Mar 10 '14 06:03

FatalCatharsis


1 Answers

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
}
like image 61
Abhishek Bansal Avatar answered Sep 17 '22 12:09

Abhishek Bansal