mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 01:42:05 +01:00
internal/graphicsdriver/opengl, internal/graphicsdriver/opengl/gl: refactoring
This commit is contained in:
parent
6fd18150d8
commit
12ae411d15
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
|
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package gl
|
package gl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2014 Eric Woroshow
|
// SPDX-FileCopyrightText: 2014 Eric Woroshow
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
//go:build !darwin && !js && !windows
|
//go:build !darwin && !js && !windows && !playstation5
|
||||||
|
|
||||||
package gl
|
package gl
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -39,7 +40,9 @@ func run() error {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
if _, err := f.WriteString(`// Copyright 2023 The Ebitengine Authors
|
out := bufio.NewWriter(f)
|
||||||
|
|
||||||
|
if _, err := fmt.Fprintf(out, `// Copyright 2023 The Ebitengine Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -55,6 +58,8 @@ func run() error {
|
|||||||
|
|
||||||
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
|
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
package gl
|
package gl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -67,7 +72,7 @@ type DebugContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ Context = (*DebugContext)(nil)
|
var _ Context = (*DebugContext)(nil)
|
||||||
`); err != nil {
|
`, "//go:build !playstation5"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,32 +96,32 @@ var _ Context = (*DebugContext)(nil)
|
|||||||
outNames = append(outNames, fmt.Sprintf("out%d", j))
|
outNames = append(outNames, fmt.Sprintf("out%d", j))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(f, "\nfunc (d *DebugContext) %s(%s) (%s) {\n", name, strings.Join(argNamesAndTypes, ", "), strings.Join(outTypes, ",")); err != nil {
|
if _, err := fmt.Fprintf(out, "\nfunc (d *DebugContext) %s(%s) (%s) {\n", name, strings.Join(argNamesAndTypes, ", "), strings.Join(outTypes, ",")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(outTypes) > 0 {
|
if len(outTypes) > 0 {
|
||||||
if _, err := fmt.Fprintf(f, "\t%s := ", strings.Join(outNames, ", ")); err != nil {
|
if _, err := fmt.Fprintf(out, "\t%s := ", strings.Join(outNames, ", ")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if _, err := fmt.Fprintf(f, "\t"); err != nil {
|
if _, err := fmt.Fprintf(out, "\t"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(f, "d.Context.%s(%s)\n", name, strings.Join(argNames, ", ")); err != nil {
|
if _, err := fmt.Fprintf(out, "d.Context.%s(%s)\n", name, strings.Join(argNames, ", ")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print logs.
|
// Print logs.
|
||||||
if name != "LoadFunctions" && name != "IsES" {
|
if name != "LoadFunctions" && name != "IsES" {
|
||||||
if _, err := fmt.Fprintf(f, "\tfmt.Fprintln(os.Stderr, %q)\n", name); err != nil {
|
if _, err := fmt.Fprintf(out, "\tfmt.Fprintln(os.Stderr, %q)\n", name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check errors.
|
// Check errors.
|
||||||
if name != "LoadFunctions" && name != "IsES" && name != "GetError" {
|
if name != "LoadFunctions" && name != "IsES" && name != "GetError" {
|
||||||
if _, err := fmt.Fprintf(f, ` if e := d.Context.GetError(); e != NO_ERROR {
|
if _, err := fmt.Fprintf(out, ` if e := d.Context.GetError(); e != NO_ERROR {
|
||||||
panic(fmt.Sprintf("gl: GetError() returned %%d at %s", e))
|
panic(fmt.Sprintf("gl: GetError() returned %%d at %s", e))
|
||||||
}
|
}
|
||||||
`, name); err != nil {
|
`, name); err != nil {
|
||||||
@ -125,15 +130,19 @@ var _ Context = (*DebugContext)(nil)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(outTypes) > 0 {
|
if len(outTypes) > 0 {
|
||||||
if _, err := fmt.Fprintf(f, "\treturn %s\n", strings.Join(outNames, ", ")); err != nil {
|
if _, err := fmt.Fprintf(out, "\treturn %s\n", strings.Join(outNames, ", ")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(f, "}\n"); err != nil {
|
if _, err := fmt.Fprintf(out, "}\n"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := out.Flush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package gl
|
package gl
|
||||||
|
|
||||||
//go:generate go run gen.go
|
//go:generate go run gen.go
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !js
|
//go:build !js && !playstation5
|
||||||
|
|
||||||
package gl
|
package gl
|
||||||
|
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2023 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 playstation5
|
|
||||||
|
|
||||||
package gl
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *defaultContext) init() error {
|
|
||||||
return errors.New("gl: defaultContext is not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *defaultContext) getProcAddress(name string) (uintptr, error) {
|
|
||||||
return 0, errors.New("gl: defaultContext is not implemented")
|
|
||||||
}
|
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,48 +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
|
|
||||||
|
|
||||||
package opengl
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewGraphics creates an implementation of graphicsdriver.Graphics for OpenGL.
|
|
||||||
// The returned graphics value is nil iff the error is not nil.
|
|
||||||
func NewGraphics() (graphicsdriver.Graphics, error) {
|
|
||||||
if microsoftgdk.IsXbox() {
|
|
||||||
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, err := gl.NewDefaultContext()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return newGraphics(ctx), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Graphics) makeContextCurrent() {
|
|
||||||
// TODO: Implement this (#2714).
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Graphics) swapBuffers() {
|
|
||||||
// TODO: Implement this (#2714).
|
|
||||||
}
|
|
@ -17,11 +17,38 @@
|
|||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl/gl"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewGraphics creates an implementation of graphicsdriver.Graphics for OpenGL.
|
||||||
|
// The returned graphics value is nil iff the error is not nil.
|
||||||
|
func NewGraphics() (graphicsdriver.Graphics, error) {
|
||||||
|
if microsoftgdk.IsXbox() {
|
||||||
|
return nil, fmt.Errorf("opengl: OpenGL is not supported on Xbox")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, err := gl.NewDefaultContext()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return newGraphics(ctx), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) makeContextCurrent() {
|
||||||
|
// TODO: Implement this (#2714).
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graphics) swapBuffers() {
|
||||||
|
// TODO: Implement this (#2714).
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Graphics) SetGLFWClientAPI() error {
|
func (g *Graphics) SetGLFWClientAPI() error {
|
||||||
if g.context.ctx.IsES() {
|
if g.context.ctx.IsES() {
|
||||||
if err := glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI); err != nil {
|
if err := glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI); err != nil {
|
||||||
|
@ -41,9 +41,7 @@ func NewGraphics(context mgl.Context) (graphicsdriver.Graphics, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) makeContextCurrent() {
|
func (g *Graphics) makeContextCurrent() {
|
||||||
// TODO: Implement this (#2714).
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) swapBuffers() {
|
func (g *Graphics) swapBuffers() {
|
||||||
// TODO: Implement this (#2714).
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
type locationCache struct {
|
type locationCache struct {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !playstation5
|
||||||
|
|
||||||
package opengl
|
package opengl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
Reference in New Issue
Block a user