Gl

Trait Gl 

Source
pub trait Gl:
    Debug
    + Renderable<Buffer = Self::Buffer, Vertices = Vertices<Self>, Texture = Self::Texture, Material = Material, IndexAccessor = BufferView<Self>, DataAccessor = BufferView<Self>>
    + Debug {
    type Program: GlProgram;
    type Buffer: GlBuffer;
    type Vao: GlVao;
    type Texture;
    type PipelineDesc<'a>: Deserialize<'a>;

Show 14 methods // Required methods fn create_pipeline<F: Fn(&str) -> Result<String, String>>( &mut self, read_src: &F, pipeline_desc: Box<Self::PipelineDesc<'_>>, ) -> Result<Self::Program, String>; fn use_program(&self, program: Option<&Self::Program>); fn init_buffer_of_indices( &mut self, buffer: &mut <Self as Gl>::Buffer, view: &BufferIndexAccessor<'_, Self>, ); fn uniform_buffer_create<F: Sized>( &mut self, _data: &[F], _is_dynamic: bool, ) -> Result<UniformBuffer<Self>, ()>; fn uniform_buffer_update_data<F: Debug>( &mut self, _uniform_buffer: &UniformBuffer<Self>, _data: &[F], _byte_offset: u32, ); fn uniform_index_of_range( &mut self, _uniform_buffer: &UniformBuffer<Self>, _gl_uindex: u32, _byte_offset: usize, _byte_length: usize, ); fn vao_create_from_indices( &mut self, indices: &IndexBuffer<Self>, ) -> Result<Self::Vao, ()>; fn buffer_bind_to_vao_attr( &mut self, buffer: &<Self as Gl>::Buffer, attr_id: &<<Self as Gl>::Program as GlProgram>::GlAttrId, count: u32, ele_type: BufferElementType, byte_offset: u32, stride: u32, ); fn program_set_uniform_mat4( &mut self, program: &Self::Program, id: UniformId, mat4: &Mat4, ); fn program_set_uniform_floats_4( &mut self, program: &Self::Program, id: UniformId, floats: &[f32], ); fn program_bind_uniform_index( &mut self, program: &<Self as Gl>::Program, uniform_buffer_id: usize, gl_uindex: u32, ) -> Result<(), ()>; fn program_use_texture( &mut self, program: &<Self as Gl>::Program, texture_id: TextureId, gl_texture: &<Self as Gl>::Texture, ); fn draw_primitive(&mut self, vaos: &[Self::Vao], primitive: &Primitive); fn bind_vao(&mut self, vao: Option<&Self::Vao>);
}
Expand description

This must provide Debug as Rust requires a type that is generic on a type of trait Gl to have that generic support Debug in order to derive Debug on the type.

The same is true of Clone, but that is too burdensome for Gl

Required Associated Types§

Required Methods§

Source

fn create_pipeline<F: Fn(&str) -> Result<String, String>>( &mut self, read_src: &F, pipeline_desc: Box<Self::PipelineDesc<'_>>, ) -> Result<Self::Program, String>

Source

fn use_program(&self, program: Option<&Self::Program>)

Use the program

Source

fn init_buffer_of_indices( &mut self, buffer: &mut <Self as Gl>::Buffer, view: &BufferIndexAccessor<'_, Self>, )

Create the OpenGL ELEMENT_ARRAY_BUFFER buffer using STATIC_DRAW - this copies the data in to OpenGL

Source

fn uniform_buffer_create<F: Sized>( &mut self, _data: &[F], _is_dynamic: bool, ) -> Result<UniformBuffer<Self>, ()>

Create a uniform buffer (a GlBuffer in the GPU bound to GlUniformBuffer)

Fill the data; if is_dynamic is true then make it dynamic draw

Source

fn uniform_buffer_update_data<F: Debug>( &mut self, _uniform_buffer: &UniformBuffer<Self>, _data: &[F], _byte_offset: u32, )

Update (a portion) of a uniform GlBuffer

Source

fn uniform_index_of_range( &mut self, _uniform_buffer: &UniformBuffer<Self>, _gl_uindex: u32, _byte_offset: usize, _byte_length: usize, )

Set the GPU’s UniformBlockMatrix index N to a range of a UniformBuffer

Source

fn vao_create_from_indices( &mut self, indices: &IndexBuffer<Self>, ) -> Result<Self::Vao, ()>

Create a VAO, add the indices as its element array buffer, and leave it bound

Source

fn buffer_bind_to_vao_attr( &mut self, buffer: &<Self as Gl>::Buffer, attr_id: &<<Self as Gl>::Program as GlProgram>::GlAttrId, count: u32, ele_type: BufferElementType, byte_offset: u32, stride: u32, )

With the currently bound VAO add this view of the specified buffer as an attribute of the program, if the program has that attribute

Source

fn program_set_uniform_mat4( &mut self, program: &Self::Program, id: UniformId, mat4: &Mat4, )

Source

fn program_set_uniform_floats_4( &mut self, program: &Self::Program, id: UniformId, floats: &[f32], )

Source

fn program_bind_uniform_index( &mut self, program: &<Self as Gl>::Program, uniform_buffer_id: usize, gl_uindex: u32, ) -> Result<(), ()>

Source

fn program_use_texture( &mut self, program: &<Self as Gl>::Program, texture_id: TextureId, gl_texture: &<Self as Gl>::Texture, )

Activate the required texture unit and set the program’s uniform to that unit, and bind the Gl texture to the unit

The texture unit and uniform are specified by the program, and can be gathered from program and texture_id

Source

fn draw_primitive(&mut self, vaos: &[Self::Vao], primitive: &Primitive)

Draw the specified primitive using its VAO index into the vaos slice

Source

fn bind_vao(&mut self, vao: Option<&Self::Vao>)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Gl for Model3DOpenGL

Source§

type Program = Program

Source§

type Buffer = Buffer

Source§

type Vao = Vao

Source§

type Texture = Texture

Source§

type PipelineDesc<'a> = PipelineDesc

Source§

impl Gl for Model3DWebGL

Source§

type Program = Program

Source§

type Buffer = Buffer

Source§

type Vao = Vao

Source§

type Texture = Texture

Source§

type PipelineDesc<'a> = PipelineDesc