gl: Remove C hashes

Remove C hashes from the gl code.
pull/769/head
lutherwenxu 2019-06-28 19:49:27 +08:00 committed by Alexander Medvednikov
parent b0bc53730c
commit ffa69921f5
1 changed files with 18 additions and 16 deletions

34
gl/gl.v
View File

@ -11,6 +11,12 @@ import const (
GL_VERTEX_SHADER GL_VERTEX_SHADER
GL_ELEMENT_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER
GL_DEPTH_TEST GL_DEPTH_TEST
GL_COLOR_BUFFER_BIT
GL_DEPTH_BUFFER_BIT
GL_STENCIL_BUFFER_BIT
GL_COMPILE_STATUS
GL_LINK_STATUS
GL_ARRAY_BUFFER
) )
// TODO: windows support // TODO: windows support
@ -33,11 +39,11 @@ pub fn viewport(a, b, c, d int) {
} }
pub fn clear_color(r, g, b, a int) { pub fn clear_color(r, g, b, a int) {
# glClearColor(((f32)r)/255.0,((f32)g)/255.0,b/255.0, a/255.0); C.glClearColor(f32(r)/255.0, f32(g)/255.0, f32(b)/255.0, f32(a)/255.0)
} }
pub fn clear() { pub fn clear() {
# glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); C.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)
} }
pub fn create_shader(typ int) int { pub fn create_shader(typ int) int {
@ -58,7 +64,7 @@ pub fn compile_shader(shader int) {
pub fn shader_compile_status(shader int) int { pub fn shader_compile_status(shader int) int {
success := 0 success := 0
# glGetShaderiv(shader, GL_COMPILE_STATUS, &success); C.glGetShaderiv(shader, GL_COMPILE_STATUS, &success)
return success return success
} }
@ -73,7 +79,7 @@ pub fn link_program(program int) {
pub fn get_program_link_status(program int) int { pub fn get_program_link_status(program int) int {
success := 0 success := 0
# glGetProgramiv(program, GL_LINK_STATUS, &success); C.glGetProgramiv(program, GL_LINK_STATUS, &success)
return success return success
} }
@ -82,19 +88,15 @@ pub fn delete_shader(shader int) {
} }
pub fn shader_info_log(shader int) string { pub fn shader_info_log(shader int) string {
# printf("GET info log\n"); infoLog := [512]byte
# char infoLog[512]; C.glGetShaderInfoLog(shader, 512, 0, infoLog)
# glGetShaderInfoLog(shader, 512, NULL, infoLog); return tos_clone(infoLog)
# printf("log=%s\n", infoLog);
# return tos2(infoLog);
return ''
} }
pub fn get_program_info_log(program int) string { pub fn get_program_info_log(program int) string {
# char infoLog[512]; infoLog := [1024]byte
# glGetProgramInfoLog(program, 1024, NULL, infoLog); C.glGetProgramInfoLog(program, 1024, 0, infoLog)
# return tos2(infoLog); return tos_clone(infoLog)
return ''
} }
pub fn bind_vao(vao u32) { pub fn bind_vao(vao u32) {
@ -166,7 +168,7 @@ pub fn use_program(program int) {
pub fn gen_vertex_array() u32 { pub fn gen_vertex_array() u32 {
VAO := u32(0) VAO := u32(0)
# glGenVertexArrays(1, &VAO); C.glGenVertexArrays(1, &VAO)
return VAO return VAO
} }
@ -176,7 +178,7 @@ pub fn enable_vertex_attrib_array(n int) {
pub fn gen_buffer() u32 { pub fn gen_buffer() u32 {
VBO := u32(0) VBO := u32(0)
# glGenBuffers(1, &VBO); C.glGenBuffers(1, &VBO)
return VBO return VBO
} }