ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Application Class

gearfried12Informe11 de Mayo de 2019

1.488 Palabras (6 Páginas)113 Visitas

Página 1 de 6

////////////////////////////////////////////////////////////////////////////////

// Filename: applicationclass.cpp

////////////////////////////////////////////////////////////////////////////////

#include "applicationclass.h"

ApplicationClass::ApplicationClass()

{

m_Input = 0;

m_Direct3D = 0;

m_Camera = 0;

m_Terrain = 0;

m_Timer = 0;

m_Position = 0;

m_Fps = 0;

m_Cpu = 0;

m_FontShader = 0;

m_Text = 0;

m_TerrainShader = 0;

m_Light = 0;

m_projectileCount = 0;

}

ApplicationClass::ApplicationClass(const ApplicationClass& other)

{

}

ApplicationClass::~ApplicationClass()

{

}

bool ApplicationClass::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)

{

bool result;

float cameraX, cameraY, cameraZ;

D3DXMATRIX baseViewMatrix;

char videoCard[128];

int videoMemory;

// Create the input object. The input object will be used to handle reading the keyboard and mouse input from the user.

m_Input = new InputClass;

if(!m_Input)

{

return false;

}

// Initialize the input object.

result = m_Input->Initialize(hinstance, hwnd, screenWidth, screenHeight);

if(!result)

{

MessageBox(hwnd, L"Could not initialize the input object.", L"Error", MB_OK);

return false;

}

// Create the Direct3D object.

m_Direct3D = new D3DClass;

if(!m_Direct3D)

{

return false;

}

// Initialize the Direct3D object.

result = m_Direct3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);

if(!result)

{

MessageBox(hwnd, L"Could not initialize DirectX 11.", L"Error", MB_OK);

return false;

}

// Create the camera object.

m_Camera = new CameraClass;

if(!m_Camera)

{

return false;

}

// Initialize a base view matrix with the camera for 2D user interface rendering.

m_Camera->SetPosition(0.0f, 0.0f, -1.0f);

m_Camera->Render();

m_Camera->GetViewMatrix(baseViewMatrix);

// Set the initial position of the camera.

cameraX = 50.0f;

cameraY = 2.0f;

cameraZ = -7.0f;

m_Camera->SetPosition(cameraX, cameraY, cameraZ);

// Create the terrain object.

m_Terrain = new TerrainClass;

if (!m_Terrain)

{

return false;

}

// Initialize the terrain object.

int textureCount = 5;

WCHAR** filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/sand.jpg";

filenames[1] = L"../Engine/data/sand_conchas.jpg";

filenames[2] = L"../Engine/data/rock.jpg";

filenames[3] = L"../Engine/data/snow.jpg";

filenames[4] = L"../Engine/data/alpha.jpg";

result = m_Terrain->Initialize(m_Direct3D->GetDevice(), "../Engine/data/heightmap.bmp", filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the terrain object.", L"Error", MB_OK);

return false;

}

// Create the terrain object.

m_Water = new TerrainClass;

if (!m_Water)

{

return false;

}

// Initialize the terrain object.

textureCount = 3;

filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/waterDiffuse.jpg";

filenames[1] = L"../Engine/data/waterNormal.png";

filenames[2] = L"../Engine/data/waterSpecular.png";

result = m_Water->Initialize(m_Direct3D->GetDevice(), "../Engine/data/waterHeightmap.bmp", filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the terrain object.", L"Error", MB_OK);

return false;

}

// Create the model object.

m_Skydome = new SkydomeClass;

if (!m_Skydome)

{

return false;

}

textureCount = 2;

filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/skydomeDay.jpg";

filenames[1] = L"../Engine/data/skydomeNight.jpg";

// Initialize the model object.

result = m_Skydome->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);

return false;

}

m_Billboard[0] = new BillboardClass;

if (!m_Billboard[0])

{

return false;

}

textureCount = 2;

filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/tree.png";

filenames[1] = L"../Engine/data/treeNormal.png";

// Initialize the model object.

result = m_Billboard[0]->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);

return false;

}

m_Billboard[1] = new BillboardClass;

if (!m_Billboard[1])

{

return false;

}

textureCount = 2;

filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/tree2.png";

filenames[1] = L"../Engine/data/tree2Normal.png";

// Initialize the model object.

result = m_Billboard[1]->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);

return false;

}

m_Billboard[2] = new BillboardClass;

if (!m_Billboard[2])

{

return false;

}

textureCount = 2;

filenames = new WCHAR*[textureCount];

filenames[0] = L"../Engine/data/tree3.png";

filenames[1] = L"../Engine/data/tree3Normal.png";

// Initialize the model object.

result = m_Billboard[2]->Initialize(m_Direct3D->GetDevice(), filenames, textureCount);

if (!result)

{

MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);

return false;

}

// Create the timer object.

m_Timer = new TimerClass;

if(!m_Timer)

{

return false;

}

// Initialize the timer object.

result = m_Timer->Initialize();

if(!result)

{

MessageBox(hwnd, L"Could not initialize the timer object.", L"Error", MB_OK);

return false;

}

// Create the position object.

m_Position = new PositionClass;

if(!m_Position)

{

return false;

}

// Set the initial position of the viewer to the same as the initial camera position.

m_Position->SetPosition(cameraX, cameraY, cameraZ);

// Create the fps object.

m_Fps = new FpsClass;

if(!m_Fps)

{

return false;

}

// Initialize the fps object.

m_Fps->Initialize();

// Create the cpu object.

m_Cpu = new CpuClass;

if(!m_Cpu)

{

return false;

}

// Initialize the cpu object.

m_Cpu->Initialize();

// Create the font shader object.

m_FontShader = new FontShaderClass;

if(!m_FontShader)

{

return false;

}

// Initialize the font shader object.

result = m_FontShader->Initialize(m_Direct3D->GetDevice(), hwnd);

if(!result)

{

MessageBox(hwnd, L"Could not initialize the font shader object.", L"Error", MB_OK);

return false;

}

// Create the text object.

m_Text = new TextClass;

if(!m_Text)

{

return false;

}

// Initialize the text object.

result = m_Text->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), hwnd, screenWidth, screenHeight, baseViewMatrix);

if(!result)

{

MessageBox(hwnd, L"Could not initialize the text object.", L"Error", MB_OK);

return false;

}

// Retrieve the video card information.

m_Direct3D->GetVideoCardInfo(videoCard, videoMemory);

// Set the video card information in the text object.

result = m_Text->SetVideoCardInfo(videoCard,

...

Descargar como (para miembros actualizados) txt (22 Kb) pdf (78 Kb) docx (24 Kb)
Leer 5 páginas más »
Disponible sólo en Clubensayos.com