graphicscommand: Add IsShaderAvailable for other packages

This commit is contained in:
Hajime Hoshi 2020-05-24 19:15:18 +09:00
parent c5aba02723
commit 465d8aa273
3 changed files with 14 additions and 25 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/shaderir"
"github.com/hajimehoshi/ebiten/internal/web"
)
var theGraphicsDriver driver.Graphics
@ -39,6 +40,17 @@ func NeedsRestoring() bool {
return theGraphicsDriver.NeedsRestoring()
}
// IsShaderAvailable reports whether shaders are available. This function is only for testing.
func IsShaderAvailable() bool {
if !theGraphicsDriver.IsGL() {
return false
}
if web.IsBrowser() {
return false
}
return true
}
// command represents a drawing command.
//
// A command for drawing that is created when Image functions are called like DrawTriangles,

View File

@ -1,19 +0,0 @@
// Copyright 2020 The Ebiten 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.
package graphicscommand
func IsGL() bool {
return theGraphicsDriver.IsGL()
}

View File

@ -23,7 +23,6 @@ import (
. "github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/shaderir"
t "github.com/hajimehoshi/ebiten/internal/testing"
"github.com/hajimehoshi/ebiten/internal/web"
)
func TestMain(m *testing.M) {
@ -82,11 +81,8 @@ func TestReplacePixelsPartAfterDrawTriangles(t *testing.T) {
}
func TestShader(t *testing.T) {
if !IsGL() {
t.Skip("shader is not implemented on non-GL environment")
}
if web.IsBrowser() {
t.Skip("shader is not implemented on browsers")
if !IsShaderAvailable() {
t.Skip("shader is not implemented on this environment")
}
const w, h = 16, 16