I have a GL 4.3 tessellation shader program which draws a Bezier curve just fine. Now, I want to draw the control points as well. Obviously, I have to turn off the TCS and TES and switch from glDrawArrays(GL_PATCHES, 0, 4) to glDrawArrays(GL_POINTS, 0, 4) (right?). So, how to do this in one program?
I have tried glGenProgramPipelines(); glBindProgramPipeline(), etc. to bind two separate pipelines, one to draw the curve the other the points, but for the life of me couldn’t get the VS-TCS-TES-FS pipeline working to draw the curve.
Is there some other way to do this in GL 4.3 core?
glDrawArrays(GL_PATCHES, 0, 4) to glDrawArrays(GL_POINTS, 0, 4) (right?).
Only if you’re going to turn off tessellation:
So the spec basically states, a little verbosely IMHO, that if tessellation is active, you need GL_PATCHES. If tessellation isn’t active, you cannot use GL_PATCHES. In essence, you can, of course, use a program pipeline to draw you control points or control polygon. You have to throw out the TCS and TES, however, because existence of any of those shaders implies tessellation is active.
EDIT: On second thought, one might add to the spec that it is an error to say that there exists a TCS without a TES because it will lead to an invalid operation no matter how you proceed.
[QUOTE=thokra;1252876]Only if you’re going to turn off tessellation:
Okay, so how do I turn off tessellation and just let the points go through VS-FS? Precisely, I want tessellation on for the curve then turn it off for the points.
how do I turn off tessellation
I already said: throw the TCS and TES out of your program pipeline. It’s as simple as drawing n points. Of course, if your vertex and fragment shader doesn’t work for rendering the points, you’ll have to use different programs. However, for the purpose of simply drawing a curve and some control points and/or a control polygon, I don’t see why they couldn’t work.
Obviously, I am missing something here. I want the same program to draw the curve and control points. So I have to throw the TCS and TES out in its drawing routine (after the curve is drawn). How does one do that is my question.
I couldn’t get glDetachShader() to work in the drawing routine. If that’s the way I would appreciate a snippet of code. Or please explain how else to turn off the TCS and TES after they have been used to draw the curve.
glUseProgramStages(pipeline, GL_TESS_CONTROL_SHADER_BIT | GL_TESS_EVALUATION_SHADER_BIT, 0);
Thanks. Your suggestion obviously requires the shaders to be bound to a pipeline created with glGenProgramPipelines(1, &pipeline), etc. Unfortunately, I have simply been unable to do this. The program works fine with the shaders attached with glCreateProgram(), glAttachShader(), etc. (no pipeline). But if I try to bind separate shader objects to a pipeline, no dice.
If you would be so kind as to look I have got the program boiled down to the basics here. It’s pretty short and, hopefully, won’t take you more than a few mins. to understand. The main program has two blocks of statements, one without pipeline and one with. The one without works fine.
If you could tell me how to get the pipeline working then I am sure the glUseProgramStages() command you suggest will work. But, first, I need the pipeline going!! Thanks again.
Doh! I thought we were talking separable programs all the time… :doh:
I couldn’t get glDetachShader() to work in the drawing routine.
This alone will do nothing to the executable. If you want a different program, you’d have to relink the program. So, detach -> link. However, this is simply nonsense performance-wise. Either create two programs, one for curve tessellation, one for control points. The latter will not attach a TCS/TES in the first place. If you want to mix-and-match existing programs, you’ll need to go separable. Please read the wiki. I’m afraid I can’t make time to look at the code.