gl: add bind_attrib_location, also add gl cleanup functions
parent
c9f3a05ef6
commit
a0ed1e2878
34
vlib/gl/gl.v
34
vlib/gl/gl.v
|
@ -22,9 +22,11 @@ fn C.glScissor()
|
|||
fn C.glVertexAttribPointer()
|
||||
fn C.glGenBuffers()
|
||||
fn C.glEnableVertexAttribArray()
|
||||
fn C.glDisableVertexAttribArray()
|
||||
fn C.glGenVertexArrays()
|
||||
fn C.glDrawElements()
|
||||
fn C.glUseProgram()
|
||||
fn C.glValidateProgram()
|
||||
fn C.glDrawArrays()
|
||||
fn C.glBufferData()
|
||||
fn C.glGenerateMipmap()
|
||||
|
@ -41,10 +43,12 @@ fn C.glDeleteShader()
|
|||
fn C.glGetProgramiv()
|
||||
fn C.glLinkProgram()
|
||||
fn C.glAttachShader()
|
||||
fn C.glDetachShader()
|
||||
fn C.glGetShaderiv()
|
||||
fn C.glCompileShader()
|
||||
fn C.glShaderSource()
|
||||
fn C.glCreateProgram() int
|
||||
fn C.glDeleteProgram()
|
||||
fn C.glClear()
|
||||
fn C.glCreateShader() int
|
||||
fn C.glClearColor()
|
||||
|
@ -54,8 +58,10 @@ fn C.glPixelStorei()
|
|||
fn C.glBlendFunc()
|
||||
fn C.glPolygonMode()
|
||||
fn C.glDeleteBuffers()
|
||||
fn C.glDeleteVertexArrays()
|
||||
fn C.glGetUniformLocation() int
|
||||
fn C.glGetAttribLocation() int
|
||||
fn C.glBindAttribLocation()
|
||||
|
||||
|
||||
pub fn init_glad() {
|
||||
|
@ -86,6 +92,10 @@ pub fn create_program() int {
|
|||
return C.glCreateProgram()
|
||||
}
|
||||
|
||||
pub fn delete_program(program int) {
|
||||
C.glDeleteProgram(program)
|
||||
}
|
||||
|
||||
pub fn shader_source(shader, a int, source string, b int) {
|
||||
C.glShaderSource(shader, a, &source.str, b)
|
||||
}
|
||||
|
@ -105,6 +115,10 @@ pub fn attach_shader(program, shader int) {
|
|||
C.glAttachShader(program, shader)
|
||||
}
|
||||
|
||||
pub fn detach_shader(program, shader int) {
|
||||
C.glDetachShader(program, shader)
|
||||
}
|
||||
|
||||
pub fn link_program(program int) {
|
||||
C.glLinkProgram(program)
|
||||
}
|
||||
|
@ -115,6 +129,10 @@ pub fn get_program_link_status(program int) int {
|
|||
return success
|
||||
}
|
||||
|
||||
pub fn validate_program(program int) {
|
||||
C.glValidateProgram(program)
|
||||
}
|
||||
|
||||
pub fn delete_shader(shader int) {
|
||||
C.glDeleteShader(shader)
|
||||
}
|
||||
|
@ -182,6 +200,14 @@ pub fn set_ebo(ebo u32, indices []int, draw_typ int) {
|
|||
gl.buffer_data_int(C.GL_ELEMENT_ARRAY_BUFFER, indices, draw_typ)
|
||||
}
|
||||
|
||||
pub fn delete_buffer(vbo u32) {
|
||||
C.glDeleteBuffers(1, vbo)
|
||||
}
|
||||
|
||||
pub fn delete_vao(vao u32) {
|
||||
C.glDeleteVertexArrays(1, vao)
|
||||
}
|
||||
|
||||
// /////////////////////
|
||||
// fn gen_vertex_arrays(a int, vao uint) {
|
||||
// # glGenVertexArrays(a, &VAO);
|
||||
|
@ -197,6 +223,10 @@ pub fn get_attrib_location(program int, key string) int {
|
|||
return C.glGetAttribLocation(program, key.str)
|
||||
}
|
||||
|
||||
pub fn bind_attrib_location(program int, index int, name string) {
|
||||
C.glBindAttribLocation(program, index, name.str)
|
||||
}
|
||||
|
||||
pub fn draw_arrays(typ, start, len int) {
|
||||
C.glDrawArrays(typ, start, len)
|
||||
}
|
||||
|
@ -219,6 +249,10 @@ pub fn enable_vertex_attrib_array(n int) {
|
|||
C.glEnableVertexAttribArray(n)
|
||||
}
|
||||
|
||||
pub fn disable_vertex_attrib_array(n int) {
|
||||
C.glDisableVertexAttribArray(n)
|
||||
}
|
||||
|
||||
pub fn gen_buffer() u32 {
|
||||
vbo := u32(0)
|
||||
C.glGenBuffers(1, &vbo)
|
||||
|
|
Loading…
Reference in New Issue