1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use super::enums::*;

use gl;
use gl::types::*;
use std::os::raw::c_void;

pub fn gl_gen_textures(count: GLsizei, texture: *mut GLuint) {
    unsafe {
        gl::GenTextures(count, texture);
    }
}

pub fn gl_active_texture(texture: GLuint) {
    unsafe {
        gl::ActiveTexture(gl::TEXTURE0 + texture);
    }
}

pub fn gl_bind_texture(target: GLTexTarget, texture: GLuint) {
    unsafe {
        gl::BindTexture(target as GLenum, texture);
    }
}

pub fn gl_delete_textures(count: GLsizei, texture: *mut GLuint) {
    unsafe {
        gl::DeleteTextures(count, texture);
    }
}

pub fn gl_tex_image_2d(
    target: GLTexTarget,
    level: GLint,
    internal_format: GLTexFormat,
    width: GLsizei,
    height: GLsizei,
    border: GLint,
    format: GLTexFormat,
    pixels: &Vec<u8>,
) {
    unsafe {
        gl::TexImage2D(
            target as GLenum,
            level,
            internal_format as i32,
            width,
            height,
            border,
            format as GLenum,
            gl::UNSIGNED_BYTE,
            pixels.as_ptr() as *const c_void,
        );
    }
}

pub fn gl_generate_mipmap(target: GLTexTarget) {
    unsafe {
        gl::GenerateMipmap(target as GLenum);
    }
}

pub fn gl_tex_parameteri(target: GLTexTarget, param_name: GLTexParamName, param: GLTexParam) {
    unsafe {
        gl::TexParameteri(target as GLenum, param_name as GLenum, param as GLenum as i32);
    }
}