All Bundles

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

AACircleColor

Raw anti-aliased circle with blending.

method : public : AACircleColor(x:Int, y:Int, rad:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the aa-circle.
yIntY coordinate of the center of the aa-circle.
radIntRadius in pixels of the aa-circle.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

AAEllipseColor

Draw ellipse with blending.

method : public : AAEllipseColor(x:Int, y:Int, rx:Int, ry:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the ellipse.
yIntY coordinate of the center of the ellipse.
rxIntHorizontal radius in pixels of the ellipse.
ryIntVertical radius in pixels of the ellipse.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

AALineColor

Draw anti-aliased line with alpha blending.

method : public : AALineColor(x1:Int, y1:Int, x2:Int, y2:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the aa-line.
y1IntY coordinate of the first point of the aa-line.
x2IntX coordinate of the second point of the aa-line.
y2IntY coordinate of the second point of the aa-line.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

AAPolygonColor

Draw anti-aliased polygon with alpha blending.

method : public : AAPolygonColor(vx:Int[], vy:Int[], color:Color) ~ Int
Parameters
NameTypeDescription
vxInt[]Vertex array containing X coordinates of the points of the polygon.
vyInt[]Vertex array containing Y coordinates of the points of the polygon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

AAtrigonColor

Draw anti-aliased trigon (triangle outline) with alpha blending. Note: Creates vertex array and uses aapolygon routine to render.

method : public : AAtrigonColor(x1:Int, y1:Int, x2:Int, y2:Int, x3:Int, y3:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the aa-trigon.
y1IntY coordinate of the first point of the aa-trigon.
x2IntX coordinate of the second point of the aa-trigon.
y2IntY coordinate of the second point of the aa-trigon.
x3IntX coordinate of the third point of the aa-trigon.
y3IntY coordinate of the third point of the aa-trigon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

ArcColor

Arc with blending.

method : public : ArcColor(x:Int, y:Int, rad:Int, start:Int, end:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the arc.
yIntY coordinate of the center of the arc.
radIntRadius in pixels of the arc.
startIntStarting radius in degrees of the arc. 0 degrees is down, increasing counterclockwise.
endIntEnding radius in degrees of the arc. 0 degrees is down, increasing counterclockwise.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

BoxColor

Draw box (filled rectangle) with blending

method : public : BoxColor(x1:Int, y1:Int, x2:Int, y2:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point (i.e. top right) of the box.
y1IntY coordinate of the first point (i.e. top right) of the box.
x2IntX coordinate of the second point (i.e. bottom left) of the box.
y2IntY coordinate of the second point (i.e. bottom left) of the box.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

CharacterColor

Draw a character of the currently set font.

method : public : CharacterColor(x:Int, y:Int, c:Char, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX (horizontal) coordinate of the upper left corner of the character.
yIntY (vertical) coordinate of the upper left corner of the character.
cCharThe character to draw.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

CircleColor

Draw circle with blending.

method : public : CircleColor(x:Int, y:Int, rad:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the circle.
yIntY coordinate of the center of the circle.
radIntRadius in pixels of the circle.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

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

CreateSoftwareRenderer

Create a 2D software rendering context for a surface

function : public : CreateSoftwareRenderer(surface:Surface) ~ Renderer
Parameters
NameTypeDescription
surfaceSurfaceSurface representing the surface where rendering is done

Return
TypeDescription
Renderervalid rendering context

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

EllipseColor

Draw ellipse with blending.

method : public : EllipseColor(x:Int, y:Int, rx:Int, ry:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the ellipse.
yIntY coordinate of the center of the ellipse.
rxIntHorizontal radius in pixels of the ellipse.
ryIntVertical radius in pixels of the ellipse.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 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

FilledCircleColor

Draw filled circle with blending.

method : public : FilledCircleColor(x:Int, y:Int, r:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the filled circle.
yIntY coordinate of the center of the filled circle.
rIntRadius in pixels of the filled circle.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

FilledEllipseColor

Draw filled ellipse with blending.

method : public : FilledEllipseColor(x:Int, y:Int, rx:Int, ry:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the filled ellipse.
yIntY coordinate of the center of the filled ellipse.
rxIntHorizontal radius in pixels of the filled ellipse.
ryIntVertical radius in pixels of the filled ellipse.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

FilledPieColor

Draw filled pie with alpha blending.

method : public : FilledPieColor(x:Int, y:Int, rad:Int, start:Int, end:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the filled pie.
yIntY coordinate of the center of the filled pie.
radIntRadius in pixels of the filled pie.
startIntStarting radius in degrees of the filled pie.
endIntEnding radius in degrees of the filled pie.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

FilledPolygonColor

Draw filled pie with alpha blending.

method : public : FilledPolygonColor(vx:Int[], vy:Int[], color:Color) ~ Int
Parameters
NameTypeDescription
vxInt[]Vertex array containing X coordinates of the points of the polygon.
vyInt[]Vertex array containing Y coordinates of the points of the polygon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

FilledTrigonColor

Draw filled trigon (triangle) with alpha blending. Note: Creates vertex array and uses aapolygon routine to render.

method : public : FilledTrigonColor(x1:Int, y1:Int, x2:Int, y2:Int, x3:Int, y3:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the filled trigon.
y1IntY coordinate of the first point of the filled trigon.
x2IntX coordinate of the second point of the filled trigon.
y2IntY coordinate of the second point of the filled trigon.
x3IntX coordinate of the third point of the filled trigon.
y3IntY coordinate of the third point of the filled trigon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 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

GetViewport

Get the drawing area for the current target

method : public : GetViewport(rect:Rect) ~ Nil
Parameters
NameTypeDescription
rectRectRect filled in with the current drawing area

HLineColor

Draw horizontal line with blending

method : public : HLineColor(x1:Int, x2:Int, y:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point (i.e. left) of the line.
x2IntX coordinate of the second point (i.e. right) of the line.
yIntY coordinate of the points of the line.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

IsNull

Determines if the underlying SDL C-struct is NULL

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

LineColor

Draw line with alpha blending

method : public : LineColor(x1:Int, y1:Int, x2:Int, y2:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the line.
y1IntY coordinate of the first point of the line.
x2IntX coordinate of the second point of the line.
y2IntY coordinate of the seond point of the line.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

PieColor

Draw pie (outline) with alpha blending.

method : public : PieColor(x:Int, y:Int, rad:Int, start:Int, end:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the center of the pie.
yIntY coordinate of the center of the pie.
radIntRadius in pixels of the pie.
startIntStarting radius in degrees of the pie.
endIntEnding radius in degrees of the pie.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

PixelColor

Draw pixel with blending enabled if a<255.

method : public : PixelColor(x:Int, y:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntx-position
yInty-position
colorColorcolor

Return
TypeDescription
Int0 on success, -1 on failure

PolygonColor

Draw polygon with alpha blending.

method : public : PolygonColor(vx:Int[], vy:Int[], color:Color) ~ Int
Parameters
NameTypeDescription
vxInt[]Vertex array containing X coordinates of the points of the polygon.
vyInt[]Vertex array containing Y coordinates of the points of the polygon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

Present

Update the screen with any rendering performed since the previous call

method : public : Present() ~ Nil

RectangleColor

Draw rectangle with blending

method : public : RectangleColor(x1:Int, y1:Int, x2:Int, y2:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point (i.e. top right) of the rectangle.
y1IntY coordinate of the first point (i.e. top right) of the rectangle.
x2IntX coordinate of the second point (i.e. bottom left) of the rectangle.
y2IntY coordinate of the second point (i.e. bottom left) of the rectangle.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

RoundedBoxColor

Draw rounded-corner box (filled rectangle) with blending

method : public : RoundedBoxColor(x1:Int, y1:Int, x2:Int, y2:Int, rad:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point (i.e. top right) of the box.
y1IntY coordinate of the first point (i.e. top right) of the box.
x2IntX coordinate of the second point (i.e. bottom left) of the box.
y2IntY coordinate of the second point (i.e. bottom left) of the box.
radIntThe radius of the corner arcs of the box.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

RoundedRectangleColor

Draw rounded-corner rectangle with blending

method : public : RoundedRectangleColor(x1:Int, y1:Int, x2:Int, y2:Int, rad:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point (i.e. top right) of the rectangle.
y1IntY coordinate of the first point (i.e. top right) of the rectangle.
x2IntX coordinate of the second point (i.e. bottom left) of the rectangle.
y2IntY coordinate of the second point (i.e. bottom left) of the rectangle.
radIntThe radius of the corner arc.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

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

StringColor

Draw a string in the currently set font.

method : public : StringColor(x:Int, y:Int, s:String, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX (horizontal) coordinate of the upper left corner of the string.
yIntY (vertical) coordinate of the upper left corner of the string.
sStringThe string to draw.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

ThickLineColor

Draw a thick line with alpha blending.

method : public : ThickLineColor(x1:Int, y1:Int, x2:Int, y2:Int, width:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the line.
y1IntY coordinate of the first point of the line.
x2IntX coordinate of the second point of the line.
y2IntY coordinate of the second point of the line.
widthIntWidth of the line in pixels. Must be >0.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

TrigonColor

Draw trigon (triangle outline) with alpha blending.

method : public : TrigonColor(x1:Int, y1:Int, x2:Int, y2:Int, x3:Int, y3:Int, color:Color) ~ Int
Parameters
NameTypeDescription
x1IntX coordinate of the first point of the trigon.
y1IntY coordinate of the first point of the trigon.
x2IntX coordinate of the second point of the trigon.
y2IntY coordinate of the second point of the trigon.
x3IntX coordinate of the third point of the trigon.
y3IntY coordinate of the third point of the trigon.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure

VlineColor

Draw vertical line with blending

method : public : VlineColor(x:Int, y1:Int, y2:Int, color:Color) ~ Int
Parameters
NameTypeDescription
xIntX coordinate of the points of the line.
y1IntY coordinate of the first point (i.e. top) of the line.
y2IntY coordinate of the second point (i.e. bottom) of the line.
colorColorcolor value

Return
TypeDescription
Int0 on success, -1 on failure