WIP Backend System Redesign Step 1
- Created 1 Context for Backend Management and Sharing - Made every class that used a static Backend require the Context or specific Backend - Bring Back 3ds support
This commit is contained in:
@@ -73,10 +73,19 @@ int main() {
|
||||
C3D_RenderTargetSetOutput(Bottom, GFX_BOTTOM, GFX_LEFT, DisplayTransferFlags);
|
||||
#endif
|
||||
/** Init Palaldium Drivers */
|
||||
PD::Init(PD_INIT_DATA);
|
||||
PD::Context Ctx;
|
||||
#ifdef __3DS__
|
||||
Ctx.UseGfxDriver<PD::GfxC3D>(PD_INIT_DATA);
|
||||
Ctx.UseHidDriver<PD::Hid3DS>(PD_INIT_DATA);
|
||||
#else
|
||||
Ctx.UseGfxDriver<PD::GfxGL2>(PD_INIT_DATA);
|
||||
Ctx.UseHidDriver<PD::HidGLFW>(PD_INIT_DATA);
|
||||
#endif
|
||||
Ctx.Gfx()->Init();
|
||||
|
||||
/** Create DrawList and Load Font */
|
||||
PD::Li::DrawList::Ref List = PD::Li::DrawList::New();
|
||||
PD::Li::Font::Ref font = PD::Li::Font::New();
|
||||
PD::Li::DrawList::Ref List = PD::Li::DrawList::New(Ctx);
|
||||
PD::Li::Font::Ref font = PD::Li::Font::New(Ctx);
|
||||
#ifdef __3DS__
|
||||
font->LoadTTF("sdmc:/ComicNeue.ttf", 32);
|
||||
auto img = PD::Image::New("sdmc:/pb.png");
|
||||
@@ -86,10 +95,10 @@ int main() {
|
||||
#endif
|
||||
List->SetFont(font);
|
||||
PD::Image::Convert(img, img->RGBA);
|
||||
auto tex = PD::Gfx::LoadTex(img->pBuffer, img->pWidth, img->pHeight);
|
||||
auto tex = Ctx.Gfx()->LoadTex(img->pBuffer, img->pWidth, img->pHeight);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
auto ui7 = PD::UI7::Context::New();
|
||||
auto ui7 = PD::UI7::Context::New(Ctx);
|
||||
PD::UI7::ID VpTop("Default");
|
||||
ui7->AddViewPort(VpTop, PD::ivec4(0, 0, 400, 240));
|
||||
ui7->UseViewPort(VpTop);
|
||||
@@ -100,15 +109,15 @@ int main() {
|
||||
font->DefaultPixelHeight = 32;
|
||||
while (!glfwWindowShouldClose(win)) {
|
||||
#else
|
||||
PD::Gfx::pGfx->ViewPort = PD::ivec2(400, 240);
|
||||
Ctx.Gfx()->SetViewPort(400, 240);
|
||||
while (aptMainLoop()) {
|
||||
#endif
|
||||
PD::Hid::Update();
|
||||
Ctx.Hid()->Update();
|
||||
#ifndef __3DS__
|
||||
/** Auto ViewPort Resize */
|
||||
int wx, wy;
|
||||
glfwGetWindowSize(win, &wx, &wy);
|
||||
PD::Gfx::pGfx->ViewPort = PD::ivec2(wx, wy);
|
||||
Ctx.Gfx()->SetViewPort(wx, wy);
|
||||
ui7->GetIO()->CurrentViewPort = PD::ivec4(0, 0, wx, wy);
|
||||
glViewport(0, 0, wx, wy);
|
||||
glClearColor(0.1, 0.1, 0.1, 1);
|
||||
@@ -121,7 +130,7 @@ int main() {
|
||||
RoundedRect(List, PD::fvec2(15, 183), PD::fvec2(100, 40), 0xaa222222);
|
||||
List->DrawTexture(tex);
|
||||
RoundedRect(List, PD::fvec2(200, 50), 100, 0xffffffff,
|
||||
((1 + std::sin(PD::OS::GetTime() / 1000.f)) * 0.5f) * 100.f);
|
||||
((1 + std::sin(Ctx.Os()->GetTime() / 1000.f)) * 0.5f) * 100.f);
|
||||
List->DrawText(PD::fvec2(50, 190), "OK", 0xffffffff);
|
||||
// List->DrawLine(PD::fvec2(0), PD::fvec2(1000, 600), 0xffffffff);
|
||||
List->PathAdd(500);
|
||||
@@ -135,8 +144,8 @@ int main() {
|
||||
"Test String oder So\nPalladium 0.6.0\n" +
|
||||
std::format("{}\nMousePos: {}",
|
||||
PD::Strings::FormatNanos(
|
||||
PD::OS::GetTraceRef("REN")->GetLastDiff()),
|
||||
PD::Hid::MousePos()) +
|
||||
Ctx.Os()->GetTraceRef("REN")->GetLastDiff()),
|
||||
Ctx.Hid()->MousePos()) +
|
||||
"\nUI7 Version: " + PD::UI7::GetVersion(),
|
||||
0xff000000);
|
||||
if (auto menu = ui7->BeginMenu("Test")) {
|
||||
@@ -147,20 +156,20 @@ int main() {
|
||||
if (menu->Button("Test")) {
|
||||
break;
|
||||
}
|
||||
menu->Label(std::format("MousePos: {}", PD::Hid::MousePos()));
|
||||
menu->Label(std::format("MousePos: {}", Ctx.Hid()->MousePos()));
|
||||
menu->Label(std::format("this->Pos: {}", menu->pLayout->GetPosition()));
|
||||
menu->Label(std::format("Dragged; #{:08X}",
|
||||
menu->Label(std::format("Dragged: #{:08X}",
|
||||
ui7->pIO->InputHandler->DraggedObject));
|
||||
menu->Label(
|
||||
std::format("Left: {}", PD::Hid::IsHeld(PD::Hid::Key::Touch)));
|
||||
std::format("Left: {}", Ctx.Hid()->IsHeld(PD::Hid::Key::Touch)));
|
||||
menu->DragData("Value", &v, 1);
|
||||
menu->Slider("Value 2", &v);
|
||||
ui7->EndMenu();
|
||||
}
|
||||
if (auto menu = ui7->BeginMenu("Yet another Window")) {
|
||||
menu->Label(std::format("this->Pos: {}", menu->pLayout->GetPosition()));
|
||||
menu->Label(std::format("Vertices: {}", PD::Gfx::pGfx->VertexCounter));
|
||||
menu->Label(std::format("Indices: {}", PD::Gfx::pGfx->IndexCounter));
|
||||
menu->Label(std::format("Vertices: {}", Ctx.Gfx()->VertexCounter));
|
||||
menu->Label(std::format("Indices: {}", Ctx.Gfx()->IndexCounter));
|
||||
ui7->EndMenu();
|
||||
}
|
||||
if (auto menu = ui7->BeginMenu("#Debug (UI7)")) {
|
||||
@@ -192,22 +201,22 @@ int main() {
|
||||
ui7->AboutMenu(&AboutOderSo);
|
||||
ui7->MetricsMenu();
|
||||
ui7->StyleEditor();
|
||||
PD::TT::Beg("ui7->Update");
|
||||
PD::TT::Beg(*Ctx.Os(), "ui7->Update");
|
||||
ui7->Update();
|
||||
PD::TT::End("ui7->Update");
|
||||
PD::TT::End(*Ctx.Os(), "ui7->Update");
|
||||
/** Render DrawData */
|
||||
#ifdef __3DS__
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C3D_FrameDrawOn(Top);
|
||||
C3D_RenderTargetClear(Top, C3D_CLEAR_ALL, 0x00000000, 0);
|
||||
#endif
|
||||
PD::TT::Beg("REN");
|
||||
PD::Gfx::NewFrame();
|
||||
PD::Gfx::RenderDrawData(List->Data());
|
||||
PD::Gfx::RenderDrawData(ui7->GetDrawData()->Data());
|
||||
PD::TT::Beg(*Ctx.Os(), "REN");
|
||||
Ctx.Gfx()->NewFrame();
|
||||
Ctx.Gfx()->RenderDrawData(List->Data());
|
||||
Ctx.Gfx()->RenderDrawData(ui7->GetDrawData()->Data());
|
||||
/** Clear The List */
|
||||
List->Clear();
|
||||
PD::TT::End("REN");
|
||||
PD::TT::End(*Ctx.Os(), "REN");
|
||||
#ifndef __3DS__
|
||||
/** Do OS Specifc Stuff (swapp buffers / window buttan events) */
|
||||
glfwPollEvents();
|
||||
@@ -221,3 +230,45 @@ int main() {
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __3DS__
|
||||
int main2() {
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
#ifdef __APPLE__
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, 0);
|
||||
#else
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
#endif
|
||||
glfwWindowHint(GLFW_SAMPLES, 8);
|
||||
auto win = glfwCreateWindow(1280, 720, "Test", nullptr, nullptr);
|
||||
glfwMakeContextCurrent(win);
|
||||
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
auto Ctx = PD::Context::Create();
|
||||
Ctx->UseOsDriver<PD::OsDriver>(nullptr);
|
||||
Ctx->UseGfxDriver<PD::GfxGL2>(nullptr);
|
||||
Ctx->UseHidDriver<PD::HidGLFW>(win);
|
||||
Ctx->Gfx()->Init(); // Need to get rid of this
|
||||
PD::Li::DrawList pDL(*Ctx);
|
||||
pDL.DrawRectFilled(0, 50, 0xffffffff);
|
||||
std::cout << Ctx->Os()->GetName() << std::endl;
|
||||
std::cout << Ctx->Gfx()->GetName() << std::endl;
|
||||
std::cout << Ctx->Hid()->GetName() << std::endl;
|
||||
while (!glfwWindowShouldClose(win)) {
|
||||
Ctx->Hid()->Update();
|
||||
int wx, wy;
|
||||
glfwGetWindowSize(win, &wx, &wy);
|
||||
Ctx->Gfx()->SetViewPort(wx, wy);
|
||||
glViewport(0, 0, wx, wy);
|
||||
glClearColor(0.1, 0.1, 0.1, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
Ctx->Gfx()->NewFrame();
|
||||
Ctx->Gfx()->RenderDrawData(pDL.Data());
|
||||
glfwPollEvents();
|
||||
glfwSwapBuffers(win);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user