• allegro5.a5_display
  • allegro5.a5_file
  • allegro5.a5_font
  • allegro5.a5_image
  • allegro5.a5_joystick
  • allegro5.a5_main
  • allegro5.a5_misc
  • allegro5.a5_opengl
  • allegro5.a5_shader
  • allegro5.a5_sound
  • allegro5.a5_thread
  • allegro5.a5_triangles
  • animation
  • array
  • atlas
  • buffer
  • color
  • common
  • csg.csg_aabb
  • csg.csg
  • csg.csg_octree
  • csg.csg_shapes
  • csg.csg_test
  • data
  • display
  • exception
  • file
  • font
  • glsl
  • grid
  • hash
  • image
  • image_op
  • index
  • ini
  • isometric
  • joystick
  • keyboard
  • land
  • layer
  • list
  • log
  • main
  • map
  • mem
  • mouse
  • net
  • noise
  • openglutil
  • perlin
  • pixelmask
  • plasma
  • pool
  • protobuf
  • queue
  • random
  • runner
  • shader
  • sound
  • sprite
  • thread
  • tilegrid
  • triangles
  • util2d
  • util3d
  • util
  • view
  • voronoi
  • widget.base
  • widget.board
  • widget.book
  • widget.box
  • widget.button
  • widget.checkbox
  • widget.container
  • widget.edit
  • widget.gul
  • widget.hbox
  • widget.layout
  • widget
  • widget.menu
  • widget.mover
  • widget.panel
  • widget.scrollbar
  • widget.scrolling
  • widget.sizer
  • widget.slider
  • widget.spin
  • widget.text
  • widget.theme
  • widget.vbox
  • widget.widget_list
  • yaml.external
  • yaml.internal
  • yaml
  • yaml.xml

land.display

Drawing Primitives in Land

Positions

The most basic information drawing primitives need is, where on the target should they be drawn. There are several ways:

Relative screen coordinates. For example, 0/0 is the upper left screen edge, 1/1 the lower right screen edge. A rectangle from 0.1/0.1 to 0.9/0.9 would span 80% of the width and the height of the screen, and leave a 10% border all around. Obviously, using such coordinates is most useful if you don’t want to care at all about the actual resolution used.

Pixel coordinates. A coordinate is given in pixels. So, if you draw a line from 1/1 to 2/2, the pixels at 1/1 and at 2/2 would be lit. This is what Land originally used in its first incarnation, a very long time ago. This has some disadvantages. Besides positions relying on the current resolution, it is also impossible to specify sub-pixel behavior, for example when anti-aliasing is switched on.

Subpixel coordinates. This is what Land uses by default, but you can easily change it. It is a mixture of the two modes above. You give coordinates in pixel positions (so positions depend on the resolution), but each integer position is the upper left corner of a pixel, not the pixel as a whole, as in the method before. To get the behavior of the previous method, you would do two things:

  1. For rectangles, draw them with their full width.

  2. For images, don’t do anything.

To make clear why, let’s compare a rectangle and an image. The rectangle is drawn at pixel 0/0 with the pixel method, and 10x10 pixels big. So the pixels that are lit are from 0/0 to 9/9, inclusive. Doing the same with the subpixel method, we would draw a rectangle from 0/0 to 10/10.

But what just happened? The rectangle of lit pixels before was 10x10 pixels big, from pixel 0 to pixel 9 inclusive. The new subpixel rectangle also is 10x10 pixels big. Just now there is no more inclusive/exclusive pixels, the rectangle coordinates are independent now.

The problem is, that what we really want with subpixel coordinates is not just an outline anymore, but a frame which is one pixel thick. Its outer rectangle would actually start at 0/0, and end at 10/10. Its inner rectangle would start at 1/1 and end at 9/9. Drawing a single rectangle from 0.5/0.5 to 9.5/9.5 just works, because we assumed a line-thickness of 1.

But with images, there is no line thickness. So if we draw an image which is 10x10 pixels big, and we draw it to 0/0, it will exactly fit the same rectangle. Would we draw it to 0.5/0.5, that just would be wrong.

Now, to make things easier, you don’t have to use sub-pixel coordinates if you absolutely don’t want to. Call:

land_use_screen_positions()

to use the method which maps the screen to 0/0..1/1,

or

land_use_pixel_positions()

to use pixel positions. That is, Land will always lit the exact pixel you specify, and also draw images correctly to full-pixel positions. In fact, this mode just maps the coordinates like described above, so you still can use non-integer positions (but there really is no reason to not use one of the other two positioning modes then) and enable e.g. anti-aliasing.

Primitives

line

This draws a line from the first point to the second point.

rectangle

This draws a rectangle from the first point to the second point.

filled_rectangle

Like rectangle, but filled.

circle/ellipse/oval

This draws a circle, inscribed into the given rectangle. The alternate names “ellipse” and “oval” for this function actually fit better.

filled_circle

Like circle, but filled.

LandDisplay

land_display_new

Parameters: int w, int h, int flags

Returns: LandDisplay*

land_display_destroy

Parameters: LandDisplay * self

land_display_del

Parameters: LandDisplay * self

land_scale_to_fit_into

Parameters: float w, float h, float l, float t, float r, float b, int how

Returns: double

land_get_scaled_dimensions

Parameters: float * x, float * y, float * w, float * h

land_scale_to_fit

Parameters: float w, float h, int how

Returns: double

land_get_left

no parameters

Returns: LandFloat

land_get_x_scale

no parameters

Returns: LandFloat

land_get_top

no parameters

Returns: LandFloat

land_get_y_scale

no parameters

Returns: LandFloat

land_set_image_display

Parameters: LandImage * image

Change the display of the current thread to an internal display which draws to the specified image. This cannot be nested.

land_unset_image_display

no parameters

Restore the display to what it was before the call to land_set_image_display.

land_display_set

no parameters

Make the active display of the current thread the active one. This may involve creating a new window. There is usually no need to call this function directly, as it will be called internally.

land_display_get

no parameters

Returns: LandDisplay*

Retrieve a handle to the currently active display of the calling thread.

land_display_unset

no parameters

Make the current display invalid. Usually there is no need for this.

land_display_init

no parameters

land_display_exit

no parameters

land_display_time_flip_speed

Parameters: double howlong

Returns: double

This function is dangerous! It will completely halt Land for the passed time in seconds. The function will try to determine how long flipping of the display takes. This can be used to see if the refresh rate is honored (usually because vsync is enabled).

land_display_toggle_fullscreen

no parameters

Toggle the current thread’s display between windowed and fullscreen mode, if possible.

land_clear

Parameters: float r, float g, float b, float a

Clear the current thread’s display to the specified color. Always set ’‘’a’’’ to 1, or you may get a transparent background.

land_clear_depth

Parameters: float z

land_color

Parameters: float r, float g, float b, float a

Change the color of the current thread’s active display. This is the color which will be used for subsequent graphics commands.

land_premul

Parameters: float r, float g, float b, float a

land_color_set

Parameters: LandColor c

land_color_get

no parameters

Returns: LandColor

land_thickness

Parameters: float t

land_get_color

Parameters: float * r, float * g, float * b, float * a

Retrieve the current color.

land_blend

Parameters: int state

Returns: int

land_clip

Parameters: float x, float y, float x_, float y_

land_clip_intersect

Parameters: float x, float y, float x_, float y_

land_clip_push

no parameters

land_clip_pop

no parameters

land_clip_on

no parameters

land_clip_off

no parameters

land_unclip

no parameters

land_get_clip

Parameters: float * cx1, float * cy1, float * cx2, float * cy2

Returns: int

land_flip

no parameters

land_rectangle

Parameters: float x, float y, float x_, float y_

land_filled_rectangle

Parameters: float x, float y, float x_, float y_

land_filled_circle

Parameters: float x, float y, float x_, float y_

land_circle

Parameters: float x, float y, float x_, float y_

land_arc

Parameters: float x, float y, float x_, float y_, float a, float a_

land_line

Parameters: float x, float y, float x_, float y_

land_move_to

Parameters: float x, float y

land_line_to

Parameters: float x, float y

land_ribbon

Parameters: int n, float * xy

land_ribbon_loop

Parameters: int n, float * xy

land_filled_ribbon

Parameters: int n, float * xy

land_polygon

Parameters: int n, float * xy

land_filled_polygon

Parameters: int n, float * xy

land_filled_triangle

Parameters: float x0, float y0, float x1, float y1, float x2, float y2

land_3d_triangles

Parameters: int n, LandFloat * xyzrgb

land_textured_polygon

Parameters: LandImage * image, int n, float * xy, float * uv

land_textured_colored_polygon

Parameters: LandImage * image, int n, float * xy, float * uv, float * rgba

land_filled_polygon_with_holes

Parameters: int n, float * xy, int * holes

land_filled_colored_polygon

Parameters: int n, float * xy, float * rgba

land_plot

Parameters: float x, float y

land_pick_color

Parameters: float x, float y

land_display_width

no parameters

Returns: int

land_display_height

no parameters

Returns: int

land_display_resize

Parameters: int w, int h

Resize the current display to the given dimensions.

land_display_move

Parameters: int x, int y

land_display_desktop_size

Parameters: int * w, int * h

land_display_title

Parameters: char const * title

land_display_icon

Parameters: LandImage * icon

land_display_flags

no parameters

Returns: int

land_display_new_image

no parameters

Returns: LandImage*

land_display_del_image

Parameters: LandImage * image

land_display_select

Parameters: LandDisplay * display

land_display_unselect

no parameters

land_screenshot

Parameters: char const * filename

land_screenshot_autoname

Parameters: char const * name

land_resize_event

Parameters: int w, int h

land_switch_out_event

no parameters

land_switched_out

no parameters

Returns: int

land_was_resized

no parameters

Returns: int

land_display_tick

no parameters

land_rotate

Parameters: LandFloat angle

Pre-rotate the current transformation.

land_scale

Parameters: LandFloat x, LandFloat y

Pre-scale the current transformation.

land_translate

Parameters: LandFloat x, LandFloat y

Pre-translate the current transformation. That is, any transformations in effect prior to this call will be applied afterwards. And transformations after this call until before the next drawing command will be applied before.

land_z

Parameters: LandFloat z

land_push_transform

no parameters

land_pop_transform

no parameters

land_reset_transform

no parameters

land_transform

Parameters: LandFloat * x, LandFloat * y, LandFloat * z

land_projection

Parameters: Land4x4Matrix m

land_reset_projection

no parameters

land_display_transform_4x4

Parameters: Land4x4Matrix * matrix

land_render_state

Parameters: int state, int value

land_display_set_default_shaders

no parameters

When using custom shaders, use this to restore the shader expected by the builtin functions.

land_display_dpi

no parameters

Returns: int


Generated: Thu 27 Feb 2020 10:49:37 PM EST