|
|
|
|
@@ -532,7 +532,7 @@
|
|
|
|
|
|
|
|
|
|
When drag'n'drop is enabled, the event callback will be invoked with an
|
|
|
|
|
event of type SAPP_EVENTTYPE_FILES_DROPPED whenever the user drops files on
|
|
|
|
|
the application window.
|
|
|
|
|
the application engine.window.
|
|
|
|
|
|
|
|
|
|
After the SAPP_EVENTTYPE_FILES_DROPPED is received, you can query the
|
|
|
|
|
number of dropped files, and their absolute paths by calling separate
|
|
|
|
|
@@ -884,7 +884,7 @@
|
|
|
|
|
=================
|
|
|
|
|
On some platforms which don't provide a physical keyboard, sokol-app
|
|
|
|
|
can display the platform's integrated onscreen keyboard for text
|
|
|
|
|
input. To request that the onscreen keyboard is shown, call
|
|
|
|
|
engine.input. To request that the onscreen keyboard is shown, call
|
|
|
|
|
|
|
|
|
|
sapp_show_keyboard(true);
|
|
|
|
|
|
|
|
|
|
@@ -949,7 +949,7 @@
|
|
|
|
|
|
|
|
|
|
sapp_desc.win32_console_create (default: false)
|
|
|
|
|
When set to true, a new console window will be created and
|
|
|
|
|
stdout/stderr will be redirected to that console window. It
|
|
|
|
|
stdout/stderr will be redirected to that console engine.window. It
|
|
|
|
|
doesn't matter if the application is started from the command
|
|
|
|
|
line or via double-click.
|
|
|
|
|
|
|
|
|
|
@@ -1750,7 +1750,7 @@ inline void sapp_run(const sapp_desc& desc) { return sapp_run(&desc); }
|
|
|
|
|
#include <winrt/Windows.Graphics.Display.h>
|
|
|
|
|
#include <winrt/Windows.UI.Core.h>
|
|
|
|
|
#include <winrt/Windows.UI.Composition.h>
|
|
|
|
|
#include <winrt/Windows.UI.Input.h>
|
|
|
|
|
#include <winrt/Windows.UI.engine.input.h>
|
|
|
|
|
#include <winrt/Windows.UI.ViewManagement.h>
|
|
|
|
|
#include <winrt/Windows.System.h>
|
|
|
|
|
#include <ppltasks.h>
|
|
|
|
|
@@ -3096,13 +3096,13 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
|
|
|
|
|
styleMask:style
|
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
|
defer:NO];
|
|
|
|
|
_sapp.macos.window.releasedWhenClosed = NO; // this is necessary for proper cleanup in applicationWillTerminate
|
|
|
|
|
_sapp.macos.window.title = [NSString stringWithUTF8String:_sapp.window_title];
|
|
|
|
|
_sapp.macos.window.acceptsMouseMovedEvents = YES;
|
|
|
|
|
_sapp.macos.window.restorable = YES;
|
|
|
|
|
_sapp.macos.engine.window.releasedWhenClosed = NO; // this is necessary for proper cleanup in applicationWillTerminate
|
|
|
|
|
_sapp.macos.engine.window.title = [NSString stringWithUTF8String:_sapp.window_title];
|
|
|
|
|
_sapp.macos.engine.window.acceptsMouseMovedEvents = YES;
|
|
|
|
|
_sapp.macos.engine.window.restorable = YES;
|
|
|
|
|
|
|
|
|
|
_sapp.macos.win_dlg = [[_sapp_macos_window_delegate alloc] init];
|
|
|
|
|
_sapp.macos.window.delegate = _sapp.macos.win_dlg;
|
|
|
|
|
_sapp.macos.engine.window.delegate = _sapp.macos.win_dlg;
|
|
|
|
|
#if defined(SOKOL_METAL)
|
|
|
|
|
_sapp.macos.mtl_device = MTLCreateSystemDefaultDevice();
|
|
|
|
|
_sapp.macos.view = [[_sapp_macos_view alloc] init];
|
|
|
|
|
@@ -3113,7 +3113,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
|
|
|
|
|
_sapp.macos.view.depthStencilPixelFormat = MTLPixelFormatDepth32Float_Stencil8;
|
|
|
|
|
_sapp.macos.view.sampleCount = (NSUInteger) _sapp.sample_count;
|
|
|
|
|
_sapp.macos.view.autoResizeDrawable = false;
|
|
|
|
|
_sapp.macos.window.contentView = _sapp.macos.view;
|
|
|
|
|
_sapp.macos.engine.window.contentView = _sapp.macos.view;
|
|
|
|
|
[_sapp.macos.window makeFirstResponder:_sapp.macos.view];
|
|
|
|
|
_sapp.macos.view.layer.magnificationFilter = kCAFilterNearest;
|
|
|
|
|
#elif defined(SOKOL_GLCORE33)
|
|
|
|
|
@@ -3150,7 +3150,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
|
|
|
|
|
[_sapp.macos.view setWantsBestResolutionOpenGLSurface:NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_sapp.macos.window.contentView = _sapp.macos.view;
|
|
|
|
|
_sapp.macos.engine.window.contentView = _sapp.macos.view;
|
|
|
|
|
[_sapp.macos.window makeFirstResponder:_sapp.macos.view];
|
|
|
|
|
|
|
|
|
|
NSTimer* timer_obj = [NSTimer timerWithTimeInterval:0.001
|
|
|
|
|
@@ -3754,7 +3754,7 @@ _SOKOL_PRIVATE void _sapp_ios_show_keyboard(bool shown) {
|
|
|
|
|
_sapp.ios.view_ctrl = [[UIViewController alloc] init];
|
|
|
|
|
_sapp.ios.view_ctrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
_sapp.ios.view_ctrl.view = _sapp.ios.view;
|
|
|
|
|
_sapp.ios.window.rootViewController = _sapp.ios.view_ctrl;
|
|
|
|
|
_sapp.ios.engine.window.rootViewController = _sapp.ios.view_ctrl;
|
|
|
|
|
#else
|
|
|
|
|
if (_sapp.desc.gl_force_gles2) {
|
|
|
|
|
_sapp.ios.eagl_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
|
|
|
|
@@ -3787,7 +3787,7 @@ _SOKOL_PRIVATE void _sapp_ios_show_keyboard(bool shown) {
|
|
|
|
|
_sapp.ios.view_ctrl = [[GLKViewController alloc] init];
|
|
|
|
|
_sapp.ios.view_ctrl.view = _sapp.ios.view;
|
|
|
|
|
_sapp.ios.view_ctrl.preferredFramesPerSecond = 60 / _sapp.swap_interval;
|
|
|
|
|
_sapp.ios.window.rootViewController = _sapp.ios.view_ctrl;
|
|
|
|
|
_sapp.ios.engine.window.rootViewController = _sapp.ios.view_ctrl;
|
|
|
|
|
#endif
|
|
|
|
|
[_sapp.ios.window makeKeyAndVisible];
|
|
|
|
|
|
|
|
|
|
@@ -4050,11 +4050,11 @@ EM_JS(void, sapp_js_add_beforeunload_listener, (void), {
|
|
|
|
|
event.returnValue = ' ';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
window.addEventListener('beforeunload', Module.sokol_beforeunload);
|
|
|
|
|
engine.window.addEventListener('beforeunload', Module.sokol_beforeunload);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
EM_JS(void, sapp_js_remove_beforeunload_listener, (void), {
|
|
|
|
|
window.removeEventListener('beforeunload', Module.sokol_beforeunload);
|
|
|
|
|
engine.window.removeEventListener('beforeunload', Module.sokol_beforeunload);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
EM_JS(void, sapp_js_add_clipboard_listener, (void), {
|
|
|
|
|
@@ -4062,11 +4062,11 @@ EM_JS(void, sapp_js_add_clipboard_listener, (void), {
|
|
|
|
|
var pasted_str = event.clipboardData.getData('text');
|
|
|
|
|
ccall('_sapp_emsc_onpaste', 'void', ['string'], [pasted_str]);
|
|
|
|
|
};
|
|
|
|
|
window.addEventListener('paste', Module.sokol_paste);
|
|
|
|
|
engine.window.addEventListener('paste', Module.sokol_paste);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
EM_JS(void, sapp_js_remove_clipboard_listener, (void), {
|
|
|
|
|
window.removeEventListener('paste', Module.sokol_paste);
|
|
|
|
|
engine.window.removeEventListener('paste', Module.sokol_paste);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
EM_JS(void, sapp_js_write_clipboard, (const char* c_str), {
|
|
|
|
|
@@ -6781,17 +6781,17 @@ _SOKOL_PRIVATE uint32_t _sapp_uwp_mods(winrt::Windows::UI::Core::CoreWindow cons
|
|
|
|
|
using namespace winrt::Windows::UI::Core;
|
|
|
|
|
|
|
|
|
|
uint32_t mods = 0;
|
|
|
|
|
if ((sender_window.GetKeyState(VirtualKey::Shift) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
if ((sender_engine.window.GetKeyState(VirtualKey::Shift) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
mods |= SAPP_MODIFIER_SHIFT;
|
|
|
|
|
}
|
|
|
|
|
if ((sender_window.GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
if ((sender_engine.window.GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
mods |= SAPP_MODIFIER_CTRL;
|
|
|
|
|
}
|
|
|
|
|
if ((sender_window.GetKeyState(VirtualKey::Menu) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
if ((sender_engine.window.GetKeyState(VirtualKey::Menu) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) {
|
|
|
|
|
mods |= SAPP_MODIFIER_ALT;
|
|
|
|
|
}
|
|
|
|
|
if (((sender_window.GetKeyState(VirtualKey::LeftWindows) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) ||
|
|
|
|
|
((sender_window.GetKeyState(VirtualKey::RightWindows) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down))
|
|
|
|
|
if (((sender_engine.window.GetKeyState(VirtualKey::LeftWindows) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down) ||
|
|
|
|
|
((sender_engine.window.GetKeyState(VirtualKey::RightWindows) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down))
|
|
|
|
|
{
|
|
|
|
|
mods |= SAPP_MODIFIER_SUPER;
|
|
|
|
|
}
|
|
|
|
|
@@ -6985,7 +6985,7 @@ private:
|
|
|
|
|
winrt::com_ptr<ID3D11DepthStencilView> m_d3dDepthStencilView;
|
|
|
|
|
D3D11_VIEWPORT m_screenViewport = { };
|
|
|
|
|
|
|
|
|
|
// Cached reference to the Window.
|
|
|
|
|
// Cached reference to the engine.window.
|
|
|
|
|
winrt::agile_ref< winrt::Windows::UI::Core::CoreWindow> m_window;
|
|
|
|
|
|
|
|
|
|
// Cached device properties.
|
|
|
|
|
@@ -7196,7 +7196,7 @@ void DeviceResources::CreateWindowSizeDependentResources() {
|
|
|
|
|
DXGI_SCALING scaling = (_sapp.uwp.dpi.content_scale == _sapp.uwp.dpi.window_scale) ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH;
|
|
|
|
|
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
|
|
|
|
|
|
|
|
|
|
swapChainDesc.Width = lround(m_d3dRenderTargetSize.Width); // Match the size of the window.
|
|
|
|
|
swapChainDesc.Width = lround(m_d3dRenderTargetSize.Width); // Match the size of the engine.window.
|
|
|
|
|
swapChainDesc.Height = lround(m_d3dRenderTargetSize.Height);
|
|
|
|
|
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
|
|
|
|
|
swapChainDesc.Stereo = false;
|
|
|
|
|
@@ -7216,7 +7216,7 @@ void DeviceResources::CreateWindowSizeDependentResources() {
|
|
|
|
|
winrt::com_ptr<IDXGIFactory4> dxgiFactory;
|
|
|
|
|
winrt::check_hresult(dxgiAdapter->GetParent(__uuidof(IDXGIFactory4), dxgiFactory.put_void()));
|
|
|
|
|
winrt::com_ptr<IDXGISwapChain1> swapChain;
|
|
|
|
|
winrt::check_hresult(dxgiFactory->CreateSwapChainForCoreWindow(m_d3dDevice.get(), m_window.get().as<::IUnknown>().get(), &swapChainDesc, nullptr, swapChain.put()));
|
|
|
|
|
winrt::check_hresult(dxgiFactory->CreateSwapChainForCoreWindow(m_d3dDevice.get(), m_engine.window.get().as<::IUnknown>().get(), &swapChainDesc, nullptr, swapChain.put()));
|
|
|
|
|
m_swapChain = swapChain.as<IDXGISwapChain3>();
|
|
|
|
|
|
|
|
|
|
// Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
|
|
|
|
|
@@ -7327,7 +7327,7 @@ void DeviceResources::UpdateRenderTargetSize() {
|
|
|
|
|
void DeviceResources::SetWindow(winrt::Windows::UI::Core::CoreWindow const& window) {
|
|
|
|
|
auto currentDisplayInformation = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
|
|
|
|
|
m_window = window;
|
|
|
|
|
m_logicalSize = winrt::Windows::Foundation::Size(window.Bounds().Width, window.Bounds().Height);
|
|
|
|
|
m_logicalSize = winrt::Windows::Foundation::Size(engine.window.Bounds().Width, engine.window.Bounds().Height);
|
|
|
|
|
m_nativeOrientation = currentDisplayInformation.NativeOrientation();
|
|
|
|
|
m_currentOrientation = currentDisplayInformation.CurrentOrientation();
|
|
|
|
|
m_dpi = currentDisplayInformation.LogicalDpi();
|
|
|
|
|
@@ -7349,8 +7349,8 @@ void DeviceResources::SetDpi(float dpi) {
|
|
|
|
|
m_dpi = dpi;
|
|
|
|
|
_sapp_uwp_configure_dpi(m_dpi);
|
|
|
|
|
// When the display DPI changes, the logical size of the window (measured in Dips) also changes and needs to be updated.
|
|
|
|
|
auto window = m_window.get();
|
|
|
|
|
m_logicalSize = winrt::Windows::Foundation::Size(window.Bounds().Width, window.Bounds().Height);
|
|
|
|
|
auto window = m_engine.window.get();
|
|
|
|
|
m_logicalSize = winrt::Windows::Foundation::Size(engine.window.Bounds().Width, engine.window.Bounds().Height);
|
|
|
|
|
CreateWindowSizeDependentResources();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -7536,7 +7536,7 @@ bool DeviceResources::SdkLayersAvailable() {
|
|
|
|
|
// The first method called when the IFrameworkView is being created.
|
|
|
|
|
void App::Initialize(winrt::Windows::ApplicationModel::Core::CoreApplicationView const& applicationView) {
|
|
|
|
|
// Register event handlers for app lifecycle. This example includes Activated, so that we
|
|
|
|
|
// can make the CoreWindow active and start rendering on the window.
|
|
|
|
|
// can make the CoreWindow active and start rendering on the engine.window.
|
|
|
|
|
applicationView.Activated({ this, &App::OnActivated });
|
|
|
|
|
|
|
|
|
|
winrt::Windows::ApplicationModel::Core::CoreApplication::Suspending({ this, &App::OnSuspending });
|
|
|
|
|
@@ -7549,19 +7549,19 @@ void App::Initialize(winrt::Windows::ApplicationModel::Core::CoreApplicationView
|
|
|
|
|
|
|
|
|
|
// Called when the CoreWindow object is created (or re-created).
|
|
|
|
|
void App::SetWindow(winrt::Windows::UI::Core::CoreWindow const& window) {
|
|
|
|
|
window.SizeChanged({ this, &App::OnWindowSizeChanged });
|
|
|
|
|
window.VisibilityChanged({ this, &App::OnVisibilityChanged });
|
|
|
|
|
engine.window.SizeChanged({ this, &App::OnWindowSizeChanged });
|
|
|
|
|
engine.window.VisibilityChanged({ this, &App::OnVisibilityChanged });
|
|
|
|
|
|
|
|
|
|
window.KeyDown({ this, &App::OnKeyDown });
|
|
|
|
|
window.KeyUp({ this, &App::OnKeyUp });
|
|
|
|
|
window.CharacterReceived({ this, &App::OnCharacterReceived });
|
|
|
|
|
engine.window.KeyDown({ this, &App::OnKeyDown });
|
|
|
|
|
engine.window.KeyUp({ this, &App::OnKeyUp });
|
|
|
|
|
engine.window.CharacterReceived({ this, &App::OnCharacterReceived });
|
|
|
|
|
|
|
|
|
|
window.PointerEntered({ this, &App::OnPointerEntered });
|
|
|
|
|
window.PointerExited({ this, &App::OnPointerExited });
|
|
|
|
|
window.PointerPressed({ this, &App::OnPointerPressed });
|
|
|
|
|
window.PointerReleased({ this, &App::OnPointerReleased });
|
|
|
|
|
window.PointerMoved({ this, &App::OnPointerMoved });
|
|
|
|
|
window.PointerWheelChanged({ this, &App::OnPointerWheelChanged });
|
|
|
|
|
engine.window.PointerEntered({ this, &App::OnPointerEntered });
|
|
|
|
|
engine.window.PointerExited({ this, &App::OnPointerExited });
|
|
|
|
|
engine.window.PointerPressed({ this, &App::OnPointerPressed });
|
|
|
|
|
engine.window.PointerReleased({ this, &App::OnPointerReleased });
|
|
|
|
|
engine.window.PointerMoved({ this, &App::OnPointerMoved });
|
|
|
|
|
engine.window.PointerWheelChanged({ this, &App::OnPointerWheelChanged });
|
|
|
|
|
|
|
|
|
|
auto currentDisplayInformation = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
|
|
|
|
|
|
|
|
|
|
|