2015-11-12 04:32:53 +00:00
|
|
|
#include <boo/boo.hpp>
|
|
|
|
#include <LogVisor/LogVisor.hpp>
|
2015-11-13 02:12:09 +00:00
|
|
|
#include "HECL/Runtime.hpp"
|
2015-11-12 04:32:53 +00:00
|
|
|
|
|
|
|
struct HECLWindowCallback : boo::IWindowCallback
|
|
|
|
{
|
|
|
|
bool m_sizeDirty = false;
|
|
|
|
boo::SWindowRect m_latestSize;
|
|
|
|
void resized(const boo::SWindowRect& rect)
|
|
|
|
{
|
|
|
|
m_sizeDirty = true;
|
|
|
|
m_latestSize = rect;
|
|
|
|
}
|
2015-11-13 02:12:09 +00:00
|
|
|
|
|
|
|
bool m_destroyed = false;
|
|
|
|
void destroyed()
|
|
|
|
{
|
|
|
|
m_destroyed = true;
|
|
|
|
}
|
2015-11-12 04:32:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HECLApplicationCallback : boo::IApplicationCallback
|
|
|
|
{
|
|
|
|
HECLWindowCallback m_windowCb;
|
|
|
|
boo::IWindow* m_mainWindow = nullptr;
|
|
|
|
bool m_running = true;
|
|
|
|
int appMain(boo::IApplication* app)
|
|
|
|
{
|
2015-11-13 02:12:09 +00:00
|
|
|
HECL::Runtime::FileStoreManager fileMgr(app->getUniqueName());
|
|
|
|
HECL::Runtime::ShaderCacheManager shaderMgr(fileMgr);
|
|
|
|
|
2015-11-12 04:32:53 +00:00
|
|
|
m_mainWindow = app->newWindow(_S("HECL Test"));
|
|
|
|
m_mainWindow->setCallback(&m_windowCb);
|
2015-11-14 08:48:31 +00:00
|
|
|
m_mainWindow->showWindow();
|
2015-11-12 04:32:53 +00:00
|
|
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
|
|
|
boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory();
|
|
|
|
boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();
|
|
|
|
boo::ITextureR* renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], 1);
|
|
|
|
gfxF->commit();
|
|
|
|
while (m_running)
|
|
|
|
{
|
|
|
|
m_mainWindow->waitForRetrace();
|
|
|
|
|
2015-11-13 02:12:09 +00:00
|
|
|
if (m_windowCb.m_destroyed)
|
|
|
|
{
|
|
|
|
m_running = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-11-12 04:32:53 +00:00
|
|
|
if (m_windowCb.m_sizeDirty)
|
|
|
|
{
|
|
|
|
gfxQ->resizeRenderTexture(renderTex,
|
|
|
|
m_windowCb.m_latestSize.size[0],
|
|
|
|
m_windowCb.m_latestSize.size[1]);
|
|
|
|
m_windowCb.m_sizeDirty = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxQ->setRenderTarget(renderTex);
|
|
|
|
gfxQ->clearTarget();
|
|
|
|
gfxQ->resolveDisplay(renderTex);
|
|
|
|
gfxQ->execute();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
void appQuitting(boo::IApplication* app)
|
|
|
|
{
|
|
|
|
m_running = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#if _WIN32
|
|
|
|
int wmain(int argc, const boo::SystemChar** argv)
|
|
|
|
#else
|
|
|
|
int main(int argc, const boo::SystemChar** argv)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
LogVisor::RegisterConsoleLogger();
|
|
|
|
HECLApplicationCallback appCb;
|
|
|
|
int ret = boo::ApplicationRun(boo::IApplication::PLAT_AUTO,
|
|
|
|
appCb, _S("hecl"), _S("HECL"), argc, argv);
|
|
|
|
printf("IM DYING!!\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if _WIN32
|
|
|
|
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
|
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
const boo::SystemChar** argv = (const wchar_t**)(CommandLineToArgvW(lpCmdLine, &argc));
|
|
|
|
static boo::SystemChar selfPath[1024];
|
|
|
|
GetModuleFileNameW(nullptr, selfPath, 1024);
|
|
|
|
static const boo::SystemChar* booArgv[32] = {};
|
|
|
|
booArgv[0] = selfPath;
|
|
|
|
for (int i=0 ; i<argc ; ++i)
|
|
|
|
booArgv[i+1] = argv[i];
|
|
|
|
|
|
|
|
LogVisor::CreateWin32Console();
|
|
|
|
return wmain(argc+1, booArgv);
|
|
|
|
}
|
|
|
|
#endif
|