mirror of https://github.com/AxioDL/metaforce.git
heclTest fixes
This commit is contained in:
parent
501f4724a3
commit
6016f2d14b
|
@ -1 +1 @@
|
||||||
Subproject commit 49da287791855dd83d71a06a1460ab2797c6a0eb
|
Subproject commit 4d133edd2cf3b31ceef7970e2b77edbd18a7d5ab
|
|
@ -5,6 +5,9 @@
|
||||||
#include "HECL/HMDLMeta.hpp"
|
#include "HECL/HMDLMeta.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
struct HECLWindowCallback : boo::IWindowCallback
|
struct HECLWindowCallback : boo::IWindowCallback
|
||||||
{
|
{
|
||||||
|
@ -28,16 +31,51 @@ struct HECLApplicationCallback : boo::IApplicationCallback
|
||||||
HECLWindowCallback m_windowCb;
|
HECLWindowCallback m_windowCb;
|
||||||
boo::IWindow* m_mainWindow = nullptr;
|
boo::IWindow* m_mainWindow = nullptr;
|
||||||
bool m_running = true;
|
bool m_running = true;
|
||||||
|
|
||||||
int appMain(boo::IApplication* app)
|
int appMain(boo::IApplication* app)
|
||||||
{
|
{
|
||||||
/* Setup boo window */
|
/* Setup boo window */
|
||||||
m_mainWindow = app->newWindow(_S("HECL Test"));
|
m_mainWindow = app->newWindow(_S("HECL Test"));
|
||||||
m_mainWindow->setCallback(&m_windowCb);
|
m_mainWindow->setCallback(&m_windowCb);
|
||||||
m_mainWindow->showWindow();
|
|
||||||
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
boo::ITextureR* renderTex = nullptr;
|
||||||
|
boo::IGraphicsBufferD* vubo = nullptr;
|
||||||
|
boo::IShaderDataBinding* binding = nullptr;
|
||||||
|
|
||||||
|
struct VertexUBO
|
||||||
|
{
|
||||||
|
float modelview[4][4] = {};
|
||||||
|
float modelviewInv[4][4] = {};
|
||||||
|
float projection[4][4] = {};
|
||||||
|
VertexUBO()
|
||||||
|
{
|
||||||
|
modelview[0][0] = 1.0;
|
||||||
|
modelview[1][1] = 1.0;
|
||||||
|
modelview[2][2] = 1.0;
|
||||||
|
modelview[3][3] = 1.0;
|
||||||
|
modelviewInv[0][0] = 1.0;
|
||||||
|
modelviewInv[1][1] = 1.0;
|
||||||
|
modelviewInv[2][2] = 1.0;
|
||||||
|
modelviewInv[3][3] = 1.0;
|
||||||
|
projection[0][0] = 1.0;
|
||||||
|
projection[1][1] = 1.0;
|
||||||
|
projection[2][2] = 1.0;
|
||||||
|
projection[3][3] = 1.0;
|
||||||
|
}
|
||||||
|
} vuboData;
|
||||||
|
|
||||||
|
std::mutex initmt;
|
||||||
|
std::condition_variable initcv;
|
||||||
|
std::mutex loadmt;
|
||||||
|
std::condition_variable loadcv;
|
||||||
|
std::unique_lock<std::mutex> outerLk(initmt);
|
||||||
|
std::thread loaderThr([&]()
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> innerLk(initmt);
|
||||||
boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory();
|
boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory();
|
||||||
|
|
||||||
boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();
|
boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();
|
||||||
boo::ITextureR* renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], 1);
|
renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], 1);
|
||||||
|
|
||||||
/* HECL managers */
|
/* HECL managers */
|
||||||
HECL::Runtime::FileStoreManager fileMgr(app->getUniqueName());
|
HECL::Runtime::FileStoreManager fileMgr(app->getUniqueName());
|
||||||
|
@ -100,36 +138,31 @@ struct HECLApplicationCallback : boo::IApplicationCallback
|
||||||
gfxF->newStaticTexture(256, 256, 1, boo::TextureFormatRGBA8, tex, 256*256*4);
|
gfxF->newStaticTexture(256, 256, 1, boo::TextureFormatRGBA8, tex, 256*256*4);
|
||||||
|
|
||||||
/* Make vertex uniform buffer */
|
/* Make vertex uniform buffer */
|
||||||
struct VertexUBO
|
vubo = gfxF->newDynamicBuffer(boo::BufferUseUniform, sizeof(VertexUBO), 1);
|
||||||
{
|
|
||||||
float modelview[4][4] = {};
|
|
||||||
float modelviewInv[4][4] = {};
|
|
||||||
float projection[4][4] = {};
|
|
||||||
VertexUBO()
|
|
||||||
{
|
|
||||||
modelview[0][0] = 1.0;
|
|
||||||
modelview[1][1] = 1.0;
|
|
||||||
modelview[2][2] = 1.0;
|
|
||||||
modelview[3][3] = 1.0;
|
|
||||||
modelviewInv[0][0] = 1.0;
|
|
||||||
modelviewInv[1][1] = 1.0;
|
|
||||||
modelviewInv[2][2] = 1.0;
|
|
||||||
modelviewInv[3][3] = 1.0;
|
|
||||||
projection[0][0] = 1.0;
|
|
||||||
projection[1][1] = 1.0;
|
|
||||||
projection[2][2] = 1.0;
|
|
||||||
projection[3][3] = 1.0;
|
|
||||||
}
|
|
||||||
} vuboData;
|
|
||||||
boo::IGraphicsBufferD* vubo =
|
|
||||||
gfxF->newDynamicBuffer(boo::BufferUseUniform, sizeof(VertexUBO), 1);
|
|
||||||
|
|
||||||
/* Assemble data binding */
|
/* Assemble data binding */
|
||||||
boo::IShaderDataBinding* binding =
|
binding = testData.newShaderDataBindng(gfxF, testShaderObj, 1, (boo::IGraphicsBuffer**)&vubo, 1, &texture);
|
||||||
testData.newShaderDataBindng(gfxF, testShaderObj, 1, (boo::IGraphicsBuffer**)&vubo, 1, &texture);
|
|
||||||
|
|
||||||
gfxF->commit();
|
gfxF->commit();
|
||||||
|
|
||||||
|
/* Return control to main thread */
|
||||||
|
innerLk.unlock();
|
||||||
|
initcv.notify_one();
|
||||||
|
|
||||||
|
/* Wait for exit */
|
||||||
|
std::unique_lock<std::mutex> lk(loadmt);
|
||||||
|
while (m_running)
|
||||||
|
{
|
||||||
|
loadcv.wait(lk);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
initcv.wait(outerLk);
|
||||||
|
|
||||||
|
m_mainWindow->showWindow();
|
||||||
|
m_windowCb.m_latestSize = m_mainWindow->getWindowFrame();
|
||||||
|
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
|
||||||
|
m_mainWindow->getMainContextDataFactory();
|
||||||
|
|
||||||
size_t frameIdx = 0;
|
size_t frameIdx = 0;
|
||||||
while (m_running)
|
while (m_running)
|
||||||
{
|
{
|
||||||
|
@ -162,6 +195,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
|
||||||
vuboData.modelview[3][0] = sinf(frameIdx / 60.0) * 0.5;
|
vuboData.modelview[3][0] = sinf(frameIdx / 60.0) * 0.5;
|
||||||
vuboData.modelview[3][1] = cosf(frameIdx / 60.0) * 0.5;
|
vuboData.modelview[3][1] = cosf(frameIdx / 60.0) * 0.5;
|
||||||
vubo->load(&vuboData, sizeof(vuboData));
|
vubo->load(&vuboData, sizeof(vuboData));
|
||||||
|
gfxQ->flushBufferUpdates();
|
||||||
|
|
||||||
gfxQ->setShaderDataBinding(binding);
|
gfxQ->setShaderDataBinding(binding);
|
||||||
gfxQ->draw(0, 4);
|
gfxQ->draw(0, 4);
|
||||||
|
@ -170,6 +204,11 @@ struct HECLApplicationCallback : boo::IApplicationCallback
|
||||||
|
|
||||||
++frameIdx;
|
++frameIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> finallk(loadmt);
|
||||||
|
finallk.unlock();
|
||||||
|
loadcv.notify_one();
|
||||||
|
loaderThr.join();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void appQuitting(boo::IApplication* app)
|
void appQuitting(boo::IApplication* app)
|
||||||
|
|
Loading…
Reference in New Issue