mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
graphics: Don't call IsTexture on browsers
This commit is contained in:
parent
e53262bfac
commit
8614599c5c
@ -37,7 +37,7 @@ type graphicsContext struct {
|
|||||||
screen *Image
|
screen *Image
|
||||||
screenScale float64
|
screenScale float64
|
||||||
initialized int32
|
initialized int32
|
||||||
invalidated bool
|
invalidated bool // browser only
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) GLContext() *opengl.Context {
|
func (c *graphicsContext) GLContext() *opengl.Context {
|
||||||
@ -100,17 +100,6 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale flo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
|
|
||||||
if c.invalidated {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
|
|
||||||
if err := graphics.FlushCommands(context); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return c.offscreen.restorable.IsInvalidated(context), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *graphicsContext) initializeIfNeeded(context *opengl.Context) error {
|
func (c *graphicsContext) initializeIfNeeded(context *opengl.Context) error {
|
||||||
if atomic.LoadInt32(&c.initialized) == 0 {
|
if atomic.LoadInt32(&c.initialized) == 0 {
|
||||||
if err := graphics.Reset(context); err != nil {
|
if err := graphics.Reset(context); err != nil {
|
||||||
|
25
graphicscontext_js.go
Normal file
25
graphicscontext_js.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
// +build js
|
||||||
|
|
||||||
|
package ebiten
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
|
||||||
|
return c.invalidated, nil
|
||||||
|
}
|
30
graphicscontext_notjs.go
Normal file
30
graphicscontext_notjs.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
// +build !js
|
||||||
|
|
||||||
|
package ebiten
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
|
||||||
|
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
|
||||||
|
if err := graphics.FlushCommands(context); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return c.offscreen.restorable.IsInvalidated(context), nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user