internal/graphicsdriver/opengl: refactoring: remove contextPlatform

This commit is contained in:
Hajime Hoshi 2023-04-22 21:52:20 +09:00
parent 8926a4213e
commit 40c38eb9ee
4 changed files with 9 additions and 66 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl" "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl"
"github.com/hajimehoshi/ebiten/v2/internal/shaderir" "github.com/hajimehoshi/ebiten/v2/internal/shaderir"
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/glsl"
) )
type blendFactor int type blendFactor int
@ -105,8 +106,6 @@ type context struct {
highp bool highp bool
highpOnce sync.Once highpOnce sync.Once
initOnce sync.Once initOnce sync.Once
contextPlatform
} }
func (c *context) bindTexture(t textureNative) { func (c *context) bindTexture(t textureNative) {
@ -482,3 +481,10 @@ func (c *context) newElementArrayBuffer(size int) buffer {
c.ctx.BufferInit(gl.ELEMENT_ARRAY_BUFFER, size, gl.DYNAMIC_DRAW) c.ctx.BufferInit(gl.ELEMENT_ARRAY_BUFFER, size, gl.DYNAMIC_DRAW)
return buffer(b) return buffer(b)
} }
func (c *context) glslVersion() glsl.GLSLVersion {
if c.ctx.IsES() {
return glsl.GLSLVersionES300
}
return glsl.GLSLVersionDefault
}

View File

@ -1,29 +0,0 @@
// Copyright 2014 Hajime Hoshi
//
// 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 opengl
import (
"syscall/js"
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/glsl"
)
type contextPlatform struct {
canvas js.Value
}
func (c *context) glslVersion() glsl.GLSLVersion {
return glsl.GLSLVersionES300
}

View File

@ -1,31 +0,0 @@
// Copyright 2014 Hajime Hoshi
//
// 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 !js
package opengl
import (
"github.com/hajimehoshi/ebiten/v2/internal/shaderir/glsl"
)
type contextPlatform struct {
}
func (c *context) glslVersion() glsl.GLSLVersion {
if c.ctx.IsES() {
return glsl.GLSLVersionES300
}
return glsl.GLSLVersionDefault
}

View File

@ -43,8 +43,5 @@ func NewGraphics(canvas js.Value) (graphicsdriver.Graphics, error) {
return nil, err return nil, err
} }
g := newGraphics(ctx) return newGraphics(ctx), nil
g.context.canvas = canvas
return g, nil
} }