View Full Version : drawing text and primitives at the same time

05-16-2013, 11:09 AM
I am writing simple GUI library for OpenGL. There are lot's of tutorials how to render text, and even more about primitives. Currenly I am experimenting on this tutorial But problem is I cannot figure out how to render both of them at the same time. For example how to draw square and some text on it. What I managed to do is draw both of them but then shader colored them in same color..

Can someone point me to the right direction?

05-17-2013, 06:23 AM
If you wish to draw them both with the same shader and a sinlge draw, call put the colour into the vertex structure and pass the colour to the fragment shader. If all the vertices for an object have the same colour any interpolated point in the fragment shader will have the same colour.

05-17-2013, 06:46 AM
Thats the point that I need to draw Panel and it's label in different color.

05-17-2013, 05:41 PM
I think you missed my point.

If I have a vertex buffer with
vertex 1 - red
vertex 2 - red
vertex 3 - blue
vertex 4 - blue
If I draw this buffer with GL_LINES I will get a red line from vertices 1,2 and a blue line from 3,4.