baseContainer.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #pragma once
  2. #include <windowSystemm/window.h>
  3. #include <iostream>
  4. #include <pikaOptional.h>
  5. #include <string>
  6. #include <pikaAllocator/freeListAllocator.h>
  7. #include <staticVector.h>
  8. #include <pikaGL/frameBuffer.h>
  9. #define READENTIREFILE(x) bool x(const char* name, void* buffer, size_t size)
  10. typedef READENTIREFILE(readEntireFile_t);
  11. #undef READENTIREFILE
  12. #define GETFILESIZE(x) bool x(const char* name, size_t &size)
  13. typedef GETFILESIZE(getFileSize_t);
  14. #undef GETFILESIZE
  15. static constexpr size_t MaxAllocatorsCount = 128;
  16. //this is passed by the engine. You should not modify the data
  17. //this is also used by the engine to give you acces to some io functions
  18. struct RequestedContainerInfo
  19. {
  20. pika::memory::FreeListAllocator *mainAllocator = {};
  21. pika::StaticVector<pika::memory::FreeListAllocator, MaxAllocatorsCount> *bonusAllocators = {};
  22. //readEntireFile_t *readEntireFilePointer = {};
  23. //getFileSize_t *getFileSizePointer = {};
  24. pika::GL::PikaFramebuffer requestedFBO = {};
  25. int requestedImguiIds = 0;
  26. int imguiTotalRequestedIds = 0;
  27. //todo implement
  28. bool readEntireFile(const char *name, void *buffer, size_t size)
  29. {
  30. //PIKA_DEVELOPMENT_ONLY_ASSERT(readEntireFilePointer, "read entire file pointer not assigned");
  31. //bool rez = readEntireFilePointer(name, buffer, size);
  32. //pika::memory::setGlobalAllocator(mainAllocator);
  33. //return rez;
  34. }
  35. bool getFileSize(const char *name, size_t &size)
  36. {
  37. //PIKA_DEVELOPMENT_ONLY_ASSERT(getFileSizePointer, "get file size pointer not assigned");
  38. }
  39. };
  40. struct ContainerStaticInfo
  41. {
  42. //this is the main heap allocator memory size
  43. size_t defaultHeapMemorySize = 0;
  44. pika::StaticVector<size_t, MaxAllocatorsCount> bonusAllocators = {};
  45. //the engine will create a new window for your container and give you the fbo to bind to
  46. //in release that fbo will just be the default framebuffer
  47. bool requestImguiFbo = 0;
  48. unsigned int requestImguiIds = 0;
  49. bool _internalNotImplemented = 0;
  50. bool operator==(const ContainerStaticInfo &other)
  51. {
  52. if (this == &other) { return true; }
  53. return
  54. this->defaultHeapMemorySize == other.defaultHeapMemorySize &&
  55. this->bonusAllocators == other.bonusAllocators &&
  56. this->_internalNotImplemented == other._internalNotImplemented &&
  57. this->requestImguiFbo == other.requestImguiFbo;
  58. this->requestImguiIds == other.requestImguiIds;
  59. ;
  60. }
  61. bool operator!=(const ContainerStaticInfo &other)
  62. {
  63. return !(*this == other);
  64. }
  65. };
  66. struct Container
  67. {
  68. //this is used to give to the engine basic information about your container.
  69. //this function should be pure
  70. //this function should not allocate memory
  71. //this should not be dependent on anything that is called on create or library initialization
  72. static ContainerStaticInfo containerInfo() { ContainerStaticInfo c; c._internalNotImplemented = true; return c; };
  73. virtual void create(RequestedContainerInfo &requestedInfo) = 0;
  74. virtual void update(
  75. pika::Input input,
  76. pika::WindowState windowState,
  77. RequestedContainerInfo &requestedInfo) = 0;
  78. virtual ~Container() {};
  79. };