Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/graphicsdriver/metal: remove C for macOS #2243

Merged
merged 39 commits into from
Aug 17, 2022
Merged
Changes from 26 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4dc947b
purego
TotallyGamerJet Jul 31, 2022
e441d7e
purego
TotallyGamerJet Jul 31, 2022
9ba8adf
Merge branch 'main' into purego
TotallyGamerJet Aug 12, 2022
c3c63a2
remove C from metal
TotallyGamerJet Aug 13, 2022
2351c07
change fields
TotallyGamerJet Aug 13, 2022
3fbee33
fix unsafe.Pointer
TotallyGamerJet Aug 13, 2022
913cd0c
fix warnings on iOS
TotallyGamerJet Aug 13, 2022
75513af
add license
TotallyGamerJet Aug 13, 2022
4c8f8b0
reoganize imports
TotallyGamerJet Aug 13, 2022
4e13a01
unify CFLAGS
TotallyGamerJet Aug 13, 2022
3a5d5bc
remove null terminator
TotallyGamerJet Aug 13, 2022
ebcd8ca
remove runtime.GOOS for iOS checks since it is not available in Go 1.15
TotallyGamerJet Aug 13, 2022
3e725a1
renamed cocoasdk to cocoa
TotallyGamerJet Aug 13, 2022
8c8c860
change signatures
TotallyGamerJet Aug 13, 2022
341fe6a
make sure to link to QuartzCore
TotallyGamerJet Aug 13, 2022
4197847
Revert "change signatures"
TotallyGamerJet Aug 13, 2022
ad8e98f
add CGFloat
TotallyGamerJet Aug 13, 2022
84bd67c
cast to CGFloat
TotallyGamerJet Aug 13, 2022
8137074
link to needed frameworks
TotallyGamerJet Aug 13, 2022
85f9b20
Merge branch 'main' into purego
TotallyGamerJet Aug 13, 2022
7aa96db
update purego
TotallyGamerJet Aug 13, 2022
b943167
remove null terminators
TotallyGamerJet Aug 14, 2022
f155a97
rename NSMethodSignature class methods
TotallyGamerJet Aug 14, 2022
34feddc
Revert "remove runtime.GOOS for iOS checks since it is not available …
TotallyGamerJet Aug 14, 2022
fc4d829
replace GOOS == "ios" with IsIOS constant
TotallyGamerJet Aug 15, 2022
fac77f5
rename NSInvocation class method
TotallyGamerJet Aug 15, 2022
ac8360e
rename ios files
TotallyGamerJet Aug 15, 2022
d3cc0ec
rename isios to ios
TotallyGamerJet Aug 15, 2022
0d0f8eb
rename IsIOS files
TotallyGamerJet Aug 16, 2022
f16408c
replace runtime.GOOS checks with IsIOS
TotallyGamerJet Aug 16, 2022
9c3a320
remove unnecessary Dlopen's
TotallyGamerJet Aug 16, 2022
2b09b20
set Cap in SliceHeader
TotallyGamerJet Aug 16, 2022
dea536f
update purego
TotallyGamerJet Aug 16, 2022
146d8ce
Add Documentation
TotallyGamerJet Aug 16, 2022
324bfd5
refactor
TotallyGamerJet Aug 16, 2022
19b0536
fix unknown type NSString in Send
TotallyGamerJet Aug 16, 2022
32619da
remove unnecessary casts
TotallyGamerJet Aug 16, 2022
27b6e93
reorder imports
TotallyGamerJet Aug 16, 2022
fd60f25
Update example_darwin_test.go
TotallyGamerJet Aug 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ module github.com/hajimehoshi/ebiten/v2
go 1.15

require (
github.com/ebitengine/purego v0.0.0-20220729024107-78cdc2949de6
github.com/ebitengine/purego v0.0.0-20220813165658-375146121d78
TotallyGamerJet marked this conversation as resolved.
Show resolved Hide resolved
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad
github.com/hajimehoshi/bitmapfont/v2 v2.2.1
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ebitengine/purego v0.0.0-20220729024107-78cdc2949de6 h1:kc3Im5Yj31aW0r3VdXHk+urwClkQilDBAYYp0TXeqE8=
github.com/ebitengine/purego v0.0.0-20220729024107-78cdc2949de6/go.mod h1:Eh8I3yvknDYZeCuXH9kRNaPuHEwvXDCk378o9xszmHg=
github.com/ebitengine/purego v0.0.0-20220813165658-375146121d78 h1:+Yx0vA2ATOEzEm3T3YTgh/jDKZukShDqJdxP7wTj93c=
github.com/ebitengine/purego v0.0.0-20220813165658-375146121d78/go.mod h1:Eh8I3yvknDYZeCuXH9kRNaPuHEwvXDCk378o9xszmHg=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad h1:kX51IjbsJPCvzV9jUoVQG9GEUqIq5hjfYzXTqQ52Rh8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20220806181222-55e207c401ad/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/hajimehoshi/bitmapfont/v2 v2.2.1 h1:y7zcy02/UgO24IL3COqYtrRZzhRucNBtmCo/SNU648k=
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Ebiten Authors
// 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.
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "stdint.h"
package cocoa

void *Window_ContentView(uintptr_t window);
type CGFloat float64

void View_SetLayer(void *view, void *layer);
void View_SetWantsLayer(void *view, unsigned char wantsLayer);
uint8_t View_IsInFullScreenMode(void *view);
type CGSize struct {
Width, Height CGFloat
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The Ebiten Authors
// Copyright 2022 The Ebitengine Authors
TotallyGamerJet marked this conversation as resolved.
Show resolved Hide resolved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,21 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "ns_darwin.h"
#import <Cocoa/Cocoa.h>
//go:build ios
// +build ios

void *Window_ContentView(uintptr_t window) {
return ((NSWindow *)window).contentView;
}
package cocoa

void View_SetLayer(void *view, void *layer) {
((NSView *)view).layer = (CALayer *)layer;
}

void View_SetWantsLayer(void *view, unsigned char wantsLayer) {
((NSView *)view).wantsLayer = (BOOL)wantsLayer;
}

uint8_t View_IsInFullScreenMode(void *view) {
return ((NSView *)view).isInFullScreenMode;
}
const IsIOS = true
20 changes: 20 additions & 0 deletions internal/cocoa/notIOS.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 The Ebitengine Authors
TotallyGamerJet marked this conversation as resolved.
Show resolved Hide resolved
//
// 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 !ios
// +build !ios

package cocoa

const IsIOS = false
61 changes: 61 additions & 0 deletions internal/cocoa/nsinvocation_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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.

package cocoa

import (
"unsafe"

"github.com/ebitengine/purego/objc"
)

var class_NSInvocation = objc.GetClass("NSInvocation")

var (
sel_invocationWithMethodSignature = objc.RegisterName("invocationWithMethodSignature:")

sel_setSelector = objc.RegisterName("setSelector:")
sel_setTarget = objc.RegisterName("setTarget:")
sel_setArgumentAtIndex = objc.RegisterName("setArgument:atIndex:")
sel_getReturnValue = objc.RegisterName("getReturnValue:")
sel_invoke = objc.RegisterName("invoke")
)

type NSInvocation struct {
objc.ID
}

func NSInvocation_invocationWithMethodSignature(sig NSMethodSignature) NSInvocation {
return NSInvocation{objc.ID(class_NSInvocation).Send(sel_invocationWithMethodSignature, objc.ID(sig))}
}

func (inv NSInvocation) SetSelector(_cmd objc.SEL) {
inv.Send(sel_setSelector, _cmd)
}

func (inv NSInvocation) SetTarget(target objc.ID) {
inv.Send(sel_setTarget, target)
}

func (inv NSInvocation) SetArgumentAtIndex(arg unsafe.Pointer, idx int) {
inv.Send(sel_setArgumentAtIndex, arg, idx)
}

func (inv NSInvocation) GetReturnValue(ret unsafe.Pointer) {
inv.Send(sel_getReturnValue, ret)
}

func (inv NSInvocation) Invoke() {
inv.Send(sel_invoke)
}
36 changes: 36 additions & 0 deletions internal/cocoa/nsmethodsignature_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

package cocoa

import (
"github.com/ebitengine/purego/objc"
)

var class_NSMethodSignature = objc.GetClass("NSMethodSignature")

var (
sel_instanceMethodSignatureForSelector = objc.RegisterName("instanceMethodSignatureForSelector:")
sel_signatureWithObjCTypes = objc.RegisterName("signatureWithObjCTypes:")
)

type NSMethodSignature objc.ID

func NSMethodSignature_InstanceMethodSignatureForSelector(self objc.ID, _cmd objc.SEL) NSMethodSignature {
return NSMethodSignature(self.Send(sel_instanceMethodSignatureForSelector, _cmd))
}

func NSMethodSignature_SignatureWithObjCTypes(types string) NSMethodSignature {
TotallyGamerJet marked this conversation as resolved.
Show resolved Hide resolved
return NSMethodSignature(objc.ID(class_NSMethodSignature).Send(sel_signatureWithObjCTypes, types))
}
Loading