class Prism::Model

Overview

Represents a 3d model that has been loaded into opengl.

Defined in:

prism/model/loader.cr
prism/model/model.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(vao_id : LibGL::UInt, vbos : Array(LibGL::UInt), vertex_count : Int32, num_attrib_arrays : Int32) #

Creates a new model The vao_id is the vertex array object id. the vbos are just an array of vertex buffers that should be deleted when the object is garbage collected. The vertex_count is how many verticies are in the model. the num_attrib_arrays indicates how many vertex attribute arrays need to be used.


[View source]

Class Method Detail

def self.load(vertices : Array(Float32), texture_coords : Array(Float32), normals : Array(Float32), indicies : Array(Int32)) : Prism::Model #

Loads some raw data into open gl and returns a model object that can be used for drawing. This is designed to load 3d vertices


[View source]
def self.load(file_name : String) : Prism::Model #

Loads an OBJ file into opengl and returns a model object that can be used for drawing.


[View source]
def self.load(data : ModelData) : Prism::Model #

[View source]
def self.load_2f(vertices : Array(Float32)) #

Loads some 2d vertices into a model. This is useful for creating models for the GUI


[View source]
def self.load_3f(vertices : Array(Float32)) #

Loads some 3d vertices into a model.


[View source]

Instance Method Detail

def bind #

[View source]
def draw #

Convenience method to draw the model. This draws using LibGL::TRIANGLES. You can always manually draw using the #bind and #unbind mthods.


[View source]
def finalize #

Deletes the vertex array and buffers durring garbage collection.


[View source]
def unbind #

[View source]
def vao_id : UInt32 #

[View source]
def vertex_count : Int32 #

[View source]