pub(crate) struct Shader {
    pub(crate) id: u32,
}
Expand description

General information

A shader instance stores the id representing a combination of a vertex and fragment shader compiled (OpenGL Shading Language) and attached to an OpenGL program. Later on, an instance of such shader can be attached to an OpenGL context to use in conjunction with a series of vertices to draw to screen.

Fields

  • id - An id field setup by OpenGL to uniquely identify shaders being passed.

Fields§

§id: u32

Implementations§

General information

Creates a new shader program composed of both a vertex and a fragment shader. Since it uses gl crate, it’s necessary that an openGL context has been initialized. Unsafe part stops rust from caching errors while compiling shaders, therefore print statements will be sent to the terminal containing a message in case an error has happened. Later use of faulty shaders will stop the program from running, but debbuging becomes hard since little information is provided by the gl crate. Should enable logging errors at a later date. Regarding the steps the function uses: first it opens and read files to strings. Then, shaders are casted to CStrings. After that, each shader is sent to be compiled and linked to a u32 variable. Finally, the u32 varaibles are linked to an OpenGL program with an id and cache is erased (compiled programs are already associated to a program, therefore can be safely erased). This last id is returned inside Shader structure.

Parameters
  • vertex_path - Path to a vertex shader file.
  • fragment_path - Path to a fragment shader file.

Use a certain pair of shaders identified by id. Program can have multiple shaders at once, but only one can be used at a time.

Send a 4x4 matrix variable to vertex shader. Matrix variable has to be declared as a uniform in shader and it’s name must be known for this to work.

Trait Implementations§

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.