|
JubeatPlus 3.9.11
|
A texture that can draw any of the sprites packed into it. More...
#include <Texture2D.h>


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. | |
A texture that can draw any of the sprites packed into it.
| - (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.
| - (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.
| point | The top-left corner to draw at. |
| scale | The uniform scale factor. |
| - (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.
| rect | The destination rectangle. |
| region | The source region in texels. |
| transform | The texture-coordinate orientation, 0..5. |
| alpha | The opacity, clamped to 0..1. |
| - (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.
| rect | The destination rectangle. |
| region | The source region in texels. |
| transform | The texture-coordinate orientation, 0..5. |
| color | The tint colour; its RGBA is multiplied into the vertices. |
| - (void) drawSprite: | (NSUInteger) | sprite | |
| atPoint: | (CGPoint) | point |
Appends a quad for one packed sprite at a point, at its own size, opaque and unrotated.
| sprite | The sprite index. |
| point | Where to draw it. |
| - (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 .
| sprite | The sprite index. |
| point | Where to draw it. |
| scale | The draw scale. |
| rotate | The rotation in radians. |
| anchor | The point to rotate about. |
| transform | The texture-coordinate orientation, 0..5. |
| alpha | The opacity. |
| - (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.
| sprite | The sprite index. |
| point | Where to draw it. |
| transform | The texture-coordinate orientation, 0..5. |
| alpha | The opacity. |
| - (void) drawSprite: | (NSUInteger) | sprite | |
| inRect: | (CGRect) | rect |
Appends a quad for one packed sprite stretched into a rectangle, opaque and unrotated.
| sprite | The sprite index. |
| rect | Where to draw it. |
| - (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.
| sprite | The sprite index. |
| rect | Where to draw it. |
| color | The tint colour. |
| - (void) drawSprite: | (NSUInteger) | sprite | |
| inRect: | (CGRect) | rect | |
| transform: | (char) | transform | |
| alpha: | (float) | alpha |
Appends a quad for one packed sprite stretched into a rectangle.
| sprite | The sprite index. |
| rect | Where to draw it. |
| transform | The texture-coordinate orientation, 0..5. |
| alpha | The opacity. |
| - (instancetype) init |
Initialises an empty texture with no GL name and a null clip rectangle.
| - (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.
| data | The pixel bytes. |
| pixelFormat | The storage format. |
| pixelSize | The square texture dimension in texels. |
| - (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.
| data | The pixel bytes. |
| pixelFormat | The storage format. |
| pixelSize | The square texture dimension in texels. |
| width | The content width. |
| height | The content height. |
| - (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: .
| image | The source image. |
nil if image is nil or rounds to a zero size. | - (void) resetDrawBuffer |
Discards every batched quad without drawing.
| + (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 .
| rect | The rectangle to scale. |
| scale | The scale factor. |
| anchor | The fixed point the scaling is centred on. |
| - (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).
| rect | The clip rectangle in top-left UIKit coordinates. |
| - (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.
| data | The pixel bytes. |
| pixelFormat | The storage format. |
| pixelSize | The square texture dimension in texels. |
| - (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.
| data | The pixel bytes. |
| pixelFormat | The storage format. |
| pixelSize | The square texture dimension in texels. |
| width | The content width. |
| height | The content height. |
| - (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.
| sprites | The sprite rectangles, as arrays of four numbers each. |
| - (void) setSubImage: | (nullable UIImage *) | image | |
| atPoint: | (CGPoint) | point |
Replaces a sub-region of the texture with an image drawn at its own size.
| image | The source image. |
| point | The destination origin in texels. |
| - (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 .
| image | The source image. |
| rect | The destination rectangle in texels. |
| - (CGRect) spriteAtIndex: | (unsigned int) | index |
Returns the rectangle of one packed sprite, halved when isScale2x is set.
| index | The sprite index. |
CGRectZero if index is out of range.
|
readnonatomicassign |
The content height in texels.
|
readwritenonatomicassign |
Whether packed sprites are treated as 2x-supersampled and drawn at half size.
|
readnonatomicassign |
The GL texture name, or 0 when no data has been uploaded.
|
readnonatomicassign |
The content width in texels.