GTGE API

com.golden.gamedev.engine
Interface BaseGraphics

All Known Implementing Classes:
AppletMode, FullScreenMode, GameLoader, WindowedMode

public interface BaseGraphics

BaseGraphics interface provides all needed graphics function for drawing unto screen.

Common methods of how-to-use BaseGraphics:

    public class GraphicsEngine implements BaseGraphics {
       .....

       public static void main(String[] args) {
          BaseGraphics engine = new GraphicsEngine(...);

          // game loop
          while (true) {
             do {
                // get backbuffer
                Graphics2D g = engine.getBackBuffer();

                // draw to backbuffer
                g.drawImage(...);

                // flip to screen
             } while (engine.flip() == false);
          }

          // dispose graphics engine
          engine.cleanup();
       }
    }
 


Method Summary
 void cleanup()
          Releases any system graphics resources and do finalization.
 boolean flip()
          Flips backbuffer to the screen (primary surface).
 Graphics2D getBackBuffer()
          Returns backbuffer where the rendering perform.
 Component getComponent()
          Returns the component where the rendering perform.
 String getGraphicsDescription()
          Returns graphics engine description, for example: fullscreen, windowed, applet, fullscreen with bufferstrategy, etc.
 Dimension getSize()
          Returns graphics engine dimension.
 Image getWindowIcon()
          Returns graphics engine window icon image or null if setting window icon image is not supported.
 String getWindowTitle()
          Returns graphics engine window title or String "" if setting window title is not supported.
 void setWindowIcon(Image icon)
          Sets graphics engine window icon image.
 void setWindowTitle(String st)
          Sets graphics engine window title.
 

Method Detail

getBackBuffer

Graphics2D getBackBuffer()
Returns backbuffer where the rendering perform.


flip

boolean flip()
Flips backbuffer to the screen (primary surface). Since most graphics engine backbuffer is VolatileImage type, thus the flipping data could be lost and need to be restored. Therefore, if this method return false, backbuffer need to be rerendered.

For example:

    do {
        Graphics2D g = BaseGraphics.getBackBuffer();
        //.... do graphics operation
    } while (BaseGraphics.flip() == false);
 
See VolatileImage for detail information.

Returns:
true, if the flipping is successfully proceed.
See Also:
getBackBuffer()

cleanup

void cleanup()
Releases any system graphics resources and do finalization.


getSize

Dimension getSize()
Returns graphics engine dimension.


getComponent

Component getComponent()
Returns the component where the rendering perform.


getGraphicsDescription

String getGraphicsDescription()
Returns graphics engine description, for example: fullscreen, windowed, applet, fullscreen with bufferstrategy, etc.


setWindowTitle

void setWindowTitle(String st)
Sets graphics engine window title.

Note: Not all graphics engine support for setting window title, for example applet graphics engine.


getWindowTitle

String getWindowTitle()
Returns graphics engine window title or String "" if setting window title is not supported.


setWindowIcon

void setWindowIcon(Image icon)
Sets graphics engine window icon image.

Note: Not all graphics engine support for setting window icon, for example applet graphics engine.

See Also:
ImageUtil.getImage(java.net.URL)

getWindowIcon

Image getWindowIcon()
Returns graphics engine window icon image or null if setting window icon image is not supported.


GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id