Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: drawing text and primitives at the same time

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2

    drawing text and primitives at the same time

    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?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    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.

  3. #3
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2
    Thats the point that I need to draw Panel and it's label in different color.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,109
    I think you missed my point.

    If I have a vertex buffer with
    [code
    vertex 1 - red
    vertex 2 - red
    vertex 3 - blue
    vertex 4 - blue
    [/code]
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •