Class 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 in SDL_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 to SDL_Texture using SDL_CreateTextureFromSurface(...), after which you can release the SDL_Surface memory by SDL_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 JNA Structure but the SDL internals keep references to all allocated SDL_Surfaces and change their internal fields without notice. Thus it is implemented as an opaque Pointer and there is a co-located SDL_Surface_internal which allows a read-only access to the fields.

    • Constructor Detail

      • SDL_Surface

        public SDL_Surface()
      • SDL_Surface

        public SDL_Surface​(com.sun.jna.Pointer p)
    • Method Detail

      • getFlags

        public int getFlags()
      • 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