internal/graphicsdriver/opengl: make context_gles.go closer to context_gl.go

Updates #2451
This commit is contained in:
Hajime Hoshi 2022-11-13 14:18:20 +09:00
parent 0c5a77eaa4
commit 5cfb7c9469
6 changed files with 44 additions and 15 deletions

View File

@ -464,10 +464,6 @@ func (c *context) flush() {
gl.Flush()
}
func (c *context) needsRestoring() bool {
return false
}
func (c *context) texSubImage2D(t textureNative, args []*graphicsdriver.WritePixelsArgs) {
c.bindTexture(t)
for _, a := range args {

View File

@ -194,7 +194,9 @@ func (c *context) newRenderbuffer(width, height int) (renderbufferNative, error)
renderbuffer := renderbufferNative(r)
c.bindRenderbuffer(renderbuffer)
c.ctx.RenderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, int32(width), int32(height))
// GL_STENCIL_INDEX8 might not be available with OpenGL 2.1.
// https://www.khronos.org/opengl/wiki/Image_Format
c.ctx.RenderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, int32(width), int32(height))
return renderbuffer, nil
}
@ -439,10 +441,6 @@ func (c *context) flush() {
c.ctx.Flush()
}
func (c *context) needsRestoring() bool {
return true
}
func (c *context) texSubImage2D(t textureNative, args []*graphicsdriver.WritePixelsArgs) {
c.bindTexture(t)
for _, a := range args {

View File

@ -570,11 +570,6 @@ func (c *context) flush() {
c.gl.flush.Invoke()
}
func (c *context) needsRestoring() bool {
// Though it is possible to have a logic to restore the graphics data for GPU, do not use it for performance (#1603).
return false
}
func (c *context) texSubImage2D(t textureNative, args []*graphicsdriver.WritePixelsArgs) {
c.bindTexture(t)
for _, a := range args {

View File

@ -279,7 +279,7 @@ func (g *Graphics) SetFullscreen(fullscreen bool) {
}
func (g *Graphics) NeedsRestoring() bool {
return g.context.needsRestoring()
return needsRestoring
}
func (g *Graphics) NeedsClearingScreen() bool {

View File

@ -0,0 +1,21 @@
// Copyright 2022 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !opengles
package opengl
// Though it is possible to have a logic to restore the graphics data for GPU, do not use it for performance (#1603).
const needsRestoring = false

View File

@ -0,0 +1,19 @@
// Copyright 2022 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build android || ios || opengles
package opengl
const needsRestoring = true