mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphicsdriver/metal: Add setView for iOS and non-iOS
This commit is contained in:
parent
3ce8babd9b
commit
ea284d86fd
@ -26,7 +26,6 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/mainthread"
|
"github.com/hajimehoshi/ebiten/internal/mainthread"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -617,9 +616,7 @@ func (d *Driver) Reset() error {
|
|||||||
func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter, address graphics.Address) error {
|
func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode, colorM *affine.ColorM, filter graphics.Filter, address graphics.Address) error {
|
||||||
if err := mainthread.Run(func() error {
|
if err := mainthread.Run(func() error {
|
||||||
// NSView can be changed anytime (probably). Set this everyframe.
|
// NSView can be changed anytime (probably). Set this everyframe.
|
||||||
cocoaWindow := ns.NewWindow(unsafe.Pointer(d.window))
|
setView(d.window, d.ml)
|
||||||
cocoaWindow.ContentView().SetLayer(d.ml)
|
|
||||||
cocoaWindow.ContentView().SetWantsLayer(true)
|
|
||||||
|
|
||||||
rpd := mtl.RenderPassDescriptor{}
|
rpd := mtl.RenderPassDescriptor{}
|
||||||
if d.dst.screen {
|
if d.dst.screen {
|
||||||
|
26
internal/graphicsdriver/metal/view_ios.go
Normal file
26
internal/graphicsdriver/metal/view_ios.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2019 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 darwin
|
||||||
|
// +build ios
|
||||||
|
|
||||||
|
package metal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setView(window uintptr, layer ca.MetalLayer) {
|
||||||
|
// TODO: Implement this
|
||||||
|
}
|
31
internal/graphicsdriver/metal/view_notios.go
Normal file
31
internal/graphicsdriver/metal/view_notios.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2019 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 darwin
|
||||||
|
// +build !ios
|
||||||
|
|
||||||
|
package metal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setView(window uintptr, layer ca.MetalLayer) {
|
||||||
|
cocoaWindow := ns.NewWindow(unsafe.Pointer(window))
|
||||||
|
cocoaWindow.ContentView().SetLayer(layer)
|
||||||
|
cocoaWindow.ContentView().SetWantsLayer(true)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user