Hello!
Ive got this problem, and I dont know what to do. I have drawn a rectangle on the screen, but then I want to delete it. Has opengl got some function, that lets you do that? I know I can use a boolean, but I am wondering how to do it some different way. And, I have searched google a lot of times for this, but I cant find a solution. Please Help! I`m using lwjgl as my rendering engine.
Troll?
I dont know if it’s a troll
But the rectangle won’t display in the next frame once you remove the glBegin call to draw it. To remove it you have to stop adding it.
Im not a troll, you idiot, I`m just looking for a answer.
Well, sorry, but it was a pretty odd and lesser detailed question.
And with no code posted, it’s pretty hard to give a definite answer.
If you know how to create a rectangle, using vertices or whatever,
and you want to remove it again, the recipe would most likely be to
remove its building-blocks in a backwards manner from how you
created it. How exactly have you created your rectangle?
Using openGL.
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(0, 50);
glVertex2f(50, 50);
glVertex2f(50, 0);
glEnd();
There is no way.
OK, thanks for the help guys.
Just put a condition before drawing your square…
For example :
boolean DrawSquare = true;
if (DrawSquare){
glBegin(GL_QUADS);
glVertex2f(0, 0);
glVertex2f(0, 50);
glVertex2f(50, 50);
glVertex2f(50, 0);
glEnd();
}
Yes, I know that. I was just wondering if openGL has a function to delete a object from the scene. ???
You seem to have an odd idea about OpenGL. OpenGL doesn’t have a scene, it doesn’t remember what you previously did. OpenGL just colors pixels. Once a pixel is overwritten, there is no way to figure out the previous value.
So openGL is a graphics driver? :o And I said I was only wondering :point:
You can create an object with the Square position and dimensions, put that Object in an Array and then draw what’s inside the Array. Then, you can delete your Object if you want. (Dont forget to clear your screen)
The method you used dont create an Object, it just draw it.
So yes, you can “delete” your object on the screen by clearing your screen, or drawing something else over your Square.
I know, I can clear the screen using
glClear(GL_COLOR_BUFFER_BIT);
(for 2d)
You know that this:
glClear(GL_COLOR_BUFFER_BIT);
just Clears the Screen?
OpenGL does not care about what’s on the Display.
By clearing the Color Buffer you just set all Pixels on the Display to the specified Clear-Color.
- Longor1996
PS: OpenGL just draws Pixels. Think of it like a bunch of colored Pencils that you can use to draw Stuff on a Surface!
Be careful Longor, Surface with the s capitalized is a tablet
Lol, good one
It not a successful tablet :