mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
graphicscommand: Add IsShaderAvailable for other packages
This commit is contained in:
parent
c5aba02723
commit
465d8aa273
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shaderir"
|
"github.com/hajimehoshi/ebiten/internal/shaderir"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
var theGraphicsDriver driver.Graphics
|
var theGraphicsDriver driver.Graphics
|
||||||
@ -39,6 +40,17 @@ func NeedsRestoring() bool {
|
|||||||
return theGraphicsDriver.NeedsRestoring()
|
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.
|
// command represents a drawing command.
|
||||||
//
|
//
|
||||||
// A command for drawing that is created when Image functions are called like DrawTriangles,
|
// A command for drawing that is created when Image functions are called like DrawTriangles,
|
||||||
|
@ -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()
|
|
||||||
}
|
|
@ -23,7 +23,6 @@ import (
|
|||||||
. "github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
. "github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shaderir"
|
"github.com/hajimehoshi/ebiten/internal/shaderir"
|
||||||
t "github.com/hajimehoshi/ebiten/internal/testing"
|
t "github.com/hajimehoshi/ebiten/internal/testing"
|
||||||
"github.com/hajimehoshi/ebiten/internal/web"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
@ -82,11 +81,8 @@ func TestReplacePixelsPartAfterDrawTriangles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestShader(t *testing.T) {
|
func TestShader(t *testing.T) {
|
||||||
if !IsGL() {
|
if !IsShaderAvailable() {
|
||||||
t.Skip("shader is not implemented on non-GL environment")
|
t.Skip("shader is not implemented on this environment")
|
||||||
}
|
|
||||||
if web.IsBrowser() {
|
|
||||||
t.Skip("shader is not implemented on browsers")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const w, h = 16, 16
|
const w, h = 16, 16
|
||||||
|
Loading…
Reference in New Issue
Block a user