Add 'ebitengl' build tag to force to use GL

Fixes #958
This commit is contained in:
Hajime Hoshi 2019-10-13 16:26:01 +09:00
parent 5027bc1af5
commit 83f93df78b
6 changed files with 27 additions and 5 deletions

View File

@ -79,6 +79,15 @@ func invokeOriginalGobind(lang string) (pkgName string, err error) {
return pkgs[0].Name, nil return pkgs[0].Name, nil
} }
func forceGL() bool {
for _, tag := range strings.Split(*tags, ",") {
if tag == "ebitengl" {
return true
}
}
return false
}
func run() error { func run() error {
writeFile := func(filename string, content string) error { writeFile := func(filename string, content string) error {
if err := ioutil.WriteFile(filepath.Join(*outdir, filename), []byte(content), 0644); err != nil { if err := ioutil.WriteFile(filepath.Join(*outdir, filename), []byte(content), 0644); err != nil {
@ -100,6 +109,12 @@ func run() error {
content = strings.ReplaceAll(content, "{{.PrefixUpper}}", prefixUpper) content = strings.ReplaceAll(content, "{{.PrefixUpper}}", prefixUpper)
content = strings.ReplaceAll(content, "{{.PrefixLower}}", prefixLower) content = strings.ReplaceAll(content, "{{.PrefixLower}}", prefixLower)
content = strings.ReplaceAll(content, "{{.JavaPkg}}", *javaPkg) content = strings.ReplaceAll(content, "{{.JavaPkg}}", *javaPkg)
f := "0"
if forceGL() {
f = "1"
}
content = strings.ReplaceAll(content, "{{.ForceGL}}", f)
return content return content
} }
@ -135,7 +150,7 @@ const objcM = `// Code generated by ebitenmobile. DO NOT EDIT.
#import <TargetConditionals.h> #import <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR #if TARGET_IPHONE_SIMULATOR || {{.ForceGL}}
#define EBITEN_METAL 0 #define EBITEN_METAL 0
#else #else
#define EBITEN_METAL 1 #define EBITEN_METAL 1

File diff suppressed because one or more lines are too long

7
doc.go
View File

@ -51,4 +51,11 @@
// In the API document, 'the main thread' means the goroutine in init(), main() and their callees without 'go' // In the API document, 'the main thread' means the goroutine in init(), main() and their callees without 'go'
// statement. It is assured that 'the main thread' runs on the OS main thread. There are some Ebiten functions that // statement. It is assured that 'the main thread' runs on the OS main thread. There are some Ebiten functions that
// must be called on the main thread under some conditions (typically, before ebiten.Run is called). // must be called on the main thread under some conditions (typically, before ebiten.Run is called).
//
// Build tags
//
// 'ebitendebug' outputs a log of graphics commands. This is useful to know what happens in Ebiten. In general, the
// number of graphics commands affects the performance of your game.
//
// 'ebitengl' forces to use OpenGL in any environments.
package ebiten package ebiten

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
// +build darwin,ios,arm darwin,ios,arm64 // +build darwin,ios,arm darwin,ios,arm64
// +build !ebitengl
package ebiten package ebiten

View File

@ -14,6 +14,7 @@
// +build darwin,!ios // +build darwin,!ios
// +build !js // +build !js
// +build !ebitengl
package ebiten package ebiten

View File

@ -12,9 +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.
// +build android darwin,ios,386 darwin,ios,amd64 freebsd js linux windows // +build android darwin,ios,386 darwin,ios,amd64 freebsd js linux windows ebitengl
// As the Go playground tries to compile this with CGO_ENABLED=0 and GOOS=linux, check Cgo on build tags.
package ebiten package ebiten