# Rendering different array types in the same vertex/fragment shader?

I have a pretty basic widget rendering, largely based upon the learnopengl.com "hello triangle." I'm actually using a tristrip to create two triangles, forming a semi-opaque square over the top of the other stuff in my window. In this square, I'm using the fragment shader to set the semi-opaque background color and an arrow that points in the direction of flight. What I want to do next is render a GL_LINES vertex buffer that contains the historical position of the aircraft.

It seems easy enough to set up a second vertex attribute object and vertex buffer, but what is unclear to me is whether it's possible to use a single vertex & fragment shader pair to handle this second dataset. It wouldn't be terribly difficult to set up a group of widgets to render the opaque square, then the historical course information, then the arrow, but I already have the first and third stages working.... and breaking everything up would mean 3 vertex and 3 fragment shaders.

I'm guessing that it's impossible to deal with the semi-opaque background, the historic course, and the arrow all in one vertex/fragment shader pair, but it'd be obtuse to just make that assumption and make a mess out of some tolerably organized code before I got an informed answer.

• Actually trying to do these "all in one" shader while doable could be very difficult using three different shaders, like you said, is much cleaner, and easier to understand. Setting up a shader to render GL_LINES is a hardware setting that can't be flipped on and off in the middle of shader. The same with turning on alpha blending. So to render "lines" would require rendering degenerate triangles or some other "hack", its just better to stick with the 3 shaders, especially if you are still learning opengl. Dec 12 '20 at 18:06
• Thanks for the confirmation. I did eventually go that route and, once the initial pain was past, it really did reduce down to a neat, clean implementation. Maybe I"ve spent too much time in shadertoy, and thought I could do the whole thing in one fragment shader. Simple newbie shortsightedness. =] Dec 14 '20 at 22:01