| 2314 | } |
| 2315 | |
| 2316 | static void Dispatch(dmMessage::Message* message, void* user_ptr) |
| 2317 | { |
| 2318 | Engine* self = (Engine*) user_ptr; |
| 2319 | |
| 2320 | if (message->m_Descriptor != 0) |
| 2321 | { |
| 2322 | dmDDF::Descriptor* descriptor = (dmDDF::Descriptor*)message->m_Descriptor; |
| 2323 | |
| 2324 | dmDDF::ResolvePointers(descriptor, message->m_Data); |
| 2325 | |
| 2326 | if (descriptor == dmSystemDDF::Exit::m_DDFDescriptor) |
| 2327 | { |
| 2328 | dmSystemDDF::Exit* ddf = (dmSystemDDF::Exit*) message->m_Data; |
| 2329 | dmEngine::Exit(self, ddf->m_Code); |
| 2330 | } |
| 2331 | else if (descriptor == dmSystemDDF::Reboot::m_DDFDescriptor) |
| 2332 | { |
| 2333 | dmSystemDDF::Reboot* reboot = (dmSystemDDF::Reboot*) message->m_Data; |
| 2334 | dmEngine::Reboot(self, reboot); |
| 2335 | } |
| 2336 | else if (descriptor == dmSystemDDF::ToggleProfile::m_DDFDescriptor) // "toogle_profile" |
| 2337 | { |
| 2338 | dmProfiler::ToggleProfiler(); |
| 2339 | } |
| 2340 | else if (descriptor == dmSystemDDF::TogglePhysicsDebug::m_DDFDescriptor) // "toggle_physics" |
| 2341 | { |
| 2342 | if(dLib::IsDebugMode()) |
| 2343 | { |
| 2344 | self->m_PhysicsContextBox2D.m_BaseContext.m_Debug = !self->m_PhysicsContextBox2D.m_BaseContext.m_Debug; |
| 2345 | self->m_PhysicsContextBullet3D.m_BaseContext.m_Debug = !self->m_PhysicsContextBullet3D.m_BaseContext.m_Debug; |
| 2346 | } |
| 2347 | } |
| 2348 | else if (descriptor == dmSystemDDF::StartRecord::m_DDFDescriptor) // "start_record" |
| 2349 | { |
| 2350 | dmSystemDDF::StartRecord* start_record = (dmSystemDDF::StartRecord*) message->m_Data; |
| 2351 | RecordData* record_data = &self->m_RecordData; |
| 2352 | |
| 2353 | record_data->m_FramePeriod = start_record->m_FramePeriod; |
| 2354 | |
| 2355 | int32_t x = 0, y = 0; |
| 2356 | uint32_t width = 0, height = 0; |
| 2357 | dmGraphics::GetViewport(self->m_GraphicsContext, &x, &y, &width, &height); |
| 2358 | dmRecord::NewParams params; |
| 2359 | params.m_Width = width; |
| 2360 | params.m_Height = height; |
| 2361 | params.m_Filename = start_record->m_FileName; |
| 2362 | params.m_Fps = start_record->m_Fps; |
| 2363 | |
| 2364 | dmRecord::Result r = dmRecord::New(¶ms, &record_data->m_Recorder); |
| 2365 | if (r == dmRecord::RESULT_OK) |
| 2366 | { |
| 2367 | record_data->m_Buffer = new char[width * height * 4]; |
| 2368 | record_data->m_FrameCount = 0; |
| 2369 | } |
| 2370 | else |
| 2371 | { |
| 2372 | dmLogError("Unable to start recording (%d)", r); |
| 2373 | record_data->m_Recorder = 0; |