diff --git a/m3dialib/source/core/applet.cpp b/m3dialib/source/core/applet.cpp index 5d3c07e..67fabc4 100644 --- a/m3dialib/source/core/applet.cpp +++ b/m3dialib/source/core/applet.cpp @@ -1,4 +1,5 @@ #include <3ds.h> +#include #include #include "m3d/core/applet.hpp" #include "m3d/core/ledPattern.hpp" @@ -15,6 +16,8 @@ namespace m3d { acInit(); romfsInit(); sdmcInit(); + gfxInitDefault(); + C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); Result res; res = ndspInit(); @@ -34,6 +37,8 @@ namespace m3d { Applet::~Applet() { m3d::LEDPattern::stop(); if (m3d::priv::ndsp::initialized) ndspExit(); + C3D_Fini(); + gfxExit(); sdmcExit(); romfsExit(); acExit(); @@ -43,7 +48,10 @@ namespace m3d { } bool Applet::isRunning() { + if (!aptMainLoop()) return false; + hidScanInput(); // scan input since this gets called every frame + C3D_FrameEnd(0); m_currentFrame++; return m_running; } diff --git a/m3dialib/source/graphics/screen.cpp b/m3dialib/source/graphics/screen.cpp index 55ca835..9c90dc4 100644 --- a/m3dialib/source/graphics/screen.cpp +++ b/m3dialib/source/graphics/screen.cpp @@ -16,8 +16,6 @@ namespace m3d { m_useFogBottom(false), m_fogDensityTop(0.05), m_fogDensityBottom(0.05) { - gfxInitDefault(); - C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C2D_Init(C2D_DEFAULT_MAX_OBJECTS); gfxSet3D(m_3dEnabled); m_targetTopLeft = new m3d::RenderTarget(400, 240); @@ -68,8 +66,6 @@ namespace m3d { Screen::~Screen() { C2D_Fini(); - C3D_Fini(); - gfxExit(); shaderProgramFree(&m_shader); DVLB_Free(m_dvlb); delete m_targetTopLeft;