graphicsdriver/opengl: Use GL_RGBA8 as the internal format at glTexImage2D

Related: #810
This commit is contained in:
Hajime Hoshi 2019-02-09 21:25:36 +09:00
parent 815f2a6b35
commit f5044f3d8f
3 changed files with 4 additions and 2 deletions

View File

@ -145,7 +145,7 @@ func (c *context) newTexture(width, height int) (textureNative, error) {
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
// If data is nil, this just allocates memory and the content is undefined.
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, nil)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, nil)
return nil
})
return texture, nil

View File

@ -172,6 +172,8 @@ func (c *context) newTexture(width, height int) (textureNative, error) {
// In Ebiten, textures are filled with pixels laster by the filter that ignores destination, so it is fine
// to leave textures as uninitialized here. Rather, extra memory allocating for initialization should be
// avoided.
// gl.RGBA8 is available as of WebGL 2.
gl.Call("texImage2D", texture2d, 0, rgba, width, height, 0, rgba, unsignedByte, nil)
return textureNative(t), nil

View File

@ -130,7 +130,7 @@ func (c *context) newTexture(width, height int) (textureNative, error) {
gl.TexParameteri(mgl.TEXTURE_2D, mgl.TEXTURE_MIN_FILTER, mgl.NEAREST)
gl.TexParameteri(mgl.TEXTURE_2D, mgl.TEXTURE_WRAP_S, mgl.CLAMP_TO_EDGE)
gl.TexParameteri(mgl.TEXTURE_2D, mgl.TEXTURE_WRAP_T, mgl.CLAMP_TO_EDGE)
gl.TexImage2D(mgl.TEXTURE_2D, 0, mgl.RGBA, width, height, mgl.RGBA, mgl.UNSIGNED_BYTE, nil)
gl.TexImage2D(mgl.TEXTURE_2D, 0, mgl.RGBA8, width, height, mgl.RGBA, mgl.UNSIGNED_BYTE, nil)
return textureNative(t), nil
}