Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
TexturePage Class Reference

#include <TexturePage.h>

Public Types

enum  { FREE = 0 , USED = 1 }
 
enum  {
  READY = 0x00000001 , PAGE_ERROR = 0x00000002 , CANT_ALLOCATE_PACKED_IMAGE = 0x00000004 , CANT_ADD_IMAGE_DATA = 0x00000008 ,
  NO_TEXTURE_DATA = 0x00000010 , ERROR_DURING_SAVE = 0x00000020
}
 

Public Member Functions

 TexturePage (Int width, Int height)
 
 ~TexturePage (void)
 
Bool addImage (ImageInfo *image)
 try to add image to this page
 
void setID (Int id)
 set page id
 
Int getID (void)
 get page id
 
Bool generateTexture (void)
 generate the final packed texture
 
Bool writeFile (char *baseFilename)
 write generated texture to file
 
ImageInfogetFirstImage (void)
 get the first image in the list
 
Int getWidth (void)
 get width of texture page
 
Int getHeight (void)
 get height of texture page
 
void getPixel (Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a=NULL)
 

Public Attributes

TexturePagem_next
 
TexturePagem_prev
 
UnsignedInt m_status
 status bits
 

Protected Member Functions

Bool spotUsed (Int x, Int y)
 is this spot used
 
Bool lineUsed (Int sx, Int sy, Int ex, Int ey)
 is any spot on the line used
 
UnsignedInt buildFitRegion (IRegion2D *region, Int startX, Int startY, Int imageWidth, Int imageHeight, Int *xGutter, Int *yGutter, Bool allSidesBorder)
 build a region to try to fit given the position, size, and border options
 
void markRegionUsed (IRegion2D *region)
 mark this region as used
 
Bool addImageData (Byte *destBuffer, Int destWidth, Int destHeight, Int destBPP, ImageInfo *image)
 add the actual image data of 'image' to the destination buffer
 
void extendImageEdges (Byte *destBuffer, Int destWidth, Int destHeight, Int destBPP, ImageInfo *image, Bool extendAlpha)
 extend edges of image outward into border if present
 
void extendToRowIfOpen (char *src, Int buffWidth, Int buffBPP, Bool extendAlpha, Int imageHeight, UnsignedInt fitBits, Int srcX, Int srcY)
 if the pixel at abolve/below row is open, extend pixel at src to its location
 

Protected Attributes

Int m_id
 texture page ID
 
ICoord2D m_size
 dimensions of texture page
 
UnsignedBytem_canvas
 as big as the texture page, a used spot is non zero
 
ImageInfom_imageList
 list of images packed on this page
 
Bytem_packedImage
 final generated image data
 
Targam_targa
 final packed image all in a nice little targa file
 

Detailed Description

A texture page continaing multiple source images

Definition at line 65 of file TexturePage.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
FREE 

open pixel in the cavas

USED 

used pixel in the canvas

Definition at line 70 of file TexturePage.h.

◆ anonymous enum

anonymous enum
Enumerator
READY 

texture page here and OK

PAGE_ERROR 

error on page somewhere

CANT_ALLOCATE_PACKED_IMAGE 

couldn't generate final image

CANT_ADD_IMAGE_DATA 

couldn't add image data to page

NO_TEXTURE_DATA 

there was no image data to write

ERROR_DURING_SAVE 

couldn't save final file

Definition at line 76 of file TexturePage.h.

Constructor & Destructor Documentation

◆ TexturePage()

TexturePage::TexturePage ( Int width,
Int height )

Definition at line 851 of file TexturePage.cpp.

◆ ~TexturePage()

TexturePage::~TexturePage ( void )

Definition at line 874 of file TexturePage.cpp.

Member Function Documentation

◆ addImage()

Bool TexturePage::addImage ( ImageInfo * image)

try to add image to this page

If this image will fit on this page, add it

Definition at line 894 of file TexturePage.cpp.

◆ addImageData()

Bool TexturePage::addImageData ( Byte * destBuffer,
Int destWidth,
Int destHeight,
Int destBPP,
ImageInfo * image )
protected

add the actual image data of 'image' to the destination buffer

Add the actual image data from 'image' to the destination buffer at the coordinates specified in the 'image' ... this puts the actual packed image data on the final texture page

NOTE that we have created our texture page regions with the assumption that we were packing images with an upper left corner at (0,0), but the targa files have the origin in the lower left corner ... thus the translation here to shift source images into the right positions

Definition at line 509 of file TexturePage.cpp.

◆ buildFitRegion()

UnsignedInt TexturePage::buildFitRegion ( IRegion2D * region,
Int startX,
Int startY,
Int imageWidth,
Int imageHeight,
Int * xGutter,
Int * yGutter,
Bool allSidesBorder )
protected

build a region to try to fit given the position, size, and border options

Build an image region to try to fit into the page based on the location given, with the image size, the gutter sizes, and the all sides border size

Note that x and y Gutter sizes can be changed as a result of this method

Returns a set of "fit bits" that describe what the components have been included in the region constructed

Definition at line 756 of file TexturePage.cpp.

◆ extendImageEdges()

void TexturePage::extendImageEdges ( Byte * destBuffer,
Int destWidth,
Int destHeight,
Int destBPP,
ImageInfo * image,
Bool extendAlpha )
protected

extend edges of image outward into border if present

We want to extend the image data in destBuffer at the location region of image->m_pagePos in "outward" directions, effectively bleeding the edges outward.

Note we will not extend outward from the image region UNLESS we have a border present on that side (described in the image->m_fitBits for the region image->m_pagePos).

Definition at line 223 of file TexturePage.cpp.

◆ extendToRowIfOpen()

void TexturePage::extendToRowIfOpen ( char * src,
Int buffWidth,
Int buffBPP,
Bool extendAlpha,
Int imageHeight,
UnsignedInt fitBits,
Int srcX,
Int srcY )
protected

if the pixel at abolve/below row is open, extend pixel at src to its location

If the pixel at location 'row' is "open", then extend the pixel at 'src' to that location

NOTE this assumes 'src' and 'row' are pointers into the same buffer and the bits per pixel (buffBPP) are treated as the same for both

Definition at line 72 of file TexturePage.cpp.

◆ generateTexture()

Bool TexturePage::generateTexture ( void )

generate the final packed texture

Generate the final packed texture given all the images that have already been assigned to this page

Definition at line 1176 of file TexturePage.cpp.

◆ getFirstImage()

ImageInfo * TexturePage::getFirstImage ( void )
inline

get the first image in the list

Definition at line 165 of file TexturePage.h.

◆ getHeight()

Int TexturePage::getHeight ( void )
inline

get height of texture page

Definition at line 167 of file TexturePage.h.

◆ getID()

Int TexturePage::getID ( void )
inline

get page id

Definition at line 164 of file TexturePage.h.

◆ getPixel()

void TexturePage::getPixel ( Int x,
Int y,
Byte * r,
Byte * g,
Byte * b,
Byte * a = NULL )

Get the RGB pixel stored at location (x,y) (where (0,0) is the upper left corner of the image ... even though the internal targa isn't stored that way

Definition at line 1313 of file TexturePage.cpp.

◆ getWidth()

Int TexturePage::getWidth ( void )
inline

get width of texture page

Definition at line 166 of file TexturePage.h.

◆ lineUsed()

Bool TexturePage::lineUsed ( Int sx,
Int sy,
Int ex,
Int ey )
protected

is any spot on the line used

Is there ANY spot in the line specified that is used

Definition at line 698 of file TexturePage.cpp.

◆ markRegionUsed()

void TexturePage::markRegionUsed ( IRegion2D * region)
protected

mark this region as used

Mark this region as used

Definition at line 723 of file TexturePage.cpp.

◆ setID()

void TexturePage::setID ( Int id)
inline

set page id

Definition at line 163 of file TexturePage.h.

◆ spotUsed()

Bool TexturePage::spotUsed ( Int x,
Int y )
protected

is this spot used

Is this spot in the texture page open?

Definition at line 688 of file TexturePage.cpp.

◆ writeFile()

Bool TexturePage::writeFile ( char * baseFilename)

write generated texture to file

Write the texture data that has already been generated to a file starting with the baseName passed in with the texture id of this texture page appended to the end of it

Definition at line 1269 of file TexturePage.cpp.

Member Data Documentation

◆ m_canvas

UnsignedByte* TexturePage::m_canvas
protected

as big as the texture page, a used spot is non zero

Definition at line 151 of file TexturePage.h.

◆ m_id

Int TexturePage::m_id
protected

texture page ID

Definition at line 149 of file TexturePage.h.

◆ m_imageList

ImageInfo* TexturePage::m_imageList
protected

list of images packed on this page

Definition at line 153 of file TexturePage.h.

◆ m_next

TexturePage* TexturePage::m_next

Definition at line 105 of file TexturePage.h.

◆ m_packedImage

Byte* TexturePage::m_packedImage
protected

final generated image data

Definition at line 155 of file TexturePage.h.

◆ m_prev

TexturePage* TexturePage::m_prev

Definition at line 106 of file TexturePage.h.

◆ m_size

ICoord2D TexturePage::m_size
protected

dimensions of texture page

Definition at line 150 of file TexturePage.h.

◆ m_status

UnsignedInt TexturePage::m_status

status bits

Definition at line 108 of file TexturePage.h.

◆ m_targa

Targa* TexturePage::m_targa
protected

final packed image all in a nice little targa file

Definition at line 156 of file TexturePage.h.


The documentation for this class was generated from the following files: