Leviathan  0.8.0.0
Leviathan game engine
Graphics.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2019 Henri Hyyryläinen
3 #pragma once
4 #include "Define.h"
5 // ------------------------------------ //
7 
8 #include "bsfCore/RenderAPI/BsRenderWindow.h"
9 
10 namespace Leviathan {
11 
12 class Graphics {
13  friend Window;
14 
15  struct Private;
16 
17 public:
20 
21  DLLEXPORT bool Init(AppDef* appdef);
22  DLLEXPORT void Release();
23 
24  DLLEXPORT bool Frame();
25 
27  bs::RenderTarget& target, const std::vector<bs::SPtr<bs::Texture>>& overlays);
28 
29  DLLEXPORT bool IsVerticalUVFlipped() const;
30 
31  // ------------------------------------ //
32  // Resource loading helpers
33 
39  DLLEXPORT bs::HShader LoadShaderByName(const std::string& name);
40 
42  DLLEXPORT bs::HTexture LoadTextureByName(const std::string& name);
43 
45  DLLEXPORT bs::HMesh LoadMeshByName(const std::string& name);
46 
48  DLLEXPORT bs::HAnimationClip LoadAnimationClipByName(const std::string& name);
49 
50 #ifdef __linux
51  DLLEXPORT static bool HasX11ErrorOccured();
58 #endif
59 
60 protected:
63  bs::SPtr<bs::RenderWindow> RegisterCreatedWindow(Window& window);
64 
67  bool UnRegisterWindow(Window& window);
68 
69 private:
70  bool InitializeBSF(AppDef* appdef);
71  void ShutdownBSF();
72 
73 private:
74  bool Initialized = false;
75  bool FirstWindowCreated = false;
76 
77  std::unique_ptr<Private> Pimpl;
78 };
79 } // namespace Leviathan
DLLEXPORT bool Init(AppDef *appdef)
Definition: Graphics.cpp:166
DLLEXPORT bs::HMesh LoadMeshByName(const std::string &name)
Works the same as LoadShaderByName.
Definition: Graphics.cpp:610
bs::SPtr< bs::RenderWindow > RegisterCreatedWindow(Window &window)
Called when Window objects are created to register them with bsf and with the case of the first windo...
Definition: Graphics.cpp:378
DLLEXPORT bool IsVerticalUVFlipped() const
Definition: Graphics.cpp:568
DLLEXPORT ~Graphics()
Definition: Graphics.cpp:161
DLLEXPORT void UpdateShownOverlays(bs::RenderTarget &target, const std::vector< bs::SPtr< bs::Texture >> &overlays)
Definition: Graphics.cpp:547
DLLEXPORT bs::HTexture LoadTextureByName(const std::string &name)
Works the same as LoadShaderByName.
Definition: Graphics.cpp:594
DLLEXPORT bs::HAnimationClip LoadAnimationClipByName(const std::string &name)
Works the same as LoadShaderByName.
Definition: Graphics.cpp:626
DLLEXPORT bool Frame()
Definition: Graphics.cpp:536
DLLEXPORT Graphics()
Definition: Graphics.cpp:159
DLLEXPORT bs::HShader LoadShaderByName(const std::string &name)
Finds and loads a shader with the name.
Definition: Graphics.cpp:576
#define DLLEXPORT
Definition: Include.h:84
DLLEXPORT void Release()
Definition: Graphics.cpp:243
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
bool UnRegisterWindow(Window &window)
Called just before a window is destroyed. This needs to stop rendering to it.
Definition: Graphics.cpp:507