Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
rendering.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <sdl2/SDL.h>
4 #include <sdl2/SDL_events.h>
5 
6 #include <OGRE/Hlms/Pbs/OgreHlmsPbsDatablock.h>
7 #include <OGRE/Hlms/Unlit/OgreHlmsUnlitDatablock.h>
8 #include <Strings/components/classes/map/map.h>
9 
10 #include <string>
11 #include <vector>
12 
16 #include "api/v1/types/tags.h"
17 
18 #ifndef BLAM
19 #define BLAM
20 #endif
21 
22 struct material;
23 struct bitmap;
25 
33 {
35  std::string referencing_tag_path = "";
36  Ogre::HlmsDatablock* instance_datablock = nullptr;
37  material* tag_instance = nullptr;
38  bool needs_reload = false;
39  bool persistent_reload = false;
40 };
41 
49 {
50 public:
51  std::string tag_path = "";
52  Ogre::HlmsDatablock* datablock = nullptr;
53  bool needs_reload = false;
54  bool persistent_reload = false;
55  Ogre::HlmsTypes hlms_type = Ogre::HlmsTypes::HLMS_UNLIT;
56 
63  BlamMap<std::string, ogre_material_instance_data*> instances = BlamMap<std::string, ogre_material_instance_data*>();
64 
73 };
74 
78 namespace Blam::Rendering
79 {
86  BLAM bool Initialize();
87 
91  BLAM void RenderLoop();
92 
98  BLAM void RenderThread();
99 
103  BLAM void Shutdown();
104 
110  BLAM void ProcessSDLEvents(SDL_Event* event);
111 
118 
127  BLAM void HandleWindowReisze(int width, int height);
128 
134  BLAM int GetRenderWidth();
135 
141  BLAM int GetRenderHeight();
142 
148  BLAM Ogre::Window* GetRenderWindow();
149 
155  BLAM double GetDeltaTime();
156 
160  BLAM void TakeScreenshot();
161 
165  BLAM void WriteScreenshot();
166 
172  BLAM Ogre::SceneManager* Get2DSceneManager();
173 
179  BLAM Ogre::Camera* Get2DCamera();
180 
186  BLAM void DisplayBasicCrashScreen(std::string additional_info = "");
187 
196  BLAM void DisplayDetailedCrashScreen(std::string expression, std::string file, int line, std::string message);
197 
203  BLAM bool GetImGuiHiddenState();
204 
208  namespace Materials
209  {
213  BLAM void RebuildDatablocks();
214 
223  BLAM bool BuildDatablockFromTag(material* material_tag, std::string tag_path);
224 
232 
240  BLAM Ogre::HlmsDatablock* GetDatablockFromTag(std::string tag_path);
241 
250  BLAM ogre_material_instance_data* GetDatablockInstanceFromTag(std::string tag_path, std::string referencing_tag_path);
251 
260  BLAM ogre_material_instance_data* CreateDatablockInstance(std::string tag_path, std::string referencing_tag_path);
261 
271  BLAM bool LoadPBSDatablockFromMaterialTag(Ogre::HlmsPbsDatablock* datablock, material* material_tag);
272 
282  BLAM bool LoadUnlitDatablockFromMaterialTag(Ogre::HlmsUnlitDatablock* datablock, material* material_tag);
283 
293  BLAM Ogre::HlmsUnlitDatablock* CreateDefaultUnlitDatablock(std::string id);
294 
305  BLAM Ogre::HlmsUnlitDatablock* CreateDefaultUnlitDatablockForPrimitives(std::string id);
306 
316  BLAM Ogre::HlmsPbsDatablock* CreateDefaultPbsDatablock(std::string id);
317 
328  BLAM Ogre::HlmsPbsDatablock* CreateDefaultPbsDatablockForPrimitives(std::string id);
329  }
330 
334  namespace Textures
335  {
342  BLAM void BuildTextureFromTag(bitmap* bitmap_tag, std::string tag_path);
343 
351  BLAM Ogre::TextureGpu* GetTextureFromTag(std::string tag_path);
352 
356  BLAM void ReloadPendingBitmaps();
357 
370  BLAM Ogre::TextureGpu* LoadTexture2D(std::string id, void* pixel_data, int width, int height, Ogre::PixelFormatGpu format, int bytes_per_line);
371  }
372 
376  namespace Utils {}
377 }
Blam::Director::GetCamera
BLAM BlamDirector * GetCamera()
Retrieves the director instance.
Definition: director.cpp:31
Blam::World::GetWorldState
BLAM BlamWorldState * GetWorldState()
Retrieves the current world state.
Definition: world.cpp:44
ui.h
Blam::Settings::Config::GetEngineConfiguration
BLAM BlamConfigurationFile * GetEngineConfiguration()
Retrieves the main engine configuration file.
Definition: config.cpp:58
tag_io.h
BlamWorldState::RenderObjects
void RenderObjects()
Definition: BlamWorldState.cpp:151
Blam::Rendering::Materials::CreateDefaultUnlitDatablockForPrimitives
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablockForPrimitives(std::string id)
Creates a default Unlit datablock for use with 2D and 3D primitives.
Definition: materials.cpp:966
Demo::BaseSystem::createScene02
virtual void createScene02(void)
Definition: BaseSystem.cpp:40
Demo::GraphicsSystem::getRenderWindow
Ogre::Window * getRenderWindow(void) const
Definition: GraphicsSystem.h:145
ogre_material_instance_data::needs_reload
bool needs_reload
Whether or not this material instance needs to be reloaded.
Definition: rendering.h:38
Blam::Rendering::Materials::LoadUnlitDatablockFromMaterialTag
BLAM bool LoadUnlitDatablockFromMaterialTag(Ogre::HlmsUnlitDatablock *datablock, material *material_tag)
Loads an Unlit datablock from a material tag.
Definition: materials.cpp:230
ogre_material_instance_data::tag_instance
material * tag_instance
Pointer to the tag that uses this material instance.
Definition: rendering.h:37
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
Blam::Rendering::Materials::CreateDefaultUnlitDatablock
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablock(std::string id)
Creates a default Unlit datablock.
Definition: materials.cpp:955
Blam::Rendering::Materials::RebuildDatablocks
BLAM void RebuildDatablocks()
Rebuilds ALL datablocks (including instances) from their original tags.
Definition: materials.cpp:669
BlamDirector::fov
float fov
The camera's current field of view.
Definition: director.h:91
screenshot_pending
bool screenshot_pending
Definition: ogre.cpp:60
BlamDirector::far_clip_plane_distance
float far_clip_plane_distance
Definition: director.h:114
imgui_impl_sdl.h
logger.h
ogre_material_info_data::hlms_type
Ogre::HlmsTypes hlms_type
The HLMS type of this material.
Definition: rendering.h:55
Blam::UI::GetUIRoot
BLAM BlamUIWidget_Group * GetUIRoot()
Retrieves the root UI group widget.
Definition: ui.cpp:64
bitmap.h
ogre_material_instance_data::referencing_tag_path
std::string referencing_tag_path
The path of the tag that uses this material instance.
Definition: rendering.h:35
Blam::Rendering::GetRenderWindow
BLAM Ogre::Window * GetRenderWindow()
Retrieves the primary OGRE rendering window.
Definition: ogre.cpp:373
imgui.h
Blam::Rendering::HandleWindowReisze
BLAM void HandleWindowReisze(int width, int height)
Instructs OGRE to handle a window resize.
Definition: ogre.cpp:341
imgui_impl_dx11.h
ogre_material_info_data
Class used to store OGRE material information.
Definition: rendering.h:48
Blam::Rendering::Materials::CreateDefaultPbsDatablockForPrimitives
BLAM Ogre::HlmsPbsDatablock * CreateDefaultPbsDatablockForPrimitives(std::string id)
Creates a default PBS datablock for use with 2D and 3D primitives.
Definition: materials.cpp:996
BlamDirector::near_clip_plane_distance
float near_clip_plane_distance
Definition: director.h:113
Blam::Rendering::TakeScreenshot
BLAM void TakeScreenshot()
Instructs OGRE to save a screenshot on the next frame.
Definition: ogre.cpp:383
director.h
ogre_graphics_system
Demo::GraphicsSystem * ogre_graphics_system
Definition: ogre.cpp:48
Blam::Rendering::DisplayDetailedCrashScreen
BLAM void DisplayDetailedCrashScreen(std::string expression, std::string file, int line, std::string message)
Displays a detailed crash screen.
Definition: ogre.cpp:414
ogre_use_render_thread
bool ogre_use_render_thread
Definition: ogre.cpp:59
BlamUIWidget_Group::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: group.cpp:155
Blam::UI::GetCrashScreenWidget
BLAM BlamUIWidget_CrashScreen * GetCrashScreenWidget()
Retrieves the built-in crash screen widget.
Definition: ui.cpp:277
Blam::Rendering::Get2DCamera
BLAM Ogre::Camera * Get2DCamera()
Retrieves the camera used to handle 2D rendering.
Definition: ogre.cpp:393
rendering.h
Blam::Rendering::RenderThread
BLAM void RenderThread()
Function used to handle the render thread.
Definition: ogre.cpp:282
Blam::UI::ImGUI::EndFrame
BLAM void EndFrame()
Ends ImGUI drawing for the current frame.
Definition: imgui.cpp:188
Blam::Rendering::Materials::CreateDefaultPbsDatablock
BLAM Ogre::HlmsPbsDatablock * CreateDefaultPbsDatablock(std::string id)
Creates a default PBS datablock.
Definition: materials.cpp:985
__debug_floor_item
Ogre::Item * __debug_floor_item
Definition: ogre.cpp:65
Blam::Rendering::Materials::LoadPBSDatablockFromMaterialTag
BLAM bool LoadPBSDatablockFromMaterialTag(Ogre::HlmsPbsDatablock *datablock, material *material_tag)
Loads a PBS (Physically-Based Shading) datablock from a material tag.
Definition: materials.cpp:372
Blam::Director::PrepareCamera
BLAM void PrepareCamera()
Prepares the director for use.
Definition: director.cpp:5
Blam::Rendering::GetDeltaTime
BLAM double GetDeltaTime()
Retrieves delta time that has passed since the previous frame was completed.
Definition: ogre.cpp:378
Demo::GraphicsSystem::getSceneManager
Ogre::SceneManager * getSceneManager(void) const
Definition: GraphicsSystem.h:146
Blam::Rendering::ProcessSDLEvents
BLAM void ProcessSDLEvents(SDL_Event *event)
Function used to allow OGRE to handle SDL events.
Definition: ogre.cpp:320
Blam::Rendering::Textures::LoadTexture2D
BLAM Ogre::TextureGpu * LoadTexture2D(std::string id, void *pixel_data, int width, int height, Ogre::PixelFormatGpu format, int bytes_per_line)
Loads a 2D texture from data in memory.
Definition: textures.cpp:140
errors.h
Demo::GraphicsSystem::debug_mode_thread_count
size_t debug_mode_thread_count
Definition: GraphicsSystem.h:98
ogre_render_thread_stopped
bool ogre_render_thread_stopped
Definition: ogre.cpp:57
ogre_material_info_data::CreateNewInstance
ogre_material_instance_data * CreateNewInstance(BlamTagData *referencing_tag)
Creates a new instance of this material.
Definition: ogre_material_info_data.cpp:5
Blam::Rendering::Materials::BuildDatablockFromTag
BLAM bool BuildDatablockFromTag(material *material_tag, std::string tag_path)
Creates an OGRE material datablock from a material tag.
Definition: materials.cpp:756
Blam::Rendering::Textures::GetTextureFromTag
BLAM Ogre::TextureGpu * GetTextureFromTag(std::string tag_path)
Retrieves an OGRE texture from a tag path.
Definition: textures.cpp:93
ogre_material_info_data::instances
BlamMap< std::string, ogre_material_instance_data * > instances
A map containing all instances of this material.
Definition: rendering.h:63
Blam::Rendering::Textures::BuildTextureFromTag
BLAM void BuildTextureFromTag(bitmap *bitmap_tag, std::string tag_path)
Loads a texture into OGRE from a bitmap tag.
Definition: textures.cpp:81
light
Definition: light.h:25
Blam::UI::Render
BLAM void Render()
Renders all UI to the screen.
Definition: ui.cpp:41
BlamUIWidget::SetSize
void SetSize(BlamVector2 new_size)
Sets the size of the widget.
Definition: BlamUIWidget.cpp:361
material.h
format
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting format
Definition: ARPHICPL.TXT:16
Blam::UI::Shutdown
BLAM void Shutdown()
Shuts down the UI system.
Definition: ui.cpp:55
Blam::Rendering::GetImGuiHiddenState
BLAM bool GetImGuiHiddenState()
Checks whether ImGUI is currently hidden or not.
Definition: ogre.cpp:430
Blam::Rendering::WriteScreenshot
BLAM void WriteScreenshot()
Saves a screenshot of the current frame to a file.
Definition: utils.cpp:25
Demo::GraphicsSystem::getCamera
Ogre::Camera * getCamera(void) const
Definition: GraphicsSystem.h:147
Blam::Director::ShutdownCamera
BLAM void ShutdownCamera()
Destroys the director and cleans up any data related to it.
Definition: director.cpp:26
max_2d_z_depth
int max_2d_z_depth
Definition: ogre.cpp:62
material
Definition: material.h:52
Demo::BaseSystem::destroyScene
virtual void destroyScene(void)
Definition: BaseSystem.cpp:48
ogre_material_info_data::needs_reload
bool needs_reload
Whether or not this material needs to be reloaded.
Definition: rendering.h:53
ogre_material_instance_data::instance_datablock
Ogre::HlmsDatablock * instance_datablock
The datablock used for this material instance.
Definition: rendering.h:36
Demo::GraphicsSystem::deinitialize
void deinitialize(void)
Definition: GraphicsSystem.cpp:494
ogre_material_instance_data
Data structure used to store OGRE material instance data.
Definition: rendering.h:32
Blam::Rendering::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Retrieves the graphics system used by OGRE.
Definition: ogre.cpp:336
Blam::Rendering::Initialize
BLAM bool Initialize()
Initializes the OGRE rendering library.
Definition: ogre.cpp:71
Blam::Rendering
Namespace for things relating to rendering.
Definition: rendering.h:78
BlamDirector
Class representing the Director.
Definition: director.h:27
Blam::Rendering::GetRenderHeight
BLAM int GetRenderHeight()
Retrieves the current height of the OGRE viewport.
Definition: ogre.cpp:368
file
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current MUST include this txt file
Definition: chiropteraDM.txt:95
imgui_impl_ogre2.h
renderWindow
Ogre::Window * renderWindow
Definition: ogre.cpp:49
Blam::Rendering::Materials::ReloadPendingMaterials
BLAM void ReloadPendingMaterials()
Reloads all datablocks which are flagged as requiring a reload.
Definition: materials.cpp:826
Blam::Rendering::Textures::ReloadPendingBitmaps
BLAM void ReloadPendingBitmaps()
Reloads all bitmaps that are currently pending a reload.
Definition: textures.cpp:112
camera
BlamDirector * camera
Definition: director.cpp:3
timeSinceLast
double timeSinceLast
Definition: ogre.cpp:52
hide_imgui
bool hide_imgui
Definition: ogre.cpp:63
GraphicsSystem.h
Demo::GraphicsSystem
Definition: GraphicsSystem.h:26
Blam::Rendering::Get2DSceneManager
BLAM Ogre::SceneManager * Get2DSceneManager()
Retrieves the scene manager used to handle 2D rendering.
Definition: ogre.cpp:388
SdlInputHandler.h
BlamUIWidget_CrashScreen
Class used for the crash screen UI.
Definition: BlamUIWidget_CrashScreen.h:14
BlamUIWidget_CrashScreen::SetDetailedMessage
void SetDetailedMessage(std::string expression, std::string file, int line, std::string details)
Reconfigures the crash screen text to display a detailed message.
Definition: BlamUIWidget_CrashScreen.cpp:49
Demo::GraphicsSystem::update
void update(float timeSinceLast)
Definition: GraphicsSystem.cpp:528
imgui.h
Demo::GraphicsSystem::getQuit
bool getQuit(void) const
Definition: GraphicsSystem.h:140
Blam::Rendering::Materials::CreateDatablockInstance
BLAM ogre_material_instance_data * CreateDatablockInstance(std::string tag_path, std::string referencing_tag_path)
Creates a new datablock instance from a material tag path, and a referencing tag path.
Definition: materials.cpp:917
Blam::Rendering::DisplayBasicCrashScreen
BLAM void DisplayBasicCrashScreen(std::string additional_info="")
Displays a basic crash screen, with an optional message.
Definition: ogre.cpp:398
timer
Ogre::Timer timer
Definition: ogre.cpp:51
bitmap
Definition: bitmap.h:32
Demo::BaseSystem::createScene01
virtual void createScene01(void)
Definition: BaseSystem.cpp:32
startTime
Ogre::uint64 startTime
Definition: ogre.cpp:53
BlamUIWidget_CrashScreen::SetHidden
void SetHidden(bool new_hidden) override
Sets the hidden state of the widget.
Definition: BlamUIWidget_CrashScreen.cpp:57
ogre_stop_render_thread
bool ogre_stop_render_thread
Definition: ogre.cpp:58
BLAM
#define BLAM
Definition: rendering.h:19
config.h
post_init_needs_datablock_update
bool post_init_needs_datablock_update
Definition: ogre.cpp:61
Demo::GraphicsSystem::initialize
void initialize(const Ogre::String &windowTitle)
Definition: GraphicsSystem.cpp:120
tags.h
BlamUIWidget_CrashScreen::SetBasicMessage
void SetBasicMessage(std::string additional_info="")
Reconfigures the crash screen text to display a basic message.
Definition: BlamUIWidget_CrashScreen.cpp:39
Blam::UI::Initialize
BLAM bool Initialize()
Initializes the UI system.
Definition: ui.cpp:16
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
ogre_material_info_data::persistent_reload
bool persistent_reload
Whether or not to continuously update this material (ie, live editing).
Definition: rendering.h:54
ogre_material_info_data::tag_path
std::string tag_path
The tag path that this material was loaded from.
Definition: rendering.h:51
compositor.h
camera2
Ogre::Camera * camera2
Definition: ogre.cpp:68
Blam::Rendering::Materials::GetDatablockFromTag
BLAM Ogre::HlmsDatablock * GetDatablockFromTag(std::string tag_path)
Retrieves an OGRE datablock from a material tag path.
Definition: materials.cpp:884
SDL_Event
Definition: SdlEmulationLayer.h:735
ogre_material_instance_data::original_material
ogre_material_info_data * original_material
Pointer to the original material information.
Definition: rendering.h:34
BlamUIWidget_CrashScreen.h
Blam::Rendering::Materials::GetDatablockInstanceFromTag
BLAM ogre_material_instance_data * GetDatablockInstanceFromTag(std::string tag_path, std::string referencing_tag_path)
Retrieves a datablock instance from a material tag path, and a referencing tag path.
Definition: materials.cpp:896
ogre_material_instance_data::persistent_reload
bool persistent_reload
Whether or not to continuously update this material (ie, live editing).
Definition: rendering.h:39
Demo::GraphicsSystem::getRoot
Ogre::Root * getRoot(void) const
Definition: GraphicsSystem.h:144
BlamDirector::camera_front
BlamVector3 camera_front
The calculated point representing the front of the camera.
Definition: director.h:84
BlamDirector::camera_pos
BlamVector3 camera_pos
The current position of the camera.
Definition: director.h:80
ogre_material_info_data::datablock
Ogre::HlmsDatablock * datablock
The datablock used for this material.
Definition: rendering.h:52
Demo::BaseSystem::beginFrameParallel
void beginFrameParallel(void)
Definition: BaseSystem.cpp:56
scene_manager_2d
Ogre::SceneManager * scene_manager_2d
Definition: ogre.cpp:69
Blam::Rendering::Shutdown
BLAM void Shutdown()
Shuts down OGRE and cleans up any memory used by it.
Definition: ogre.cpp:295
Demo::BaseSystem::finishFrameParallel
void finishFrameParallel(void)
Definition: BaseSystem.cpp:72
Blam::Rendering::RenderLoop
BLAM void RenderLoop()
Function to handle the render loop.
Definition: ogre.cpp:213
ogre_initialized
bool ogre_initialized
Definition: ogre.cpp:55
Blam::Globals::GetGlobalAsInteger
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:391
Blam::Rendering::GetRenderWidth
BLAM int GetRenderWidth()
Retrieves the current width of the OGRE viewport.
Definition: ogre.cpp:363