PolyCore.h 3.1 KB

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