Featured image of post Game Engine II Assignment02

Game Engine II Assignment02

The details of assignment 02 for eae6320.

Gif of My Game

animatedcolor

GPU Capture

Direct3D

image-20240906154148737 image-20240906154232063

OpenGL

image-20240906154748413 image-20240906154831756 image-20240906155025832

Interface Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//declare variables
namespace{
	// Geometry Data
	//--------------
	eae6320::Graphics::Mesh mesh;

	// Shading Data
	//-------------
	eae6320::Graphics::Effect effect;
}

//In RenderFrame function
{
	// Bind the shading data
	effect.BindShadingData();

	// Draw the geometry
	mesh.Draw();
}

//In Initialize function
{
    // Initialize the shading data
    {
        if ( !( result = effect.InitializeShadingData() ) )
        {
            EAE6320_ASSERTF( false, "Can't initialize Graphics without the shading data" );
            return result;
        }
    }
    // Initialize the geometry
    {
        if ( !( result = mesh.InitializeGeometry() ) )
        {
            EAE6320_ASSERTF( false, "Can't initialize Graphics without the geometry data" );
            return result;
        }
    }
}

//In CleanUp function
{
    result = mesh.CleanUp();

	result = effect.CleanUp();
}

Platform Difference

In Graphics.d3d.cpp, there are variables and functions work for “views”. Considering that these codes only exist in the d3d file, a view class can be created to handle the relevant logic, and macros (EAE6320_PLATFORM_D3D) can be used in Graphics.cpp to support this part.

1
2
3
4
5
6
//Graphics.d3d.cpp
// In Direct3D "views" are objects that allow a texture to be used a particular way:
// A render target view allows a texture to have color rendered to it
ID3D11RenderTargetView* s_renderTargetView = nullptr;
// A depth/stencil view allows a texture to have depth rendered to it
ID3D11DepthStencilView* s_depthStencilView = nullptr;

In Graphics.d3d.cpp, direct3dImmediateContext is used to clear image buffer and depth buffer, while the functions provided by OpenGL are used to do the same job in Graphics.gl.cpp. Considering do the similar job like mesh class of this assignment to make Graphics.cpp can be platform-independent.

Game Sample

Download and have a try: MyGame

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus