Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 1558 times)
0 Members and 1 Guest are viewing this topic.
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Posted 2012-12-11 10: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  

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


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

Troll?

- Jonas
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



« Reply #2 - Posted 2012-12-11 11: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 11:21:21 »

Troll?

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

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Ultroman

JGO Knight


Medals: 25
Projects: 1


Snappin' at snizzes since '83


« Reply #4 - Posted 2012-12-11 11: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 11: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();

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 802
Projects: 4
Exp: 16 years


Hand over your head.


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

There is no way.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



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

OK, thanks for the help guys.  Smiley

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline hug0x

Senior Newbie





« Reply #8 - Posted 2012-12-11 12: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 13:11:17 »

Yes, I know that. I was just wondering if openGL has a function to delete a object from the scene.  Huh

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 802
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2012-12-11 13: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
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



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

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

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline hug0x

Senior Newbie





« Reply #12 - Posted 2012-12-11 13: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 13:22:56 »

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

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Longor1996
« Reply #14 - Posted 2012-12-11 21: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
« League of Dukes »

JGO Kernel


Medals: 133
Projects: 4
Exp: 3 years



« Reply #15 - Posted 2012-12-11 21: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 06:55:06 »

Lol, good one Wink

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline Joshua Waring

Senior Member


Medals: 4
Projects: 2



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

It not a successful tablet Roll Eyes

The world is big, so learn it in small bytes.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (20 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!