Elaztek Developer Hub
Blamite Game Engine - blam!  00368.02.12.23.1347.blamite
The core library for the Blamite Game Engine.
rendering.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <d3d11_1.h>
4 #include <d2d1_1.h>
5 #include <dwrite.h>
6 
7 #include <sdl2/SDL.h>
8 #include <sdl2/SDL_events.h>
9 
10 #include <string>
11 #include <vector>
12 
16 
17 #ifndef BLAM
18 #define BLAM
19 #endif
20 
21 struct material;
22 struct bitmap;
23 
32 {
37 };
38 
42 namespace BlamRendering
43 {
49  namespace DirectX
50  {
54  namespace D2D
55  {
61  BLAM ID2D1DeviceContext* GetD2DRenderTarget();
62 
68  BLAM ID2D1Factory* GetD2DFactory();
69 
75  BLAM IDWriteFactory* GetDWriteFactory();
76 
85  BLAM HRESULT LoadFontFromFile(std::string id, std::string file_path);
86  }
87 
91  namespace WIC
92  {
98  BLAM IWICImagingFactory* GetWICFactory();
99 
111  BLAM HRESULT CreateD2DBitmapFromResource(int res_id, const char* res_type, ID2D1Bitmap **bitmap_pointer);
112 
121  BLAM HRESULT CreateD2DBitmapFromFile(std::wstring path, ID2D1Bitmap **bitmap_pointer);
122 
131  BLAM HRESULT CreateWICBitmapFromFile(std::wstring path, IWICBitmap** bitmap_pointer);
132 
142  BLAM HRESULT CreateWICBitmapFromMemory(void* data, int size, IWICBitmap** bitmap_pointer);
143 
152  BLAM HRESULT ConvertWICBitmapToD2D(IWICBitmap* wic_bitmap, ID2D1Bitmap** d2d_bitmap);
153 
163  BLAM HRESULT ConvertWICBitmapToD2D(IWICBitmap* wic_bitmap, ID2D1Bitmap** d2d_bitmap, ID2D1RenderTarget* render_target);
164 
173  BLAM HRESULT ConvertWICBitmapTo32bppPBGRA(IWICBitmap* source, IWICBitmap** destination);
174 
183  BLAM HRESULT Initialize();
184 
191  BLAM void Shutdown();
192  }
193 
199  BLAM ID3D11Device* GetD3DDevice();
200 
206  BLAM ID3D11DeviceContext* GetD3DContext();
207 
218  BLAM IDXGISwapChain* GetDXGISwapChain();
219 
225  BLAM ID3D11RenderTargetView* GetD3DRenderTargetView();
226 
232  BLAM DXGI_SWAP_CHAIN_DESC GetSwapChainDesc();
233 
244  BLAM HRESULT Initialize(HWND hWnd);
245 
252  BLAM void Cleanup();
253 
265  BLAM HRESULT HandleWindowResize(LPARAM lParam);
266 
274  BLAM bool* RenderTargetClearing();
275 
286  BLAM void RenderLoop(bool debug);
287 
295  BLAM void ShutdownRenderThread();
296 
307  BLAM void RenderThread(bool debug);
308 
318 
325 
332 
341  BLAM HRESULT UpdateResolution(int x, int y);
342 
348  BLAM ID3D11Texture2D** GetLastFrameTexture();
349 
356  BLAM HRESULT GetLastFrameTextureAlt(ID3D11Texture2D* texture);
357 
364  BLAM void ScreenshotDone();
365 
372  BLAM HRESULT GetLastFrameHResult();
373 
383  BLAM void DisplayDetailedCrashScreen(const char* expression, const char* file, int line, std::string details);
384 
390 
395  BLAM void DisplaySignalCrashScreen(int signal);
396  }
397 
401  namespace BGFX
402  {
403  BLAM void SetPlatformData();
404 
405  BLAM void Initialize();
406  BLAM void RenderLoop();
407  BLAM void Shutdown();
408 
409  BLAM void HandleWindowReisze(int width, int height);
410 
411  BLAM void SetViewClearFlags(int new_flags);
412 
415 
416  BLAM int GetRenderWidth();
417  BLAM int GetRenderHeight();
418  }
419 
420  namespace OGRE
421  {
422  BLAM bool Initialize();
423  BLAM void RenderLoop();
424  BLAM void RenderThread();
425  BLAM void Shutdown();
426 
427  BLAM void ProcessSDLEvents(SDL_Event* event);
428 
430 
431  BLAM void HandleWindowReisze(int width, int height);
432 
433  BLAM int GetRenderWidth();
434  BLAM int GetRenderHeight();
435 
436  BLAM Ogre::Window* GetRenderWindow();
437 
438  namespace Utils
439  {
440  BLAM void RebuildDatablocks();
441 
442  BLAM void BuildTextureFromTag(bitmap* bitmap_tag, std::string tag_path);
443 
444  BLAM bool BuildDatablockFromTag(material* material_tag, std::string tag_path);
445 
446  BLAM Ogre::TextureGpu* GetTextureFromTag(std::string tag_path);
447 
449 
450  BLAM void ReloadPendingBitmaps();
451  }
452  }
453 
455  // Abstract/Shared Functions, these will usually interface with the active graphics API themselves //
457 
464 
471 
478 
487  BLAM void ShowCrashScreen(const char* exc, const char* file, int line, std::string message);
488 
499  BLAM HRESULT SetDisplayRes(int x, int y); //Sets screen resolution
500 
501 
502  BLAM void HandleWindowResize(int width, int height, WPARAM wParam);
503 }
504 
505 namespace Blam
506 {
510  BLAM void TakeScreenshot();
511 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:28
BlamRendering::SetClearColor
BLAM void SetClearColor(ImVec4 color)
Changes the color to used to clear the render target.
Definition: rendering_abstraction.cpp:27
BlamRendering::DirectX::WIC::ConvertWICBitmapToD2D
BLAM HRESULT ConvertWICBitmapToD2D(IWICBitmap *wic_bitmap, ID2D1Bitmap **d2d_bitmap)
Converts a WIC bitmap to a D2D bitmap.
Definition: wic.cpp:91
BlamRendering::DirectX::GetClearColor
BLAM ImVec4 * GetClearColor()
Retrieves the current color used to clear the render target.
Definition: render_manage.cpp:613
BlamRendering::BGFX::SetViewClearFlags
BLAM void SetViewClearFlags(int new_flags)
Definition: bgfx.cpp:170
BlamRendering::DirectX::ShutdownRenderThread
BLAM void ShutdownRenderThread()
Instructs the rendering thread to stop running.
Definition: render_manage.cpp:331
BlamRendering::DirectX::GetLastFrameTextureAlt
BLAM HRESULT GetLastFrameTextureAlt(ID3D11Texture2D *texture)
Retrieves the last frame that was rendered.
Definition: render_manage.cpp:647
width
int width
Definition: bgfx.cpp:19
BlamRendering::DirectX::WIC::ConvertWICBitmapTo32bppPBGRA
BLAM HRESULT ConvertWICBitmapTo32bppPBGRA(IWICBitmap *source, IWICBitmap **destination)
Converts a WIC bitmap to a WIC bitmap, with the 32 bits-per-pixe, PBGRA format.
Definition: wic.cpp:58
details
LPSTR details
Definition: error_notice.cpp:17
uint16_t
unsigned short uint16_t
Definition: stdint.h:125
BlamRendering::OGRE::Shutdown
BLAM void Shutdown()
Definition: ogre.cpp:232
BlamRendering::GetCurrentRenderingEngine
BLAM BlamRenderingEngine GetCurrentRenderingEngine()
Retrieves the current rendering engine being used.
Definition: rendering_abstraction.cpp:104
BlamRendering::OGRE::Initialize
BLAM bool Initialize()
Definition: ogre.cpp:63
BlamRendering::OGRE::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Definition: ogre.cpp:273
BlamRendering::HandleWindowResize
BLAM void HandleWindowResize(int width, int height, WPARAM wParam)
Definition: rendering_abstraction.cpp:81
imgui.h
BlamRendering::DirectX::D2D::GetDWriteFactory
BLAM IDWriteFactory * GetDWriteFactory()
Retrieves the DirectWrite factory.
Definition: render_manage.cpp:573
OGRE
@ OGRE
Definition: rendering.h:35
ImVec4
Definition: imgui.h:192
BlamRenderingEngine
BlamRenderingEngine
Enumerator listing possible rendering APIs/engines.
Definition: rendering.h:31
BlamRendering::DirectX::D2D::GetD2DRenderTarget
BLAM ID2D1DeviceContext * GetD2DRenderTarget()
Retrieves the Direct2D render target.
Definition: render_manage.cpp:598
BlamRendering::ShowCrashScreen
BLAM void ShowCrashScreen(const char *exc, const char *file, int line, std::string message)
Displays the engine crash screen.
Definition: rendering_abstraction.cpp:62
BlamRendering::SetDisplayRes
BLAM HRESULT SetDisplayRes(int x, int y)
Changes the game's display resolution.
Definition: rendering_abstraction.cpp:8
BlamRendering::DirectX::DisplaySignalCrashScreen
BLAM void DisplaySignalCrashScreen(int signal)
Displays a signal-based engine crash screen.
Definition: render_manage.cpp:464
BlamRendering::DirectX::SetClearColor
BLAM void SetClearColor(ImVec4 color)
Changes the color to used to clear the render target.
Definition: render_manage.cpp:567
BlamRendering::DirectX::DisplayDetailedCrashScreen
BLAM void DisplayDetailedCrashScreen(const char *expression, const char *file, int line, std::string details)
Displays a detailed engine crash screen.
Definition: render_manage.cpp:443
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:319
BlamRendering::OGRE::Utils::ReloadPendingBitmaps
BLAM void ReloadPendingBitmaps()
Definition: textures.cpp:115
BlamRendering::DirectX::WIC::CreateWICBitmapFromMemory
BLAM HRESULT CreateWICBitmapFromMemory(void *data, int size, IWICBitmap **bitmap_pointer)
Creates a WIC bitmap from a block of memory.
Definition: wic.cpp:173
BlamRendering::BGFX::HandleWindowReisze
BLAM void HandleWindowReisze(int width, int height)
Definition: bgfx.cpp:150
BlamRendering::DirectX::GetLastFrameHResult
BLAM HRESULT GetLastFrameHResult()
Unused.
Definition: render_manage.cpp:642
BlamRendering::DirectX::Initialize
BLAM HRESULT Initialize(HWND hWnd)
Initializes DirectX 11.
Definition: render_manage.cpp:74
BlamRendering::DirectX::UpdateResolution
BLAM HRESULT UpdateResolution(int x, int y)
Changes the DirectX render target resolution.
Definition: resolution.cpp:9
BlamRendering::GetClearColor
BLAM ImVec4 * GetClearColor()
Retrieves the color used for render target clearing.
Definition: rendering_abstraction.cpp:46
BlamRendering::BGFX::Shutdown
BLAM void Shutdown()
Definition: bgfx.cpp:143
BlamRendering::BGFX::GetRenderHeight
BLAM int GetRenderHeight()
Definition: bgfx.cpp:190
BlamRendering::DirectX::WIC::Initialize
BLAM HRESULT Initialize()
Initializes the Windows Imaging Component (WIC).
Definition: wic.cpp:12
BlamRendering::DirectX::GetLastFrameTexture
BLAM ID3D11Texture2D ** GetLastFrameTexture()
Retrieves the last frame that was rendered.
Definition: render_manage.cpp:626
BlamRendering::DirectX::D2D::LoadFontFromFile
BLAM HRESULT LoadFontFromFile(std::string id, std::string file_path)
Loads a TrueType font from the specified file into the list of loaded font collections.
Definition: render_manage.cpp:555
errors.h
BlamRendering::DirectX::GetSwapChainDesc
BLAM DXGI_SWAP_CHAIN_DESC GetSwapChainDesc()
Retrieves the current Direct3D Swap Chain description.
Definition: render_manage.cpp:618
BlamRendering::DirectX::HandleWindowResize
BLAM HRESULT HandleWindowResize(LPARAM lParam)
Handles a window resize event.
Definition: render_manage.cpp:306
Blam::TakeScreenshot
BLAM void TakeScreenshot()
Captures the current frame and saves it to a file.
Definition: screenshot.cpp:101
y
font DisplayOffset y
Definition: README.txt:68
BlamRendering::DirectX::D2D::GetD2DFactory
BLAM ID2D1Factory * GetD2DFactory()
Retrieves the Direct2D factory.
Definition: render_manage.cpp:603
BlamRendering::OGRE::RenderLoop
BLAM void RenderLoop()
Definition: ogre.cpp:182
BlamRendering::BGFX::RenderLoop
BLAM void RenderLoop()
Definition: bgfx.cpp:65
BlamRendering::OGRE::Utils::GetTextureFromTag
BLAM Ogre::TextureGpu * GetTextureFromTag(std::string tag_path)
Definition: textures.cpp:96
BlamRendering::BGFX::SetPlatformData
BLAM void SetPlatformData()
BlamRendering::DirectX::ScreenshotDone
BLAM void ScreenshotDone()
Informs DirectX that the screenshot has finished being captured.
Definition: render_manage.cpp:664
BlamRendering::OGRE::GetRenderHeight
BLAM int GetRenderHeight()
Definition: ogre.cpp:305
BlamRendering::OGRE::ProcessSDLEvents
BLAM void ProcessSDLEvents(SDL_Event *event)
Definition: ogre.cpp:257
material
Structure representing a Material tag.
Definition: material.h:46
BlamRendering::OGRE::Utils::BuildDatablockFromTag
BLAM bool BuildDatablockFromTag(material *material_tag, std::string tag_path)
Definition: materials.cpp:553
BlamRendering::OGRE::Utils::ReloadPendingMaterials
BLAM void ReloadPendingMaterials()
Definition: materials.cpp:615
BlamRendering::DirectX::WIC::CreateD2DBitmapFromResource
BLAM HRESULT CreateD2DBitmapFromResource(int res_id, const char *res_type, ID2D1Bitmap **bitmap_pointer)
Creates a Direct2D bitmap from an application resource.
Definition: wic.cpp:262
BlamRendering::DirectX::GetD3DRenderTargetView
BLAM ID3D11RenderTargetView * GetD3DRenderTargetView()
Retrieves the current Direct3D Render Target.
Definition: render_manage.cpp:593
BlamRendering::DirectX::GetDXGISwapChain
BLAM IDXGISwapChain * GetDXGISwapChain()
Retrieves the current DXGI Swap Chain.
Definition: render_manage.cpp:588
BlamRendering::DirectX::DisplayBasicCrashScreen
BLAM void DisplayBasicCrashScreen()
Displays a basic engine crash screen.
Definition: render_manage.cpp:456
BlamRendering::DirectX::GetD3DDevice
BLAM ID3D11Device * GetD3DDevice()
Retrieves the current Direct3D device.
Definition: render_manage.cpp:578
NotReady
@ NotReady
Definition: rendering.h:36
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
BlamRendering::DirectX::WIC::CreateWICBitmapFromFile
BLAM HRESULT CreateWICBitmapFromFile(std::wstring path, IWICBitmap **bitmap_pointer)
Creates a WIC bitmap from a file.
Definition: wic.cpp:141
BlamRendering::BGFX::GetRenderWidth
BLAM int GetRenderWidth()
Definition: bgfx.cpp:185
DirectX11
@ DirectX11
Definition: rendering.h:33
height
int height
Definition: bgfx.cpp:20
BlamRendering
Namespace for things relating to rendering.
Definition: primitives.h:24
GraphicsSystem.h
Demo::GraphicsSystem
Definition: GraphicsSystem.h:26
BlamRendering::OGRE::GetRenderWidth
BLAM int GetRenderWidth()
Definition: ogre.cpp:300
BlamRendering::OGRE::RenderThread
BLAM void RenderThread()
Definition: ogre.cpp:219
BlamRendering::DirectX::RenderLoop
BLAM void RenderLoop(bool debug)
Renders everything to the screen.
Definition: render_manage.cpp:370
BlamRendering::DirectX::GetD3DContext
BLAM ID3D11DeviceContext * GetD3DContext()
Retrieves the current Direct3D context.
Definition: render_manage.cpp:583
BlamRendering::DirectX::WIC::GetWICFactory
BLAM IWICImagingFactory * GetWICFactory()
Retrieves the WIC Imaging Factory.
Definition: wic.cpp:53
BlamRendering::BGFX::Get3DViewID
BLAM uint16_t Get3DViewID()
Definition: bgfx.cpp:175
bitmap
Structure representing a Bitmap tag.
Definition: bitmap.h:27
BLAM
#define BLAM
Definition: rendering.h:18
BlamRendering::OGRE::HandleWindowReisze
BLAM void HandleWindowReisze(int width, int height)
Definition: ogre.cpp:278
x
config GlyphExtraSpacing x
Definition: README.txt:30
BlamRendering::DirectX::WIC::Shutdown
BLAM void Shutdown()
Shuts down the Windows Imaging Component (WIC).
Definition: wic.cpp:47
BlamRendering::DirectX::Cleanup
BLAM void Cleanup()
Cleans up all DirectX data.
Definition: render_manage.cpp:237
BlamRendering::BGFX::Initialize
BLAM void Initialize()
Definition: bgfx.cpp:28
SDL_Event
Definition: SdlEmulationLayer.h:735
BlamRendering::DirectX::HasRenderThreadStopped
BLAM bool HasRenderThreadStopped()
Determines whether or not the render thread has finished stopping.
Definition: render_manage.cpp:326
BlamRendering::BGFX::Get2DViewID
BLAM uint16_t Get2DViewID()
Definition: bgfx.cpp:180
BlamRendering::OGRE::Utils::RebuildDatablocks
BLAM void RebuildDatablocks()
Definition: materials.cpp:530
BlamRendering::DirectX::RenderTargetClearing
BLAM bool * RenderTargetClearing()
Retrieves whether or not to enable render target clearing.
Definition: render_manage.cpp:608
BGFX
@ BGFX
Definition: rendering.h:34
BlamRendering::DirectX::WIC::CreateD2DBitmapFromFile
BLAM HRESULT CreateD2DBitmapFromFile(std::wstring path, ID2D1Bitmap **bitmap_pointer)
Creates a Direct2D bitmap from a file.
Definition: wic.cpp:216
BlamRendering::OGRE::GetRenderWindow
BLAM Ogre::Window * GetRenderWindow()
Definition: ogre.cpp:310
BlamRendering::DirectX::RenderThread
BLAM void RenderThread(bool debug)
Instructs the engine to start rendering on a separate thread.
Definition: render_manage.cpp:337
BlamRendering::OGRE::Utils::BuildTextureFromTag
BLAM void BuildTextureFromTag(bitmap *bitmap_tag, std::string tag_path)
Definition: textures.cpp:84
source
const CharType(& source)[N]
Definition: pointer.h:1272