Elaztek Developer Hub
Blamite Game Engine - blam!  00357.06.18.22.0809.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 
29 {
34 };
35 
39 namespace BlamRendering
40 {
46  namespace DirectX
47  {
51  namespace D2D
52  {
58  BLAM ID2D1DeviceContext* GetD2DRenderTarget();
59 
65  BLAM ID2D1Factory* GetD2DFactory();
66 
72  BLAM IDWriteFactory* GetDWriteFactory();
73 
82  BLAM HRESULT LoadFontFromFile(std::string id, std::string file_path);
83  }
84 
88  namespace WIC
89  {
95  BLAM IWICImagingFactory* GetWICFactory();
96 
108  BLAM HRESULT CreateD2DBitmapFromResource(int res_id, const char* res_type, ID2D1Bitmap **bitmap_pointer);
109 
118  BLAM HRESULT CreateD2DBitmapFromFile(std::wstring path, ID2D1Bitmap **bitmap_pointer);
119 
128  BLAM HRESULT CreateWICBitmapFromFile(std::wstring path, IWICBitmap** bitmap_pointer);
129 
139  BLAM HRESULT CreateWICBitmapFromMemory(void* data, int size, IWICBitmap** bitmap_pointer);
140 
149  BLAM HRESULT ConvertWICBitmapToD2D(IWICBitmap* wic_bitmap, ID2D1Bitmap** d2d_bitmap);
150 
160  BLAM HRESULT ConvertWICBitmapToD2D(IWICBitmap* wic_bitmap, ID2D1Bitmap** d2d_bitmap, ID2D1RenderTarget* render_target);
161 
170  BLAM HRESULT ConvertWICBitmapTo32bppPBGRA(IWICBitmap* source, IWICBitmap** destination);
171 
180  BLAM HRESULT Initialize();
181 
188  BLAM void Shutdown();
189  }
190 
196  BLAM ID3D11Device* GetD3DDevice();
197 
203  BLAM ID3D11DeviceContext* GetD3DContext();
204 
215  BLAM IDXGISwapChain* GetDXGISwapChain();
216 
222  BLAM ID3D11RenderTargetView* GetD3DRenderTargetView();
223 
229  BLAM DXGI_SWAP_CHAIN_DESC GetSwapChainDesc();
230 
241  BLAM HRESULT Initialize(HWND hWnd);
242 
249  BLAM void Cleanup();
250 
262  BLAM HRESULT HandleWindowResize(LPARAM lParam);
263 
271  BLAM bool* RenderTargetClearing();
272 
283  BLAM void RenderLoop(bool debug);
284 
292  BLAM void ShutdownRenderThread();
293 
304  BLAM void RenderThread(bool debug);
305 
315 
321  BLAM void SetClearColor(ImVec4 color);
322 
329 
338  BLAM HRESULT UpdateResolution(int x, int y);
339 
345  BLAM ID3D11Texture2D** GetLastFrameTexture();
346 
353  BLAM HRESULT GetLastFrameTextureAlt(ID3D11Texture2D* texture);
354 
361  BLAM void ScreenshotDone();
362 
369  BLAM HRESULT GetLastFrameHResult();
370 
380  BLAM void DisplayDetailedCrashScreen(const char* expression, const char* file, int line, std::string details);
381 
387 
392  BLAM void DisplaySignalCrashScreen(int signal);
393  }
394 
398  namespace BGFX
399  {
400  BLAM void SetPlatformData();
401 
402  BLAM void Initialize();
403  BLAM void RenderLoop();
404  BLAM void Shutdown();
405 
406  BLAM void HandleWindowReisze(int width, int height);
407 
408  BLAM void SetViewClearFlags(int new_flags);
409 
412 
413  BLAM int GetRenderWidth();
414  BLAM int GetRenderHeight();
415  }
416 
417  namespace OGRE
418  {
419  BLAM bool Initialize();
420  BLAM void RenderLoop();
421  BLAM void Shutdown();
422 
423  BLAM void ProcessSDLEvents(SDL_Event* event);
424 
426 
427  BLAM void HandleWindowReisze(int width, int height);
428 
429  BLAM int GetRenderWidth();
430  BLAM int GetRenderHeight();
431 
432  BLAM Ogre::Window* GetRenderWindow();
433  }
434 
436  // Abstract/Shared Functions, these will usually interface with the active graphics API themselves //
438 
445 
451  BLAM void SetClearColor(ImVec4 color);
452 
459 
468  BLAM void ShowCrashScreen(const char* exc, const char* file, int line, std::string message);
469 
480  BLAM HRESULT SetDisplayRes(int x, int y); //Sets screen resolution
481 
482 
483  BLAM void HandleWindowResize(int width, int height, WPARAM wParam);
484 }
485 
486 namespace Blam
487 {
491  BLAM void TakeScreenshot();
492 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:27
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:80
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:33
BlamRendering::OGRE::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Definition: ogre.cpp:105
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:32
ImVec4
Definition: imgui.h:192
BlamRenderingEngine
BlamRenderingEngine
Enumerator listing possible rendering APIs/engines.
Definition: rendering.h:28
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
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:62
BlamRendering::BGFX::RenderLoop
BLAM void RenderLoop()
Definition: bgfx.cpp:65
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:132
BlamRendering::OGRE::ProcessSDLEvents
BLAM void ProcessSDLEvents(SDL_Event *event)
Definition: ogre.cpp:94
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:33
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:30
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:127
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
BLAM
#define BLAM
Definition: rendering.h:18
BlamRendering::OGRE::HandleWindowReisze
BLAM void HandleWindowReisze(int width, int height)
Definition: ogre.cpp:110
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::DirectX::RenderTargetClearing
BLAM bool * RenderTargetClearing()
Retrieves whether or not to enable render target clearing.
Definition: render_manage.cpp:608
BGFX
@ BGFX
Definition: rendering.h:31
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:137
BlamRendering::DirectX::RenderThread
BLAM void RenderThread(bool debug)
Instructs the engine to start rendering on a separate thread.
Definition: render_manage.cpp:337
source
const CharType(& source)[N]
Definition: pointer.h:1272