Struct speedy2d::GLRenderer[][src]

pub struct GLRenderer { /* fields omitted */ }
Expand description

A graphics renderer using an OpenGL backend.

Note: There is no need to use this struct if you are letting Speedy2D create a window for you.

Implementations

Creates a GLRenderer for the current OpenGL context. viewport_size_pixels should be set to the initial viewport size, however this can be changed later using [GLRenderer:: set_viewport_size_pixels()].

Note: This function must not be called if you are letting Speedy2D create a window for you.

Deprecation

Note: This function will be removed in a future version of Speedy2D. Please use GLRenderer::new_for_gl_context instead.

Safety

While a GLRenderer object is active, you must not make any changes to the active GL context. Doing so may lead to undefined behavior, which is why this function is marked unsafe. It is strongly advised not to use any other OpenGL libraries in the same thread as GLRenderer.

Creates a GLRenderer with the specified OpenGL loader function. The loader function takes the name of an OpenGL function, and returns the associated function pointer. viewport_size_pixels should be set to the initial viewport size, however this can be changed later using [GLRenderer:: set_viewport_size_pixels()].

Note: This function must not be called if you are letting Speedy2D create a window for you.

Safety

While a GLRenderer object is active, you must not make any changes to the active GL context. Doing so may lead to undefined behavior, which is why this function is marked unsafe. It is strongly advised not to use any other OpenGL libraries in the same thread as GLRenderer.

Sets the renderer viewport to the specified pixel size, in response to a change in the window size.

Creates a new ImageHandle from the specified raw pixel data.

The data provided in the data parameter must be in the format specified by data_type.

The returned ImageHandle is valid only for the current graphics context.

Loads an image from the specified file path.

If no data_type is provided, an attempt will be made to guess the file format.

For a list of supported image types, see image::ImageFileFormat.

The returned ImageHandle is valid only for the current graphics context.

Loads an image from the provided encoded image file data.

If no data_type is provided, an attempt will be made to guess the file format.

The data source must implement std::io::BufRead and std::io::Seek. For example, if you have a &[u8], you may wrap it in a std::io::Cursor as follows:

use std::io::Cursor;

let image_bytes : &[u8] = include_bytes!("../assets/screenshots/hello_world.png");

let image_result = renderer.create_image_from_file_bytes(
    None,
    ImageSmoothingMode::Linear,
    Cursor::new(image_bytes));

For a list of supported image types, see image::ImageFileFormat.

The returned ImageHandle is valid only for the current graphics context.

Starts the process of drawing a frame. A Graphics2D object will be provided to the callback. When the callback returns, the internal render queue will be flushed.

Note: if calling this method, you are responsible for swapping the window context buffers if necessary.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.