disable mipmaping in Texture
This commit is contained in:
parent
2a5fddabd8
commit
de21a40184
|
@ -4,6 +4,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/go-gl/gl/v3.3-core/gl"
|
"github.com/go-gl/gl/v3.3-core/gl"
|
||||||
|
"github.com/go-gl/mathgl/mgl32"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Texture is an OpenGL texture.
|
// Texture is an OpenGL texture.
|
||||||
|
@ -47,19 +48,19 @@ func NewTexture(width, height int, smooth bool, pixels []uint8) *Texture {
|
||||||
gl.Ptr(pixels),
|
gl.Ptr(pixels),
|
||||||
)
|
)
|
||||||
|
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT)
|
borderColor := mgl32.Vec4{0, 0, 0, 0}
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT)
|
gl.TexParameterfv(gl.TEXTURE_2D, gl.TEXTURE_BORDER_COLOR, &borderColor[0])
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_BORDER)
|
||||||
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_BORDER)
|
||||||
|
|
||||||
if smooth {
|
if smooth {
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
|
||||||
} else {
|
} else {
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST)
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
|
||||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
|
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.GenerateMipmap(gl.TEXTURE_2D)
|
|
||||||
|
|
||||||
runtime.SetFinalizer(tex, (*Texture).delete)
|
runtime.SetFinalizer(tex, (*Texture).delete)
|
||||||
|
|
||||||
return tex
|
return tex
|
||||||
|
|
Loading…
Reference in New Issue