gxruntime.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef GXRUNTIME_H
  2. #define GXRUNTIME_H
  3. #include <windows.h>
  4. #include <string>
  5. #include <vector>
  6. #include "gxaudio.h"
  7. #include "gxinput.h"
  8. #include "gxgraphics.h"
  9. #include "gxfilesystem.h"
  10. #include "gxtimer.h"
  11. #include "../debugger/debugger.h"
  12. class gxRuntime{
  13. /***** INTERNAL INTERFACE *****/
  14. public:
  15. HWND hwnd;
  16. HINSTANCE hinst;
  17. gxAudio *audio;
  18. gxInput *input;
  19. gxGraphics *graphics;
  20. gxFileSystem *fileSystem;
  21. void flip( bool vwait );
  22. void moveMouse( int x,int y );
  23. LRESULT windowProc( HWND hwnd,UINT msg,WPARAM w,LPARAM l );
  24. struct GfxMode;
  25. struct GfxDriver;
  26. private:
  27. gxRuntime( HINSTANCE hinst,const std::string &cmd_line,HWND hwnd );
  28. ~gxRuntime();
  29. void paint();
  30. void suspend();
  31. void forceSuspend();
  32. void resume();
  33. void forceResume();
  34. void backupWindowState();
  35. void restoreWindowState();
  36. RECT t_rect;
  37. int t_style;
  38. std::string cmd_line;
  39. bool pointer_visible;
  40. std::string app_title;
  41. std::string app_close;
  42. bool setDisplayMode( int w,int h,int d,bool d3d,IDirectDraw7 *dd );
  43. gxGraphics *openWindowedGraphics( int w,int h,int d,bool d3d );
  44. gxGraphics *openExclusiveGraphics( int w,int h,int d,bool d3d );
  45. bool enum_all;
  46. std::vector<GfxDriver*> drivers;
  47. GfxDriver *curr_driver;
  48. int use_di;
  49. void enumGfx();
  50. void denumGfx();
  51. void resetInput();
  52. void pauseAudio();
  53. void resumeAudio();
  54. void backupGraphics();
  55. void restoreGraphics();
  56. void acquireInput();
  57. void unacquireInput();
  58. /***** APP INTERFACE *****/
  59. public:
  60. static gxRuntime *openRuntime( HINSTANCE hinst,const std::string &cmd_line,Debugger *debugger );
  61. static void closeRuntime( gxRuntime *runtime );
  62. void asyncStop();
  63. void asyncRun();
  64. void asyncEnd();
  65. /***** GX INTERFACE *****/
  66. public:
  67. enum{
  68. GFXMODECAPS_3D=1
  69. };
  70. //return true if program should continue, or false for quit.
  71. bool idle();
  72. bool delay( int ms );
  73. bool execute( const std::string &cmd );
  74. void setTitle( const std::string &title,const std::string &close );
  75. int getMilliSecs();
  76. void setPointerVisible( bool vis );
  77. std::string commandLine();
  78. std::string systemProperty( const std::string &t );
  79. void debugStop();
  80. void debugProfile( int per );
  81. void debugStmt( int pos,const char *file );
  82. void debugEnter( void *frame,void *env,const char *func );
  83. void debugLeave();
  84. void debugInfo( const char *t );
  85. void debugError( const char *t );
  86. void debugLog( const char *t );
  87. int numGraphicsDrivers();
  88. void graphicsDriverInfo( int driver,std::string *name,int *caps );
  89. int numGraphicsModes( int driver );
  90. void graphicsModeInfo( int driver,int mode,int *w,int *h,int *d,int *caps );
  91. void windowedModeInfo( int *caps );
  92. gxAudio *openAudio( int flags );
  93. void closeAudio( gxAudio *audio );
  94. gxInput *openInput( int flags );
  95. void closeInput( gxInput *input );
  96. gxGraphics *openGraphics( int w,int h,int d,int driver,int flags );
  97. void closeGraphics( gxGraphics *graphics );
  98. bool graphicsLost();
  99. gxFileSystem *openFileSystem( int flags );
  100. void closeFileSystem( gxFileSystem *filesys );
  101. gxTimer *createTimer( int hertz );
  102. void freeTimer( gxTimer *timer );
  103. void enableDirectInput( bool use );
  104. int directInputEnabled(){ return use_di; }
  105. int callDll( const std::string &dll,const std::string &func,const void *in,int in_sz,void *out,int out_sz );
  106. OSVERSIONINFO osinfo;
  107. };
  108. #endif