PDA

View Full Version : Does freeglut allow you to draw in top of other?



programmer17
01-02-2012, 11:28 AM
I have white image. I am trying to draw another image in top of it.
But I cannot see it.
And is there a way to erase a drawing? Not from the code :p

Zyx_2000
01-02-2012, 03:22 PM
To "erase", use glClear(GL_COLOR_BUFFER_BIT), and swap buffers if using double buffering.

programmer17
01-02-2012, 08:32 PM
But that deletes everything. However i want to delete just a single part. How can I do that?

Alfonse Reinheart
01-02-2012, 08:53 PM
You redraw everything except that part you don't want to see anymore. This is how the vast majority of OpenGL applications operates.

programmer17
01-02-2012, 09:31 PM
true.
but what I am trying to do is let the user change the color of the object. Unfortunately, I could not learn picking. So, I thought i would use if statements like if x>122&amp;&amp; x< 213 return 1. same for y. So I would know which object was clicked. And then I called a popupmenu function for the user to choose color. Then I decided to redraw the colored object on top of other. If i erase all and draw again it will not work because I have different functions for drawing not colored things and colored things.
anyway I will try.
If you dont get this then I can provide a better explanation with code

V-man
01-04-2012, 05:15 AM
If you want to do color picking, you have 2 choices. Either you use the back buffer or a RenderBuffer. Assuming you want to use the back buffer.

Whichever you choose, all you need to do is
glCear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENIL_BUFFER_BIT);
RenderObjectsWithUniqueColor();
//Read back color under the mouse
uint thecolor;
glReadPixels(x, y, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, thecolor);

//And clear again
glCear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENIL_BUFFER_BIT);
RenderObjects();
SwapBuffers();