Module conrod::backend::glium::glium [] [src]

Easy-to-use, high-level, OpenGL3+ wrapper.

Glium is based on glutin - a cross-platform crate for building an OpenGL window and handling application events.

Glium provides a Display which extends the glutin::GlWindow with a high-level, safe API.

Initialization

The initialisation of a glium display occurs in several steps.

extern crate glium;

fn main() {
    // 1. The **winit::EventsLoop** for handling events.
    let mut events_loop = glium::glutin::EventsLoop::new();
    // 2. Parameters for building the Window.
    let window = glium::glutin::WindowBuilder::new()
        .with_dimensions(1024, 768)
        .with_title("Hello world");
    // 3. Parameters for building the OpenGL context.
    let context = glium::glutin::ContextBuilder::new();
    // 4. Build the Display with the given window and OpenGL context parameters and register the
    //    window with the events_loop.
    let display = glium::Display::new(window, context, &events_loop).unwrap();
}

The display object is the most important object of this library and is used when you build buffers, textures, etc. and when you draw.

You can clone it and pass it around. However it doesn't implement the Send and Sync traits, meaning that you can't pass it to another thread.

The display has ownership of both the window and context, and also provides some methods related to domains such as events handling.

Overview

OpenGL is similar to a drawing software: you draw something, then draw over it, then over it again, etc. until you are satisfied of the result.

Once you have a display, you can call let mut frame = display.draw(); to start drawing. This frame object implements the Surface trait and provides some functions such as clear_color, but also allows you to draw with the rendering pipeline.

In order to draw something, you will need to pass:

Once you have finished drawing, you can call frame.finish() to swap buffers and present the result to the user.

OpenGL equivalents in glium

Modules

backend

The backend module allows one to link between glium and the OpenGL context..

buffer

A buffer is a memory location accessible to the video card.

debug
draw_parameters

Describes miscellaneous parameters to be used when drawing.

framebuffer

Framebuffers allow you to customize the color, depth and stencil buffers you will draw on.

glutin

The purpose of this library is to provide an OpenGL context on as many platforms as possible.

index

In order to draw, you need to provide a way for the video card to know how to link primitives together.

pixel_buffer

DEPRECATED. Moved to the texture module.

program

Items related to creating an OpenGL program.

texture

A texture is an image loaded in video memory, which can be sampled in your shaders.

uniforms

A uniform is a global variable in your program. In order to draw something, you will need to give glium the values of all your uniforms. Objects that implement the Uniform trait are here to do that.

vertex

Contains everything related to vertex sources.

Structs

Blend

Blend effect that the GPU will use for blending.

BlitTarget

Area of a surface in pixels. Similar to a Rect except that dimensions can be negative.

Depth

Represents the depth parameters of a draw command.

Display

A GL context combined with a facade for drawing upon.

DrawParameters

Represents the parameters to use when drawing.

Frame

Implementation of Surface, targeting the default framebuffer.

HeadlessRenderer

A headless glutin context.

IncompatibleOpenGl

Returned during Context creation if the OpenGL implementation is too old.

IndexBuffer

A list of indices loaded in the graphics card's memory.

LinearSyncFence

Prototype for a SyncFence.

Program

A combination of shaders linked together.

Rect

Area of a surface in pixels.

SyncFence

Provides a way to wait for a server-side operation to be finished.

Texture2d

A two-dimensional texture containing floating-point data.

Version

Describes a version.

VertexBuffer

A list of vertices loaded in the graphics card's memory.

Enums

Api

Describes an OpenGL-related API.

BackfaceCullingMode

Describes how triangles should be filtered before the fragment processing. Backface culling is purely an optimization. If you don't know what this does, just use CullingDisabled.

BlendingFunction

Function that the GPU will use for blending.

DepthTest

The function that the GPU will use to determine whether to write over an existing pixel on the target.

DrawError

Error that can happen while drawing.

Handle

Handle to a shader or a program.

LinearBlendingFactor

Indicates which value to multiply each component with.

PolygonMode

Defines how the device should render polygons.

Profile

Describes the OpenGL context profile.

ProgramCreationError

Error that can be triggered when creating a Program.

RawUniformValue

A raw value of a uniform. "Raw" means that it's passed directly with glUniform. Textures for example are just passed as integers.

Smooth

Specifies a hint for the smoothing.

StencilOperation

Specificies which operation the GPU will do depending on the result of the stencil test.

StencilTest

Specifies which comparison the GPU will do to determine whether a sample passes the stencil test. The general equation is (ref & mask) CMP (stencil & mask), where ref is the reference value (stencil_reference_value_clockwise or stencil_reference_value_counter_clockwise), CMP is the comparison chosen, and stencil is the current value in the stencil buffer.

SwapBuffersError

Error that can happen when swapping buffers.

Traits

CapabilitiesSource

Trait for objects that describe the capabilities of an OpenGL backend.

GlObject

Trait for objects that are OpenGL objects.

Surface

Object that can be drawn upon.

Vertex

Trait for structures that represent a vertex.

Functions

get_supported_glsl_version

Given an API version, this function returns the GLSL version that the implementation is required to support.

Type Definitions

VertexFormat

Describes the layout of each vertex in a vertex buffer.