Browse Source

nx: ensure projects that use OpenGL compile properly.

legacy
Sam Hocevar 5 years ago
parent
commit
c4df7f7f91
6 changed files with 20 additions and 14 deletions
  1. +1
    -1
      build/msbuild/lol.rules.props
  2. +4
    -0
      build/msbuild/lol.vars.props
  3. +11
    -11
      src/gpu/framebuffer.cpp
  4. +1
    -1
      src/lol/engine.h
  5. +2
    -0
      src/lolgl.h
  6. +1
    -1
      src/private/nx

+ 1
- 1
build/msbuild/lol.rules.props View File

@@ -32,11 +32,11 @@
$(PegtlIncludes); $(PegtlIncludes);
$(ImguiIncludes); $(ImguiIncludes);
$(BtPhysIncludes); $(BtPhysIncludes);
$(GlIncludes);
%(AdditionalIncludeDirectories) %(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories> </AdditionalIncludeDirectories>


<AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'"> <AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32' Or '$(Platform)'=='x64'">
$(GlIncludes);
$(SdlIncludes); $(SdlIncludes);
$(FfmpegIncludes); $(FfmpegIncludes);
$(AssimpIncludes); $(AssimpIncludes);


+ 4
- 0
build/msbuild/lol.vars.props View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />

<PropertyGroup Label="UserMacros"> <PropertyGroup Label="UserMacros">
<ExternalDir>$(LolDir)\external</ExternalDir> <ExternalDir>$(LolDir)\external</ExternalDir>


@@ -142,6 +143,9 @@
<BuildMacro Include="XinputLibs"><Value>$(XinputLibs)</Value></BuildMacro> <BuildMacro Include="XinputLibs"><Value>$(XinputLibs)</Value></BuildMacro>
<BuildMacro Include="XinputDeps"><Value>$(XinputDeps)</Value></BuildMacro> <BuildMacro Include="XinputDeps"><Value>$(XinputDeps)</Value></BuildMacro>
<BuildMacro Include="Win32Defines"><Value>$(Win32Defines)</Value></BuildMacro> <BuildMacro Include="Win32Defines"><Value>$(Win32Defines)</Value></BuildMacro>
<BuildMacro Include="Nx64Deps"><Value>$(Nx64Deps)</Value></BuildMacro>
<BuildMacro Include="Nx64Libs"><Value>$(Nx64Libs)</Value></BuildMacro>
<BuildMacro Include="Nx64Defines"><Value>$(Nx64Defines)</Value></BuildMacro>
<BuildMacro Include="OrbisDeps"><Value>$(OrbisDeps)</Value></BuildMacro> <BuildMacro Include="OrbisDeps"><Value>$(OrbisDeps)</Value></BuildMacro>
<BuildMacro Include="OrbisLibs"><Value>$(OrbisLibs)</Value></BuildMacro> <BuildMacro Include="OrbisLibs"><Value>$(OrbisLibs)</Value></BuildMacro>
<BuildMacro Include="OrbisDefines"><Value>$(OrbisDefines)</Value></BuildMacro> <BuildMacro Include="OrbisDefines"><Value>$(OrbisDefines)</Value></BuildMacro>


+ 11
- 11
src/gpu/framebuffer.cpp View File

@@ -173,12 +173,12 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
{ {
m_data->m_size = size; m_data->m_size = size;
m_data->m_bound = false; 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. */ /* In OpenGL ES, internal format and format must match. */
GLenum internal_format = fbo_format.GetFormat(); GLenum internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormat(); GLenum format = fbo_format.GetFormat();
GLenum depth = GL_DEPTH_COMPONENT16; /* for WebGL */ 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 internal_format = fbo_format.GetFormat();
GLenum format = fbo_format.GetFormatOrder(); GLenum format = fbo_format.GetFormatOrder();
GLenum depth = GL_DEPTH_COMPONENT; GLenum depth = GL_DEPTH_COMPONENT;
@@ -190,7 +190,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
GLenum wrapmode = GL_CLAMP_TO_EDGE; GLenum wrapmode = GL_CLAMP_TO_EDGE;
GLenum filtering = GL_LINEAR; 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); glGenFramebuffers(1, &m_data->m_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, m_data->m_fbo); glBindFramebuffer(GL_FRAMEBUFFER, m_data->m_fbo);
#else #else
@@ -208,7 +208,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size.x, size.y, 0, glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size.x, size.y, 0,
format, GL_UNSIGNED_BYTE, nullptr); 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, glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, m_data->m_texture, 0); GL_TEXTURE_2D, m_data->m_texture, 0);
#else #else
@@ -217,7 +217,7 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)
#endif #endif


m_data->m_depth = GL_INVALID_ENUM; 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) if (depth != GL_INVALID_ENUM)
{ {
/* XXX: might not work on GL ES, see /* XXX: might not work on GL ES, see
@@ -233,13 +233,13 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)


glBindTexture(GL_TEXTURE_2D, 0); 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); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
ASSERT(status == GL_FRAMEBUFFER_COMPLETE, ASSERT(status == GL_FRAMEBUFFER_COMPLETE,
"invalid framebuffer status 0x%x", status); "invalid framebuffer status 0x%x", status);
#endif #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); glBindFramebuffer(GL_FRAMEBUFFER, 0);
#else #else
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
@@ -248,13 +248,13 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format)


Framebuffer::~Framebuffer() 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); glDeleteFramebuffers(1, &m_data->m_fbo);
#else #else
glDeleteFramebuffersOES(1, &m_data->m_fbo); glDeleteFramebuffersOES(1, &m_data->m_fbo);
#endif #endif
glDeleteTextures(1, &m_data->m_texture); 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) if (m_data->m_depth != GL_INVALID_ENUM)
glDeleteRenderbuffers(1, &m_data->m_depth); glDeleteRenderbuffers(1, &m_data->m_depth);
#endif #endif
@@ -289,7 +289,7 @@ void Framebuffer::Bind()
{ {
ASSERT(!m_data->m_bound, "trying to bind an already bound framebuffer"); 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); glBindFramebuffer(GL_FRAMEBUFFER, m_data->m_fbo);
#else #else
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_data->m_fbo); 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"); 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); glBindFramebuffer(GL_FRAMEBUFFER, 0);
#else #else
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);


+ 1
- 1
src/lol/engine.h View File

@@ -23,7 +23,7 @@
#endif #endif


// If using NX, do that, too // If using NX, do that, too
#if NN_NINTENDO_SDK
#if __NX__
# define main lol_nx_main # define main lol_nx_main
#endif #endif




+ 2
- 0
src/lolgl.h View File

@@ -35,6 +35,8 @@
* links with X11 whereas we want the system’s Cocoa-friendly GL libs. */ * links with X11 whereas we want the system’s Cocoa-friendly GL libs. */
#if defined LOL_USE_GLEW && !defined __APPLE__ #if defined LOL_USE_GLEW && !defined __APPLE__
# include <GL/glew.h> # include <GL/glew.h>
#elif defined HAVE_NN_GLL_GLL_GL_H
# include <nn/gll/gll_Gl.h>
#elif defined HAVE_GL_2X #elif defined HAVE_GL_2X
# if defined __APPLE__ && defined __MACH__ && defined __arm__ # if defined __APPLE__ && defined __MACH__ && defined __arm__
# include <OpenGL/gl.h> # include <OpenGL/gl.h>


+ 1
- 1
src/private/nx

@@ -1 +1 @@
Subproject commit 659497041784fef0adff7b0ce7ab22b9379e5f66
Subproject commit c2da1a20c6fa7b23efab7f1154d9d0ee49e7cd37

Loading…
Cancel
Save