sdlReadSurfacePixelFloat function

bool sdlReadSurfacePixelFloat(
  1. Pointer<SdlSurface> surface,
  2. int x,
  3. int y,
  4. Pointer<Float> r,
  5. Pointer<Float> g,
  6. Pointer<Float> b,
  7. Pointer<Float> a,
)

Retrieves a single pixel from a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

\param surface the surface to read. \param x the horizontal coordinate, 0 <= x < width. \param y the vertical coordinate, 0 <= y < height. \param r a pointer filled in with the red channel, normally in the range 0-1, or NULL to ignore this channel. \param g a pointer filled in with the green channel, normally in the range 0-1, or NULL to ignore this channel. \param b a pointer filled in with the blue channel, normally in the range 0-1, or NULL to ignore this channel. \param a a pointer filled in with the alpha channel, normally in the range 0-1, or NULL to ignore this channel. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a)

Implementation

bool sdlReadSurfacePixelFloat(Pointer<SdlSurface> surface, int x, int y,
    Pointer<Float> r, Pointer<Float> g, Pointer<Float> b, Pointer<Float> a) {
  final sdlReadSurfacePixelFloatLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(
          Pointer<SdlSurface> surface,
          Int32 x,
          Int32 y,
          Pointer<Float> r,
          Pointer<Float> g,
          Pointer<Float> b,
          Pointer<Float> a),
      int Function(
          Pointer<SdlSurface> surface,
          int x,
          int y,
          Pointer<Float> r,
          Pointer<Float> g,
          Pointer<Float> b,
          Pointer<Float> a)>('SDL_ReadSurfacePixelFloat');
  return sdlReadSurfacePixelFloatLookupFunction(surface, x, y, r, g, b, a) == 1;
}