Cavestory Mod API
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
VideoTexture Class Reference

An editable texture API. More...

#include <VideoTexture.h>

Public Member Functions

 VideoTexture ()
 Default constructor.
 
 ~VideoTexture ()
 Default deconstructor.
 
void SetTextureSize (int iWidth, int iHeight)
 Resize this video texture. More...
 
void RecreateTexture ()
 Recreate this texture. More...
 
void SetClipRect (GUI_RECT *pRect, bool bAbsoluteRect=false)
 Set the clip rect for this texture. More...
 
void ClearClipRects ()
 Clear the clip rect list.
 
GUI_RECT GetClipRect ()
 Get the current clip rect. More...
 
GUI_RECT GetNonScaledClipRect ()
 Get the current clip rect (not scaled to local magnification level). More...
 
void SetDrawColor (unsigned char iRed, unsigned char iGreen, unsigned char iBlue, unsigned char iAlpha)
 Set the drawing color. More...
 
void SetDrawColor (unsigned long iColor)
 Set the drawing color. More...
 
void Lock ()
 Lock this texture for editing.
 
void Unlock ()
 Unlock this texture.
 
void ClearTexture (GUI_RECT *pRect=NULL)
 Clear this texture. More...
 
void ClearPixels (GUI_POINT *pPointList, unsigned int iPointCount)
 Clear multiple pixels. More...
 
void DrawPixel (GUI_POINT pPoint, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw a pixel. More...
 
void DrawPixels (GUI_POINT *pPointList, unsigned int iPointCount, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw multiple pixels. More...
 
void DrawMagnifiedPixels (GUI_POINT *pPointList, unsigned int iPointCount, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw multiple pre-magnified pixels. More...
 
void DrawStretchedBitmap (GUI_RECT *pRect, GUI_RECT *pSourceRect, Surface_Ids iSurfaceId, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bAbsloutePos=false)
 Draw a stretched bitmap. More...
 
void DrawColoredBitmap (GUI_POINT pPoint, GUI_RECT *pSourceRect, Surface_Ids iSurfaceId, unsigned long iColor, bool bAbsolutePos=false)
 Draw a colored bitmap. More...
 
void DrawBitmap (GUI_POINT pPoint, GUI_RECT *pSourceRect, Surface_Ids iSurfaceId, bool bAbsolutePos=false)
 Draw a bitmap. More...
 
void DrawBitmapBox (GUI_RECT *out_rect, GUI_RECT *bmp_rects, CacheSurface::BitmapBoxType type, Surface_Ids bmp_id, int iAlpha=255)
 Draw a bitmap box. More...
 
void DrawStripedRect (GUI_RECT *pRect, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw a striped rectangle to this texture. More...
 
void DrawRect (GUI_RECT *pRect, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bAbsolutePos=false)
 Draw a rectangle to this texture. More...
 
void DrawFilledRect (GUI_RECT *pRect, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bAbsolutePos=false)
 Draw a filled rectangle to this texture. More...
 
void DrawStripedLine (GUI_POINT pStart, GUI_POINT pEnd, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw a striped line. More...
 
void DrawLine (GUI_POINT pStart, GUI_POINT pEnd, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bAbsolutePos=false)
 Draw a line. More...
 
void DrawMagnifiedLine (GUI_POINT pStart, GUI_POINT pEnd, unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw a pre-magnified line. More...
 
void DrawText (GUI_POINT pPoint, FontObject *pFont, const char *pText, int iTextLen=-1, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bWrap=false, int iShadowSize=0, unsigned long iShadowColor=0)
 Draw text on this texture. More...
 
void DrawMagnifiedText (GUI_POINT pPoint, FontObject *pFont, const char *pText, int iTextLen=-1, unsigned long iColor=INVALID_TEXTURE_COLOR, bool bWrap=false, int iShadowSize=0, unsigned long iShadowColor=0)
 Draw pre-magnified text on this texture. More...
 
void DrawRects (unsigned long iColor=INVALID_TEXTURE_COLOR)
 Draw multiple rectangles to this texture. More...
 
void ClearTempRectList ()
 Reset the temporary rectangle list.
 
void AddTempRect (GUI_RECT pRect)
 Add a temporary rect to the rect list. More...
 
void PutAlpha (int iX, int iY, int iAlpha)
 Draw this texture onto the screen with an alpha value. More...
 
void PutSubPixel (int iX, int iY, int iAlpha)
 Draw this texture onto the screen at a subpixel coordinate. More...
 
void Put (int iX, int iY)
 Draw this texture onto the screen. More...
 
void PutStretchedAlpha (int iDstX, int iDstY, int iDstW, int iDstH, int iSrcX, int iSrcY, int iSrcW, int iSrcH, int iAlpha)
 Draw this texture onto the screen. More...
 
void PutStretchedSubPixel (int iDstX, int iDstY, int iDstW, int iDstH, int iSrcX, int iSrcY, int iSrcW, int iSrcH, int iAlpha)
 Draw this texture onto the screen. More...
 
void PutStretched (int iDstX, int iDstY, int iDstW, int iDstH, int iSrcX, int iSrcY, int iSrcW, int iSrcH)
 Draw this texture onto the screen. More...
 

Static Public Member Functions

static VideoTextureCreateTexture (int iWidth, int iHeight, int iBitsPerPixel=32, ExternalWindow *pWindow=NULL, int iMagnification=-1, bool bNoTexture=false)
 Create a texture. More...
 
static VideoTextureCreateTexture (const char *pFileName, ExternalWindow *pWindow=NULL, int iMagnification=-1)
 Create a texture with an image. More...
 
static bool FreeTexture (VideoTexture *pTexture)
 Free a texture. More...
 
static void ReloadRenderer (int iMagnification)
 Reload the main renderer's texture. More...
 

Public Attributes

VideoTextureprev
 
VideoTexturenext
 
ExternalWindowm_pWindow
 The window object this texture belongs to.
 
GUI_COLOR m_pDrawColor
 The current draw color.
 
SDL_Texture * m_pOldLockTexture
 The old lock texture to restore after unlocking this texture.
 
GUI_RECT m_pOldClipRect
 The old clip rect to restore after unlocking this texture.
 
bool m_bHasOldClip
 Whether the renderer can use the old clip rect.
 
SDL_Texture * m_pTexture
 This texture's ACTUAL texture.
 
SDL_Renderer * m_pRenderer
 This texture's renderer.
 
int m_iWidth
 The width of this texture.
 
int m_iHeight
 The height of this texture.
 
int m_iBitsPerPixel
 Number of bits per pixel.
 
GUI_RECTm_pClipRectList
 A list of clip rects.
 
int m_iClipRectCount
 The number of elements in the clip rect list.
 
int m_iClipRectSize
 The size of the clip rect size.
 
int m_iMagnification
 The local magnification for this texture.
 
bool m_bLocked
 Whether this texture is currently locked or not.
 
SDL_Rectm_pTempArray
 A temporary array containing SDL rects. More...
 
int m_iTempCount
 The number of rects in m_pTempArray.
 
int m_iTempSize
 The size of m_pTempArray.
 

Static Public Attributes

static VideoTexturefirst
 

Protected Member Functions

bool InClipRect (GUI_RECT pRect)
 Check to see if a rect is inside of the clip rect. More...
 

Detailed Description

An editable texture API.

Member Function Documentation

◆ AddTempRect()

void VideoTexture::AddTempRect ( GUI_RECT  pRect)

Add a temporary rect to the rect list.

Parameters
pRectThe rect to add.
Note
This function is used for DrawRects functionality.

◆ ClearPixels()

void VideoTexture::ClearPixels ( GUI_POINT pPointList,
unsigned int  iPointCount 
)

Clear multiple pixels.

Parameters
pPointListA list containing all points that should be drawn.
iPointCountThe number of points stored in pPointList.
iColorThe color to modulate the texture by.

◆ ClearTexture()

void VideoTexture::ClearTexture ( GUI_RECT pRect = NULL)

Clear this texture.

Parameters
pRectThe rect to clear. Pass 'NULL' to clear the entire texture.

◆ CreateTexture() [1/2]

static VideoTexture* VideoTexture::CreateTexture ( const char *  pFileName,
ExternalWindow pWindow = NULL,
int  iMagnification = -1 
)
static

Create a texture with an image.

Parameters
pFileNameThe file path to the image.
pWindowThe external window this texture should belong to.
pRendererThe renderer that should create this texture. Leave 'NULL' to use the default renderer.
iMagnificationThe magnification level for this texture. Leave at '-1' to use the current screen magnification level.
Returns
Returns a newly allocated VideoTexture object on success, otherwise returns NULL.

◆ CreateTexture() [2/2]

static VideoTexture* VideoTexture::CreateTexture ( int  iWidth,
int  iHeight,
int  iBitsPerPixel = 32,
ExternalWindow pWindow = NULL,
int  iMagnification = -1,
bool  bNoTexture = false 
)
static

Create a texture.

Parameters
iWidthThe width of the new texture.
iHeightThe height of the new texture.
iBitsPerPixelBits per pixel.
pWindowThe external window this texture should belong to.
pRendererThe renderer that should create this texture. Leave 'NULL' to use the default renderer.
iMagnificationThe magnification level for this texture. Leave at '-1' to use the current screen magnification level.
bNoTextureIf set to 'true', then no texture will be allocated.
Returns
Returns a newly allocated VideoTexture object on success, otherwise returns NULL.

◆ DrawBitmap()

void VideoTexture::DrawBitmap ( GUI_POINT  pPoint,
GUI_RECT pSourceRect,
Surface_Ids  iSurfaceId,
bool  bAbsolutePos = false 
)

Draw a bitmap.

Parameters
pPointThe point to draw the bitmap at.
pSourceRectThe source rect the surface should use. Pass 'NULL' to draw the entire surface.
iSurfaceIdThe source surface id.
bAbsolutePosIf true, then the rect is not magnified.
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.

◆ DrawBitmapBox()

void VideoTexture::DrawBitmapBox ( GUI_RECT out_rect,
GUI_RECT bmp_rects,
CacheSurface::BitmapBoxType  type,
Surface_Ids  bmp_id,
int  iAlpha = 255 
)

Draw a bitmap box.

Parameters
out_rectThe rect in which the box will be drawn. Pass 'NULL' to fill the entire texture.
bmp_rects
typeThe source surface id.
bmp_idThe surface to pull the source textures from.
iAlphaThe alpha transparency value.

◆ DrawColoredBitmap()

void VideoTexture::DrawColoredBitmap ( GUI_POINT  pPoint,
GUI_RECT pSourceRect,
Surface_Ids  iSurfaceId,
unsigned long  iColor,
bool  bAbsolutePos = false 
)

Draw a colored bitmap.

Parameters
pPointThe point to draw the bitmap at.
pSourceRectThe source rect the surface should use. Pass 'NULL' to draw the entire surface.
iSurfaceIdThe source surface id.
iColorThe color to modulate the texture by.
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.

◆ DrawFilledRect()

void VideoTexture::DrawFilledRect ( GUI_RECT pRect,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bAbsolutePos = false 
)

Draw a filled rectangle to this texture.

Parameters
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.
iColorThe color to draw.
bAbsolutePosIf true, then the rect is not magnified.

◆ DrawLine()

void VideoTexture::DrawLine ( GUI_POINT  pStart,
GUI_POINT  pEnd,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bAbsolutePos = false 
)

Draw a line.

Parameters
pStartThe starting point.
pEndThe ending point.
bAbsolutePosIf true, then the rect is not magnified.

◆ DrawMagnifiedLine()

void VideoTexture::DrawMagnifiedLine ( GUI_POINT  pStart,
GUI_POINT  pEnd,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw a pre-magnified line.

Parameters
pStartThe starting point.
pEndThe ending point.

◆ DrawMagnifiedPixels()

void VideoTexture::DrawMagnifiedPixels ( GUI_POINT pPointList,
unsigned int  iPointCount,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw multiple pre-magnified pixels.

Parameters
pPointListA list containing all points that should be drawn.
iPointCountThe number of points stored in pPointList.
iColorThe color to modulate the texture by.

◆ DrawMagnifiedText()

void VideoTexture::DrawMagnifiedText ( GUI_POINT  pPoint,
FontObject *  pFont,
const char *  pText,
int  iTextLen = -1,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bWrap = false,
int  iShadowSize = 0,
unsigned long  iShadowColor = 0 
)

Draw pre-magnified text on this texture.

Parameters
pPointThe point at which to draw the text.
pFontThe font object to use.
pTextThe text to draw.
iTextLenThe length of the text.
iColorThe color of the text. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.
bWrapWrap the text inside of the clip rect.
iShadowSizeThe size of the text shadow.
iShadowColorThe color of the text shadow.

◆ DrawPixel()

void VideoTexture::DrawPixel ( GUI_POINT  pPoint,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw a pixel.

Parameters
pPointThe point to draw the pixel at.
iColorThe color to modulate the texture by.

◆ DrawPixels()

void VideoTexture::DrawPixels ( GUI_POINT pPointList,
unsigned int  iPointCount,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw multiple pixels.

Parameters
pPointListA list containing all points that should be drawn.
iPointCountThe number of points stored in pPointList.
iColorThe color to modulate the texture by.

◆ DrawRect()

void VideoTexture::DrawRect ( GUI_RECT pRect,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bAbsolutePos = false 
)

Draw a rectangle to this texture.

Parameters
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.
iColorThe color of the rect. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.
bAbsolutePosIf true, then the rect is not magnified.

◆ DrawRects()

void VideoTexture::DrawRects ( unsigned long  iColor = INVALID_TEXTURE_COLOR)

Draw multiple rectangles to this texture.

Parameters
iColorThe color of the rect. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.

◆ DrawStretchedBitmap()

void VideoTexture::DrawStretchedBitmap ( GUI_RECT pRect,
GUI_RECT pSourceRect,
Surface_Ids  iSurfaceId,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bAbsloutePos = false 
)

Draw a stretched bitmap.

Parameters
pRectThe point to draw the bitmap inside of. Pass 'NULL' to use the entire destination texture's size.
pSourceRectThe source rect the surface should use. Pass 'NULL' to draw the entire surface.
iSurfaceIdThe source surface id.
iColorThe color to modulate the texture by.
bAbsolutePosIf this is true, then pRect will not be magnified.
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.

◆ DrawStripedLine()

void VideoTexture::DrawStripedLine ( GUI_POINT  pStart,
GUI_POINT  pEnd,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw a striped line.

Parameters
pStartThe starting point.
pEndThe ending point.
iColorThe color of the rect. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.

◆ DrawStripedRect()

void VideoTexture::DrawStripedRect ( GUI_RECT pRect,
unsigned long  iColor = INVALID_TEXTURE_COLOR 
)

Draw a striped rectangle to this texture.

Parameters
pRectThe rect to draw the rect at. Pass 'NULL' to fill the entire texture.
iColorThe color of the rect. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.

◆ DrawText()

void VideoTexture::DrawText ( GUI_POINT  pPoint,
FontObject *  pFont,
const char *  pText,
int  iTextLen = -1,
unsigned long  iColor = INVALID_TEXTURE_COLOR,
bool  bWrap = false,
int  iShadowSize = 0,
unsigned long  iShadowColor = 0 
)

Draw text on this texture.

Parameters
pPointThe point at which to draw the text.
pFontThe font object to use.
pTextThe text to draw.
iTextLenThe length of the text.
iColorThe color of the text. Keep as 'INVALID_TEXTURE_COLOR' to use the currently defined draw color.
bWrapWrap the text inside of the clip rect.
iShadowSizeThe size of the text shadow.
iShadowColorThe color of the text shadow.

◆ FreeTexture()

static bool VideoTexture::FreeTexture ( VideoTexture pTexture)
static

Free a texture.

Parameters
pTextureThe texture to free.
Returns
Returns true on success, false on failure.

◆ GetClipRect()

GUI_RECT VideoTexture::GetClipRect ( )

Get the current clip rect.

Returns
Returns the current clip rect.

◆ GetNonScaledClipRect()

GUI_RECT VideoTexture::GetNonScaledClipRect ( )

Get the current clip rect (not scaled to local magnification level).

Returns
Returns the current clip rect.

◆ InClipRect()

bool VideoTexture::InClipRect ( GUI_RECT  pRect)
inlineprotected

Check to see if a rect is inside of the clip rect.

Parameters
pRectThe rect to check.
Returns
Returns true if the rect is visible, false otherwise.

◆ Put()

void VideoTexture::Put ( int  iX,
int  iY 
)

Draw this texture onto the screen.

Parameters
iXThe X position to draw the texture at.
iYThe Y position to draw the texture at.

◆ PutAlpha()

void VideoTexture::PutAlpha ( int  iX,
int  iY,
int  iAlpha 
)

Draw this texture onto the screen with an alpha value.

Parameters
iXThe X position to draw the texture at.
iYThe Y position to draw the texture at.
iAlphaThe alpha value.

◆ PutStretched()

void VideoTexture::PutStretched ( int  iDstX,
int  iDstY,
int  iDstW,
int  iDstH,
int  iSrcX,
int  iSrcY,
int  iSrcW,
int  iSrcH 
)

Draw this texture onto the screen.

Parameters
iDstXThe X position to draw the texture at.
iDstYThe Y position to draw the texture at.
iDstWThe destined width.
iDstHThe destined height.
iSrcXThe source X position.
iSrcYThe source Y position.
iSrcWThe source width.
iSrcHThe source height.

◆ PutStretchedAlpha()

void VideoTexture::PutStretchedAlpha ( int  iDstX,
int  iDstY,
int  iDstW,
int  iDstH,
int  iSrcX,
int  iSrcY,
int  iSrcW,
int  iSrcH,
int  iAlpha 
)

Draw this texture onto the screen.

Parameters
iDstXThe X position to draw the texture at.
iDstYThe Y position to draw the texture at.
iDstWThe destined width.
iDstHThe destined height.
iSrcXThe source X position.
iSrcYThe source Y position.
iSrcWThe source width.
iSrcHThe source height.
iAlphaThe alpha value.

◆ PutStretchedSubPixel()

void VideoTexture::PutStretchedSubPixel ( int  iDstX,
int  iDstY,
int  iDstW,
int  iDstH,
int  iSrcX,
int  iSrcY,
int  iSrcW,
int  iSrcH,
int  iAlpha 
)

Draw this texture onto the screen.

Parameters
iDstXThe X position to draw the texture at.
iDstYThe Y position to draw the texture at.
iDstWThe destined width.
iDstHThe destined height.
iSrcXThe source X position.
iSrcYThe source Y position.
iSrcWThe source width.
iSrcHThe source height.
iAlphaThe alpha value.

◆ PutSubPixel()

void VideoTexture::PutSubPixel ( int  iX,
int  iY,
int  iAlpha 
)

Draw this texture onto the screen at a subpixel coordinate.

Parameters
iXThe X position to draw the texture at.
iYThe Y position to draw the texture at.
iAlphaThe alpha value.

◆ RecreateTexture()

void VideoTexture::RecreateTexture ( )

Recreate this texture.

@warn This does not destroy the old texture beforehand.

◆ ReloadRenderer()

static void VideoTexture::ReloadRenderer ( int  iMagnification)
static

Reload the main renderer's texture.

Parameters
iMagnificationThe magnification level of the new renderer texture.

◆ SetClipRect()

void VideoTexture::SetClipRect ( GUI_RECT pRect,
bool  bAbsoluteRect = false 
)

Set the clip rect for this texture.

Parameters
pRectThe rect to use. Pass 'NULL' to clear the last cliprect.
bAbsoluteRectIf this is true, then pRect will not be magnified.

◆ SetDrawColor() [1/2]

void VideoTexture::SetDrawColor ( unsigned char  iRed,
unsigned char  iGreen,
unsigned char  iBlue,
unsigned char  iAlpha 
)

Set the drawing color.

Parameters
iRedThe red value.
iGreenThe green value.
iBlueThe blue value.
iAlphaThe alpha value.

◆ SetDrawColor() [2/2]

void VideoTexture::SetDrawColor ( unsigned long  iColor)

Set the drawing color.

Parameters
iColorThe color.

◆ SetTextureSize()

void VideoTexture::SetTextureSize ( int  iWidth,
int  iHeight 
)

Resize this video texture.

Parameters
iWidthThe new width.
iHeightThe new height.

Member Data Documentation

◆ m_pTempArray

SDL_Rect* VideoTexture::m_pTempArray

A temporary array containing SDL rects.

Used for converting GUI_RECTs in functions like DrawRects.


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