Solarus quests
1.6
Quest maker's reference
|
A surface is a 2D image. It is essentially a rectangle of pixels. Its main feature is that you can draw objects on it.
Creates an empty surface.
width
(number, optional): Width of the surface to create in pixels. The default value is the width of the logical screen.height
(number, optional): Height of the surface to create in pixels. The default value is the height of the logical screen.Creates a surface from an image file.
file_name
(string): Name of the image file to load.language_specific
(boolean, optional): true
to load the image from the images
subdirectory of the current language directory (default is false
and loads the image from the sprites
directory).nil
if the image file could not be loaded.Surfaces are particular drawable objects. Therefore, they inherit all methods from the type drawable.
See Methods of all drawable types to know these methods.
The following methods are specific to surfaces.
Returns the size of this surface.
Erases all pixels of this surface.
All pixels become transparent. The opacity property and the size of the surface are preserved.
Fills a region of this surface with a color.
If no region is specified, the entire surface is filled. If the color has an alpha component different from 255 (opaque), then the color is blended onto the existing pixels.
color
(table): The color as an array of 3 RGB values or 4 RGBA values (0
to 255
).x
(number, optional): X coordinate of the region to fill on this surface.y
(number, optional): Y coordinate of the region to fill on this surface.width
(number, optional): Width of the region to fill on this surface.height
(number, optional): Height of the region to fill on this surface.Returns all pixel values of this surface.
Sets all pixel values of this surface.
The number of pixels should match the size of the surface (the size does not change).
pixels
(string): The pixels as a pack of bytes in 32-bit RGBA format. Every pixel is stored on 4 bytes (red, green, blue, alpha).Binds this surface as a target for next OpenGL calls.
This method is only useful for advanced users who want to directly call OpenGL primitives, which is possible with Lua bindings, for example via LuaJIT FFI.
This is equivalent to glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ...)
. It will make this surface the destination for any further OpenGL draw call.
When you call OpenGL directly, it is your responsability to restore the OpenGL state if you want the Solarus rendering to remain correct. In particular, pay attention to restore :
glProgram
glBlendModes
VertexBufferObjects
GL_DEPTH_TEST
.Bind this surface as the current texture for next OpenGL calls.
This method is only useful for advanced users who want to directly call OpenGL primitives, which is possible with Lua bindings, for example via LuaJIT FFI.
This is equivalent to glBindTexture(...)
.
See surface:gl_bind_as_target() for details about calling OpenGL directly.