internal/ui: refactoring: reduce opengles build tags

Updates #292
This commit is contained in:
Hajime Hoshi 2022-11-14 02:46:09 +09:00
parent 114a8aa6ea
commit 1e86e7fa18
3 changed files with 12 additions and 32 deletions

View File

@ -12,15 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk && !opengles
//go:build !android && !ios && !js && !nintendosdk
package ui
package opengl
import (
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
)
func setGLFWClientAPI() {
func (g *Graphics) SetGLFWClientAPI() {
if g.context.isES() {
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 0)
glfw.WindowHint(glfw.ContextCreationAPI, glfw.EGLContextAPI)
return
}
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLAPI)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 1)

View File

@ -906,7 +906,7 @@ func (u *userInterfaceImpl) init() error {
u.graphicsDriver.SetTransparent(u.isInitScreenTransparent())
if u.graphicsDriver.IsGL() {
setGLFWClientAPI()
u.graphicsDriver.(interface{ SetGLFWClientAPI() }).SetGLFWClientAPI()
} else {
glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
}

View File

@ -1,28 +0,0 @@
// 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 && !js && !nintendosdk && opengles
package ui
import (
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
)
func setGLFWClientAPI() {
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 0)
glfw.WindowHint(glfw.ContextCreationAPI, glfw.EGLContextAPI)
}