1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

remove "import const" everywhere

This commit is contained in:
Alexander Medvednikov
2019-08-23 00:00:31 +03:00
parent dcfc9eb1a1
commit f61b14584a
11 changed files with 172 additions and 308 deletions

View File

@@ -20,14 +20,6 @@ mut:
ext string
}
import const (
GL_RGBA
GL_RGB
GL_UNSIGNED_BYTE
GL_TEXTURE_2D
STBI_rgb_alpha
)
pub fn load(path string) Image {
ext := path.all_after('.')
mut res := Image {
@@ -35,14 +27,10 @@ pub fn load(path string) Image {
ext: ext
data: 0
}
if ext == 'png' {
res.data = C.stbi_load(path.str, &res.width, &res.height, &res.nr_channels, STBI_rgb_alpha)
}
else {
res.data = C.stbi_load(path.str, &res.width, &res.height, &res.nr_channels, 0)
}
flag := if ext == 'png' { C.STBI_rgb_alpha } else { 0 }
res.data = C.stbi_load(path.str, &res.width, &res.height, &res.nr_channels, flag)
if isnil(res.data) {
println('stbi cant load')
println('stbi image failed to load')
exit(1)
}
return res
@@ -53,12 +41,12 @@ pub fn (img Image) free() {
}
pub fn (img Image) tex_image_2d() {
mut rgb_flag := GL_RGB
mut rgb_flag := C.GL_RGB
if img.ext == 'png' {
rgb_flag = GL_RGBA
rgb_flag = C.GL_RGBA
}
C.glTexImage2D(GL_TEXTURE_2D, 0, rgb_flag, img.width, img.height, 0, rgb_flag, GL_UNSIGNED_BYTE,
img.data)
C.glTexImage2D(C.GL_TEXTURE_2D, 0, rgb_flag, img.width, img.height, 0,
rgb_flag, C.GL_UNSIGNED_BYTE, img.data)
}
pub fn set_flip_vertically_on_load(val bool) {