#include <qafBigTexture.h>
Following a "slower and working is better than faster and broken" philosopy, BigTexture
will juggle textures and sub-textures for you, ensuring your large tile libraries will look the same no matter what the video card's texture dimension constraints are.
BigTexture
is an extension for Haaf's Game Engine, using Direct3DX as its image loader.
When you create a BigTexture
object, the constructor will automatically divide the source image into smaller images until all of them fit within the video card's texture dimension constraints. This is transparent to the user; you just tell BT to render a rectangular area from the source image.
Public Member Functions | |
BigTexture (const char *sourceImage) | |
Loads the image, breaking it into sub-textures as needed. | |
int | getImageWidth () const |
| |
int | getImageHeight () const |
| |
void | renderRectangle (int x0, int y0, int tx=0, int ty=0, int width=0, int height=0, unsigned long color=0xFFFFFFFF, unsigned long blend=2, bool flipX=false, bool flipY=false) const |
Draws an axis-aligned rectangular area from this image. | |
void | renderTriple (const hgeTriple *triple) const |
Use this to render a triangular section of the big texture. | |
void | renderQuad (const hgeQuad *quad) const |
Use this to render a freeform rectangular area of the texture. | |
virtual | ~BigTexture () |
Deletes the sub-textures. | |
Classes | |
struct | SubTexture |
qaf::BigTexture::BigTexture | ( | const char * | sourceImage | ) |
Loads the image, breaking it into sub-textures as needed.
If any errors are encountered, they will be reported in the HGE log file.
This process is very slow; you should manage your BTs so as to minimize the creation/destruction of these objects.
void qaf::BigTexture::renderRectangle | ( | int | x0, | |
int | y0, | |||
int | tx = 0 , |
|||
int | ty = 0 , |
|||
int | width = 0 , |
|||
int | height = 0 , |
|||
unsigned long | color = 0xFFFFFFFF , |
|||
unsigned long | blend = 2 , |
|||
bool | flipX = false , |
|||
bool | flipY = false | |||
) | const |
Draws an axis-aligned rectangular area from this image.
Make sure you invoke this method between a pair of Gfx_BeginScene()
/Gfx_EndScene()
calls.
x0 | Screen coordinates of the rectangle's top-left corner | |
y0 | Screen coordinates of the rectangle's top-left corner | |
tx | Coordinates of the rectangle's top-left corner in the image space. | |
ty | Coordinates of the rectangle's top-left corner in the image space | |
width | Width of the rectangular area to be drawn. If zero or negative, the image's width is used. | |
height | Height of the rectangular area to be drawn. If zero or negative, the image's height is used. | |
color | Has the same effect as the color field in hgeVertex . Default is full-alpha white. | |
blend | Has the same effect as the blend field in hgeQuad . | |
flipX | If true, the rectangle will be flipped along the X axis. | |
flipY | If true, the rectangle will be flipped along the Y axis. |
void qaf::BigTexture::renderTriple | ( | const hgeTriple * | triple | ) | const |
Use this to render a triangular section of the big texture.
All the hgeTriple fields have their usual meanings; this method works exactly like HGE::Gfx_RenderTriple()
, with the following exceptions:
tex
field is ignored, and the Bigtexture
is used instead.This method is much slower than its "core" HGE equivalent; use it sparingly.
You are advised to disable HGE_TEXTUREFILTER
before invoking this method.
void qaf::BigTexture::renderQuad | ( | const hgeQuad * | quad | ) | const |
Use this to render a freeform rectangular area of the texture.
See renderTriple()
for more information.