Property definitions

sdl2 $ SDLRenderer :: defaultinit
# A renderer, maybe software or hardware
extern class SDLRenderer `{ SDL_Renderer * `}
	# Create a new `SDLRenderer` for the `window` using the `index`th renderer according to `flags`
	#
	# Use an `index` of `-1` to get the default renderer for the given flags.
	new (window: SDLWindow, index: Int, flags: SDLRendererFlags) `{
		return SDL_CreateRenderer(window, index, flags);
	`}

	# Create a new software `SDLRenderer`
	new software(surface: SDLSurface) `{
		return SDL_CreateSoftwareRenderer(surface);
	`}

	# Destroy this renderer
	fun destroy `{ SDL_DestroyRenderer(self); `}

	# Clear the rendering target with the current `draw_color`
	fun clear `{ SDL_RenderClear(self); `}

	# Copy the rectangle at `src` from `texture` to fill the `dst` at the rendering `target`
	#
	# If `dst` has a different size than `src`, the image will be stretched.
	#
	# If `src == null` the whole source texture will be drawn, and if
	# `dst == null` then the texture will fill the rendering `target`.
	fun copy(texture: SDLTexture, src, dst: nullable SDLRect)
	do
		if src == null then src = new SDLRect.nil
		if dst == null then dst = new SDLRect.nil

		native_copy(texture, src, dst)
	end

	private fun native_copy(texture: SDLTexture, src, dst: SDLRect) `{
		SDL_RenderCopy(self, texture, src, dst);
	`}

	# Update the screen with all rendering since the previous call
	fun present `{ SDL_RenderPresent(self); `}

	# Get the `SDLRendererInfo` for this renderer
	fun info_copy(out: SDLRendererInfo) `{ SDL_GetRendererInfo(self, out); `}

	# Set the drawing color
	fun draw_color=(val: SDLColor) `{
		SDL_SetRenderDrawColor(self, val->r, val->g, val->b, val->a);
	`}

	# Get the drawing color of this renderer
	#
	# The returned `SDLColor` is malloced here and must be freed by the called.
	# For a more efficient usage, it is recommended to use instead `draw_color_copy`.
	fun draw_color: SDLColor
	do
		var color = new SDLColor.malloc
		draw_color_copy color
		return color
	end

	# Copy the drawing color of this renderer in `color`
	fun draw_color_copy(color: SDLColor) `{
		SDL_GetRenderDrawColor(self, &color->r, &color->g, &color->b, &color->a);
	`}

	# Fill a rectangle with the current `draw_color`
	#
	# If `rect.address_is_null` then fills the entire screen.
	fun fill_rect(rect: SDLRect) `{ SDL_RenderFillRect(self, rect); `}

	# Draw a rectangle with the current `draw_color`
	fun draw_rect(rect: SDLRect) `{ SDL_RenderDrawRect(self, rect); `}

	# Draw a point with the current `draw_color`
	fun draw_point(x, y: Int) `{ SDL_RenderDrawPoint(self, x, y); `}

	# Draw a line with the current `draw_color`
	fun draw_line(x1, y1, x2, y2: Int) `{ SDL_RenderDrawLine(self, x1, y1, x2, y2); `}

	# Set the viewport of this renderer
	fun viewport=(rect: SDLRect) `{ SDL_RenderSetViewport(self, rect); `}

	# Get the rendering target of this renderer
	fun target: SDLTexture `{ return SDL_GetRenderTarget(self); `}

	# Set the rendering target of this renderer
	fun target=(val: SDLTexture) `{ SDL_SetRenderTarget(self, val); `}

	# TODO add other renderer related methods:
	#
	# draw_rects
	# draw_lines
end
lib/sdl2/sdl2_base.nit:232,1--324,3