PolyCore.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * PolyCore.h
  3. * TAU
  4. *
  5. * Created by Ivan Safrin on 3/12/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package Core
  10. #pragma once
  11. #include "PolyLogger.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyRenderer.h"
  14. #include "PolyThreaded.h"
  15. #include "PolyCoreInput.h"
  16. //#include "PolyGLRenderer.h"
  17. #include "PolyMaterialManager.h"
  18. #include "PolyCoreServices.h"
  19. #include "PolyRectangle.h"
  20. #include <vector>
  21. #include <string>
  22. #define CURSOR_ARROW 0
  23. #define CURSOR_TEXT 1
  24. #define CURSOR_POINTER 2
  25. #define CURSOR_CROSSHAIR 3
  26. #define CURSOR_RESIZE_LEFT_RIGHT 4
  27. #define CURSOR_RESIZE_UP_DOWN 5
  28. using std::vector;
  29. using std::wstring;
  30. long getThreadID();
  31. namespace Polycode {
  32. class CoreServices;
  33. class _PolyExport CoreMutex {
  34. public:
  35. int mutexID;
  36. };
  37. class _PolyExport CoreFileExtension {
  38. public:
  39. string extension;
  40. string description;
  41. };
  42. class _PolyExport Core : public EventDispatcher {
  43. public:
  44. Core(int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
  45. virtual ~Core();
  46. virtual bool Update() = 0;
  47. virtual unsigned int getTicks() = 0;
  48. virtual void enableMouse(bool newval);
  49. virtual void setCursor(int cursorType) = 0;
  50. virtual void createThread(Threaded *target) = 0;
  51. virtual void lockMutex(CoreMutex *mutex) = 0;
  52. virtual void unlockMutex(CoreMutex *mutex) = 0;
  53. virtual CoreMutex *createMutex() = 0;
  54. virtual void copyStringToClipboard(wstring str) = 0;
  55. virtual wstring getClipboardString() = 0;
  56. CoreServices *getServices();
  57. float getFPS();
  58. void Shutdown();
  59. bool isFullscreen(){ return fullScreen; }
  60. int getAALevel() { return aaLevel; }
  61. CoreInput *getInput();
  62. float getXRes();
  63. float getYRes();
  64. int getNumVideoModes();
  65. virtual vector<Rectangle> getVideoModes() = 0;
  66. virtual void createFolder(string folderPath) = 0;
  67. virtual void copyDiskItem(string itemPath, string destItemPath) = 0;
  68. virtual void moveDiskItem(string itemPath, string destItemPath) = 0;
  69. virtual void removeDiskItem(string itemPath) = 0;
  70. virtual string openFolderPicker() = 0;
  71. virtual vector<string> openFilePicker(vector<CoreFileExtension> extensions, bool allowMultiple) = 0;
  72. void setVideoModeIndex(int index, bool fullScreen, int aaLevel);
  73. virtual void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) = 0;
  74. virtual void resizeTo(int xRes, int yRes) = 0;
  75. void doSleep();
  76. float getElapsed();
  77. float getTicksFloat();
  78. void setUserPointer(void *ptr) { userPointer = ptr; }
  79. void *getUserPointer() { return userPointer; }
  80. static const int EVENT_CORE_RESIZE = 0;
  81. protected:
  82. void *userPointer;
  83. long refreshInterval;
  84. bool fullScreen;
  85. int aaLevel;
  86. vector<Vector2> videoModes;
  87. void updateCore();
  88. int numVideoModes;
  89. bool running;
  90. float fps;
  91. unsigned int frameTicks;
  92. unsigned int lastFrameTicks;
  93. unsigned int lastFPSTicks;
  94. unsigned int elapsed;
  95. bool mouseEnabled;
  96. unsigned int lastSleepFrameTicks;
  97. int xRes;
  98. int yRes;
  99. int frames;
  100. CoreInput *input;
  101. Renderer *renderer;
  102. CoreServices *services;
  103. };
  104. }