PolyCocoaCore.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * PolyCocoaCore.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 2/16/10.
  6. * Copyright 2010 Ivan Safrin. All rights reserved.
  7. *
  8. */
  9. // @package Core
  10. #pragma once
  11. #include "PolyGlobals.h"
  12. #include "PolyCore.h"
  13. #include "PolyRectangle.h"
  14. #include <vector>
  15. #include <OpenGL/gl.h>
  16. #include <OpenGL/OpenGL.h>
  17. #include "PolyGLRenderer.h"
  18. #include <mach/mach_time.h>
  19. #import <Cocoa/Cocoa.h>
  20. using std::vector;
  21. @class SubstanceView;
  22. namespace Polycode {
  23. class _PolyExport PosixMutex : public CoreMutex {
  24. public:
  25. pthread_mutex_t pMutex;
  26. };
  27. class CocoaEvent {
  28. public:
  29. int eventGroup;
  30. int eventCode;
  31. int mouseX;
  32. int mouseY;
  33. TAUKey keyCode;
  34. wchar_t unicodeChar;
  35. char mouseButton;
  36. static const int INPUT_EVENT = 0;
  37. };
  38. class _PolyExport CocoaCore : public Core {
  39. public:
  40. CocoaCore(SubstanceView *view, int xRes, int yRes, bool fullScreen, int aaLevel, int frameRate);
  41. virtual ~CocoaCore();
  42. void enableMouse(bool newval);
  43. unsigned int getTicks();
  44. bool Update();
  45. void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);
  46. void resizeTo(int xRes, int yRes);
  47. void createThread(Threaded *target);
  48. void createFolder(string folderPath);
  49. void copyDiskItem(string itemPath, string destItemPath);
  50. void moveDiskItem(string itemPath, string destItemPath);
  51. void removeDiskItem(string itemPath);
  52. string openFolderPicker();
  53. vector<string> openFilePicker(vector<CoreFileExtension> extensions, bool allowMultiple);
  54. void setCursor(int cursorType);
  55. void copyStringToClipboard(wstring str);
  56. wstring getClipboardString();
  57. // static pascal OSStatus coreEventHandler (EventHandlerCallRef next, EventRef event, void *data);
  58. void lockMutex(CoreMutex *mutex);
  59. void unlockMutex(CoreMutex *mutex);
  60. CoreMutex *createMutex();
  61. void checkEvents();
  62. vector<Rectangle> getVideoModes();
  63. int lastMouseY;
  64. int lastMouseX;
  65. CoreMutex *eventMutex;
  66. vector<CocoaEvent> cocoaEvents;
  67. NSOpenGLContext *context;
  68. private:
  69. SubstanceView *glView;
  70. uint64_t initTime;
  71. };
  72. }