JubeatPlus 3.9.11
Loading...
Searching...
No Matches
Texture2D Class Reference

A texture that can draw any of the sprites packed into it. More...

#include <Texture2D.h>

Inheritance diagram for Texture2D:
Collaboration diagram for Texture2D:

Instance Methods

(instancetype) - init
 Initialises an empty texture with no GL name and a null clip rectangle.
(void) - setData:pixelFormat:pixelSize:width:height:
 Uploads pixel data into the texture, (re)creating its GL name.
(void) - setData:pixelFormat:pixelSize:
 Uploads a square image, using pixelSize as both the texture size and the content size.
(instancetype) - initWithData:pixelFormat:pixelSize:width:height:
 Initialises a texture and uploads pixel data into it.
(instancetype) - initWithData:pixelFormat:pixelSize:
 Initialises a square texture, using pixelSize as both the texture and content size.
(instancetype) - initWithImage:
 Initialises a texture from a UIImage , rasterising it into a power-of-two buffer.
(void) - setSubImage:inRect:
 Replaces a sub-rectangle of the texture with an image's pixels.
(void) - setSubImage:atPoint:
 Replaces a sub-region of the texture with an image drawn at its own size.
(void) - drawAtPoint:scale:
 Appends a quad drawing the whole texture at point , scaled by scale .
(void) - drawInRect:fromRegion:transform:color:
 Appends a quad drawing a texture region into a rectangle, tinted by a colour.
(void) - drawInRect:fromRegion:transform:alpha:
 Appends a quad drawing a texture region into a rectangle at a given alpha.
(void) - drawSprite:atPoint:scale:rotate:anchor:transform:alpha:
 Appends a quad for one packed sprite, with a scale, a rotation about an anchor, and an alpha.
(void) - drawSprite:atPoint:transform:alpha:
 Appends a quad for one packed sprite at a point, at its own size.
(void) - drawSprite:inRect:transform:alpha:
 Appends a quad for one packed sprite stretched into a rectangle.
(void) - drawSprite:atPoint:
 Appends a quad for one packed sprite at a point, at its own size, opaque and unrotated.
(void) - drawSprite:inRect:color:
 Appends a quad for one packed sprite stretched into a rectangle, tinted by a colour.
(void) - drawSprite:inRect:
 Appends a quad for one packed sprite stretched into a rectangle, opaque and unrotated.
(void) - commitDraw
 Flushes every batched quad in one glDrawElements , honouring the clip rectangle.
(void) - resetDrawBuffer
 Discards every batched quad without drawing.
(void) - setSprites:
 Replaces the sprite table from an array of four-element rectangle descriptions.
(CGRect) - spriteAtIndex:
 Returns the rectangle of one packed sprite, halved when isScale2x is set.
(void) - setClipRect:
 Sets the scissor clip rectangle, flipping it into GL's bottom-left coordinate space.

Class Methods

(CGRect) + scaledRect:scale:anchor:
 Scales a rectangle about an anchor point.

Properties

BOOL isScale2x
 Whether packed sprites are treated as 2x-supersampled and drawn at half size.
GLuint name
 The GL texture name, or 0 when no data has been uploaded.
NSUInteger width
 The content width in texels.
NSUInteger height
 The content height in texels.

Detailed Description

A texture that can draw any of the sprites packed into it.

Method Documentation

◆ commitDraw

- (void) commitDraw

Flushes every batched quad in one glDrawElements , honouring the clip rectangle.

Points the fixed-function vertex, texture-coordinate, and colour pointers at the interleaved scratch buffer, binds the texture, enables a scissor from _clipRect unless it is null, draws currentPolys * 6 indices as triangles, then resets the batch.

Ghidra address:
0xefc0
Ghidra address:
0xefc0

◆ drawAtPoint:scale:

- (void) drawAtPoint: (CGPoint) point
scale: (double) scale 

Appends a quad drawing the whole texture at point , scaled by scale .

The quad spans _size * scale texels from point . Only the positions and texture coordinates are written; the vertex colours are left as whatever the slot last held.

Parameters
pointThe top-left corner to draw at.
scaleThe uniform scale factor.
Ghidra address:
0xe5e4
Ghidra address:
0xe5e4

◆ drawInRect:fromRegion:transform:alpha:

- (void) drawInRect: (CGRect) rect
fromRegion: (CGRect) region
transform: (char) transform
alpha: (float) alpha 

Appends a quad drawing a texture region into a rectangle at a given alpha.

Parameters
rectThe destination rectangle.
regionThe source region in texels.
transformThe texture-coordinate orientation, 0..5.
alphaThe opacity, clamped to 0..1.
Ghidra address:
0xe944
Ghidra address:
0xe944

◆ drawInRect:fromRegion:transform:color:

- (void) drawInRect: (CGRect) rect
fromRegion: (CGRect) region
transform: (char) transform
color: (nullable UIColor *) color 

Appends a quad drawing a texture region into a rectangle, tinted by a colour.

Parameters
rectThe destination rectangle.
regionThe source region in texels.
transformThe texture-coordinate orientation, 0..5.
colorThe tint colour; its RGBA is multiplied into the vertices.
Ghidra address:
0xe694

◆ drawSprite:atPoint:

- (void) drawSprite: (NSUInteger) sprite
atPoint: (CGPoint) point 

Appends a quad for one packed sprite at a point, at its own size, opaque and unrotated.

Parameters
spriteThe sprite index.
pointWhere to draw it.
Ghidra address:
0xeea4
Ghidra address:
0xeea4

◆ drawSprite:atPoint:scale:rotate:anchor:transform:alpha:

- (void) drawSprite: (NSUInteger) sprite
atPoint: (CGPoint) point
scale: (float) scale
rotate: (float) rotate
anchor: (CGPoint) anchor
transform: (char) transform
alpha: (float) alpha 

Appends a quad for one packed sprite, with a scale, a rotation about an anchor, and an alpha.

The scale, rotation, and alpha are float ; transform is a char . The four corner positions are produced by a translate/scale/rotate/translate affine transform about anchor .

Parameters
spriteThe sprite index.
pointWhere to draw it.
scaleThe draw scale.
rotateThe rotation in radians.
anchorThe point to rotate about.
transformThe texture-coordinate orientation, 0..5.
alphaThe opacity.
Ghidra address:
0xeb28
Ghidra address:
0xeb28

◆ drawSprite:atPoint:transform:alpha:

- (void) drawSprite: (NSUInteger) sprite
atPoint: (CGPoint) point
transform: (char) transform
alpha: (float) alpha 

Appends a quad for one packed sprite at a point, at its own size.

A transposing transform (mode 1 or 3, a 90-degree rotation) swaps the sprite's width and height to produce the draw size; any other value uses them as they are.

Parameters
spriteThe sprite index.
pointWhere to draw it.
transformThe texture-coordinate orientation, 0..5.
alphaThe opacity.
Ghidra address:
0xedb8
Ghidra address:
0xedb8

◆ drawSprite:inRect:

- (void) drawSprite: (NSUInteger) sprite
inRect: (CGRect) rect 

Appends a quad for one packed sprite stretched into a rectangle, opaque and unrotated.

Parameters
spriteThe sprite index.
rectWhere to draw it.
Ghidra address:
0xef64
Ghidra address:
0xef64

◆ drawSprite:inRect:color:

- (void) drawSprite: (NSUInteger) sprite
inRect: (CGRect) rect
color: (nullable UIColor *) color 

Appends a quad for one packed sprite stretched into a rectangle, tinted by a colour.

Parameters
spriteThe sprite index.
rectWhere to draw it.
colorThe tint colour.
Ghidra address:
0xef24

◆ drawSprite:inRect:transform:alpha:

- (void) drawSprite: (NSUInteger) sprite
inRect: (CGRect) rect
transform: (char) transform
alpha: (float) alpha 

Appends a quad for one packed sprite stretched into a rectangle.

Parameters
spriteThe sprite index.
rectWhere to draw it.
transformThe texture-coordinate orientation, 0..5.
alphaThe opacity.
Ghidra address:
0xee48
Ghidra address:
0xee48

◆ init

- (instancetype) init

Initialises an empty texture with no GL name and a null clip rectangle.

Returns
The initialised texture.
Ghidra address:
0xdc70
Ghidra address:
0xdc70

◆ initWithData:pixelFormat:pixelSize:

- (instancetype) initWithData: (nullable const void *) data
pixelFormat: (Texture2DPixelFormat) pixelFormat
pixelSize: (GLuint) pixelSize 

Initialises a square texture, using pixelSize as both the texture and content size.

Parameters
dataThe pixel bytes.
pixelFormatThe storage format.
pixelSizeThe square texture dimension in texels.
Returns
The initialised texture.
Ghidra address:
0xdf58

◆ initWithData:pixelFormat:pixelSize:width:height:

- (instancetype) initWithData: (nullable const void *) data
pixelFormat: (Texture2DPixelFormat) pixelFormat
pixelSize: (GLuint) pixelSize
width: (int) width
height: (int) height 

Initialises a texture and uploads pixel data into it.

Parameters
dataThe pixel bytes.
pixelFormatThe storage format.
pixelSizeThe square texture dimension in texels.
widthThe content width.
heightThe content height.
Returns
The initialised texture.
Ghidra address:
0xde9c

◆ initWithImage:

- (instancetype) initWithImage: (nullable UIImage *) image

Initialises a texture from a UIImage , rasterising it into a power-of-two buffer.

Picks a storage format from the image's alpha info and colour space, rounds the larger image dimension up to a power of two, and halves that (and the content dimensions) while it exceeds GL_MAX_TEXTURE_SIZE . The image is drawn bottom-aligned into a fresh bitmap context, which is then uploaded via -initWithData:pixelFormat:pixelSize:width:height: .

Parameters
imageThe source image.
Returns
The initialised texture, or nil if image is nil or rounds to a zero size.
Ghidra address:
0xdf6c

◆ resetDrawBuffer

- (void) resetDrawBuffer

Discards every batched quad without drawing.

Ghidra address:
0xf0cc

◆ scaledRect:scale:anchor:

+ (CGRect) scaledRect: (CGRect) rect
scale: (double) scale
anchor: (CGPoint) anchor 

Scales a rectangle about an anchor point.

The origin moves towards anchor as scale shrinks, and the size scales directly: origin = anchor + (rect.origin - anchor) * scale , size = rect.size * scale .

Parameters
rectThe rectangle to scale.
scaleThe scale factor.
anchorThe fixed point the scaling is centred on.
Returns
The scaled rectangle.
Ghidra address:
0xdc4c
Ghidra address:
0xdc4c

◆ setClipRect:

- (void) setClipRect: (CGRect) rect

Sets the scissor clip rectangle, flipping it into GL's bottom-left coordinate space.

The vertical flip uses the current device idiom's screen height (480 on a phone, 1024 on a pad).

Parameters
rectThe clip rectangle in top-left UIKit coordinates.
Ghidra address:
0xf40c
Ghidra address:
0xf40c

◆ setData:pixelFormat:pixelSize:

- (void) setData: (nullable const void *) data
pixelFormat: (Texture2DPixelFormat) pixelFormat
pixelSize: (GLuint) pixelSize 

Uploads a square image, using pixelSize as both the texture size and the content size.

Parameters
dataThe pixel bytes.
pixelFormatThe storage format.
pixelSizeThe square texture dimension in texels.
Ghidra address:
0xde88

◆ setData:pixelFormat:pixelSize:width:height:

- (void) setData: (nullable const void *) data
pixelFormat: (Texture2DPixelFormat) pixelFormat
pixelSize: (GLuint) pixelSize
width: (int) width
height: (int) height 

Uploads pixel data into the texture, (re)creating its GL name.

Deletes any existing GL texture, generates a fresh one, sets linear filtering and repeat wrapping, then uploads a pixelSize by pixelSize image in pixelFormat . The content dimensions width and height are recorded separately from the (square) texture size.

Parameters
dataThe pixel bytes.
pixelFormatThe storage format.
pixelSizeThe square texture dimension in texels.
widthThe content width.
heightThe content height.
Ghidra address:
0xdcd4

◆ setSprites:

- (void) setSprites: (nullable NSArray< NSArray< NSNumber * > * > *) sprites

Replaces the sprite table from an array of four-element rectangle descriptions.

Each element of sprites is itself an array of four NSNumber values giving the sprite's x , y , width , and height in texels.

Parameters
spritesThe sprite rectangles, as arrays of four numbers each.
Ghidra address:
0xf0dc

◆ setSubImage:atPoint:

- (void) setSubImage: (nullable UIImage *) image
atPoint: (CGPoint) point 

Replaces a sub-region of the texture with an image drawn at its own size.

Parameters
imageThe source image.
pointThe destination origin in texels.
Ghidra address:
0xe52c

◆ setSubImage:inRect:

- (void) setSubImage: (nullable UIImage *) image
inRect: (CGRect) rect 

Replaces a sub-rectangle of the texture with an image's pixels.

Rasterises image into a bitmap context matching the texture's pixel format, then uploads it with glTexSubImage2D at rect .

Parameters
imageThe source image.
rectThe destination rectangle in texels.
Ghidra address:
0xe2dc

◆ spriteAtIndex:

- (CGRect) spriteAtIndex: (unsigned int) index

Returns the rectangle of one packed sprite, halved when isScale2x is set.

Parameters
indexThe sprite index.
Returns
The sprite rectangle, or CGRectZero if index is out of range.
Ghidra address:
0xf3a0
Ghidra address:
0xf3a0

Property Documentation

◆ height

- (NSUInteger) height
readnonatomicassign

The content height in texels.

Ghidra address:
0xf57c

◆ isScale2x

- (BOOL) isScale2x
readwritenonatomicassign

Whether packed sprites are treated as 2x-supersampled and drawn at half size.

Ghidra address:
0xf53c (getter), 0xf54c (setter)

◆ name

- (GLuint) name
readnonatomicassign

The GL texture name, or 0 when no data has been uploaded.

Ghidra address:
0xf55c

◆ width

- (NSUInteger) width
readnonatomicassign

The content width in texels.

Ghidra address:
0xf56c

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