Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
RehtiGraphics.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <vulkan/vulkan.h>
3 
4 #include "AABB.hpp"
5 #include "Camera.hpp"
7 #include "Mesh.hpp"
9 
10 #include <algorithm>
11 #include <chrono>
12 #include <iostream>
13 #include <map>
14 #include <memory>
15 #include <set>
16 #include <string>
17 
18 // Forward declarations
19 class RehtiGui;
20 
22 {
23  NO_FLAGS = 0,
25  UNKNOWN = 1 << 7
26 };
27 
28 // Useful structs
30 {
31  std::optional<uint32_t> graphicsFamily;
32  std::optional<uint32_t> presentFamily;
33  std::optional<uint32_t> transferFamily;
34 
35  bool isComplete()
36  {
37  return graphicsFamily.has_value() && presentFamily.has_value();
38  }
40  {
41  return transferFamily.has_value();
42  }
43 };
44 
46 {
47  VkSurfaceCapabilitiesKHR capabilities;
48  std::vector<VkSurfaceFormatKHR> formats;
49  std::vector<VkPresentModeKHR> presentModes;
50 };
51 
53 {
54  uint64_t frameTime; // In microseconds
55  double ftPerSec; // time per second
56 };
57 
58 // The actual application class
60 {
61 public:
65  void startMainLoop();
66 
72  RehtiGraphics(uint32_t width = 1200, uint32_t height = 900, glm::vec3 cameraLocation = glm::vec3(0.f));
73 
78 
92  bool addCharacterObject(int characterID, std::vector<CharacterVertex> vertices, std::vector<uint32_t> indices, ImageData texture, std::array<Animation, ANIMATION_TYPE_COUNT> animations, std::vector<BoneNode> bones, std::vector<glm::mat4> transformations, glm::vec3 location = glm::vec3(0.f), float rotation = 0.f, bool isPlayer = false);
93 
99  bool removeCharacterObject(int characterID);
100 
111  bool addGameObject(int objectID, std::vector<Vertex> vertices, std::vector<uint32_t> indices, ImageData texture, glm::vec3 location = glm::vec3(0.f), float rotation = 0.f);
112 
118  bool removeGameObject(int objectID);
119 
125  bool doesGameObjectExist(int objectID);
126 
132  bool doesCharacterExist(int characterID);
133 
140  void moveGameObject(int objectID, glm::vec3 location, float timeInSeconds);
141 
148  void rotateGameObject(int objectID, float radians, float timeInSeconds);
149 
155  void forceGameObjectMove(int objectID, glm::vec3 location);
156 
162  void forceGameObjectRotate(int objectID, float radians);
163 
170  void movePlayer(int playerID, glm::vec3 location, float timeInSeconds);
171 
177  void playAnimation(int characterID, AnimationConfig cfg);
178 
184  void forcePlayerMove(int playerID, glm::vec3 location);
185 
192  void moveCharacter(int characterID, glm::vec3 location, float timeInSeconds);
193 
199  void forceCharacterMove(int characterID, glm::vec3 location);
200 
208  bool addArea(std::vector<Vertex> vertices, std::vector<uint32_t> indices, std::array<ImageData, 6> textures);
209 
213  void transformTestObject(int id, glm::mat4 transformation);
214 
219  void addMapBoundingBox(const MapAABBData& mapAABBData);
220 
225  Hit traceClick();
226 
231  void setEngineFlags(EngineFlags flags);
232 
237  void addMouseClickCallback(std::function<void(const Hit&)> callback);
238 
239  std::shared_ptr<RehtiGui> getGui();
240 
241 private:
242  // Functions
243 
247  void initWindow();
248 
252  void initVulkan();
253 
258  void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);
259 
263  void setupDebugMessenger();
264 
268  void pickPhysicalDevice();
269 
273  void createLogicalDevice();
274 
278  void createObjectManager();
279 
283  void createSwapChain();
284 
288  void recreateSwapChain();
289 
293  void cleanupSwapChain();
294 
298  void createImageViews();
299 
303  void createRenderPass();
304 
308  void createGraphicsPipeline();
309 
313  void createFramebuffers();
314 
318  void createCommandPool();
319 
323  void createCommandBuffers();
324 
330  void recordCommandBuffer(VkCommandBuffer cmdBuffer, uint32_t imageIndex);
331 
335  void createSynchronization();
336 
340  void drawFrame();
341 
345  void mainLoop();
346 
350  void cleanup();
351 
352  // Helper functions
353 
357  void createInstance();
358 
362  void createSurface();
363 
367  void createTextureSampler();
368 
372  void createDepthResources();
373 
377  void createGui();
378 
384  bool checkDeviceExtensionSupport(VkPhysicalDevice device);
385 
391 
397  bool isDeviceSuitable(VkPhysicalDevice device);
398 
408  bool bbHit(const glm::vec3 min, const glm::vec3 max, const glm::vec3 rayOrig, const glm::vec3 dirInv, float& t);
409 
418  bool trace(const glm::vec3 orig, const glm::vec3 dirInv, const AABB* pBoxNode, AABB& boxHit, float& t);
419 
424  int rateDevice(VkPhysicalDevice device);
425 
431  QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device);
432 
438  SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
439 
444  std::vector<const char*> getRequiredExtensions();
445 
451  VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR> availableFormats);
452 
458  VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR> availableModes);
459 
465  VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
466 
471  VkPushConstantRange getCameraRange();
472 
480  VkFormat findSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
481 
486  size_t getNextFrame();
487 
494  void moveBoundingBox(int objectID, ObjectType objType, glm::vec3 location);
495 
500  void debugMatrix(glm::mat4 matrix);
501 
506  void debugAABB(const AABB& aabb, int level);
507 
513  void fillAABB(std::vector<Vertex> vertices, AABB& box);
514 
515  // Private members:
516  GLFWwindow* pWindowM;
517  VkInstance instanceM;
518  VkDebugUtilsMessengerEXT debugMessengerM;
519  VkSurfaceKHR surfaceM;
520 
521  // Camera
523 
524  // Gpu
525  VkPhysicalDevice gpuM;
526 
527  // Logicaldevice
528  VkDevice logDeviceM;
529 
530  // Auxiliary classes
531  std::shared_ptr<GraphicsObjectManager> pObjectManagerM;
532  std::shared_ptr<RehtiGui> pGuiM;
533 
534  // Queues
535  std::shared_mutex graphicsQueueMutexM;
536  VkQueue graphicsQueueM;
537  VkQueue presentQueueM;
538 
539  // Swapchain
540  VkSwapchainKHR swapChainM;
541  std::vector<VkImage> swapChainImagesM;
543  VkExtent2D swapChainExtentM;
544  std::vector<VkImageView> swapChainImageViewsM;
545 
546  // Framebuffer
547  std::vector<VkFramebuffer> swapChainFramebuffersM;
548  // Depth image
550  VkImageView depthImageViewM;
551  VkFormat depthFormatM;
552  // Sampler
553  VkSampler textureSamplerM;
554 
555  // Pipeline
556  VkRenderPass renderPassM;
557  std::array<VkPipelineLayout, OBJECT_TYPE_COUNT> pipelineLayoutsM;
558  std::array<VkPipeline, OBJECT_TYPE_COUNT> pipelinesM;
559 
560  // Commands
561  VkCommandPool commandPoolM;
562  std::vector<VkCommandBuffer> commandBuffersM;
563 
564  // Semaphores
565  std::vector<VkSemaphore> imagesReadyM;
566  std::vector<VkSemaphore> rendersFinishedM;
567  std::vector<VkFence> frameFencesM;
568 
569  // Callbacks
570  std::function<void(const Hit&)> mouseClickCallbackM;
571 
572  // Other variables
573  uint32_t widthM;
574  uint32_t heightM;
575  float anisotropyM;
578 
579  std::shared_mutex dataMutexM;
580  // Bounding box lists in an array. Each index corresponds to an object type.
581  std::array<std::map<int, AABB>, OBJECT_TYPE_COUNT> boundingBoxesM;
582  // Location and animation storage
583  std::map<int, GfxOrientation> gameObjectOrientationsM;
584  std::map<int, CharacterData> characterOrientationsM;
585 
587 
588  // timer callback system
590 
591  const int kConcurrentFramesM = 2;
592  size_t currentFrameM = 0;
593 
595 
596  const std::vector<const char*> kValidationlayersM = {
597  "VK_LAYER_KHRONOS_validation"};
598 
599  const std::vector<const char*> kDeviceExtensionsM = {
600  VK_KHR_SWAPCHAIN_EXTENSION_NAME};
601 
602  // Debugging functions
603  static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
604  VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
605  VkDebugUtilsMessageTypeFlagsEXT messageType,
606  const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
607  void* pUserData);
608 
609  static VkResult CreateDebugUtilsMessengerEXT(
610  VkInstance instance,
611  const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
612  const VkAllocationCallbacks* pAllocator,
613  VkDebugUtilsMessengerEXT* pDebugMessenger);
614 
615  static void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator);
616 
617  static void frameBufferResizeCallback(GLFWwindow* window, int width, int height);
618 
619 #ifdef NDEBUG
620  const bool enableValidationLayers = false;
621 #else
622  const bool enableValidationLayers = true;
623 #endif
624 };
ObjectType
Definition: BasicTypes.hpp:29
constexpr size_t OBJECT_TYPE_COUNT
Definition: BasicTypes.hpp:26
EngineFlags
Definition: RehtiGraphics.hpp:22
@ NO_FLAGS
Definition: RehtiGraphics.hpp:23
@ UNKNOWN
Definition: RehtiGraphics.hpp:25
@ FRAME_BUFFER_RESIZED
Definition: RehtiGraphics.hpp:24
Definition: Camera.hpp:32
Definition: RehtiGraphics.hpp:60
std::function< void(const Hit &)> mouseClickCallbackM
Definition: RehtiGraphics.hpp:570
bool isDeviceSuitable(VkPhysicalDevice device)
Checks whether the given device supports the required features.
Definition: RehtiGraphics.cpp:1346
void rotateGameObject(int objectID, float radians, float timeInSeconds)
Rotates a game object by given radian angle in the given time frame.
Definition: RehtiGraphics.cpp:165
void forceGameObjectRotate(int objectID, float radians)
Forces game object rotation to the given angle, quitting any remaining rotation callbacks.
Definition: RehtiGraphics.cpp:300
const std::vector< const char * > kDeviceExtensionsM
Definition: RehtiGraphics.hpp:599
size_t getNextFrame()
Returns the index of the next frame.
Definition: RehtiGraphics.cpp:1606
std::shared_ptr< RehtiGui > getGui()
Definition: RehtiGraphics.cpp:1729
bool addArea(std::vector< Vertex > vertices, std::vector< uint32_t > indices, std::array< ImageData, 6 > textures)
Adds an area to the game.
Definition: RehtiGraphics.cpp:306
VkDevice logDeviceM
Definition: RehtiGraphics.hpp:528
void moveBoundingBox(int objectID, ObjectType objType, glm::vec3 location)
Helper function to move a bounding box.
Definition: RehtiGraphics.cpp:1611
const bool enableValidationLayers
Definition: RehtiGraphics.hpp:622
void cleanupSwapChain()
Cleans up swapchain related resources. This function is used for easier recreation of the swap chain.
Definition: RehtiGraphics.cpp:1105
Hit traceClick()
Traces a ray against all bounding boxes, starting with objects, then characters and lastly the map.
Definition: RehtiGraphics.cpp:332
VkFormat depthFormatM
Definition: RehtiGraphics.hpp:551
void recreateSwapChain()
Recreates the swapchain.
Definition: RehtiGraphics.cpp:638
bool checkDeviceExtensionSupport(VkPhysicalDevice device)
Checks whether the given device supports the required extensions.
Definition: RehtiGraphics.cpp:1297
VkSampler textureSamplerM
Definition: RehtiGraphics.hpp:553
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device)
Looks for swapchain support.
Definition: RehtiGraphics.cpp:1491
void createCommandPool()
Creates the command pool.
Definition: RehtiGraphics.cpp:901
void createInstance()
Creates vulkan instance.
Definition: RehtiGraphics.cpp:1165
void addMapBoundingBox(const MapAABBData &mapAABBData)
Adds a bounding box for the world map.
Definition: RehtiGraphics.cpp:321
void createSwapChain()
Creates the swapchain.
Definition: RehtiGraphics.cpp:575
DirectionalLight sunM
Definition: RehtiGraphics.hpp:586
void forceGameObjectMove(int objectID, glm::vec3 location)
Forces the game object to move to the given location, quitting any remaining movement callbacks.
Definition: RehtiGraphics.cpp:180
std::vector< VkSemaphore > imagesReadyM
Definition: RehtiGraphics.hpp:565
void addMouseClickCallback(std::function< void(const Hit &)> callback)
Adds a mouse click callback.
Definition: RehtiGraphics.cpp:1701
std::array< VkPipeline, OBJECT_TYPE_COUNT > pipelinesM
Definition: RehtiGraphics.hpp:558
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device)
Looks for queue families.
Definition: RehtiGraphics.cpp:1457
TimerCallbackSystem timersM
Definition: RehtiGraphics.hpp:589
std::array< VkPipelineLayout, OBJECT_TYPE_COUNT > pipelineLayoutsM
Definition: RehtiGraphics.hpp:557
bool bbHit(const glm::vec3 min, const glm::vec3 max, const glm::vec3 rayOrig, const glm::vec3 dirInv, float &t)
Checks whether the given bounding box is hit by the given ray.
Definition: RehtiGraphics.cpp:1374
std::array< std::map< int, AABB >, OBJECT_TYPE_COUNT > boundingBoxesM
Definition: RehtiGraphics.hpp:581
const std::vector< const char * > kValidationlayersM
Definition: RehtiGraphics.hpp:596
bool doesGameObjectExist(int objectID)
Checks if a game object with the given id exists.
Definition: RehtiGraphics.cpp:134
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT &createInfo)
Populates the debug messenger info.
Definition: RehtiGraphics.cpp:443
void createTextureSampler()
Creates a texture sampler.
Definition: RehtiGraphics.cpp:1222
std::vector< VkFence > frameFencesM
Definition: RehtiGraphics.hpp:567
bool removeGameObject(int objectID)
Removes a game object with the given id from the graphics backend.
Definition: RehtiGraphics.cpp:116
VkQueue graphicsQueueM
Definition: RehtiGraphics.hpp:536
void createObjectManager()
Creates the graphics object manager.
Definition: RehtiGraphics.cpp:553
EngineStatistics statsM
Definition: RehtiGraphics.hpp:577
VkFormat findSupportedFormat(const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
Looks for a suitable format from given candidates.
Definition: RehtiGraphics.cpp:1587
static VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pDebugMessenger)
Definition: RehtiGraphics.cpp:1679
uint32_t widthM
Definition: RehtiGraphics.hpp:573
void setEngineFlags(EngineFlags flags)
Sets flags for engine. Flags can only be set by this interface, not unset.
Definition: RehtiGraphics.cpp:397
void createImageViews()
Creates the image views.
Definition: RehtiGraphics.cpp:658
VkPhysicalDevice gpuM
Definition: RehtiGraphics.hpp:525
std::vector< VkImage > swapChainImagesM
Definition: RehtiGraphics.hpp:541
VkRenderPass renderPassM
Definition: RehtiGraphics.hpp:556
void moveGameObject(int objectID, glm::vec3 location, float timeInSeconds)
Moves a game object to the given location in the given time.
Definition: RehtiGraphics.cpp:146
VkFormat swapChainImageFormatM
Definition: RehtiGraphics.hpp:542
void fillAABB(std::vector< Vertex > vertices, AABB &box)
Fills the min and max of the given bounding box.
Definition: RehtiGraphics.cpp:1655
void recordCommandBuffer(VkCommandBuffer cmdBuffer, uint32_t imageIndex)
Records the command buffer.
Definition: RehtiGraphics.cpp:928
void forcePlayerMove(int playerID, glm::vec3 location)
Forces player to move to the location given, cancelling any remaining movement callbacks and animatio...
Definition: RehtiGraphics.cpp:250
void transformTestObject(int id, glm::mat4 transformation)
Transforms object with the given id.
Definition: RehtiGraphics.cpp:315
VkDebugUtilsMessengerEXT debugMessengerM
Definition: RehtiGraphics.hpp:518
int rateDevice(VkPhysicalDevice device)
Rates the given gpu.
Definition: RehtiGraphics.cpp:1447
std::vector< const char * > getRequiredExtensions()
Returns the required extensions as c strings.
Definition: RehtiGraphics.cpp:1519
static void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks *pAllocator)
Definition: RehtiGraphics.cpp:1692
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities)
Chooses a swap extent based on the provided capabilities.
Definition: RehtiGraphics.cpp:1557
void createFramebuffers()
Creates the framebuffers.
Definition: RehtiGraphics.cpp:880
void createGui()
Creates RehtiGui member and initializes it.
Definition: RehtiGraphics.cpp:1262
AllocatedImage depthImageM
Definition: RehtiGraphics.hpp:549
std::map< int, GfxOrientation > gameObjectOrientationsM
Definition: RehtiGraphics.hpp:583
void setupDebugMessenger()
Setups the debug messenger.
Definition: RehtiGraphics.cpp:452
void mainLoop()
Loops, polls events and draws frames.
Definition: RehtiGraphics.cpp:1075
void playAnimation(int characterID, AnimationConfig cfg)
Plays an animation for the given character.
Definition: RehtiGraphics.cpp:221
void initWindow()
Initializes the window.
Definition: RehtiGraphics.cpp:402
static void frameBufferResizeCallback(GLFWwindow *window, int width, int height)
Definition: RehtiGraphics.cpp:416
EngineFlags engineFlagsM
Definition: RehtiGraphics.hpp:576
void createLogicalDevice()
Creates the interactable logical device.
Definition: RehtiGraphics.cpp:496
VkImageView depthImageViewM
Definition: RehtiGraphics.hpp:550
void forceCharacterMove(int characterID, glm::vec3 location)
Forces character to the given location, cancelling any remaining movement callbacks and animations.
Definition: RehtiGraphics.cpp:290
std::vector< VkSemaphore > rendersFinishedM
Definition: RehtiGraphics.hpp:566
float anisotropyM
Definition: RehtiGraphics.hpp:575
bool removeCharacterObject(int characterID)
Removes a character object with the given id from the graphics backend.
Definition: RehtiGraphics.cpp:77
void pickPhysicalDevice()
Chooses an appropriate gpu.
Definition: RehtiGraphics.cpp:465
size_t currentFrameM
Definition: RehtiGraphics.hpp:592
VkInstance instanceM
Definition: RehtiGraphics.hpp:517
VkSwapchainKHR swapChainM
Definition: RehtiGraphics.hpp:540
void createRenderPass()
Creates the render pass.
Definition: RehtiGraphics.cpp:686
const int kConcurrentFramesM
Definition: RehtiGraphics.hpp:591
std::vector< VkFramebuffer > swapChainFramebuffersM
Definition: RehtiGraphics.hpp:547
GLFWwindow * pWindowM
Definition: RehtiGraphics.hpp:516
std::vector< VkCommandBuffer > commandBuffersM
Definition: RehtiGraphics.hpp:562
VkExtent2D swapChainExtentM
Definition: RehtiGraphics.hpp:543
std::map< int, CharacterData > characterOrientationsM
Definition: RehtiGraphics.hpp:584
VkQueue presentQueueM
Definition: RehtiGraphics.hpp:537
void startMainLoop()
Starts a rendering loop until the window is closed.
Definition: RehtiGraphics.cpp:8
void createSurface()
Creates a surface to draw on.
Definition: RehtiGraphics.cpp:1214
void drawFrame()
Draws a frame and records the previous frame time.
Definition: RehtiGraphics.cpp:1010
void moveCharacter(int characterID, glm::vec3 location, float timeInSeconds)
Moves character smoothly (without animation) to the given location in the given time.
Definition: RehtiGraphics.cpp:266
void createGraphicsPipeline()
Creates the graphics pipeline.
Definition: RehtiGraphics.cpp:744
bool checkValidationLayerSupport()
Checks whether the given device supports the required layers.
Definition: RehtiGraphics.cpp:1315
~RehtiGraphics()
Cleans up all the resources used by vulkan.
Definition: RehtiGraphics.cpp:22
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector< VkSurfaceFormatKHR > availableFormats)
Chooses a surface format.
Definition: RehtiGraphics.cpp:1535
bool addCharacterObject(int characterID, std::vector< CharacterVertex > vertices, std::vector< uint32_t > indices, ImageData texture, std::array< Animation, ANIMATION_TYPE_COUNT > animations, std::vector< BoneNode > bones, std::vector< glm::mat4 > transformations, glm::vec3 location=glm::vec3(0.f), float rotation=0.f, bool isPlayer=false)
Adds a character object with the given id to the graphics backend. Also creates a bounding box for th...
Definition: RehtiGraphics.cpp:27
bool validationLayersEnabledM
Definition: RehtiGraphics.hpp:594
void createCommandBuffers()
Creates the command buffers.
Definition: RehtiGraphics.cpp:914
VkSurfaceKHR surfaceM
Definition: RehtiGraphics.hpp:519
void movePlayer(int playerID, glm::vec3 location, float timeInSeconds)
Moves the player smoothly (without animation) to the given location in the given time.
Definition: RehtiGraphics.cpp:191
uint32_t heightM
Definition: RehtiGraphics.hpp:574
void debugAABB(const AABB &aabb, int level)
Prints out the given aabb.
Definition: RehtiGraphics.cpp:1630
void createSynchronization()
Initializes the appropriate semaphores and fences.
Definition: RehtiGraphics.cpp:990
void cleanup()
Cleans up used resources.
Definition: RehtiGraphics.cpp:1117
bool trace(const glm::vec3 orig, const glm::vec3 dirInv, const AABB *pBoxNode, AABB &boxHit, float &t)
Traces a given ray against a given bounding box.
Definition: RehtiGraphics.cpp:1402
void debugMatrix(glm::mat4 matrix)
Prints out a matrix.
Definition: RehtiGraphics.cpp:1621
VkCommandPool commandPoolM
Definition: RehtiGraphics.hpp:561
std::vector< VkImageView > swapChainImageViewsM
Definition: RehtiGraphics.hpp:544
RehtiGraphics(uint32_t width=1200, uint32_t height=900, glm::vec3 cameraLocation=glm::vec3(0.f))
Initializes the graphics backend.
Definition: RehtiGraphics.cpp:13
std::shared_ptr< RehtiGui > pGuiM
Definition: RehtiGraphics.hpp:532
void initVulkan()
Initializes vulkan instance.
Definition: RehtiGraphics.cpp:422
void createDepthResources()
Creates resources required for a depth buffer.
Definition: RehtiGraphics.cpp:1252
bool addGameObject(int objectID, std::vector< Vertex > vertices, std::vector< uint32_t > indices, ImageData texture, glm::vec3 location=glm::vec3(0.f), float rotation=0.f)
Adds a game object with the given id to the graphics backend. Also creates a bounding box for the obj...
Definition: RehtiGraphics.cpp:91
std::shared_ptr< GraphicsObjectManager > pObjectManagerM
Definition: RehtiGraphics.hpp:531
bool doesCharacterExist(int characterID)
Checks if a characterwith the given id exists.
Definition: RehtiGraphics.cpp:140
std::shared_mutex dataMutexM
Mutex that must be acquired before modifying the data structures below (timer has its own mutex)
Definition: RehtiGraphics.hpp:579
Camera cameraM
Definition: RehtiGraphics.hpp:522
VkPresentModeKHR chooseSwapPresentMode(const std::vector< VkPresentModeKHR > availableModes)
Chooses a present mode.
Definition: RehtiGraphics.cpp:1546
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData)
Definition: RehtiGraphics.cpp:1669
std::shared_mutex graphicsQueueMutexM
Definition: RehtiGraphics.hpp:535
VkPushConstantRange getCameraRange()
Returns the size of the camera matrix.
Definition: RehtiGraphics.cpp:1578
Class that manages the GUI window.
Definition: RehtiGui.hpp:27
Class for handling smooth interpolation of events. A callback can be registered with a given id and t...
Definition: TimerCallbackSystem.hpp:22
Axis Aligned Bounding Box data structure.
Definition: AABB.hpp:14
Definition: GraphicsTypes.hpp:15
Definition: BasicTypes.hpp:190
Directional light struct representing a directional light.
Definition: BasicTypes.hpp:118
Definition: RehtiGraphics.hpp:53
uint64_t frameTime
Definition: RehtiGraphics.hpp:54
double ftPerSec
Definition: RehtiGraphics.hpp:55
Definition: BasicTypes.hpp:153
Definition: BasicTypes.hpp:161
Helper struct to store all the data necessary for creating a map AABB tree.
Definition: AABB.hpp:48
Definition: RehtiGraphics.hpp:30
std::optional< uint32_t > transferFamily
Definition: RehtiGraphics.hpp:33
std::optional< uint32_t > graphicsFamily
Definition: RehtiGraphics.hpp:31
bool isComplete()
Definition: RehtiGraphics.hpp:35
std::optional< uint32_t > presentFamily
Definition: RehtiGraphics.hpp:32
bool hasTransferOnlyQueue()
Definition: RehtiGraphics.hpp:39
Definition: RehtiGraphics.hpp:46
std::vector< VkSurfaceFormatKHR > formats
Definition: RehtiGraphics.hpp:48
VkSurfaceCapabilitiesKHR capabilities
Definition: RehtiGraphics.hpp:47
std::vector< VkPresentModeKHR > presentModes
Definition: RehtiGraphics.hpp:49