2021-12-17 07:03:23 +01:00
|
|
|
// Copyright 2021 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.
|
|
|
|
|
2022-08-12 05:40:23 +02:00
|
|
|
//go:build nintendosdk
|
2021-12-17 07:03:23 +01:00
|
|
|
|
2022-02-06 08:08:22 +01:00
|
|
|
package ui
|
2021-12-17 07:03:23 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
|
2022-12-16 10:34:14 +01:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
2022-03-21 16:02:37 +01:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
2022-03-22 15:33:21 +01:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
2022-08-12 10:19:28 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/nintendosdk"
|
2021-12-17 07:03:23 +01:00
|
|
|
)
|
|
|
|
|
2022-06-16 19:10:29 +02:00
|
|
|
type graphicsDriverCreatorImpl struct{}
|
2022-03-22 15:33:21 +01:00
|
|
|
|
2022-07-30 19:56:16 +02:00
|
|
|
func (g *graphicsDriverCreatorImpl) newAuto() (graphicsdriver.Graphics, GraphicsLibrary, error) {
|
|
|
|
graphics, err := g.newOpenGL()
|
|
|
|
return graphics, GraphicsLibraryOpenGL, err
|
2022-03-22 15:33:21 +01:00
|
|
|
}
|
|
|
|
|
2022-06-16 19:10:29 +02:00
|
|
|
func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) {
|
2022-11-13 07:25:22 +01:00
|
|
|
return opengl.NewGraphics()
|
2022-03-22 15:33:21 +01:00
|
|
|
}
|
|
|
|
|
2022-06-17 04:39:43 +02:00
|
|
|
func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) {
|
|
|
|
return nil, nil
|
2022-03-25 11:43:32 +01:00
|
|
|
}
|
|
|
|
|
2022-06-16 19:10:29 +02:00
|
|
|
func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|
|
|
return nil, nil
|
2022-03-22 15:33:21 +01:00
|
|
|
}
|
|
|
|
|
2021-12-17 07:03:23 +01:00
|
|
|
const deviceScaleFactor = 1
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
runtime.LockOSThread()
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
type userInterfaceImpl struct {
|
2022-03-21 16:02:37 +01:00
|
|
|
graphicsDriver graphicsdriver.Graphics
|
|
|
|
|
2022-12-16 10:34:14 +01:00
|
|
|
context *context
|
|
|
|
inputState InputState
|
|
|
|
nativeTouches []nintendosdk.Touch
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-12-09 06:07:04 +01:00
|
|
|
func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error {
|
2022-04-01 10:59:44 +02:00
|
|
|
u.context = newContext(game)
|
2022-12-09 06:07:04 +01:00
|
|
|
g, err := newGraphicsDriver(&graphicsDriverCreatorImpl{}, options.GraphicsLibrary)
|
2022-03-22 15:33:21 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
u.graphicsDriver = g
|
2022-08-12 10:19:28 +02:00
|
|
|
nintendosdk.InitializeGame()
|
2021-12-17 07:03:23 +01:00
|
|
|
for {
|
2022-08-12 10:19:28 +02:00
|
|
|
nintendosdk.BeginFrame()
|
2022-12-16 10:34:14 +01:00
|
|
|
gamepad.Update()
|
|
|
|
u.updateInputState()
|
2021-12-17 07:03:23 +01:00
|
|
|
|
2022-08-12 10:19:28 +02:00
|
|
|
w, h := nintendosdk.ScreenSize()
|
2022-09-25 17:46:03 +02:00
|
|
|
if err := u.context.updateFrame(u.graphicsDriver, float64(w), float64(h), deviceScaleFactor, u); err != nil {
|
2021-12-17 07:03:23 +01:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-08-12 10:19:28 +02:00
|
|
|
nintendosdk.EndFrame()
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) DeviceScaleFactor() float64 {
|
2021-12-17 07:03:23 +01:00
|
|
|
return deviceScaleFactor
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) IsFocused() bool {
|
2021-12-17 07:03:23 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) ScreenSizeInFullscreen() (int, int) {
|
2021-12-17 07:03:23 +01:00
|
|
|
return 0, 0
|
|
|
|
}
|
|
|
|
|
2022-12-20 01:52:13 +01:00
|
|
|
func (u *userInterfaceImpl) readInputState(inputState *InputState) {
|
|
|
|
*inputState = u.inputState
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *userInterfaceImpl) resetForTick() {
|
|
|
|
u.inputState.resetForTick()
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) CursorMode() CursorMode {
|
2022-02-06 09:43:52 +01:00
|
|
|
return CursorModeHidden
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) SetCursorMode(mode CursorMode) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) CursorShape() CursorShape {
|
2022-02-06 09:43:52 +01:00
|
|
|
return CursorShapeDefault
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) SetCursorShape(shape CursorShape) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) IsFullscreen() bool {
|
2021-12-17 07:03:23 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) SetFullscreen(fullscreen bool) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) IsRunnableOnUnfocused() bool {
|
2021-12-17 07:03:23 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) SetRunnableOnUnfocused(runnableOnUnfocused bool) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) SetFPSMode(mode FPSModeType) {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:00:50 +01:00
|
|
|
func (*userInterfaceImpl) ScheduleFrame() {
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
|
|
|
|
2022-05-31 19:09:10 +02:00
|
|
|
func (*userInterfaceImpl) Window() Window {
|
|
|
|
return &nullWindow{}
|
2021-12-17 07:03:23 +01:00
|
|
|
}
|
2022-09-25 17:34:11 +02:00
|
|
|
|
2022-12-20 01:52:13 +01:00
|
|
|
func (u *userInterfaceImpl) beginFrame() {
|
2022-09-25 17:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (u *userInterfaceImpl) endFrame() {
|
|
|
|
}
|
2022-12-09 13:23:41 +01:00
|
|
|
|
|
|
|
func IsScreenTransparentAvailable() bool {
|
|
|
|
return false
|
|
|
|
}
|