diff --git a/.gitignore b/.gitignore index d8a3643..1d6d3a3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build *.nacp *.nro *.bz2 +*~ diff --git a/graphics/opengl/dynamic_resolution/source/main.cpp b/graphics/opengl/dynamic_resolution/source/main.cpp index 34ad9df..a800cf8 100644 --- a/graphics/opengl/dynamic_resolution/source/main.cpp +++ b/graphics/opengl/dynamic_resolution/source/main.cpp @@ -77,7 +77,7 @@ static EGLDisplay s_display; static EGLContext s_context; static EGLSurface s_surface; -static bool initEgl() +static bool initEgl(NWindow* win) { // Connect to the EGL default display s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -119,7 +119,7 @@ static bool initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", nullptr); + s_surface = eglCreateWindowSurface(s_display, config, win, nullptr); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); @@ -450,7 +450,7 @@ static void sceneUpdate(u32 kHeld) glUniformMatrix4fv(loc_mdlvMtx, 1, GL_FALSE, glm::value_ptr(mdlvMtx)); } -static void configureResolution(bool halved) +static void configureResolution(NWindow* win, bool halved) { int width, height; @@ -484,7 +484,7 @@ static void configureResolution(bool halved) // remain unused when rendering at a smaller resolution than the framebuffer). // Note that glViewport expects the coordinates of the bottom-left corner of // the viewport, so we have to calculate that too. - gfxConfigureResolution(width, height); + nwindowSetCrop(win, 0, 0, width, height); glViewport(0, 1080-height, width, height); } @@ -511,11 +511,12 @@ int main(int argc, char* argv[]) // Set mesa configuration (useful for debugging) setMesaConfig(); - // Configure the framebuffer dimensions (1080p) - gfxInitResolution(1920, 1080); + // Retrieve the default window and configure its dimensions (1080p) + NWindow* win = nwindowGetDefault(); + nwindowSetDimensions(win, 1920, 1080); - // Initialize EGL - if (!initEgl()) + // Initialize EGL on the default window + if (!initEgl(win)) return EXIT_FAILURE; // Load OpenGL routines using glad @@ -540,7 +541,7 @@ int main(int argc, char* argv[]) // will be different in handheld mode/docked mode. // As an additional demonstration, when holding A we render the scene // at half the original resolution. - configureResolution(shouldHalveResolution); + configureResolution(win, shouldHalveResolution); // Update our scene sceneUpdate(kHeld); diff --git a/graphics/opengl/es2gears/source/main.c b/graphics/opengl/es2gears/source/main.c index 2f029a4..6ebfa55 100644 --- a/graphics/opengl/es2gears/source/main.c +++ b/graphics/opengl/es2gears/source/main.c @@ -105,7 +105,7 @@ static EGLDisplay s_display; static EGLContext s_context; static EGLSurface s_surface; -static bool initEgl() +static bool initEgl(NWindow* win) { // Connect to the EGL default display s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -139,7 +139,7 @@ static bool initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", NULL); + s_surface = eglCreateWindowSurface(s_display, config, win, NULL); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); @@ -847,8 +847,8 @@ int main(int argc, char* argv[]) // Set mesa configuration (useful for debugging) setMesaConfig(); - // Initialize EGL - if (!initEgl()) + // Initialize EGL on the default window + if (!initEgl(nwindowGetDefault())) return EXIT_FAILURE; // Initialize gears demo diff --git a/graphics/opengl/gpu_console/source/gpu_console.cpp b/graphics/opengl/gpu_console/source/gpu_console.cpp index 79e5a81..c01ebed 100644 --- a/graphics/opengl/gpu_console/source/gpu_console.cpp +++ b/graphics/opengl/gpu_console/source/gpu_console.cpp @@ -404,7 +404,7 @@ bool GpuConsole::initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", nullptr); + s_surface = eglCreateWindowSurface(s_display, config, nwindowGetDefault(), nullptr); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); diff --git a/graphics/opengl/lenny/source/main.cpp b/graphics/opengl/lenny/source/main.cpp index fd22049..8cd29c1 100644 --- a/graphics/opengl/lenny/source/main.cpp +++ b/graphics/opengl/lenny/source/main.cpp @@ -74,7 +74,7 @@ static EGLDisplay s_display; static EGLContext s_context; static EGLSurface s_surface; -static bool initEgl() +static bool initEgl(NWindow* win) { // Connect to the EGL default display s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -116,7 +116,7 @@ static bool initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", nullptr); + s_surface = eglCreateWindowSurface(s_display, config, win, nullptr); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); @@ -404,8 +404,8 @@ int main(int argc, char* argv[]) // Set mesa configuration (useful for debugging) setMesaConfig(); - // Initialize EGL - if (!initEgl()) + // Initialize EGL on the default window + if (!initEgl(nwindowGetDefault())) return EXIT_FAILURE; // Load OpenGL routines using glad diff --git a/graphics/opengl/simple_triangle/source/main.cpp b/graphics/opengl/simple_triangle/source/main.cpp index 961198d..b93cdc0 100644 --- a/graphics/opengl/simple_triangle/source/main.cpp +++ b/graphics/opengl/simple_triangle/source/main.cpp @@ -61,7 +61,7 @@ static EGLDisplay s_display; static EGLContext s_context; static EGLSurface s_surface; -static bool initEgl() +static bool initEgl(NWindow* win) { // Connect to the EGL default display s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -103,7 +103,7 @@ static bool initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", nullptr); + s_surface = eglCreateWindowSurface(s_display, config, win, nullptr); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); @@ -315,8 +315,8 @@ int main(int argc, char* argv[]) // Set mesa configuration (useful for debugging) setMesaConfig(); - // Initialize EGL - if (!initEgl()) + // Initialize EGL on the default window + if (!initEgl(nwindowGetDefault())) return EXIT_FAILURE; // Load OpenGL routines using glad diff --git a/graphics/opengl/textured_cube/source/main.cpp b/graphics/opengl/textured_cube/source/main.cpp index 206ed53..1e9c91d 100644 --- a/graphics/opengl/textured_cube/source/main.cpp +++ b/graphics/opengl/textured_cube/source/main.cpp @@ -74,7 +74,7 @@ static EGLDisplay s_display; static EGLContext s_context; static EGLSurface s_surface; -static bool initEgl() +static bool initEgl(NWindow* win) { // Connect to the EGL default display s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); @@ -116,7 +116,7 @@ static bool initEgl() } // Create an EGL window surface - s_surface = eglCreateWindowSurface(s_display, config, (char*)"", nullptr); + s_surface = eglCreateWindowSurface(s_display, config, win, nullptr); if (!s_surface) { TRACE("Surface creation failed! error: %d", eglGetError()); @@ -504,8 +504,8 @@ int main(int argc, char* argv[]) // Set mesa configuration (useful for debugging) setMesaConfig(); - // Initialize EGL - if (!initEgl()) + // Initialize EGL on the default window + if (!initEgl(nwindowGetDefault())) return EXIT_FAILURE; // Load OpenGL routines using glad