mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-06 07:23:37 +08:00
sdl app now downshifts when backgrounded/minimized
This commit is contained in:
parent
ee8fec761b
commit
1dfc78e6dd
56
.efrocachemap
generated
56
.efrocachemap
generated
@ -4056,26 +4056,26 @@
|
|||||||
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
||||||
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
||||||
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
||||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "4d8d52da9915f4190afb737a12c2a4a6",
|
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "202a2e3e7dbb0fd70f631826c1dbaf0a",
|
||||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "34424d97b81cfc82cbbfe88e9978928b",
|
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "22ecb313cd505be3cd636b40b82aaf4e",
|
||||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "b719a269b2b7800b33df6e235630fe6a",
|
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "5c885286ec7d31db5beec842e0d74f04",
|
||||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "bf758fd915923d37fe79846181d46e7e",
|
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "fa8322a1fc0b158db47f22f8f67bce40",
|
||||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "542145537e5315ebf1f2e8cd6e2bdebc",
|
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "026341fd254d8192d6593c78ed106f9e",
|
||||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "e4776c2f7288079b56ba45aec3931a98",
|
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "c48a68814f8c4f9c14f75857ac721756",
|
||||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "4a2c6aa6ec4b13398dc468d07d149e31",
|
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "74da3142016212cd6ec612d3f4a04461",
|
||||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "afc1712caa72d1c81c2b310501fce1c3",
|
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "d0efb84cfb947c901c4b371a68c4983e",
|
||||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "8144382107928e18dbdda1cd94ef61c9",
|
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "5a34c14e75fe4cb23c15866e622a95b9",
|
||||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "e281fafc908a8bc56b9673197eb2ce09",
|
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "55eb23b8e4c58366a9206d19b7583b59",
|
||||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "4faf1ce6711ce63fe03e53931a636818",
|
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "14c485729c8c8dee8208e303eaa9c149",
|
||||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "ae6ebe1ae25ceb19bd16721eeecc8ff0",
|
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "a0f44a88e6452866610c77b988e82fbf",
|
||||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "1ee0eac0f087c62652cebf839f93b5be",
|
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "d9e990f175d61d32e825b9c9704a5883",
|
||||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "50dfea89bbaa44cf3c2e3f3e726c4294",
|
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "cf9a0ca90fad523d38aeafa4aa6d8abb",
|
||||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "655ab674cd46d6238e9776a19690db5c",
|
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "6a2df7fa5d02d4b353a408e33716d532",
|
||||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "746e00a43761362ad35947dbac10b418",
|
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "6cf962925756084b5dfde18a8ec46ecd",
|
||||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "0bb3c5679477cc060ddd822efbc84622",
|
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "39a7a8b26bfb1241af1983f478a32e17",
|
||||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "0dc3da0e30cd8016edd2e57db4e5e57e",
|
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "ecc017287c8665d20724b50d1d9fc114",
|
||||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "9b5a5c36c791f9bdc782872248976262",
|
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "c64f407e7f134b6961379f09b0b45f30",
|
||||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "c98d0387c178bbd7b94124d7d7b5c334",
|
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "68e9c85cb35bbf3bf44a81b913ba7d20",
|
||||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "ed4f56d8c3f411d4ee509d688fa75ed2",
|
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "ed4f56d8c3f411d4ee509d688fa75ed2",
|
||||||
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "7703e63545add0d6baf9a2c0c48a8ff0",
|
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "7703e63545add0d6baf9a2c0c48a8ff0",
|
||||||
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "ed4f56d8c3f411d4ee509d688fa75ed2",
|
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "ed4f56d8c3f411d4ee509d688fa75ed2",
|
||||||
@ -4092,14 +4092,14 @@
|
|||||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "7b1e17863d20f12dd11f13e0e9e94726",
|
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "7b1e17863d20f12dd11f13e0e9e94726",
|
||||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "4b5b600e7f830a92ed41e165afba0d29",
|
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "4b5b600e7f830a92ed41e165afba0d29",
|
||||||
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "7b1e17863d20f12dd11f13e0e9e94726",
|
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "7b1e17863d20f12dd11f13e0e9e94726",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "7eb2391ed4c9ed1f46dd6e83b71b1b62",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "3283c623553f920fa2f3a9ec0030ac0d",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "bd52a679e048fc3adbc6f06b8e4f6bc2",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "fbe90d6ae5948402094786f0f3780a43",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "0e4e93745d1059bcdefa0eeebc325fb6",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "da351ad49a02bf9ea47173971258aba4",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "c8412bc125285588dc1d8e723ce3d32e",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "8f2bec2e58845179da06bb3846ef1009",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "87b7984235393fc7169dce8c9a63eaac",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "2997bb1199bee10e628e4c05e8e3f91a",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "263c866d0c20317b900e4e5bad67c778",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "1439c19607ba8ecafbc601a848fe51da",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "dcfdbd19c9a6a8430a20e3e5a31b5b96",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "503be144a9e8836f71eff0abbd29c5ad",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "0cb59737b1fcbaa2aa12d6bf447aeedc",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "ee250e8c6a40bcfeda25cbc0df88486c",
|
||||||
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
||||||
"src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318",
|
"src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318",
|
||||||
"src/ballistica/base/mgen/pyembed/binding_base.inc": "9f71f171464dc004dbaab87e9bb4b03b",
|
"src/ballistica/base/mgen/pyembed/binding_base.inc": "9f71f171464dc004dbaab87e9bb4b03b",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
### 1.7.28 (build 21408, api 8, 2023-10-02)
|
### 1.7.28 (build 21409, api 8, 2023-10-03)
|
||||||
|
|
||||||
- Massively cleaned up code related to rendering and window systems (OpenGL,
|
- Massively cleaned up code related to rendering and window systems (OpenGL,
|
||||||
SDL, etc). This code had been growing into a nasty tangle for 15 years
|
SDL, etc). This code had been growing into a nasty tangle for 15 years
|
||||||
|
|||||||
@ -52,7 +52,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
# Build number and version of the ballistica binary we expect to be
|
# Build number and version of the ballistica binary we expect to be
|
||||||
# using.
|
# using.
|
||||||
TARGET_BALLISTICA_BUILD = 21408
|
TARGET_BALLISTICA_BUILD = 21409
|
||||||
TARGET_BALLISTICA_VERSION = '1.7.28'
|
TARGET_BALLISTICA_VERSION = '1.7.28'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,8 @@ class AppAdapter {
|
|||||||
/// called if ManagesMainThreadEventLoop() returns true.
|
/// called if ManagesMainThreadEventLoop() returns true.
|
||||||
virtual void DoExitMainThreadEventLoop();
|
virtual void DoExitMainThreadEventLoop();
|
||||||
|
|
||||||
/// Push a call to be run in the app's main thread.
|
/// Push a call to be run in the app's 'main' thread. This is the thread
|
||||||
|
/// where the OS generally expects event and UI processing to happen in.
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void PushMainThreadCall(const F& lambda) {
|
void PushMainThreadCall(const F& lambda) {
|
||||||
DoPushMainThreadRunnable(NewLambdaRunnableUnmanaged(lambda));
|
DoPushMainThreadRunnable(NewLambdaRunnableUnmanaged(lambda));
|
||||||
@ -57,7 +58,8 @@ class AppAdapter {
|
|||||||
/// implementation, this simply returns true in the main thread.
|
/// implementation, this simply returns true in the main thread.
|
||||||
virtual auto InGraphicsContext() -> bool;
|
virtual auto InGraphicsContext() -> bool;
|
||||||
|
|
||||||
/// Push a call to be run in the app's graphics context.
|
/// Push a call to be run in the app's graphics context. Be aware that
|
||||||
|
/// this may mean different threads on different platforms.
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void PushGraphicsContextCall(const F& lambda) {
|
void PushGraphicsContextCall(const F& lambda) {
|
||||||
DoPushGraphicsContextRunnable(NewLambdaRunnableUnmanaged(lambda));
|
DoPushGraphicsContextRunnable(NewLambdaRunnableUnmanaged(lambda));
|
||||||
|
|||||||
@ -107,52 +107,66 @@ void AppAdapterSDL::RunMainThreadEventLoopToCompletion() {
|
|||||||
while (!done_) {
|
while (!done_) {
|
||||||
microsecs_t cycle_start_time = g_core->GetAppTimeMicrosecs();
|
microsecs_t cycle_start_time = g_core->GetAppTimeMicrosecs();
|
||||||
|
|
||||||
// Run all pending events.
|
// Events.
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event) && (!done_)) {
|
while (SDL_PollEvent(&event) && (!done_)) {
|
||||||
HandleSDLEvent_(event);
|
HandleSDLEvent_(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a frame.
|
// Draw.
|
||||||
if (g_base->graphics_server->TryRender()) {
|
if (!hidden_ && g_base->graphics_server->TryRender()) {
|
||||||
SDL_GL_SwapWindow(sdl_window_);
|
SDL_GL_SwapWindow(sdl_window_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In some cases, sleep until we should start our next cycle (depending
|
// Sleep.
|
||||||
// on max-frame-rate or other factors).
|
|
||||||
SleepUntilNextEventCycle_(cycle_start_time);
|
SleepUntilNextEventCycle_(cycle_start_time);
|
||||||
|
|
||||||
|
// Repeat.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) {
|
void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) {
|
||||||
// Special case which means no max. Farewell poor laptop battery.
|
// Special case: if we're hidden, we simply sleep for a long bit; no fancy
|
||||||
|
// timing.
|
||||||
|
if (hidden_) {
|
||||||
|
g_core->platform->SleepMillisecs(100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special case which means no max, and thus no sleeping. Farewell poor
|
||||||
|
// laptop battery; we hardly knew ye.
|
||||||
if (max_fps_ == -1) {
|
if (max_fps_ == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normally we just calc when our next draw should happen and sleep 'til
|
||||||
|
// then.
|
||||||
microsecs_t now = g_core->GetAppTimeMicrosecs();
|
microsecs_t now = g_core->GetAppTimeMicrosecs();
|
||||||
auto used_max_fps = max_fps_;
|
auto used_max_fps = max_fps_;
|
||||||
millisecs_t millisecs_per_frame = 1000000 / used_max_fps;
|
millisecs_t millisecs_per_frame = 1000000 / used_max_fps;
|
||||||
// Special case: if we've got vsync enabled, let's tweak max-fps to be
|
|
||||||
// just a *tiny* bit higher than requested. This means if our max-fps
|
// Special case: if we've got vsync enabled, let's tweak our drawing to
|
||||||
// matches the refresh rate we'll be trying to render just a bit faster
|
// happen just a *tiny* bit faster than requested. This means, if our
|
||||||
// than vsync which should push us up against the vsync wall and keep
|
// max-fps matches the refresh rate, we'll be trying to render just a
|
||||||
// vsync doing most of the delay work. In that case the logging below
|
// *bit* faster than vsync which should push us up against the vsync wall
|
||||||
// should show mostly 'no sleep.'. Without this delay, our render
|
// and keep vsync doing most of the delay work. In that case the logging
|
||||||
|
// below should show mostly 'no sleep.'. Without this delay, our render
|
||||||
// kick-offs tend to drift around the middle of the vsync cycle and I
|
// kick-offs tend to drift around the middle of the vsync cycle and I
|
||||||
// worry there could be bad interference patterns in certain spots close
|
// worry there could be bad interference patterns in certain spots close
|
||||||
// to the edges. Note that we want this tweak to be small enough that it
|
// to the edges. Note that we want this tweak to be small enough that it
|
||||||
// won't be noticable in situations where vsync and max-fps *don't*
|
// won't be noticable in situations where vsync and max-fps *don't* match.
|
||||||
// match. (for instance limiting to 60hz on a 120hz vsynced monitor).
|
// For instance, limiting to 60hz on a 120hz vsynced monitor should still
|
||||||
|
// work as expected.
|
||||||
if (vsync_actually_enabled_) {
|
if (vsync_actually_enabled_) {
|
||||||
millisecs_per_frame = 99 * millisecs_per_frame / 100;
|
millisecs_per_frame = 99 * millisecs_per_frame / 100;
|
||||||
}
|
}
|
||||||
microsecs_t target_time = cycle_start_time + millisecs_per_frame - oversleep_;
|
microsecs_t target_time = cycle_start_time + millisecs_per_frame - oversleep_;
|
||||||
|
|
||||||
// Set a minimum so we don't sleep if we're within a few millisecs of
|
// Set a minimum so we don't sleep if we're within a few millisecs of
|
||||||
// where we want to be. Sleep tends to run over by a bit so we'll
|
// where we want to be. Sleep tends to run over by a bit so we'll probably
|
||||||
// probably render closer to our target time by just skipping the sleep.
|
// render closer to our target time by just skipping the sleep. And the
|
||||||
// And the oversleep system will compensate just as it does if we sleep
|
// oversleep system will compensate for our earliness just as it does if
|
||||||
// too long.
|
// we sleep too long.
|
||||||
const microsecs_t min_sleep{2000};
|
const microsecs_t min_sleep{2000};
|
||||||
if (now + min_sleep >= target_time) {
|
if (now + min_sleep >= target_time) {
|
||||||
if (debug_log_sdl_frame_timing_) {
|
if (debug_log_sdl_frame_timing_) {
|
||||||
@ -182,6 +196,7 @@ void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AppAdapterSDL::DoPushMainThreadRunnable(Runnable* runnable) {
|
void AppAdapterSDL::DoPushMainThreadRunnable(Runnable* runnable) {
|
||||||
|
// Our main thread is the SDL event loop, so add this as an SDL event.
|
||||||
assert(sdl_runnable_event_id_ != 0);
|
assert(sdl_runnable_event_id_ != 0);
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_memset(&event, 0, sizeof(event));
|
SDL_memset(&event, 0, sizeof(event));
|
||||||
@ -330,12 +345,19 @@ void AppAdapterSDL::HandleSDLEvent_(const SDL_Event& event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_HIDDEN: {
|
case SDL_WINDOWEVENT_HIDDEN: {
|
||||||
// PauseApp();
|
// Let's keep track of when we're hidden so we can stop drawing
|
||||||
|
// and sleep more. Theoretically we could put the app into a full
|
||||||
|
// suspended state like we do on mobile (pausing event loops/etc.)
|
||||||
|
// but that would be more involved; we'd need to ignore most SDL
|
||||||
|
// events while sleeping (except for SDL_WINDOWEVENT_SHOWN) and
|
||||||
|
// would need to rebuild our controller lists/etc when we resume.
|
||||||
|
// For now just gonna keep things simple and keep running.
|
||||||
|
hidden_ = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_SHOWN: {
|
case SDL_WINDOWEVENT_SHOWN: {
|
||||||
// ResumeApp();
|
hidden_ = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,20 +592,18 @@ void AppAdapterSDL::ReloadRenderer_(
|
|||||||
auto width = static_cast<int>(kBaseVirtualResX * 0.8f);
|
auto width = static_cast<int>(kBaseVirtualResX * 0.8f);
|
||||||
auto height = static_cast<int>(kBaseVirtualResY * 0.8f);
|
auto height = static_cast<int>(kBaseVirtualResY * 0.8f);
|
||||||
|
|
||||||
uint32_t flags = SDL_WINDOW_OPENGL
|
uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
|
||||||
| SDL_WINDOW_SHOWN
|
|
||||||
// | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
|
|
||||||
| SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE;
|
| SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE;
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Mac we ask for a GL 4.1 Core profile. This is supported by all
|
|
||||||
// hardware the game officially supports and is also the last version of
|
|
||||||
// GL supported on Apple hardware. So we know exactly what we have to
|
|
||||||
// work with.
|
|
||||||
int context_flags{};
|
int context_flags{};
|
||||||
if (g_buildconfig.ostype_macos()) {
|
if (g_buildconfig.ostype_macos()) {
|
||||||
|
// On Mac we ask for a GL 4.1 Core profile. This is supported by all
|
||||||
|
// hardware that we officially support and is also the last version of
|
||||||
|
// GL supported on Apple hardware. So we have a nice fixed target to
|
||||||
|
// work with.
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
|
||||||
@ -596,8 +616,14 @@ void AppAdapterSDL::ReloadRenderer_(
|
|||||||
|
|
||||||
// Wondering if there would be a smarter strategy here; for example
|
// Wondering if there would be a smarter strategy here; for example
|
||||||
// trying a few different specific core profiles.
|
// trying a few different specific core profiles.
|
||||||
|
|
||||||
|
// Actually, in reading a bit more, Nvidia actually recommends
|
||||||
|
// compatibility profiles and their core profiles may actually be
|
||||||
|
// slightly slower due to extra checks, so what we're doing here might
|
||||||
|
// be optimal.
|
||||||
}
|
}
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
|
// Curious if this has any real effects anywhere.
|
||||||
context_flags |= SDL_GL_CONTEXT_DEBUG_FLAG;
|
context_flags |= SDL_GL_CONTEXT_DEBUG_FLAG;
|
||||||
}
|
}
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, context_flags);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, context_flags);
|
||||||
@ -613,8 +639,6 @@ void AppAdapterSDL::ReloadRenderer_(
|
|||||||
if (!sdl_gl_context_) {
|
if (!sdl_gl_context_) {
|
||||||
FatalError("Unable to create SDL GL Context");
|
FatalError("Unable to create SDL GL Context");
|
||||||
}
|
}
|
||||||
// auto result = SDL_GL_SetSwapInterval(-1);
|
|
||||||
// printf("GOT RESULT %d\n", result);
|
|
||||||
|
|
||||||
SDL_SetWindowTitle(sdl_window_, "BallisticaKit");
|
SDL_SetWindowTitle(sdl_window_, "BallisticaKit");
|
||||||
|
|
||||||
@ -637,14 +661,14 @@ void AppAdapterSDL::ReloadRenderer_(
|
|||||||
void AppAdapterSDL::UpdateScreenSizes_() {
|
void AppAdapterSDL::UpdateScreenSizes_() {
|
||||||
assert(g_base->app_adapter->InGraphicsContext());
|
assert(g_base->app_adapter->InGraphicsContext());
|
||||||
|
|
||||||
// Grab logical window dimensions (points?).
|
// Grab logical window dimensions (points?). This is the coordinate space
|
||||||
// This is the coordinate space SDL's events deal in.
|
// SDL's events deal in.
|
||||||
int win_size_x, win_size_y;
|
int win_size_x, win_size_y;
|
||||||
SDL_GetWindowSize(sdl_window_, &win_size_x, &win_size_y);
|
SDL_GetWindowSize(sdl_window_, &win_size_x, &win_size_y);
|
||||||
window_size_ = Vector2f(win_size_x, win_size_y);
|
window_size_ = Vector2f(win_size_x, win_size_y);
|
||||||
|
|
||||||
// Also grab the new size of the drawable; this is our physical
|
// Also grab the new size of the drawable; this is our physical (pixel)
|
||||||
// (pixel) dimensions.
|
// dimensions.
|
||||||
int pixels_x, pixels_y;
|
int pixels_x, pixels_y;
|
||||||
SDL_GL_GetDrawableSize(sdl_window_, &pixels_x, &pixels_y);
|
SDL_GL_GetDrawableSize(sdl_window_, &pixels_x, &pixels_y);
|
||||||
g_base->graphics_server->SetScreenResolution(static_cast<float>(pixels_x),
|
g_base->graphics_server->SetScreenResolution(static_cast<float>(pixels_x),
|
||||||
|
|||||||
@ -56,39 +56,23 @@ class AppAdapterSDL : public AppAdapter {
|
|||||||
auto GetSDLJoystickInput_(int sdl_joystick_id) const -> JoystickInput*;
|
auto GetSDLJoystickInput_(int sdl_joystick_id) const -> JoystickInput*;
|
||||||
// The same but using sdl events.
|
// The same but using sdl events.
|
||||||
auto GetSDLJoystickInput_(const SDL_Event* e) const -> JoystickInput*;
|
auto GetSDLJoystickInput_(const SDL_Event* e) const -> JoystickInput*;
|
||||||
// void DoSwap_();
|
|
||||||
// void SwapBuffers_();
|
|
||||||
// void UpdateAutoVSync_(int diff);
|
|
||||||
void AddSDLInputDevice_(JoystickInput* input, int index);
|
void AddSDLInputDevice_(JoystickInput* input, int index);
|
||||||
void RemoveSDLInputDevice_(int index);
|
void RemoveSDLInputDevice_(int index);
|
||||||
void SleepUntilNextEventCycle_(microsecs_t cycle_start_time);
|
void SleepUntilNextEventCycle_(microsecs_t cycle_start_time);
|
||||||
// millisecs_t last_swap_time_{};
|
|
||||||
// millisecs_t swap_start_time_{};
|
bool done_{};
|
||||||
// int too_slow_frame_count_{};
|
bool fullscreen_{};
|
||||||
// bool auto_vsync_{};
|
bool vsync_actually_enabled_{};
|
||||||
// bool vsync_enabled_{true};
|
bool debug_log_sdl_frame_timing_{};
|
||||||
// float average_vsync_fps_{60.0f};
|
bool hidden_{};
|
||||||
// int vsync_good_frame_count_{};
|
VSync vsync_{VSync::kUnset};
|
||||||
// int vsync_bad_frame_count_{};
|
|
||||||
uint32_t sdl_runnable_event_id_{};
|
uint32_t sdl_runnable_event_id_{};
|
||||||
|
int max_fps_{60};
|
||||||
|
microsecs_t oversleep_{};
|
||||||
std::vector<JoystickInput*> sdl_joysticks_;
|
std::vector<JoystickInput*> sdl_joysticks_;
|
||||||
/// This is in points, not pixels.
|
|
||||||
Vector2f window_size_{1.0f, 1.0f};
|
Vector2f window_size_{1.0f, 1.0f};
|
||||||
SDL_Window* sdl_window_{};
|
SDL_Window* sdl_window_{};
|
||||||
void* sdl_gl_context_{};
|
void* sdl_gl_context_{};
|
||||||
// SDL_Surface* sdl_screen_surface_{};
|
|
||||||
bool done_{};
|
|
||||||
bool fullscreen_{};
|
|
||||||
VSync vsync_{VSync::kUnset};
|
|
||||||
bool vsync_actually_enabled_{};
|
|
||||||
microsecs_t oversleep_{};
|
|
||||||
int max_fps_{60};
|
|
||||||
bool debug_log_sdl_frame_timing_{};
|
|
||||||
// std::unique_ptr<GLContext> gl_context_;
|
|
||||||
|
|
||||||
// TEMP
|
|
||||||
// friend class GLContext;
|
|
||||||
friend class GraphicsServer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ballistica::base
|
} // namespace ballistica::base
|
||||||
|
|||||||
@ -119,7 +119,7 @@ class UIV1SoftInterface;
|
|||||||
class AppAdapterVR;
|
class AppAdapterVR;
|
||||||
class GraphicsVR;
|
class GraphicsVR;
|
||||||
|
|
||||||
enum class QuitType {
|
enum class QuitType : uint8_t {
|
||||||
/// Leads to the process exiting.
|
/// Leads to the process exiting.
|
||||||
kHard,
|
kHard,
|
||||||
/// May hide/reset the app but keep the process running. Generally how
|
/// May hide/reset the app but keep the process running. Generally how
|
||||||
@ -131,7 +131,7 @@ enum class QuitType {
|
|||||||
kBack,
|
kBack,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class AssetType {
|
enum class AssetType : uint8_t {
|
||||||
kTexture,
|
kTexture,
|
||||||
kCollisionMesh,
|
kCollisionMesh,
|
||||||
kMesh,
|
kMesh,
|
||||||
@ -140,19 +140,19 @@ enum class AssetType {
|
|||||||
kLast,
|
kLast,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DrawType {
|
enum class DrawType : uint8_t {
|
||||||
kTriangles,
|
kTriangles,
|
||||||
kPoints,
|
kPoints,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Hints to the renderer - stuff that is changed rarely should be static,
|
/// Hints to the renderer - stuff that is changed rarely should be static,
|
||||||
/// and stuff changed often should be dynamic.
|
/// and stuff changed often should be dynamic.
|
||||||
enum class MeshDrawType {
|
enum class MeshDrawType : uint8_t {
|
||||||
kStatic,
|
kStatic,
|
||||||
kDynamic,
|
kDynamic,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ReflectionType {
|
enum class ReflectionType : uint8_t {
|
||||||
kNone,
|
kNone,
|
||||||
kChar,
|
kChar,
|
||||||
kPowerup,
|
kPowerup,
|
||||||
@ -162,7 +162,7 @@ enum class ReflectionType {
|
|||||||
kSharpest,
|
kSharpest,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GraphicsQuality {
|
enum class GraphicsQuality : uint8_t {
|
||||||
/// Quality has not yet been set.
|
/// Quality has not yet been set.
|
||||||
kUnset,
|
kUnset,
|
||||||
/// Bare minimum graphics.
|
/// Bare minimum graphics.
|
||||||
@ -175,11 +175,11 @@ enum class GraphicsQuality {
|
|||||||
kHigher,
|
kHigher,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class VSync { kUnset, kNever, kAlways, kAdaptive };
|
enum class VSync : uint8_t { kUnset, kNever, kAlways, kAdaptive };
|
||||||
enum class VSyncRequest { kNever, kAlways, kAuto };
|
enum class VSyncRequest : uint8_t { kNever, kAlways, kAuto };
|
||||||
|
|
||||||
/// Requests for exact or auto graphics quality values.
|
/// Requests for exact or auto graphics quality values.
|
||||||
enum class GraphicsQualityRequest {
|
enum class GraphicsQualityRequest : uint8_t {
|
||||||
kUnset,
|
kUnset,
|
||||||
kLow,
|
kLow,
|
||||||
kMedium,
|
kMedium,
|
||||||
@ -245,7 +245,7 @@ struct VertexSprite {
|
|||||||
float color[4];
|
float color[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class MeshFormat {
|
enum class MeshFormat : uint8_t {
|
||||||
/// 16bit UV, 8bit normal, 8bit pt-index.
|
/// 16bit UV, 8bit normal, 8bit pt-index.
|
||||||
kUV16N8Index8,
|
kUV16N8Index8,
|
||||||
/// 16bit UV, 8bit normal, 16bit pt-index.
|
/// 16bit UV, 8bit normal, 16bit pt-index.
|
||||||
@ -254,12 +254,12 @@ enum class MeshFormat {
|
|||||||
kUV16N8Index32,
|
kUV16N8Index32,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureType {
|
enum class TextureType : uint8_t {
|
||||||
k2D,
|
k2D,
|
||||||
kCubeMap,
|
kCubeMap,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureFormat {
|
enum class TextureFormat : uint8_t {
|
||||||
kNone,
|
kNone,
|
||||||
kRGBA_8888,
|
kRGBA_8888,
|
||||||
kRGB_888,
|
kRGB_888,
|
||||||
@ -274,25 +274,25 @@ enum class TextureFormat {
|
|||||||
kETC2_RGBA,
|
kETC2_RGBA,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureCompressionType {
|
enum class TextureCompressionType : uint8_t {
|
||||||
kS3TC,
|
kS3TC,
|
||||||
kPVR,
|
kPVR,
|
||||||
kETC1,
|
kETC1,
|
||||||
kETC2,
|
kETC2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureMinQuality {
|
enum class TextureMinQuality : uint8_t {
|
||||||
kLow,
|
kLow,
|
||||||
kMedium,
|
kMedium,
|
||||||
kHigh,
|
kHigh,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CameraMode {
|
enum class CameraMode : uint8_t {
|
||||||
kFollow,
|
kFollow,
|
||||||
kOrbit,
|
kOrbit,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class MeshDataType {
|
enum class MeshDataType : uint8_t {
|
||||||
kIndexedSimpleSplit,
|
kIndexedSimpleSplit,
|
||||||
kIndexedObjectSplit,
|
kIndexedObjectSplit,
|
||||||
kIndexedSimpleFull,
|
kIndexedSimpleFull,
|
||||||
@ -310,44 +310,45 @@ struct TouchEvent {
|
|||||||
float y{};
|
float y{};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextMeshEntryType {
|
enum class TextMeshEntryType : uint8_t {
|
||||||
kRegular,
|
kRegular,
|
||||||
kExtras,
|
kExtras,
|
||||||
kOSRendered,
|
kOSRendered,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MeshDrawFlags {
|
enum MeshDrawFlags : uint8_t {
|
||||||
kMeshDrawFlagNoReflection = 1,
|
kMeshDrawFlagNoReflection = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class LightShadowType {
|
enum class LightShadowType : uint8_t {
|
||||||
kNone,
|
kNone,
|
||||||
kTerrain,
|
kTerrain,
|
||||||
kObject,
|
kObject,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureQualityRequest {
|
enum class TextureQualityRequest : uint8_t {
|
||||||
kUnset,
|
kUnset,
|
||||||
kAuto,
|
kAuto,
|
||||||
kHigh,
|
kHigh,
|
||||||
kMedium,
|
kMedium,
|
||||||
kLow,
|
kLow,
|
||||||
};
|
};
|
||||||
enum class TextureQuality {
|
|
||||||
|
enum class TextureQuality : uint8_t {
|
||||||
kUnset,
|
kUnset,
|
||||||
kHigh,
|
kHigh,
|
||||||
kMedium,
|
kMedium,
|
||||||
kLow,
|
kLow,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BenchmarkType {
|
enum class BenchmarkType : uint8_t {
|
||||||
kNone,
|
kNone,
|
||||||
kCPU,
|
kCPU,
|
||||||
kGPU,
|
kGPU,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BA_VR_BUILD
|
#if BA_VR_BUILD
|
||||||
enum class VRHandType {
|
enum class VRHandType : uint8_t {
|
||||||
kNone,
|
kNone,
|
||||||
kDaydreamRemote,
|
kDaydreamRemote,
|
||||||
kOculusTouchL,
|
kOculusTouchL,
|
||||||
@ -372,7 +373,7 @@ struct VRHandsState {
|
|||||||
/// These do not necessarily correspond to actual shader objects in the renderer
|
/// These do not necessarily correspond to actual shader objects in the renderer
|
||||||
/// (a single shader may handle more than one of these, etc).
|
/// (a single shader may handle more than one of these, etc).
|
||||||
/// These are simply categories of looks.
|
/// These are simply categories of looks.
|
||||||
enum class ShadingType {
|
enum class ShadingType : uint8_t {
|
||||||
kSimpleColor,
|
kSimpleColor,
|
||||||
kSimpleColorTransparent,
|
kSimpleColorTransparent,
|
||||||
kSimpleColorTransparentDoubleSided,
|
kSimpleColorTransparentDoubleSided,
|
||||||
@ -416,7 +417,7 @@ enum class ShadingType {
|
|||||||
kCount
|
kCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SysTextureID {
|
enum class SysTextureID : uint8_t {
|
||||||
kUIAtlas,
|
kUIAtlas,
|
||||||
kButtonSquare,
|
kButtonSquare,
|
||||||
kWhite,
|
kWhite,
|
||||||
@ -484,7 +485,7 @@ enum class SysTextureID {
|
|||||||
kWings
|
kWings
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SysCubeMapTextureID {
|
enum class SysCubeMapTextureID : uint8_t {
|
||||||
kReflectionChar,
|
kReflectionChar,
|
||||||
kReflectionPowerup,
|
kReflectionPowerup,
|
||||||
kReflectionSoft,
|
kReflectionSoft,
|
||||||
@ -494,7 +495,7 @@ enum class SysCubeMapTextureID {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class SysSoundID {
|
enum class SysSoundID {
|
||||||
kDeek = 0,
|
kDeek,
|
||||||
kBlip,
|
kBlip,
|
||||||
kBlank,
|
kBlank,
|
||||||
kPunch,
|
kPunch,
|
||||||
@ -512,9 +513,9 @@ enum class SysSoundID {
|
|||||||
kSparkle3
|
kSparkle3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SystemDataID {};
|
enum class SystemDataID : uint8_t {};
|
||||||
|
|
||||||
enum class SysMeshID {
|
enum class SysMeshID : uint8_t {
|
||||||
kButtonSmallTransparent,
|
kButtonSmallTransparent,
|
||||||
kButtonSmallOpaque,
|
kButtonSmallOpaque,
|
||||||
kButtonMediumTransparent,
|
kButtonMediumTransparent,
|
||||||
|
|||||||
@ -36,13 +36,13 @@ void BGDynamics::Emit(const BGDynamicsEmission& e) {
|
|||||||
g_base->bg_dynamics_server->PushEmitCall(e);
|
g_base->bg_dynamics_server->PushEmitCall(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call friend client to step our sim.
|
|
||||||
void BGDynamics::Step(const Vector3f& cam_pos, int step_millisecs) {
|
void BGDynamics::Step(const Vector3f& cam_pos, int step_millisecs) {
|
||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
|
|
||||||
// The BG dynamics thread just processes steps as fast as it can;
|
// The BG dynamics thread just processes steps as fast as it can;
|
||||||
// we need to throttle what we send or tell it to cut back if its behind
|
// we need to throttle what we send or tell it to cut back if its behind
|
||||||
int step_count = g_base->bg_dynamics_server->step_count();
|
int step_count = g_base->bg_dynamics_server->step_count();
|
||||||
|
// printf("STEP COUNT %d\n", step_count);
|
||||||
|
|
||||||
// If we're really getting behind, start pruning stuff.
|
// If we're really getting behind, start pruning stuff.
|
||||||
if (step_count > 3) {
|
if (step_count > 3) {
|
||||||
|
|||||||
@ -2332,8 +2332,8 @@ void BGDynamicsServer::Step(StepData* step_data) {
|
|||||||
// Step the world.
|
// Step the world.
|
||||||
dWorldQuickStep(ode_world_, step_seconds_);
|
dWorldQuickStep(ode_world_, step_seconds_);
|
||||||
|
|
||||||
// Now generate a snapshot of our state and send it to the game thread,
|
// Now generate a snapshot of our state and send it to the logic thread so
|
||||||
// so they can draw us.
|
// they can draw us.
|
||||||
BGDynamicsDrawSnapshot* snapshot = CreateDrawSnapshot();
|
BGDynamicsDrawSnapshot* snapshot = CreateDrawSnapshot();
|
||||||
g_base->logic->event_loop()->PushCall([snapshot] {
|
g_base->logic->event_loop()->PushCall([snapshot] {
|
||||||
snapshot->SetLogicThreadOwnership();
|
snapshot->SetLogicThreadOwnership();
|
||||||
|
|||||||
@ -60,13 +60,7 @@ class GraphicsServer {
|
|||||||
/// non-functional state.
|
/// non-functional state.
|
||||||
void SetNullGraphics();
|
void SetNullGraphics();
|
||||||
|
|
||||||
// void PushSetScreenGammaCall(float gamma);
|
|
||||||
void PushSetScreenPixelScaleCall(float pixel_scale);
|
void PushSetScreenPixelScaleCall(float pixel_scale);
|
||||||
// void PushSetVSyncCall(bool sync, bool auto_sync);
|
|
||||||
// void PushSetScreenCall(bool fullscreen, int width, int height,
|
|
||||||
// TextureQualityRequest texture_quality_request,
|
|
||||||
// GraphicsQualityRequest graphics_quality_request,
|
|
||||||
// const std::string& android_res);
|
|
||||||
void PushReloadMediaCall();
|
void PushReloadMediaCall();
|
||||||
void PushRemoveRenderHoldCall();
|
void PushRemoveRenderHoldCall();
|
||||||
void PushComponentUnloadCall(
|
void PushComponentUnloadCall(
|
||||||
|
|||||||
@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
|
|||||||
namespace ballistica {
|
namespace ballistica {
|
||||||
|
|
||||||
// These are set automatically via script; don't modify them here.
|
// These are set automatically via script; don't modify them here.
|
||||||
const int kEngineBuildNumber = 21408;
|
const int kEngineBuildNumber = 21409;
|
||||||
const char* kEngineVersion = "1.7.28";
|
const char* kEngineVersion = "1.7.28";
|
||||||
const int kEngineApiVersion = 8;
|
const int kEngineApiVersion = 8;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user