Skip to content

Commit f950ebd

Browse files
Stary2001halotroop2288
authored andcommitted
Switch
Co-authored-by: Cpasjuste <[email protected]> Signed-off-by: Caroline Bell <[email protected]>
1 parent 6c81413 commit f950ebd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3263
-55
lines changed

.github/workflows/runner.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ jobs:
4444
name: 🏁 Windows
4545
needs: static-checks
4646
uses: ./.github/workflows/windows_builds.yml
47+
48+
switch-build:
49+
name: 🔄 Switch
50+
needs: static-checks
51+
uses: ./.github/workflows/switch_builds.yml

.github/workflows/switch_builds.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 🔄 Switch Builds
2+
on:
3+
workflow_call:
4+
5+
# Global Cache Settings
6+
env:
7+
GODOT_BASE_BRANCH: 3.5
8+
SCONS_CACHE_LIMIT: 4096
9+
10+
jobs:
11+
switch-template:
12+
runs-on: ubuntu-latest
13+
container: devkitpro/devkita64
14+
15+
name: Template (target=release, tools=no)
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
# Upload cache on completion and check it out now
21+
- name: Load .scons_cache directory
22+
id: switch-template-cache
23+
uses: actions/cache@v2
24+
with:
25+
path: ${{github.workspace}}/.scons_cache/
26+
key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
27+
restore-keys: |
28+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
29+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
30+
${{github.job}}-${{env.GODOT_BASE_BRANCH}}
31+
32+
- name: Install scons from pip
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get -y install python3-pip
36+
sudo python3 -m pip install scons
37+
38+
- name: Compilation
39+
env:
40+
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
41+
run: |
42+
scons -j2 verbose=yes warnings=all werror=no platform=switch target=release tools=no
43+
44+
- uses: actions/upload-artifact@v2
45+
with:
46+
name: ${{ github.job }}
47+
path: bin/*
48+
retention-days: 14

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,13 @@ $RECYCLE.BIN/
363363
*.msm
364364
*.msp
365365
*.lnk
366+
367+
# Templates
368+
templates/
369+
/*.zip
370+
/*.tpz
371+
372+
# Switch
373+
*.nro
374+
switch/
375+
config/nx-hbmenu/

README-switch.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Godot for Switch
2+
3+
It's a port of the Godot open source game engine to the Switch, via homebrew libraries provided by devkitPro/switchbrew.
4+
See the original [README.md](./README.md) for info about Godot.
5+
6+
## Releases
7+
8+
See [the GitHub releases page](https://github.com/Homebrodot/Godot/releases) for pre-built editors for Windows, macOS and
9+
Linux.
10+
11+
## How do I export my game?
12+
13+
The editor builds above add a `Switch` exporter to the list - it will generate a .nro and a .pck file that can be
14+
transferred to your Switch.
15+
If additional debugging is required, sending the nro via nxlink (make sure to send it to the right place with the -p
16+
argument) will allow the output of the console to be viewed on PC.
17+
18+
## How to build?
19+
20+
You shouldn't need to build the engine if you use a release as the templates should be included - these instructions are
21+
for development!
22+
23+
[See the official docs](https://docs.godotengine.org/en/latest/development/compiling/)
24+
for compilation instructions for every officially supported platform.
25+
26+
### For Switch:
27+
28+
Install these packages from [devkitPro pacman](https://devkitpro.org/wiki/devkitPro_pacman):
29+
`switch-pkg-config switch-freetype switch-bulletphysics switch-libtheora switch-libpcre2 switch-mesa switch-opusfile switch-mbedtls switch-libwebp switch-libvpx switch-miniupnpc switch-libzstd switch-wslay`
30+
then run `scons platform=switch` in the root of the repo. Add `target=release` to build for release instead of debug.
31+
32+
Then, to build an engine release for Switch,
33+
run `./scripts/create-switch-release.sh` in the root of the repo.
34+
35+
Or to build an export template for the editor,
36+
run `./scripts/create-switch-template.sh` in the root of the repo.
37+
38+
## How can I get help?
39+
40+
Either make an issue on this repo, or join the [Discord](https://discord.gg/yUC3rUk "Homebrodot - Godot Homebrew Hub")!
41+
42+
# Credits
43+
44+
* Thanks to devkitPro / switchbrew for producing devkitA64/libnx.
45+
* Extra special thanks to fincs from devkitPro - This port would have never been possible without their port of the open
46+
source nouveau graphics driver.
47+
* cpasjuste for help with development.
48+
* fhidalgosola/utnad for their port / help with development.

README.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,71 @@
1-
# Godot Engine
1+
[![Godot Engine logo](/logo.png)](https://godotengine.org)
22

3-
<p align="center">
4-
<a href="https://godotengine.org">
5-
<img src="logo_outlined.svg" width="400" alt="Godot Engine logo">
6-
</a>
7-
</p>
3+
## Godot Engine
84

9-
## 2D and 3D cross-platform game engine
5+
Homepage: https://godotengine.org
106

11-
**[Godot Engine](https://godotengine.org) is a feature-packed, cross-platform
12-
game engine to create 2D and 3D games from a unified interface.** It provides a
13-
comprehensive set of [common tools](https://godotengine.org/features), so that users can focus on making games
14-
without having to reinvent the wheel. Games can be exported with one click to a
15-
number of platforms, including the major desktop platforms (Linux, macOS,
16-
Windows), mobile platforms (Android, iOS), as well as Web-based platforms
17-
(HTML5) and
18-
[consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
7+
#### 2D and 3D cross-platform game engine
198

20-
## Free, open source and community-driven
9+
Godot Engine is a feature-packed, cross-platform game engine to create 2D and
10+
3D games from a unified interface. It provides a comprehensive set of common
11+
tools, so that users can focus on making games without having to reinvent the
12+
wheel. Games can be exported in one click to a number of platforms, including
13+
the major desktop platforms (Linux, Mac OSX, Windows) as well as mobile
14+
(Android, iOS) and web-based (HTML5) platforms.
2115

22-
Godot is completely free and open source under the very permissive [MIT license](https://godotengine.org/license).
16+
#### Free, open source and community-driven
17+
18+
Godot is completely free and open source under the very permissive MIT license.
2319
No strings attached, no royalties, nothing. The users' games are theirs, down
2420
to the last line of engine code. Godot's development is fully independent and
2521
community-driven, empowering users to help shape their engine to match their
26-
expectations. It is supported by the [Software Freedom Conservancy](https://sfconservancy.org/)
22+
expectations. It is supported by the Software Freedom Conservancy
2723
not-for-profit.
2824

29-
Before being open sourced in [February 2014](https://github.com/godotengine/godot/commit/0b806ee0fc9097fa7bda7ac0109191c9c5e0a1ac),
30-
Godot had been developed by [Juan Linietsky](https://github.com/reduz) and
31-
[Ariel Manzur](https://github.com/punto-) (both still maintaining the project) for several
25+
Before being open sourced in February 2014, Godot had been developed by Juan
26+
Linietsky and Ariel Manzur (both still maintaining the project) for several
3227
years as an in-house engine, used to publish several work-for-hire titles.
3328

34-
![Screenshot of a 3D scene in the Godot Engine editor](https://raw.githubusercontent.com/godotengine/godot-design/master/screenshots/editor_tps_demo_1920x1080.jpg)
29+
![Screenshot of a 3D scene in Godot Engine](https://download.tuxfamily.org/godotengine/media/screenshots/editor_3d_fracteed.jpg)
3530

36-
## Getting the engine
31+
### Getting the engine
3732

38-
### Binary downloads
33+
#### Binary downloads
3934

4035
Official binaries for the Godot editor and the export templates can be found
4136
[on the homepage](https://godotengine.org/download).
4237

43-
### Compiling from source
38+
#### Compiling from source
4439

4540
[See the official docs](https://docs.godotengine.org/en/latest/development/compiling/)
4641
for compilation instructions for every supported platform.
4742

48-
## Community and contributing
43+
### Community and contributing
4944

5045
Godot is not only an engine but an ever-growing community of users and engine
5146
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).
5247

53-
The best way to get in touch with the core engine developers is to join the
54-
[Godot Contributors Chat](https://chat.godotengine.org).
48+
To get in touch with the developers, the best way is to join the
49+
[#godotengine IRC channel](https://webchat.freenode.net/?channels=godotengine)
50+
on Freenode.
5551

5652
To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md).
5753

58-
## Documentation and demos
54+
### Documentation and demos
5955

6056
The official documentation is hosted on [ReadTheDocs](https://docs.godotengine.org).
6157
It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).
6258

6359
The [class reference](https://docs.godotengine.org/en/latest/classes/)
64-
is also accessible from the Godot editor.
60+
is also accessible from within the engine.
6561

66-
We also maintain official demos in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)
67-
as well as a list of [awesome Godot community resources](https://github.com/godotengine/awesome-godot).
62+
The official demos are maintained in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)
63+
as well.
6864

69-
There are also a number of other
70-
[learning resources](https://docs.godotengine.org/en/latest/community/tutorials.html)
71-
provided by the community, such as text and video tutorials, demos, etc.
72-
Consult the [community channels](https://godotengine.org/community)
73-
for more information.
65+
There are also a number of other learning resources provided by the community,
66+
such as text and video tutorials, demos, etc. Consult the [community channels](https://godotengine.org/community)
67+
for more info.
7468

75-
[![Actions Build Status](https://github.com/godotengine/godot/workflows/Godot/badge.svg?branch=master)](https://github.com/godotengine/godot/actions)
69+
[![Travis Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot)
70+
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/bfiihqq6byxsjxxh/branch/master?svg=true)](https://ci.appveyor.com/project/akien-mga/godot)
7671
[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
77-
[![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
78-
[![Total alerts on LGTM](https://img.shields.io/lgtm/alerts/g/godotengine/godot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/godotengine/godot/alerts)
79-
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/godotengine/godot)](https://www.tickgit.com/browse?repo=github.com/godotengine/godot)

core/project_settings.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
420420
}
421421
#endif
422422

423+
#ifdef HORIZON_ENABLED
424+
if (!found) {
425+
if (_load_resource_pack("romfs:/game.pck")) {
426+
found = true;
427+
}
428+
}
429+
#endif
430+
423431
if (!found) {
424432
// Try to load data pack at the location of the executable.
425433
// As mentioned above, we have two potential names to attempt.

drivers/gles2/rasterizer_storage_gles2.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,20 @@ GLuint RasterizerStorageGLES2::system_fbo = 0;
8989
#ifndef GLES_OVER_GL
9090
#define glClearDepth glClearDepthf
9191

92+
#if defined IPHONE_ENABLED || defined ANDROID_ENABLED
9293
// enable extensions manually for android and ios
9394
#ifndef UWP_ENABLED
9495
#include <dlfcn.h> // needed to load extensions
9596
#endif
97+
#endif
9698

9799
#ifdef IPHONE_ENABLED
98100

99101
#include <OpenGLES/ES2/glext.h>
100102
//void *glRenderbufferStorageMultisampleAPPLE;
101103
//void *glResolveMultisampleFramebufferAPPLE;
102104
#define glRenderbufferStorageMultisample glRenderbufferStorageMultisampleAPPLE
103-
#elif defined(ANDROID_ENABLED)
105+
#elif defined ANDROID_ENABLED || defined HORIZON_ENABLED
104106

105107
#include <GLES2/gl2ext.h>
106108
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glRenderbufferStorageMultisampleEXT;
@@ -6294,6 +6296,17 @@ void RasterizerStorageGLES2::initialize() {
62946296
config.render_to_mipmap_supported = config.extensions.has("GL_OES_fbo_render_mipmap") && config.extensions.has("GL_EXT_texture_lod");
62956297
#endif
62966298

6299+
// If the desktop build is using S3TC, and you export / run from the IDE for android, if the device supports
6300+
// S3TC it will crash trying to load these textures, as they are not exported in the APK. This is a simple way
6301+
// to prevent Android devices trying to load S3TC, by faking lack of hardware support.
6302+
6303+
// Switch: this happens on Horizon too.
6304+
#ifndef TOOLS_ENABLED
6305+
#if defined ANDROID_ENABLED || defined HORIZON_ENABLED
6306+
config.s3tc_supported = false;
6307+
#endif
6308+
#endif
6309+
62976310
#ifdef GLES_OVER_GL
62986311
config.use_rgba_2d_shadows = false;
62996312
config.support_depth_texture = true;

drivers/gles3/rasterizer_storage_gles3.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8086,11 +8086,10 @@ void RasterizerStorageGLES3::initialize() {
80868086
// If the desktop build is using S3TC, and you export / run from the IDE for android, if the device supports
80878087
// S3TC it will crash trying to load these textures, as they are not exported in the APK. This is a simple way
80888088
// to prevent Android devices trying to load S3TC, by faking lack of hardware support.
8089-
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED)
8089+
#if defined(ANDROID_ENABLED) || defined(IPHONE_ENABLED) || defined(HORIZON_ENABLED)
80908090
config.s3tc_supported = false;
80918091
#endif
80928092
#endif
8093-
80948093
// not yet detected on GLES3 (is this mandated?)
80958094
config.support_npot_repeat_mipmap = true;
80968095

drivers/unix/dir_access_unix.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ String DirAccessUnix::read_link(String p_file) {
413413

414414
p_file = fix_path(p_file);
415415

416+
#ifdef HORIZON_ENABLED
417+
return p_file;
418+
#else
416419
char buf[256];
417420
memset(buf, 0, 256);
418421
ssize_t len = readlink(p_file.utf8().get_data(), buf, sizeof(buf));
@@ -421,9 +424,13 @@ String DirAccessUnix::read_link(String p_file) {
421424
link.parse_utf8(buf, len);
422425
}
423426
return link;
427+
#endif
424428
}
425429

426430
Error DirAccessUnix::create_link(String p_source, String p_target) {
431+
#ifdef HORIZON_ENABLED
432+
return FAILED;
433+
#else
427434
if (p_target.is_rel_path())
428435
p_target = get_current_dir().plus_file(p_target);
429436

@@ -435,6 +442,7 @@ Error DirAccessUnix::create_link(String p_source, String p_target) {
435442
} else {
436443
return FAILED;
437444
}
445+
#endif
438446
}
439447

440448
uint64_t DirAccessUnix::get_space_left() {

drivers/unix/file_access_unix.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <errno.h>
4242

43-
#if defined(UNIX_ENABLED)
43+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
4444
#include <unistd.h>
4545
#endif
4646

@@ -130,6 +130,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
130130
return last_error;
131131
}
132132

133+
#ifndef HORIZON_ENABLED
133134
// Set close on exec to avoid leaking it to subprocesses.
134135
int fd = fileno(f);
135136

@@ -142,7 +143,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) {
142143
fcntl(fd, F_SETFD, opts | FD_CLOEXEC);
143144
#endif
144145
}
145-
146+
#endif
146147
last_error = OK;
147148
flags = p_mode_flags;
148149
return OK;
@@ -279,7 +280,7 @@ bool FileAccessUnix::file_exists(const String &p_path) {
279280
return false;
280281
}
281282

282-
#ifdef UNIX_ENABLED
283+
#if defined(UNIX_ENABLED) || defined(HORIZON_ENABLED)
283284
// See if we have access to the file
284285
if (access(filename.utf8().get_data(), F_OK)) {
285286
return false;

0 commit comments

Comments
 (0)