From 685dcd1c8a3bc07e756e9a2ccaaccb2ba304268d Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sat, 20 Mar 2021 09:36:56 +0100 Subject: [PATCH] Variable length arrays not supported by msvc. Fix MacOS project --- core/rend/gles/quad.cpp | 17 +++++++++---- .../reicast-osx.xcodeproj/project.pbxproj | 24 ++++++++++++------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/core/rend/gles/quad.cpp b/core/rend/gles/quad.cpp index b629bb9bd..1b554c518 100644 --- a/core/rend/gles/quad.cpp +++ b/core/rend/gles/quad.cpp @@ -82,17 +82,24 @@ void initQuad() { if (shader == 0) { - char vtx[strlen(VertexShader) * 2]; - snprintf(vtx, sizeof(vtx), VertexShader, gl.glsl_version_header, gl.gl_version, 0); - char frag[strlen(FragmentShader) * 2]; - snprintf(frag, sizeof(frag), FragmentShader, gl.glsl_version_header, gl.gl_version); + size_t shaderLength = strlen(FragmentShader) * 2; + char *frag = new char[shaderLength]; + snprintf(frag, shaderLength, FragmentShader, gl.glsl_version_header, gl.gl_version); + + shaderLength = strlen(VertexShader) * 2; + char *vtx = new char[shaderLength]; + snprintf(vtx, shaderLength, VertexShader, gl.glsl_version_header, gl.gl_version, 0); shader = gl_CompileAndLink(vtx, frag); GLint tex = glGetUniformLocation(shader, "tex"); glUniform1i(tex, 0); // texture 0 - snprintf(vtx, sizeof(vtx), VertexShader, gl.glsl_version_header, gl.gl_version, 1); + + snprintf(vtx, shaderLength, VertexShader, gl.glsl_version_header, gl.gl_version, 1); rot90shader = gl_CompileAndLink(vtx, frag); tex = glGetUniformLocation(rot90shader, "tex"); glUniform1i(tex, 0); // texture 0 + + delete [] vtx; + delete [] frag; } #ifndef GLES2 if (quadVertexArray == 0 && gl.gl_major >= 3) diff --git a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj index d898ab9cd..2c0374c87 100644 --- a/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj +++ b/shell/apple/emulator-osx/reicast-osx.xcodeproj/project.pbxproj @@ -330,6 +330,7 @@ AEA93E68259D07A30076297F /* pico_dhcp_common.c in Sources */ = {isa = PBXBuildFile; fileRef = AEA93E66259D07A30076297F /* pico_dhcp_common.c */; }; AEA93E6D259DE9160076297F /* pico_icmp4.c in Sources */ = {isa = PBXBuildFile; fileRef = AEA93E6C259DE9160076297F /* pico_icmp4.c */; }; AEA94931244CDF50001134C7 /* naomi_flashrom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEA9492F244CDF50001134C7 /* naomi_flashrom.cpp */; }; + AED4473C25FC0CF100B045FF /* quad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED4473B25FC0CF100B045FF /* quad.cpp */; }; AED73DC42303E19200ECDB64 /* sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73DC02303E19100ECDB64 /* sdl.cpp */; }; AED73DCC233ACC9800ECDB64 /* cheats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73DCB233ACC9800ECDB64 /* cheats.cpp */; }; AED73EBE2348E49900ECDB64 /* CustomTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73EAB2348E49800ECDB64 /* CustomTexture.cpp */; }; @@ -664,10 +665,6 @@ 84B7BF821B727AD700F9733F /* osx-main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "osx-main.mm"; sourceTree = ""; }; 84B7BF841B72821900F9733F /* emulator-osx-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "emulator-osx-Bridging-Header.h"; sourceTree = ""; }; 84B7BF851B72871600F9733F /* EmuGLView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmuGLView.swift; sourceTree = ""; }; - AE1E292820947D4700FC6BA2 /* xbyak.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbyak.h; sourceTree = ""; }; - AE1E292920947D4700FC6BA2 /* xbyak_bin2hex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbyak_bin2hex.h; sourceTree = ""; }; - AE1E292A20947D4700FC6BA2 /* xbyak_mnemonic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbyak_mnemonic.h; sourceTree = ""; }; - AE1E292B20947D4700FC6BA2 /* xbyak_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbyak_util.h; sourceTree = ""; }; AE1E293A2095FB1600FC6BA2 /* rec_cpp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rec_cpp.cpp; sourceTree = ""; }; AE1E293F20A96B0B00FC6BA2 /* rec_x64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rec_x64.cpp; sourceTree = ""; }; AE2A234922941A0500DD3034 /* NaomiConfig.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NaomiConfig.xcconfig; sourceTree = ""; }; @@ -993,6 +990,13 @@ AEA93E6C259DE9160076297F /* pico_icmp4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pico_icmp4.c; sourceTree = ""; }; AEA9492F244CDF50001134C7 /* naomi_flashrom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = naomi_flashrom.cpp; sourceTree = ""; }; AEA94930244CDF50001134C7 /* naomi_roms_eeprom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = naomi_roms_eeprom.h; sourceTree = ""; }; + AED4473B25FC0CF100B045FF /* quad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = quad.cpp; sourceTree = ""; }; + AED4473D25FCB8C600B045FF /* xbyak_bin2hex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xbyak_bin2hex.h; path = xbyak/xbyak_bin2hex.h; sourceTree = ""; }; + AED4473E25FCB8C600B045FF /* xbyak.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xbyak.h; path = xbyak/xbyak.h; sourceTree = ""; }; + AED4473F25FCB8C600B045FF /* xbyak_mnemonic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xbyak_mnemonic.h; path = xbyak/xbyak_mnemonic.h; sourceTree = ""; }; + AED4474025FCB8C600B045FF /* xbyak_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xbyak_util.h; path = xbyak/xbyak_util.h; sourceTree = ""; }; + AED4474125FCBC8900B045FF /* xbyak_base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbyak_base.h; sourceTree = ""; }; + AED4474225FCBC8900B045FF /* x64_regalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = x64_regalloc.h; sourceTree = ""; }; AED73DC02303E19100ECDB64 /* sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sdl.cpp; sourceTree = ""; }; AED73DC12303E19100ECDB64 /* sdl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl.h; sourceTree = ""; }; AED73DC22303E19100ECDB64 /* sdl_gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl_gamepad.h; sourceTree = ""; }; @@ -2016,6 +2020,7 @@ 84B7BE9F1B72720200F9733F /* gltex.cpp */, AEE6278B2224762000EC7E89 /* imgui_impl_opengl3.cpp */, AEE6278D2224762000EC7E89 /* imgui_impl_opengl3.h */, + AED4473B25FC0CF100B045FF /* quad.cpp */, ); path = gles; sourceTree = ""; @@ -2023,10 +2028,10 @@ AE1E292620947D4700FC6BA2 /* xbyak */ = { isa = PBXGroup; children = ( - AE1E292820947D4700FC6BA2 /* xbyak.h */, - AE1E292920947D4700FC6BA2 /* xbyak_bin2hex.h */, - AE1E292A20947D4700FC6BA2 /* xbyak_mnemonic.h */, - AE1E292B20947D4700FC6BA2 /* xbyak_util.h */, + AED4473D25FCB8C600B045FF /* xbyak_bin2hex.h */, + AED4473F25FCB8C600B045FF /* xbyak_mnemonic.h */, + AED4474025FCB8C600B045FF /* xbyak_util.h */, + AED4473E25FCB8C600B045FF /* xbyak.h */, ); path = xbyak; sourceTree = ""; @@ -2042,6 +2047,8 @@ AE1E293E20A96B0B00FC6BA2 /* rec-x64 */ = { isa = PBXGroup; children = ( + AED4474225FCBC8900B045FF /* x64_regalloc.h */, + AED4474125FCBC8900B045FF /* xbyak_base.h */, AE1E293F20A96B0B00FC6BA2 /* rec_x64.cpp */, ); path = "rec-x64"; @@ -3079,6 +3086,7 @@ 559E933F25FCBFCA001B0F40 /* disasm-aarch64.cc in Sources */, AE2A2D5E21D68470004B308D /* decrypt.cpp in Sources */, AE82C68725B64AE200C79BC2 /* zip_set_archive_flag.c in Sources */, + AED4473C25FC0CF100B045FF /* quad.cpp in Sources */, AEFF7F56214D9D590068CE11 /* pico_ethernet.c in Sources */, AEE6277E220D7B7E00EC7E89 /* imgui_widgets.cpp in Sources */, 559E934425FCBFCA001B0F40 /* code-buffer-vixl.cc in Sources */,