mako5.gfx
Class DefaultImage

java.lang.Object
  extended by mako5.gfx.DefaultImage
All Implemented Interfaces:
Image

public class DefaultImage
extends Object
implements Image

An image designed for use with OpenGL. This is specifically for use in a 2D environment in which sprites are needed. These types of images have their image data stored as a reference in video memory like those in C++.

Version:
24-Jun 2006
Author:
Paul Jarrett

Constructor Summary
DefaultImage(int width_, int height_, int texID)
          Makes a new image with the given height, width, and texture id.
 
Method Summary
 void bind()
          Binds the texture for this image.
 void blindRender(float x, float y)
          Renders a quad of the image width and height without binding the texture first.
 void blindRenderAt(float x, float y)
          Renders this image centered at the desired coordinates.
 boolean destroy()
          Attempts to destroy this image.
 int getHeight()
          Returns the height of this image.
 int getWidth()
          Returns the width of this image.
 boolean isDestroyed()
          Returns true if this image has been destroyed and is therefore unusable.
 void render(float x, float y)
          Renders this image so that the bottom left corner is at the desired coordinates, and image data goes up and to the right.
 void renderAt(float x, float y)
          Renders this image centered at the desired coordinates.
 boolean resize(int width_, int height_)
          This does not support resizing of images and simply returns false.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultImage

public DefaultImage(int width_,
                    int height_,
                    int texID)
Makes a new image with the given height, width, and texture id. Asserts that the height and width are not negative.

Since:
24-Jul 2006
Method Detail

destroy

public boolean destroy()
Attempts to destroy this image. This can only be done when then image has video memory data to destroy. If it performs this task, then it will return the value of "true", otherwise returns "false".

Specified by:
destroy in interface Image
Returns:
true if succeeds, false if operation fails
Since:
24-Jul 2006

isDestroyed

public boolean isDestroyed()
Returns true if this image has been destroyed and is therefore unusable.

Specified by:
isDestroyed in interface Image
Returns:
true if this image is destroyed
Since:
24-Jul 2006

getWidth

public int getWidth()
Returns the width of this image.

Specified by:
getWidth in interface Image
Returns:
the width of this image
Since:
24-Jul 2006

getHeight

public int getHeight()
Returns the height of this image.

Specified by:
getHeight in interface Image
Returns:
the height of this image
Since:
24-Jul 2006

resize

public boolean resize(int width_,
                      int height_)
This does not support resizing of images and simply returns false.

Specified by:
resize in interface Image
Parameters:
width_ - the new image width
height_ - the new image height
Returns:
true if the operation is successful.
Since:
24-Jul 2006

bind

public void bind()
Binds the texture for this image. Assumes that 2D textures have been enabled.

Since:
24-Jul 2006

render

public void render(float x,
                   float y)
Renders this image so that the bottom left corner is at the desired coordinates, and image data goes up and to the right. The texture data is bound during this operation, which can result in performance hits if the same image is used for many rendering calls consecutively. In order to regain performance, bind() may be called, followed by multiple blindRender() calls.

Specified by:
render in interface Image
Parameters:
x - the target x-coordinate to render to
y - the target y-coordinate to render to
Since:
04-Mar 2006

renderAt

public void renderAt(float x,
                     float y)
Renders this image centered at the desired coordinates. This can be useful when you would rather store an object's location, and have the image be shown at its location and not have to make the correction yourself.

Specified by:
renderAt in interface Image
Parameters:
x - the target x-coordinate to render to
y - the target y-coordinate to render to
Since:
04-Mar 2006

blindRender

public void blindRender(float x,
                        float y)
Renders a quad of the image width and height without binding the texture first. This is done so that the bottom left corner is at the desired coordinates, and image data goes up and to the right. This can increase performance when the same texture is used multiple times, thereby removing the time needed for the bind call.

Parameters:
x - the target x-coordinate to render to
y - the target y-coordinate to render to
Since:
04-Mar 2006

blindRenderAt

public void blindRenderAt(float x,
                          float y)
Renders this image centered at the desired coordinates. This can be useful when you would rather store an object's location, and have the image be shown at its location and not have to make the correction yourself.

Parameters:
x - the target x-coordinate to render to
y - the target y-coordinate to render to
Since:
04-Mar 2006