From c4df7f7f91645d9f3c72bdf19425e036d129e73c Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 2 May 2019 13:54:42 +0200 Subject: [PATCH] nx: ensure projects that use OpenGL compile properly. --- build/msbuild/lol.rules.props | 2 +- build/msbuild/lol.vars.props | 4 ++++ src/gpu/framebuffer.cpp | 22 +++++++++++----------- src/lol/engine.h | 2 +- src/lolgl.h | 2 ++ src/private/nx | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/build/msbuild/lol.rules.props b/build/msbuild/lol.rules.props index 6c4297d1..8662e5b6 100644 --- a/build/msbuild/lol.rules.props +++ b/build/msbuild/lol.rules.props @@ -32,11 +32,11 @@ $(PegtlIncludes); $(ImguiIncludes); $(BtPhysIncludes); + $(GlIncludes); %(AdditionalIncludeDirectories) - $(GlIncludes); $(SdlIncludes); $(FfmpegIncludes); $(AssimpIncludes); diff --git a/build/msbuild/lol.vars.props b/build/msbuild/lol.vars.props index 4e56e22e..410857e4 100644 --- a/build/msbuild/lol.vars.props +++ b/build/msbuild/lol.vars.props @@ -1,6 +1,7 @@  + $(LolDir)\external @@ -142,6 +143,9 @@ $(XinputLibs) $(XinputDeps) $(Win32Defines) + $(Nx64Deps) + $(Nx64Libs) + $(Nx64Defines) $(OrbisDeps) $(OrbisLibs) $(OrbisDefines) diff --git a/src/gpu/framebuffer.cpp b/src/gpu/framebuffer.cpp index 0ec4bd7b..ee1c4943 100644 --- a/src/gpu/framebuffer.cpp +++ b/src/gpu/framebuffer.cpp @@ -173,12 +173,12 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) { m_data->m_size = size; m_data->m_bound = false; -#if GL_ES_VERSION_2_0 +#if defined GL_ES_VERSION_2_0 /* In OpenGL ES, internal format and format must match. */ GLenum internal_format = fbo_format.GetFormat(); GLenum format = fbo_format.GetFormat(); GLenum depth = GL_DEPTH_COMPONENT16; /* for WebGL */ -#elif GL_VERSION_1_1 +#elif defined GL_VERSION_1_1 GLenum internal_format = fbo_format.GetFormat(); GLenum format = fbo_format.GetFormatOrder(); GLenum depth = GL_DEPTH_COMPONENT; @@ -190,7 +190,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) GLenum wrapmode = GL_CLAMP_TO_EDGE; GLenum filtering = GL_LINEAR; -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glGenFramebuffers(1, &m_data->m_fbo); glBindFramebuffer(GL_FRAMEBUFFER, m_data->m_fbo); #else @@ -208,7 +208,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size.x, size.y, 0, format, GL_UNSIGNED_BYTE, nullptr); -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_data->m_texture, 0); #else @@ -217,7 +217,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) #endif m_data->m_depth = GL_INVALID_ENUM; -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 if (depth != GL_INVALID_ENUM) { /* XXX: might not work on GL ES, see @@ -233,13 +233,13 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) glBindTexture(GL_TEXTURE_2D, 0); -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); ASSERT(status == GL_FRAMEBUFFER_COMPLETE, "invalid framebuffer status 0x%x", status); #endif -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glBindFramebuffer(GL_FRAMEBUFFER, 0); #else glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); @@ -248,13 +248,13 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) Framebuffer::~Framebuffer() { -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glDeleteFramebuffers(1, &m_data->m_fbo); #else glDeleteFramebuffersOES(1, &m_data->m_fbo); #endif glDeleteTextures(1, &m_data->m_texture); -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 if (m_data->m_depth != GL_INVALID_ENUM) glDeleteRenderbuffers(1, &m_data->m_depth); #endif @@ -289,7 +289,7 @@ void Framebuffer::Bind() { ASSERT(!m_data->m_bound, "trying to bind an already bound framebuffer"); -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glBindFramebuffer(GL_FRAMEBUFFER, m_data->m_fbo); #else glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_data->m_fbo); @@ -308,7 +308,7 @@ void Framebuffer::Unbind() { ASSERT(m_data->m_bound, "trying to unbind an unbound framebuffer"); -#if GL_VERSION_1_1 || GL_ES_VERSION_2_0 +#if defined GL_VERSION_1_1 || defined GL_ES_VERSION_2_0 glBindFramebuffer(GL_FRAMEBUFFER, 0); #else glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); diff --git a/src/lol/engine.h b/src/lol/engine.h index 14b6f14c..1ab6f42b 100644 --- a/src/lol/engine.h +++ b/src/lol/engine.h @@ -23,7 +23,7 @@ #endif // If using NX, do that, too -#if NN_NINTENDO_SDK +#if __NX__ # define main lol_nx_main #endif diff --git a/src/lolgl.h b/src/lolgl.h index 3643706b..af012909 100644 --- a/src/lolgl.h +++ b/src/lolgl.h @@ -35,6 +35,8 @@ * links with X11 whereas we want the system’s Cocoa-friendly GL libs. */ #if defined LOL_USE_GLEW && !defined __APPLE__ # include +#elif defined HAVE_NN_GLL_GLL_GL_H +# include #elif defined HAVE_GL_2X # if defined __APPLE__ && defined __MACH__ && defined __arm__ # include diff --git a/src/private/nx b/src/private/nx index 65949704..c2da1a20 160000 --- a/src/private/nx +++ b/src/private/nx @@ -1 +1 @@ -Subproject commit 659497041784fef0adff7b0ce7ab22b9379e5f66 +Subproject commit c2da1a20c6fa7b23efab7f1154d9d0ee49e7cd37