mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
parent
bd3f16dbba
commit
9cb1ff9cea
@ -147,6 +147,18 @@ func (ml MetalLayer) NextDrawable() (MetalDrawable, error) {
|
|||||||
return MetalDrawable{md}, nil
|
return MetalDrawable{md}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetFramebufferOnly sets a Boolean value that determines whether the layer’s textures are used only for rendering.
|
||||||
|
//
|
||||||
|
// https://developer.apple.com/documentation/quartzcore/cametallayer/1478168-framebufferonly
|
||||||
|
func (ml MetalLayer) SetFramebufferOnly(framebufferOnly bool) {
|
||||||
|
switch framebufferOnly {
|
||||||
|
case true:
|
||||||
|
C.MetalLayer_SetFramebufferOnly(ml.metalLayer, 1)
|
||||||
|
case false:
|
||||||
|
C.MetalLayer_SetFramebufferOnly(ml.metalLayer, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MetalDrawable is a displayable resource that can be rendered or written to by Metal.
|
// MetalDrawable is a displayable resource that can be rendered or written to by Metal.
|
||||||
//
|
//
|
||||||
// Reference: https://developer.apple.com/documentation/quartzcore/cametaldrawable.
|
// Reference: https://developer.apple.com/documentation/quartzcore/cametaldrawable.
|
||||||
|
@ -30,5 +30,6 @@ void MetalLayer_SetDisplaySyncEnabled(void *metalLayer,
|
|||||||
uint8_t displaySyncEnabled);
|
uint8_t displaySyncEnabled);
|
||||||
void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height);
|
void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height);
|
||||||
void *MetalLayer_NextDrawable(void *metalLayer);
|
void *MetalLayer_NextDrawable(void *metalLayer);
|
||||||
|
void MetalLayer_SetFramebufferOnly(void *metalLayer, uint8_t framebufferOnly);
|
||||||
|
|
||||||
void *MetalDrawable_Texture(void *drawable);
|
void *MetalDrawable_Texture(void *drawable);
|
||||||
|
@ -98,3 +98,7 @@ void *MetalLayer_NextDrawable(void *metalLayer) {
|
|||||||
void *MetalDrawable_Texture(void *metalDrawable) {
|
void *MetalDrawable_Texture(void *metalDrawable) {
|
||||||
return ((id<CAMetalDrawable>)metalDrawable).texture;
|
return ((id<CAMetalDrawable>)metalDrawable).texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MetalLayer_SetFramebufferOnly(void *metalLayer, uint8_t framebufferOnly) {
|
||||||
|
[((CAMetalLayer *)metalLayer) setFramebufferOnly:framebufferOnly];
|
||||||
|
}
|
||||||
|
@ -1215,7 +1215,7 @@ func (i *Image) mtlTexture() mtl.Texture {
|
|||||||
if i.screen {
|
if i.screen {
|
||||||
g := i.graphics
|
g := i.graphics
|
||||||
if g.screenDrawable == (ca.MetalDrawable{}) {
|
if g.screenDrawable == (ca.MetalDrawable{}) {
|
||||||
drawable := g.view.drawable()
|
drawable := g.view.nextDrawable()
|
||||||
if drawable == (ca.MetalDrawable{}) {
|
if drawable == (ca.MetalDrawable{}) {
|
||||||
return mtl.Texture{}
|
return mtl.Texture{}
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,12 @@ func (v *view) reset() error {
|
|||||||
|
|
||||||
// The vsync state might be reset. Set the state again (#1364).
|
// The vsync state might be reset. Set the state again (#1364).
|
||||||
v.ml.SetDisplaySyncEnabled(v.vsync)
|
v.ml.SetDisplaySyncEnabled(v.vsync)
|
||||||
|
v.ml.SetFramebufferOnly(true)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *view) drawable() ca.MetalDrawable {
|
func (v *view) nextDrawable() ca.MetalDrawable {
|
||||||
d, err := v.ml.NextDrawable()
|
d, err := v.ml.NextDrawable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Drawable is nil. This can happen at the initial state. Let's wait and see.
|
// Drawable is nil. This can happen at the initial state. Let's wait and see.
|
||||||
|
Loading…
Reference in New Issue
Block a user