EmulatorMain.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // EmulatorMain.c
  3. // RootlessForEmulators
  4. //
  5. // Created by Uli Kusterer on 08/03/15.
  6. // Copyright (c) 2015 Uli Kusterer. All rights reserved.
  7. //
  8. #include "RootlessForEmulators.h"
  9. #include <stdio.h>
  10. #include <memory.h>
  11. #include <stdint.h>
  12. #include <stdlib.h>
  13. #include <stdbool.h>
  14. int EmulatorMain( int argc, const char** argv )
  15. {
  16. // We get all command-line arguments (note that MacOS X adds its own arguments when launching GUI apps, so be prepared for unknown args):
  17. for( int x = 0; x < argc; x++ )
  18. {
  19. printf( "%s ", argv[x] );
  20. }
  21. printf("\n");
  22. // Create a back buffer:
  23. int screenWidth = 1024, screenHeight = 768;
  24. GetScreenSize( &screenWidth, &screenHeight );
  25. uint32_t* backBuffer = malloc(screenWidth * screenHeight * 4);
  26. for( int x = 0; x < (screenWidth * screenHeight); x++ )
  27. backBuffer[x] = 0xFF0000FF; // Red with 100% alpha.
  28. BackBufferChanged( backBuffer, screenWidth * 4, screenWidth, screenHeight ); // And tell the rootless code to load it. You do that every time something changes.
  29. // Everything that should show up as a window should be registered using this call:
  30. RootlessWindow wd = CreateWindowWithRect( 100, 100, 512, 342 );
  31. // SetWindowRect(wd,150,100,512,342); // Move a window.
  32. // Now process events coming in (We just loop until you click the right mouse button in a window):
  33. while( true )
  34. {
  35. int buttonDown, x, y;
  36. if( QueryInputDevices( &buttonDown, &x, &y ) && buttonDown == 1 )
  37. {
  38. break;
  39. }
  40. }
  41. FreeWindow(wd); // Get rid of a window.
  42. return 0;
  43. }