Question SDL2 Switch Development Woes

Discussion in 'Switch - Emulation, Homebrew & Software Projects' started by delete12345, Apr 17, 2018.

  1. Jpe230

    Jpe230 Member

    Newcomer
    3
    May 14, 2018
    Mexico
    Replace in your make file:
    With
     
    XorTroll likes this.
  2. XorTroll

    XorTroll Dev: Goldleaf, emuiibo, Brew.js...

    Member
    11
    Dec 28, 2017
    Spain
    Nowhere
    Yeah, that's what i did, thanks anyway
     
  3. Jpe230

    Jpe230 Member

    Newcomer
    3
    May 14, 2018
    Mexico

    if you want to make your life easier you can put your font in the ROMFS folder and load it from there.

    Declare a pointer to your font:
    Init TTF and Romfs:
    Load your font from your ROMFS folder.
    When you finish your program call this functions:
     
  4. XorTroll

    XorTroll Dev: Goldleaf, emuiibo, Brew.js...

    Member
    11
    Dec 28, 2017
    Spain
    Nowhere
    I
    I already know how to use RomFS, thanks anyway again, I've loaded text from a font inside RomFS
     
  5. delete12345
    OP

    delete12345 GBAtemp Advanced Fan

    Member
    6
    Feb 27, 2010
    United States
    Taipei, Taiwan
    It's been a while since I touched my project, but thanks for the tips. I always appreciate any SDL2 information.
     
  6. 730

    730 Professional Shitposter

    Member
    4
    Apr 2, 2015
    Argentina
    Sorry to bump but I've been having the original problem as well and this seems like a pretty appropriate place to ask.
    Trying to use SDL2 but everything that isn't just init and quit results in a crash.
    I have the following code in a .cpp file https://pastebin.com/q8g8gEfa
    Makefile is the following https://pastebin.com/JW4yf7H2

    At this point I've pretty much copied both of those things from this program, which I've actually managed to compile and successfully run, and that includes modifying it from how it originally was by renaming the files to .cpp/.hpp and putting draw.cpp/hpp in an include folder.
    As you can see I haven't included switch.h, and if there are any weird things in the code like main() not having arguments or the window not being fullscreen it's because I have tried that, didn't work, and just ended up copying it the way it was from the sdl-hello-world program I linked, which has those peculiarities and still manages to run perfectly well when compiled.

    I just don't see what can be wrong, I've tried everything and the code right now is just the simplest thing, almost fully copied from something else and still doesn't run. There must be one little thing I missed in the makefile or something but I've no idea.

    Edit: the actual, longer code that isn't just a test that I want to eventually get running, which also crashes https://pastebin.com/JijWGbj2
     
    Last edited by 730, Aug 16, 2018
  7. Reisyukaku

    Reisyukaku Onii-sama~

    Member
    15
    Feb 11, 2014
    United States
    I was having weird hangs on console from my app after a good few seconds. Ran it on emulator to find that the emu said NOPE immediately.. dumped a stack trace and realized that Mix_OpenAudio is garbage. Mixer_Init is fine though. Not sure if people are aware, or have a work around. I'd like to hear if there is a work around. It throws a nullptr exception with the settings ive tried.

    Edit: I'm thinking the hanging is another underlying issue and that Audio is fine and Ryujinx just doesnt like it. Hmmm
     
    Last edited by Reisyukaku, Aug 19, 2018
  8. delete12345
    OP

    delete12345 GBAtemp Advanced Fan

    Member
    6
    Feb 27, 2010
    United States
    Taipei, Taiwan
    When you do get a follow-up, please update us. Any findings on SDL2, the problems around it, and the solutions after it, as a whole, would be great for me to log and add to the table of contents in OP.
     
    Last edited by delete12345, Aug 22, 2018
  9. Reisyukaku

    Reisyukaku Onii-sama~

    Member
    15
    Feb 11, 2014
    United States
    Audio was fine on console. Talked to gdkchan and got audio issue figured out there.. The hanging itself was fragments of spaghetti code I was working with. Everything works like a dream now.
     
  10. cpasjuste

    cpasjuste GBAtemp Advanced Fan

    Member
    12
    Aug 27, 2015
    France
    Of course, as I did the sdl2 port, it must be perfect :P
     
  11. delete12345
    OP

    delete12345 GBAtemp Advanced Fan

    Member
    6
    Feb 27, 2010
    United States
    Taipei, Taiwan
    Oh ok, great to hear.
     
  12. XorTroll

    XorTroll Dev: Goldleaf, emuiibo, Brew.js...

    Member
    11
    Dec 28, 2017
    Spain
    Nowhere
    Hey guys, I'm having various problems with SDL2.
    I free everything before closing it, but if I close and reinit SDL2, I always get 2168-0002 error
    I've has same error in various apps. Am I doing anything wrong, or is SDL2 fucked up?
     
  13. MRJPGames

    MRJPGames Pretty great guy

    Member
    7
    Aug 17, 2013
    Netherlands
    The Netherlands
    How can I make it so my homebrew is in 1080p, It defaults to 720p and setting the windows size to 1920x1080 doesn't seem to change that... My switch is setup to do 1080p at least when connected to a TV.
     
  14. cpasjuste

    cpasjuste GBAtemp Advanced Fan

    Member
    12
    Aug 27, 2015
    France
    Hi,

    From what i remember it needs to be docked before launching the homebrew to be able to create a 1080p window. There is maybe some bugs thought as I only really tested in 720p. That said, I'm actually refactoring sdl2 video driver for the switch (as libnx will publish some change soon), and it for sure now work correctly. It should be out very soon (a few days I hope).
     
    coppertj and MRJPGames like this.
  15. Shachah

    Shachah Newbie

    Newcomer
    1
    Jun 21, 2018
    United States
    I can get SDL to work for audio, input and video but as soon as I try to use anything in TTF, I get crazy link errors.

    Here is the relevent portion of my makefile


    ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
    CFLAGS := -g -Wall -O2 -ffunction-sections \
    $(ARCH) $(DEFINES)
    CFLAGS += $(INCLUDE) -D__SWITCH__
    CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
    ASFLAGS := -g $(ARCH)
    LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
    LIBS := -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lSDL2_mixer -lSDL2 -lpng -ljpeg -lglad -lEGL -lglapi -ldrm_nouveau -lvorbisidec -logg -lmpg123 -lmodplug -lstdc++ -lavformat -lavcodec -lswresample -lswscale -lavutil -lbz2 -lass -ltheora -lvorbis -lopus -lnx



    and here is the code in question


    #include <switch.h>
    #include <SDL2/SDL.h>
    #include <SDL2/SDL_ttf.h>
    ...

    if (TTF_Init() < 0)
    {
    printf("Error initializing TTF : %s\n", TTF_GetError());
    return false;
    }


    as soon as TTF_Init is put in the code, I get this in the terminal.


    aarch64-none-elf-g++ -MMD -MP -MF /c/development/Projects/CPP/Switch_SDLPractice/Switch_SDLPractice/build/window.d -g -Wall -O2 -ffunction-sections -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -I/c/development/Projects/CPP/Switch_SDLPractice/Switch_SDLPractice/include -I/C\devkitPro/portlibs/switch/include -IC:\devkitPro/libnx/include -I/c/development/Projects/CPP/Switch_SDLPractice/Switch_SDLPractice/build -D__SWITCH__ -fno-rtti -fno-exceptions -c /c/development/Projects/CPP/Switch_SDLPractice/Switch_SDLPractice/source/window.cpp -o window.o
    linking Switch_SDLPractice.elf
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `Load_Glyph':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:602: undefined reference to `FT_Load_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:687: undefined reference to `FT_Render_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:888: undefined reference to `FT_Done_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:600: undefined reference to `FT_Get_Char_Index'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:602: undefined reference to `FT_Load_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:670: undefined reference to `FT_Get_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:671: undefined reference to `FT_Stroker_New'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:675: undefined reference to `FT_Stroker_Set'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:676: undefined reference to `FT_Glyph_Stroke'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:677: undefined reference to `FT_Stroker_Done'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:679: undefined reference to `FT_Glyph_To_Bitmap'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:664: undefined reference to `FT_Outline_Transform'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:681: undefined reference to `FT_Done_Glyph'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_Init':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:339: undefined reference to `FT_Init_FreeType'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_CloseFont':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:920: undefined reference to `FT_Done_Face'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_OpenFontIndexRW':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:431: undefined reference to `FT_Open_Face'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:453: undefined reference to `FT_Set_Charmap'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:483: undefined reference to `FT_Set_Pixel_Sizes'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:459: undefined reference to `FT_Set_Char_Size'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:468: undefined reference to `FT_MulFix'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:469: undefined reference to `FT_MulFix'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:471: undefined reference to `FT_MulFix'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:472: undefined reference to `FT_MulFix'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:473: undefined reference to `FT_MulFix'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_GlyphIsProvided':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:1131: undefined reference to `FT_Get_Char_Index'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_SizeUTF8':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:1234: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_RenderUTF8_Solid':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:1422: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_RenderUTF8_Shaded':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:1603: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_RenderUTF8_Blended':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:1773: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_RenderUTF8_Blended_Wrapped':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:2041: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_Quit':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:2189: undefined reference to `FT_Done_FreeType'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_GetFontKerningSize':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:2203: undefined reference to `FT_Get_Kerning'
    c:/devkitpro/devkita64/bin/../lib/gcc/aarch64-none-elf/8.2.0/../../../../aarch64-none-elf/bin/ld.exe: C:/devkitPro/portlibs/switch/lib\libSDL2_ttf.a(SDL_ttf.o): in function `TTF_GetFontKerningSizeGlyphs':
    /home/davem/projects/devkitpro/pacman-packages/switch/SDL2_ttf/src/SDL2_ttf-2.0.14/SDL_ttf.c:2235: undefined reference to `FT_Get_Kerning'
    collect2.exe: error: ld returned 1 exit status
    make[1]: *** [C:\devkitPro/libnx/switch_rules:80: /c/development/Projects/CPP/Switch_SDLPractice/Switch_SDLPractice/Switch_SDLPractice.elf] Error 1
    make: *** [Makefile:290: build] Error 2




    I've tried:
    1. reinstalling all switch related pacman packages.
    2. Re-ordering include statements.
    3. Re-ordering libs := ...
    Does anyone have any pointers for where to go next with this?
     
  16. aicjofs

    aicjofs Newbie

    Newcomer
    2
    Sep 22, 2010
    United States
    I have had a hard time compiling some newer stuff with the libnx from the devkitpro, but it looks like you are just using a sample template build. While packman grabs libnx 2.0.1, there are a lot of commits since then. Build it yourself it fixed a lot of problems I was having. Just a guess though.
     
  17. Shachah

    Shachah Newbie

    Newcomer
    1
    Jun 21, 2018
    United States
    I'm a bit confused, this is from my own project that I'm porting over, all that's left is text implementation. So with that said I've been building it the whole time. The makefile is a slightly modified version compiled from a template in examples, the SDL_Helper repo, and from a comment I found while bug fixing.

    I got all the libraries through the latest devkitpro last week and see them installed with pacman -Sl. Is there some other way I can get more recent revisions of the dependencies then just pacman?

    — Posts automatically merged - Please don't double post! —

    EDIT:

    So from what I can tell, grabbing this tarball https://github.com/devkitPro/buildscripts/releases/tag/v20190220 and run ./build-devkit.sh.
    At which point my includes will be up to date?

    EDIT 2:

    I tried what I mentioned in the first Edit but nothing changed, I may have done something wrong though. I chose 'switch' for which to download and let everything extract, it doesn't look like any files were changed though.
     
    Last edited by Shachah, Feb 25, 2019
  18. clank

    clank Advanced Member

    Newcomer
    4
    Jan 24, 2015
    Antigua and Barbuda
    /dev/nvme0n1p1
    You might've solved it already, but in case you didn't, you were missing "-lfreetype" in your LIBS line on the makefile, possibly among some others. Just use "`$(PORTLIBS)/bin/freetype-config --libs`" somewhere in your LIBS line instead. If you wanna take a look at my makefile, here you go: https://pastebin.com/hPBnZi2w
     
Loading...