Home

Renderer

Rendering state

Operations

New

Create a 2D rendering context for a window

New(window:Window, index:Int, flags:Int)
Parameters
NameTypeDescription
windowWindowwindow context
indexIntthe index of the rendering driver to initialize, or -1 to initialize the first one supporting the requested flags
flagsInt0, or one or more SDL_RendererFlags OR'd together

Return
TypeDescription
@return_typerendering context

Clear

Clear the current rendering target with the drawing color

method : public : Clear() ~ Int

Copy

Copy a portion of the texture to the current rendering target

method : public : Copy(texture:Texture, srcrect:Rect, dstrect:Rect) ~ Int
Parameters
NameTypeDescription
textureTexturethe source texture; see Remarks for details
srcrectRectthe source SDL_Rect structure or Nil for the entire texture
dstrectRectthe destination SDL_Rect structure or Nil for the entire rendering target; the texture will be stretched to fill the given rectangle

Return
TypeDescription
Int0 on success or a negative error code on failure

CopyEx

Copy a portion of the texture to the current rendering target, optionally rotating it by angle around the given center and also flipping it top-bottom and/or left-right

method : public : CopyEx(texture:Texture, srcrect:Rect, dstrect:Rect, angle:Float, center:Point, flip:RendererFlip) ~ Int
Parameters
NameTypeDescription
textureTexturethe source texture; see Remarks for details
srcrectRectthe source SDL_Rect structure or Nil for the entire texture
dstrectRectthe destination SDL_Rect structure or Nil for the entire rendering target
angleFloatan angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
centerPointa holder to a point indicating the point around which dstrect will be rotated (if Nil, rotation will be done around dstrect.w/2, dstrect.h/2)
flipRendererFlipa SDL_RendererFlip value stating which flipping actions should be performed on the texture

Return
TypeDescription
Int0 on success or a negative error code on failure

CreateTexture

Create a texture for a rendering context

method : public : CreateTexture(format:Int, access:Int, w:Int, h:Int) ~ Texture
Parameters
NameTypeDescription
formatIntone of the enumerated values in PixelFormatEnum
accessIntone of the enumerated values in TextureAccess
wIntthe width of the texture in pixels
hIntthe height of the texture in pixels

Return
TypeDescription
Texturecreated texture

Destroy

Destroy the rendering context for a window and free associated textures

method : public : Destroy() ~ Nil

DrawLine

Draw a line on the current rendering target

method : public : DrawLine(x1:Int, y1:Int, x2:Int, y2:Int) ~ Int
Parameters
NameTypeDescription
x1Intthe x coordinate of the start point
y1Intthe y coordinate of the start point
x2Intthe x coordinate of the end point
y2Intthe y coordinate of the end point

Return
TypeDescription
Int0 on success or a negative error code on failure

DrawPoint

Draw a point on the current rendering target

method : public : DrawPoint(x:Int, y:Int) ~ Int
Parameters
NameTypeDescription
xIntthe x coordinate of the point
yIntthe y coordinate of the point

Return
TypeDescription
Int0 on success or a negative error code on failure

DrawRect

Draw a rectangle on the current rendering target

method : public : DrawRect(rect:Rect) ~ Int
Parameters
NameTypeDescription
rectRectRect representing the rectangle to draw, or Nil to outline the entire rendering target

Return
TypeDescription
Int0 on success or a negative error code on failure

FillRect

Fill a rectangle on the current rendering target with the drawing color

method : public : FillRect(rect:Rect) ~ Int
Parameters
NameTypeDescription
rectRectRect representing the rectangle to fill, or NULL for the entire rendering target

Return
TypeDescription
Int0 on success or a negative error code on failure

Get

Get the renderer associated with a window

function : public : Get(window:Window) ~ Renderer
Parameters
NameTypeDescription
windowWindowthe window to query

GetInfo

Get information about a rendering context

method : public : GetInfo(info:RendererInfo) ~ Int
Parameters
NameTypeDescription
infoRendererInfoan RendererInfo filled with information about the current renderer

Return
TypeDescription
Int0 on success or a negative error code on failure

GetNumRenderDrivers

Get the number of 2D rendering drivers available for the current display

function : public : GetNumRenderDrivers() ~ Int
Return
TypeDescription
Inta number >= 0 on success or a negative error code on failure

GetRenderDrawColor

Get the color used for drawing operations (Rect, Line and Clear)

method : public : GetRenderDrawColor(r:IntHolder, g:IntHolder, b:IntHolder, a:IntHolder) ~ Int
Parameters
NameTypeDescription
rIntHolderpointer filled in with the red value used to draw on the rendering target
gIntHolderpointer filled in with the green value used to draw on the rendering target
bIntHolderpointer filled in with the blue value used to draw on the rendering target
aIntHolderholder filled in with the alpha value used to draw on the rendering target

Return
TypeDescription
Int0 on success or a negative error code on failure

GetRenderDriverInfo

Get information about a specific 2D rendering driver for the current display

function : public : GetRenderDriverInfo(index:Int, info:RendererInfo) ~ Int
Parameters
NameTypeDescription
indexIntindex of the driver to query information about
infoRendererInfoRendererInfo to be filled with information on the rendering driver

Return
TypeDescription
Int0 on success or a negative error code on failure

GetTarget

Get the current render target.

method : public : GetTarget() ~ Texture
Return
TypeDescription
Texturecurrent target

IsNull

Determines if the underlying SDL C-struct is NULL

method : public : IsNull() ~ Bool
Return
TypeDescription
Booltrue if NULL, false otherwise

Present

Update the screen with any rendering performed since the previous call

method : public : Present() ~ Nil

SetDrawColor

Set the color used for drawing operations (Rect, Line and Clear)

method : public : SetDrawColor(r:Int, g:Int, b:Int, a:Int) ~ Int
Parameters
NameTypeDescription
rIntthe red value used to draw on the rendering target
gIntthe green value used to draw on the rendering target
bIntthe blue value used to draw on the rendering target
aIntthe alpha value used to draw on the rendering target

Return
TypeDescription
Int0 on success or a negative error code on failure

SetTarget

Set a texture as the current rendering target.

method : public : SetTarget(texture:Texture) ~ Int
Parameters
NameTypeDescription
textureTexturethe targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or Nil for the default render target

Return
TypeDescription
Int0 on success or a negative error code on failure

SetViewport

set the drawing area for rendering on the current target

method : public : SetViewport(rect:Rect) ~ Int
Parameters
NameTypeDescription
rectRectRect representing the drawing area, or Nil to set the viewport to the entire target

Return
TypeDescription
Int0 on success or a negative error code on failure