Class SDL_Surface
- java.lang.Object
-
- com.sun.jna.PointerType
-
- io.github.libsdl4j.api.surface.SDL_Surface
-
- All Implemented Interfaces:
com.sun.jna.NativeMapped
public final class SDL_Surface extends com.sun.jna.PointerType
SDL_Surface
is a structure holding a collection of pixels used in software rendering (also called blitting).The pixel data are stored in the regular RAM as opposed to SDL_Texture, which can store data in GPU memory. Thus, in most cases you can access data buffer associated with surface directly, modifying its content, i.e. it is using CPU, hence the software rendering.
SDL_Texture
on the other hand, is used in a hardware rendering, textures are stored in GPU memory and you don't have access to it directly, unlike inSDL_Surface
. The rendering operations are accelerated by GPU, using, internally, either OpenGL or DirectX (available only on Windows) API, which in turn are using the video hardware, hence the hardware rendering.SDL_Surface
is the original image data structure from SDL 1.x.SDL_Texture
was added in SDL 2.x for hardware optimized rendering.You can convert
SDL_Surface
toSDL_Texture
usingSDL_CreateTextureFromSurface(...)
, after which you can release theSDL_Surface
memory bySDL_FreeSurface(...)
Note:This structure should be treated as read-only, except for
pixels
, which, if not null, contains the raw pixel data for the surface.Implementation note:
SDL_Surface
would normally be implemented as a JNAStructure
but the SDL internals keep references to all allocatedSDL_Surface
s and change their internal fields without notice. Thus it is implemented as an opaque Pointer and there is a co-locatedSDL_Surface_internal
which allows a read-only access to the fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SDL_Surface.Ref
-
Constructor Summary
Constructors Constructor Description SDL_Surface()
SDL_Surface(com.sun.jna.Pointer p)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SDL_Rect
getClipRect()
Get the clipping informationint
getFlags()
SDL_PixelFormat
getFormat()
int
getH()
int
getLocked()
int
getPitch()
com.sun.jna.Pointer
getPixels()
int
getRefcount()
Get the reference count -- used when freeing surfacecom.sun.jna.Pointer
getUserdata()
Read the application data associated with the surfaceint
getW()
void
setUserdata(com.sun.jna.Pointer newValue)
Set the application data associated with the surface
-
-
-
Method Detail
-
getFlags
public int getFlags()
-
getFormat
public SDL_PixelFormat getFormat()
-
getW
public int getW()
-
getH
public int getH()
-
getPitch
public int getPitch()
-
getPixels
public com.sun.jna.Pointer getPixels()
-
getUserdata
public com.sun.jna.Pointer getUserdata()
Read the application data associated with the surface
-
setUserdata
public void setUserdata(com.sun.jna.Pointer newValue)
Set the application data associated with the surface
-
getLocked
public int getLocked()
-
getClipRect
public SDL_Rect getClipRect()
Get the clipping information
-
getRefcount
public int getRefcount()
Get the reference count -- used when freeing surface
-
-