MCPcopy Create free account
hub / github.com/defold/defold / OnWindowResize

Function OnWindowResize

engine/engine/src/engine.cpp:220–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218 }
219
220 static void OnWindowResize(void* user_data, uint32_t width, uint32_t height)
221 {
222 uint32_t data_size = sizeof(dmRenderDDF::WindowResized);
223 uintptr_t descriptor = (uintptr_t)dmRenderDDF::WindowResized::m_DDFDescriptor;
224 dmhash_t message_id = dmRenderDDF::WindowResized::m_DDFDescriptor->m_NameHash;
225
226 dmRenderDDF::WindowResized window_resized;
227 window_resized.m_Width = width;
228 window_resized.m_Height = height;
229
230 dmMessage::URL receiver;
231 dmMessage::ResetURL(&receiver);
232 dmMessage::Result result = dmMessage::GetSocket(dmRender::RENDER_SOCKET_NAME, &receiver.m_Socket);
233 if (result != dmMessage::RESULT_OK)
234 {
235 dmLogError("Could not find '%s' socket.", dmRender::RENDER_SOCKET_NAME);
236 }
237 else
238 {
239 result = dmMessage::Post(0x0, &receiver, message_id, 0, descriptor, &window_resized, data_size, 0);
240 if (result != dmMessage::RESULT_OK)
241 {
242 dmLogError("Could not send 'window_resized' to '%s' socket.", dmRender::RENDER_SOCKET_NAME);
243 }
244 }
245
246 Engine* engine = (Engine*)user_data;
247 engine->m_InvPhysicalWidth = 1.0f / width;
248 engine->m_InvPhysicalHeight = 1.0f / height;
249 // update gui context if it exists
250 if (engine->m_GuiContext)
251 {
252 dmGui::SetPhysicalResolution(engine->m_GuiContext, width, height);
253 }
254
255 if (engine->m_GraphicsContext)
256 {
257 UpdateGuiSafeAreaAdjust(engine, width, height);
258 }
259
260 dmGameSystem::OnWindowResized(width, height);
261 }
262
263 static int OnWindowClose(void* user_data)
264 {

Callers

nothing calls this directly

Calls 6

ResetURLFunction · 0.85
UpdateGuiSafeAreaAdjustFunction · 0.85
OnWindowResizedFunction · 0.85
GetSocketFunction · 0.50
PostFunction · 0.50
SetPhysicalResolutionFunction · 0.50

Tested by

no test coverage detected