Analysis of Hieroglyph3 (open-source Rendering Engine Based on DirectX 11) Framework

Source: Internet
Author: User

Hieroglyph3 is a Rendering engine based on Microsoft's latest graphic API: DirectX 11. It is also a supporting teaching material for Practical Rendering and Computation with Direct3D 11. It provides a more convenient and easy-to-use secondary encapsulation for DX11, making it easier to use dx, without having to manually repeat the lengthy and unchanged code each time. The runtime framework of Glyph3 is based on the class Application, which is defined as follows:

View Code

 1 namespace Glyph3
2 {
3 class Application : public IEventListener
4 {
5 public:
6 Application();
7 virtual ~Application();
8
9 // Initialization functions
10 static Application* GetApplication( );
11
12 // Overloadable functions for end user
13 virtual bool ConfigureEngineComponents() = 0;
14 virtual void ShutdownEngineComponents() = 0;
15 virtual void Initialize() = 0;
16 virtual void Update() = 0;
17 virtual void Shutdown() = 0;
18
19 virtual bool HandleEvent( IEvent* pEvent );
20
21 // Request an exit from windows
22 void RequestTermination();
23
24 // Helpers
25 Timer* m_pTimer;
26
27 // Engine Components
28 EventManager* m_pEventMgr;
29
30 Scene* m_pScene;
31
32 protected:
33 // CApplication pointer to ensure single instance
34 static Application* ms_pApplication;
35 };
36 };

Currently, we mainly focus on the following functions:

virtual bool ConfigureEngineComponents() =0;

When starting the engine, configure the dx components used, such as backbuffer and shader.

virtual void ShutdownEngineComponents() =0;

When the engine is in a relationship, resources are released.

virtual void Initialize() =0;

You can configure this function when the application needs to be initialized.

virtual void Update() =0;

This callback function is called when each frame is updated.

virtual void Shutdown() =0;

This callback is called when the application is closed.

The Framework calls the following code for these callback functions (some code has been removed for ease of viewing ):

View Code

 1 int WINAPI WinMain(    HINSTANCE h_Inst, HINSTANCE h_PrevInst,    LPSTR lpcmdline, int ncmdshow)
2 {
3
4 m_pApp->ConfigureEngineComponents() )
5 m_pApp->Initialize();
6 while( bLoop )
7 {
8 while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
9 {
10 if ( msg.message == WM_QUIT )
11 {
12 bLoop = false;
13 break;
14 }
15 TranslateMessage( &msg );
16 DispatchMessage( &msg );
17 }
18
19 m_pApp->Update();
20 }
21 m_pApp->Shutdown();
22 m_pApp->ShutdownEngineComponents();
23 return( true );
24 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.