ezResult ezRendererTestBasics::InitializeSubTest(ezInt32 iIdentifier) { m_iFrame = -1; if (ezGraphicsTest::InitializeSubTest(iIdentifier).Failed()) return EZ_FAILURE; if (iIdentifier == SubTests::ST_ClearScreen) { return SetupRenderer(320, 240); } if (SetupRenderer().Failed()) return EZ_FAILURE; m_hSphere = CreateSphere(3, 1.0f); m_hSphere2 = CreateSphere(1, 0.75f); m_hTorus = CreateTorus(16, 0.5f, 0.75f); m_hLongBox = CreateBox(0.4f, 0.2f, 2.0f); m_hLineBox = CreateLineBox(0.4f, 0.2f, 2.0f); return EZ_SUCCESS; }
void ezImguiRenderer::RenderBatch(const ezRenderViewContext& renderContext, ezRenderPipelinePass* pPass, const ezRenderDataBatch& batch) { if (ezImgui::GetSingleton() == nullptr) return; SetupRenderer(); ezRenderContext* pRenderContext = renderContext.m_pRenderContext; ezGALContext* pGALContext = pRenderContext->GetGALContext(); pRenderContext->BindShader(m_hShader); const auto& textures = ezImgui::GetSingleton()->m_hTextures; const ezUInt32 numTextures = textures.GetCount(); for (auto it = batch.GetIterator<ezImguiRenderData>(); it.IsValid(); ++it) { const ezImguiRenderData* pRenderData = pRenderData = it; EZ_ASSERT_DEV(pRenderData->m_Vertices.GetCount() < VertexBufferSize, "GUI has too many elements to render in one drawcall"); EZ_ASSERT_DEV(pRenderData->m_Indices.GetCount() < IndexBufferSize, "GUI has too many elements to render in one drawcall"); pGALContext->UpdateBuffer(m_hVertexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Vertices.GetPtr(), pRenderData->m_Vertices.GetCount()).ToByteArray()); pGALContext->UpdateBuffer(m_hIndexBuffer, 0, ezMakeArrayPtr(pRenderData->m_Indices.GetPtr(), pRenderData->m_Indices.GetCount()).ToByteArray()); pRenderContext->BindMeshBuffer(m_hVertexBuffer, m_hIndexBuffer, &m_VertexDeclarationInfo, ezGALPrimitiveTopology::Triangles, pRenderData->m_Indices.GetCount() / 3); ezUInt32 uiFirstIndex = 0; const ezUInt32 numBatches = pRenderData->m_Batches.GetCount(); for (ezUInt32 batchIdx = 0; batchIdx < numBatches; ++batchIdx) { const ezImguiBatch& batch = pRenderData->m_Batches[batchIdx]; if (batch.m_uiVertexCount > 0 && batch.m_uiTextureID < numTextures) { pGALContext->SetScissorRect(batch.m_ScissorRect); pRenderContext->BindTexture2D("BaseTexture", textures[batch.m_uiTextureID]); pRenderContext->DrawMeshBuffer(batch.m_uiVertexCount / 3, uiFirstIndex / 3); } uiFirstIndex += batch.m_uiVertexCount; } } }
int main(int argc, char** argv) { #ifdef PIONEER_PROFILER Profiler::detect( argc, argv ); #endif RunMode mode = MODE_MODELCOMPILER; if (argc > 1) { const char switchchar = argv[1][0]; if (!(switchchar == '-' || switchchar == '/')) { mode = MODE_USAGE_ERROR; goto start; } const std::string modeopt(std::string(argv[1]).substr(1)); if (modeopt == "compile" || modeopt == "c") { mode = MODE_MODELCOMPILER; goto start; } if (modeopt == "batch" || modeopt == "b") { mode = MODE_MODELBATCHEXPORT; goto start; } if (modeopt == "version" || modeopt == "v") { mode = MODE_VERSION; goto start; } if (modeopt == "help" || modeopt == "h" || modeopt == "?") { mode = MODE_USAGE; goto start; } mode = MODE_USAGE_ERROR; } start: // Init here since we'll need it for both batch and RunCompiler modes. FileSystem::Init(); // what mode are we in? switch (mode) { case MODE_MODELCOMPILER: { std::string modelName; if (argc > 2) { modelName = argv[2]; SetupRenderer(); RunCompiler(modelName, s_dummyPath, false); } break; } case MODE_MODELBATCHEXPORT: { // determine if we're meant to be writing these in the source directory bool isInPlace = false; if (argc > 2) { std::string arg2 = argv[2]; isInPlace = (arg2 == "inplace" || arg2 == "true"); } // find all of the models std::vector<std::pair<std::string, std::string>> list_model; FileSystem::FileSource &fileSource = FileSystem::gameDataFiles; for (FileSystem::FileEnumerator files(fileSource, "models", FileSystem::FileEnumerator::Recurse); !files.Finished(); files.Next()) { const FileSystem::FileInfo &info = files.Current(); const std::string &fpath = info.GetPath(); //check it's the expected type if (info.IsFile()) { if (ends_with_ci(fpath, ".model")) { // store the path for ".model" files list_model.push_back( std::make_pair(info.GetName().substr(0, info.GetName().size()-6), fpath) ); } } } SetupRenderer(); for (auto &modelName : list_model) { RunCompiler(modelName.first, modelName.second, isInPlace); } break; } case MODE_VERSION: { std::string version(PIONEER_VERSION); if (strlen(PIONEER_EXTRAVERSION)) version += " (" PIONEER_EXTRAVERSION ")"; Output("modelcompiler %s\n", version.c_str()); break; } case MODE_USAGE_ERROR: Output("modelcompiler: unknown mode %s\n", argv[1]); // fall through case MODE_USAGE: Output( "usage: modelcompiler [mode] [options...]\n" "available modes:\n" " -compile [-c] model compiler\n" " -batch [-b] batch mode output into users home/Pioneer directory\n" " -batch inplace [-b inplace] batch mode output into the source folder\n" " -version [-v] show version\n" " -help [-h,-?] this help\n" ); break; } return 0; }