📄 resourcetestapp.cpp
字号:
// ResourceTestApp.cpp
//
// Author: Lea Hayes
// Date Created: 10/03/2006
// Date Modified: 10/03/2006
#include "Common.h"
#include "ResourceTestApp.h"
#include "ResMan.h"
#include "TestResource.h"
using namespace Resources;
// The one and only resource application.
ResourceTestApp ResourceTestApp::m_sTheApp;
// ResourceTestApp - Construction and destruction.
ResourceTestApp::ResourceTestApp()
{
}
ResourceTestApp::~ResourceTestApp()
{
}
// ResourceTestApp - Application control flow.
// Function Name: Begin
//
// Author: Lea Hayes
// Date Created: 10/03/2006
// Date Modified: 10/03/2006
//
// Description: Begin application control.
//
void ResourceTestApp::Begin()
{
DisplayHeader();
//m_sTheApp.GenerateTestResources007();
m_sTheApp.ResArrayTest008();
}
// Function Name: DisplayHeader
//
// Author: Lea Hayes
// Date Created: 10/03/2006
// Date Modified: 10/03/2006
//
// Description: Display application heading information.
//
void ResourceTestApp::DisplayHeader()
{
printf("BEng Games and Entertainment Systems Software Engineering");
printf("\nGames Systems - Assignment - Group Game\n");
printf("Lecturer: Jodie Wetherall\n\n");
printf("Programmed by Lea Hayes\n\n");
}
// ResourceTestApp - Test and debug functions.
// Test Function: GenerateTestResources001
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Display resource count.
// 3. Generate 3 test resources.
// 4. Display resource count.
// 5. Render resources.
// 6. Remove 2nd resource.
// 7. Display resource count.
// 8. Render resources.
//
void ResourceTestApp::GenerateTestResources001()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("TestArray: GetCount = %d\n\n", TestArray.GetCount());
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("TestArray: GetCount = %d\n", TestArray.GetCount());
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("TestArray: GetCount = %d\n", TestArray.GetCount());
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("TestArray: GetCount = %d\n", TestArray.GetCount());
printf("\nDisplaying array contents:\n");
// Iterate through resources and display their details.
ResourceArray::iterator itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\nRemoving second element...\n");
TestArray.Release(1);
printf("TestArray: GetCount = %d\n\n", TestArray.GetCount());
// Iterate through resources and display their details.
for(itCur = TestArray.Begin(); itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\n=== End of Test Function #001 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources002
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 3 test resources.
// 3. Display resource count.
// 4. Render resources.
// 5. Remove 2nd resource.
// 6. Remove 2nd resource.
// 7. Display resource count.
// 8. Render resources.
//
void ResourceTestApp::GenerateTestResources002()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("TestArray: GetCount = %d\n", TestArray.GetCount());
printf("\nDisplaying array contents:\n");
// Iterate through resources and display their details.
ResourceArray::iterator itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\nRemoving elements...\n");
TestArray.Release(1);
TestArray.Release(1);
printf("TestArray: GetCount = %d\n\n", TestArray.GetCount());
// Iterate through resources and display their details.
for(itCur = TestArray.Begin(); itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\n=== End of Test Function #002 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources003
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 3 test resources.
// 3. Render resources.
// 4. Attempt invalid remove End().
// 5. Remove 2nd resource.
// 6. Remove 2nd resource.
// 7. Remove 1st resource.
// 8. Display resource count.
// 9. Render resources.
//
void ResourceTestApp::GenerateTestResources003()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("\nDisplaying array contents:\n");
// Iterate through resources and display their details.
ResourceArray::iterator itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\nRemoving elements...\n");
TestArray.Release(TestArray.End());
TestArray.Release(TestArray.Last());
TestArray.Release(TestArray.Last());
TestArray.Release(TestArray.Begin());
printf("TestArray: GetCount = %d\n\n", TestArray.GetCount());
// Iterate through resources and display their details.
for(itCur = TestArray.Begin(); itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\n=== End of Test Function #003 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources004
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 3 test resources.
// 3. Render resources.
// 4. Remove 1st resource.
// 5. Remove 1st resource.
// 6. Remove 1st resource.
// 7. Display resource count.
// 8. Generate test resource.
// 9. Render resources.
//
void ResourceTestApp::GenerateTestResources004()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("\nDisplaying array contents:\n");
// Iterate through resources and display their details.
ResourceArray::iterator itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\nRemoving elements...\n");
TestArray.Release((size_t)0);
TestArray.Release((size_t)0);
TestArray.Release((size_t)0);
printf("TestArray: GetCount = %d\n\n", TestArray.GetCount());
TestArray.Append(CREATE_RESOURCE(TestResource));
// Iterate through resources and display their details.
for(itCur = TestArray.Begin(); itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", (*itCur)->GetIndex());
itCur->Render(0.0f);
}
printf("\n\n=== End of Test Function #004 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources005
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 6 test resources.
// 3. Render resources.
// 4. Iterate through and render odd resources
//
void ResourceTestApp::GenerateTestResources005()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("\nDisplaying array contents:\n");
// Iterate through resources and display their details.
ResourceArray::iterator itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur++)
{
printf("Index = %03d;\t", itCur.GetIndex());
itCur->Render(0.0f);
}
// Iterate through odd resources.
printf("\n\nDisplaying odd resources:\n");
itCur = TestArray.Begin();
for(; itCur != TestArray.End(); itCur += 2)
{
printf("Index = %03d;\t", itCur.GetIndex());
itCur->Render(0.0f);
}
printf("\n\n=== End of Test Function #005 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources006
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 6 test resources.
// 3. Determine distance between several iterators.
// 4. Iterate through and render odd resources
//
void ResourceTestApp::GenerateTestResources006()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
// Determine iterator index by way of arithematic.
ResourceArray::iterator itB = TestArray.Begin() + 3U;
size_t nID = itB - TestArray.Begin(); // should be 3.
printf("nID = %d\n", nID);
ResourceArray::iterator itA = TestArray.Begin() + 1U;
size_t nDistAB = itB - itA; // should be 2.
printf("nDistAB = %d\n", nDistAB);
printf("\n\n=== End of Test Function #006 - Auto Cleanup ===\n\n");
}
// Test Function: GenerateTestResources007
//
// Author: Lea Hayes
// Date Created: 11/03/2006
// Date Modified: 11/03/2006
//
// Description: 1. Instantiate test array.
// 2. Generate 3 test resources.
// 3. Release resources directly.
// 4. Iterate through and render odd resources
//
void ResourceTestApp::GenerateTestResources007()
{
printf("Creating array instance...\n");
ResourceArray TestArray;
printf("Instantiating several test resources...\n");
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
TestArray.Append(CREATE_RESOURCE(TestResource));
printf("\nTestArray: GetCount = %d\n\n", TestArray.GetCount());
// Retrieve two iterators which are to be released.
ResourceArray::iterator itResA = TestArray.Begin();
ResourceArray::iterator itResB = TestArray.Last();
// Release these two resources.
printf("Releasing resources A and B...\n");
itResA->Release();
itResB->Release();
printf("\nTestArray: GetCount = %d", TestArray.GetCount());
printf("\n\n=== End of Test Function #007 - Auto Cleanup ===\n\n");
}
/*
#define CREATE_RESOURCE(class_name) \
new class_name
#define OPEN_RESOURCE(class_name, filename) \
new class_name(filename)
*/
// Test Function: ResArrayTest008
//
// Author: Lea Hayes
// Date Created: 13/03/2006
// Date Modified: 13/03/2006
//
// Description: 1.
//
void ResourceTestApp::ResArrayTest008()
{
ResourceManager::AppendCustom(CREATE_RESOURCE(TestResource));
ResourceManager::AppendCustom(CREATE_RESOURCE(TestResource));
//ResourceManager::AquireCustom(ENTITY_);
ResourceManager::ResHandle resShip = ResourceManager::AquireObjectX("main.x");
printf("\n\n=== End of Test Function #008 - Auto Cleanup ===\n\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -