Sign in to follow this  
omgh4x0rz

undoing a drawImage

Recommended Posts

Is there a way to undo a drawImage in Java so that the screen only shows what was there right before? Right now my game is really simple so I can just draw a big white rectangle where the image was and then move the image over. However, I don't think this will suffice in the long run. What do you suggest the best method for this is? Thanks even if you don't have any suggestions for java in particular, I would like to hear how you would do this with another language so I can get ideas.

Share this post


Link to post
Share on other sites
The general way of doing this is with double buffering. The entire screen is rendered to a buffer. Then you just replace the current screen with the contents of the buffer. Then you clear the back-buffer and start drawing to that. Your graphics hardware can do this automatically by just passing a couple parameters in the setup (assuming you're using some graphics library to draw).

If you're writing a software renderer you'll have to implement this by hand.

-me

Share this post


Link to post
Share on other sites
Swing is a GUI toolkit, like Gtk+, Qt and wxWidgets (although those are all C/C++ - I'm not aware of any other Java toolkits ignoring AWT). Basically a GUI toolkit gives you a library of common user interface elements like menus, buttons, textboxes and lots of others.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this