Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED] How to delete a object from the screen?  (Read 686 times)
0 Members and 1 Guest are viewing this topic.
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Posted 2012-12-11 11:50:09 »

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.  Smiley  
Offline Ultroman

JGO Knight


Medals: 23
Projects: 1


Snappin' at snizzes since '83


« Reply #1 - Posted 2012-12-11 12:00:19 »

Troll?

- Jonas
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« Reply #2 - Posted 2012-12-11 12:10:33 »

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.

The world is big, so learn it in small bytes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #3 - Posted 2012-12-11 12:21:21 »

Troll?

Im not a troll, you idiot, I`m just looking for a answer.
Offline Ultroman

JGO Knight


Medals: 23
Projects: 1


Snappin' at snizzes since '83


« Reply #4 - Posted 2012-12-11 12:45:40 »

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?

- Jonas
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #5 - Posted 2012-12-11 12:50:31 »

Using openGL.

1  
2  
3  
4  
5  
6  
glBegin(GL_QUADS);
   glVertex2f(0, 0);
   glVertex2f(0, 50);
   glVertex2f(50, 50);
   glVertex2f(50, 0);
glEnd();
Online Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #6 - Posted 2012-12-11 12:52:22 »

There is no way.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #7 - Posted 2012-12-11 12:53:06 »

OK, thanks for the help guys.  Smiley
Offline hug0x

Senior Newbie





« Reply #8 - Posted 2012-12-11 13:12:52 »

Just put a condition before drawing your square..

For example :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
boolean DrawSquare = true;


if (DrawSquare){
glBegin(GL_QUADS);
   glVertex2f(0, 0);
   glVertex2f(0, 50);
   glVertex2f(50, 50);
   glVertex2f(50, 0);
glEnd();
}
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #9 - Posted 2012-12-11 14:11:17 »

Yes, I know that. I was just wondering if openGL has a function to delete a object from the scene.  Huh
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #10 - Posted 2012-12-11 14:14:26 »

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.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #11 - Posted 2012-12-11 14:18:39 »

So openGL is a graphics driver?  Shocked And I said I was only wondering  Pointing
Offline hug0x

Senior Newbie





« Reply #12 - Posted 2012-12-11 14:21:00 »

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.
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #13 - Posted 2012-12-11 14:22:56 »

I know, I can clear the screen using
1  
glClear(GL_COLOR_BUFFER_BIT);
(for 2d)  Smiley
Offline Longor1996

Senior Member


Medals: 5
Projects: 1



« Reply #14 - Posted 2012-12-11 22:23:50 »

You know that this:
1  
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!

Sorry for my bad English! That's because i am from Germany.
Offline Jimmt
« Reply #15 - Posted 2012-12-11 22:54:37 »

Be careful Longor, Surface with the s capitalized is a tablet Wink
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #16 - Posted 2012-12-12 07:55:06 »

Lol, good one Wink
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« Reply #17 - Posted 2012-12-12 13:49:35 »

It not a successful tablet Roll Eyes

The world is big, so learn it in small bytes.
Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (67 views)
2013-05-17 21:29:12

alaslipknot (76 views)
2013-05-16 21:24:48

gouessej (109 views)
2013-05-16 00:53:38

gouessej (104 views)
2013-05-16 00:17:58

theagentd (115 views)
2013-05-15 15:01:13

theagentd (104 views)
2013-05-15 15:00:54

StreetDoggy (149 views)
2013-05-14 15:56:26

kutucuk (172 views)
2013-05-12 17:10:36

kutucuk (170 views)
2013-05-12 15:36:09

UnluckyDevil (179 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.102 seconds with 21 queries.