Revert "internal/graphicsdriver/opengl/gl: refactoring"

This reverts commit c9cff69dcb.

Reason: compmile error for browsers
This commit is contained in:
Hajime Hoshi 2022-11-14 02:17:27 +09:00
parent c9cff69dcb
commit e87e4ffbd2
13 changed files with 42 additions and 35 deletions

View File

@ -41,10 +41,6 @@ func (defaultContext) Init() error {
return nil
}
func (defaultContext) IsES() bool {
return true
}
func (defaultContext) ActiveTexture(texture uint32) {
C.glActiveTexture(C.GLenum(texture))
}

View File

@ -406,10 +406,6 @@ func boolToInt(b bool) int {
return 0
}
func (c *defaultContext) IsES() bool {
return isES
}
func (c *defaultContext) ActiveTexture(texture uint32) {
C.glowActiveTexture(c.gpActiveTexture, (C.GLenum)(texture))
}

View File

@ -107,10 +107,6 @@ func boolToInt(b bool) int {
return 0
}
func (c *defaultContext) IsES() bool {
return isES
}
func (c *defaultContext) ActiveTexture(texture uint32) {
purego.SyscallN(c.gpActiveTexture, uintptr(texture))
}

View File

@ -39,10 +39,6 @@ func (g *gomobileContext) Init() error {
return nil
}
func (g *gomobileContext) IsES() bool {
return true
}
func (g *gomobileContext) ActiveTexture(texture uint32) {
g.ctx.ActiveTexture(gl.Enum(texture))
}

View File

@ -20,7 +20,6 @@ package gl
// See https://pkg.go.dev/golang.org/x/mobile/gl#Context
type Context interface {
Init() error
IsES() bool
ActiveTexture(texture uint32)
AttachShader(program uint32, shader uint32)

View File

@ -18,15 +18,11 @@ import (
"github.com/ebitengine/purego"
)
var (
opengl uintptr
isES bool
)
var opengl uintptr
func init() {
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGLES.framework/Versions/Current/OpenGLES", purego.RTLD_GLOBAL)
if opengl != 0 {
isES = true
return
}
opengl = purego.Dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", purego.RTLD_GLOBAL)

View File

@ -28,8 +28,6 @@ import "C"
import "unsafe"
var isES = false
func getProcAddress(namea string) unsafe.Pointer {
cname := C.CString(namea)
defer C.free(unsafe.Pointer(cname))

View File

@ -35,8 +35,6 @@ import (
"unsafe"
)
var isES = true
func getProcAddress(namea string) unsafe.Pointer {
const ext = "EXT"
if strings.HasSuffix(namea, ext) {

View File

@ -28,8 +28,6 @@ import "C"
import "unsafe"
var isES = false
func getProcAddress(namea string) unsafe.Pointer {
cname := C.CString(namea)
defer C.free(unsafe.Pointer(cname))

View File

@ -24,7 +24,6 @@ import (
var (
opengl32 = windows.NewLazySystemDLL("opengl32")
procWglGetProcAddress = opengl32.NewProc("wglGetProcAddress")
isES = false
)
func getProcAddress(namea string) uintptr {

View File

@ -16,7 +16,6 @@ package opengl
import (
"fmt"
"runtime"
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
@ -266,11 +265,7 @@ func (g *Graphics) SetFullscreen(fullscreen bool) {
}
func (g *Graphics) NeedsRestoring() bool {
// Though it is possible to have a logic to restore the graphics data for GPU, do not use it for performance (#1603).
if runtime.GOOS == "js" {
return false
}
return g.context.ctx.IsES()
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