28 March 2021, 21:36 | #1 |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Correct Game Loop and Event Loop?
Hello,
I want my application to be able to run in two modes: - FULLSCREEN on custom screen - and WINDOWED on public screen It's realtime rendering application targeted to strongers accelerators like Vampires or Warp with RTG. I would like to have as much as possible optimal but system correct Event Loop in my Main Loop. I have two questions: 1. FULLSCREEN - here I am making custom screen and fullscreen backdrop window to get the keyboard and mouse informations. How the Event/Message loop should look like? Should my application "disable" the workbench to get maximum performance or must be still aware of multitasking? I am pasting my actual code below. Is it correct? What would You suggest? Please note. in fullscreen mode - I am not using Write Pixel Array but copy my buffer directly into RTG memory. Also at this moment I don't have double buffering yet or any WaitTOF. Code:
void APP_Main_Loop() { APP_main_loop = 1; u_int8 is_32 = EM_prefs.is_32; u_int8 is_24 = EM_prefs.is_24; // precalculated output buffer size u_int32 frame_buffer_size = EM_prefs.screen_frame_buffer_size; // signals for event and messages APP_signals = ( 1 << APP_window->UserPort->mp_SigBit ); // holf locked bitmap adress ULONG* base_address = NULL; // Raycast Engine - init timer TM_Init(); u_int16 fps_count_1 = 0; u_int32 t1 = clock(); // get local copies of pointers struct BitMap* app_destination_bitmap = { APP_window->RPort->BitMap }; PLANEPTR app_destination_buffer = APP_window->RPort->BitMap->Planes[0]; // Enter APP main loop while (APP_main_loop) { EM_input.mouse_dx = 0; EM_input.mouse_dy = 0; // handle messages and events APP_Message_Loop(); float32 dt = TM_Get_Delta(); // Raycast Engine - make everything EM_Update_And_Render(dt); // APP display generated graphic on the RTG screen APTR handle = LockBitMapTags(app_destination_bitmap, LBMI_BASEADDRESS, (ULONG)&base_address, TAG_DONE); if (handle) { memcpy(app_destination_buffer, EM_output_buffer_32, frame_buffer_size); UnLockBitMap(handle); } } } void APP_Message_Loop() { if(SetSignal(0L, APP_signals) & APP_signals) { struct IntuiMessage *imsg; while( imsg=(struct IntuiMessage *)GetMsg(APP_window->UserPort) ) { switch (imsg->Class) { case IDCMP_MOUSEMOVE: EM_input.mouse_dx = imsg->MouseX; EM_input.mouse_dy = imsg->MouseY; break; case IDCMP_RAWKEY: if (imsg->Code & 0x80) { EM_input.keys[ (u_int8)(imsg->Code & 0x7F) ] = 0; } else { EM_input.keys[ (u_int8)(imsg->Code & 0x7F) ] = 1; } if (imsg->Code == 0x45) APP_main_loop = 0; break; } ReplyMsg((struct Message *)imsg); } } } 2. And the second question is about WINDOWED MODE.. this mode probably should be as much system correct as possibe I guess.. is above Loop correct or I nedd to add some Wait commad to be multitasking? Is direct copying to RTG allowed in that mode? or now only Wrte Pixel Array can be used? Thank You in advance!! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
copper loop? | JoeJoe | Coders. Asm / Hardware | 4 | 01 May 2020 10:20 |
Help needed for an Intuition event loop | thyslo | Coders. System | 8 | 29 October 2018 19:08 |
WinUAE stuck in a loop | Leandro Jardim | support.WinUAE | 2 | 07 April 2018 21:38 |
It Came from the Desert crashing in a Loop | gb_pdx | support.FS-UAE | 5 | 04 January 2017 20:43 |
Sampled loop in cracktro | absence | request.Music | 2 | 30 June 2012 11:33 |
|
|