From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a37:948:0:b0:6cd:e5cf:aca8 with SMTP id 69-20020a370948000000b006cde5cfaca8mr11406220qkj.253.1663022636808; Mon, 12 Sep 2022 15:43:56 -0700 (PDT) X-Received: by 2002:a05:620a:2844:b0:6b8:5f52:a6b5 with SMTP id h4-20020a05620a284400b006b85f52a6b5mr20747267qkp.351.1663022636589; Mon, 12 Sep 2022 15:43:56 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 Sep 2022 15:43:56 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=173.44.80.176; posting-account=IXTsPgoAAAAN-Due6ITniBLUa_e3nCQf NNTP-Posting-Host: 173.44.80.176 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Struggling to use fonts in SDLAda From: Troy Jacobs Injection-Date: Mon, 12 Sep 2022 22:43:56 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 6365 Xref: reader01.eternal-september.org comp.lang.ada:64325 List-Id: I'm relatively new to programming with Ada, and as I've been learning the l= anguage I decided to try making a simple 2D game with it to apply what I le= arn about Ada. After unsuccessfully attempting to make my own binding to SD= L2, I decided to simply use the SDLAda package because it seemed well put t= ogether. However, I've been running into this issue while trying to render text wher= e the program fails at runtime because it failed to load the font. I've bee= n desperately scouring the web & my code for a solution ever since to no av= ail. As I am newish to Ada, I don't know the GNAT tools well enough to pinp= oint what could be causing the problem. Below is my .gpr file, Ada source file, and the message produced when I try= to run it through Alire. .gpr file: with "config/coolgame1_config.gpr"; project Coolgame1 is for Source_Dirs use ("src/", "config/"); for Object_Dir use "obj/" & Coolgame1_Config.Build_Profile; for Create_Missing_Dirs use "True"; for Exec_Dir use "bin"; for Main use ("coolgame1.adb"); package Compiler is for Default_Switches ("Ada") use Coolgame1_Config.Ada_Compiler_Switches= ; end Compiler; package Linker is for Default_Switches ("Ada") use ("-lSDL2", "-lSDL2_ttf"); end Linker; package Binder is for Switches ("Ada") use ("-Es"); -- Symbolic traceback end Binder; package Install is for Artifacts (".") use ("share"); end Install; end Coolgame1; Ada Source File (abridged for clarity:) with SDL; with SDL.Video.Renderers.Makers; with SDL.Video.Textures.Makers; with SDL.Video.Windows.Makers; with SDL.Video.Pixel_Formats; with SDL.Events.Events; with SDL.Events.Keyboards; with SDL.TTFs.Makers; with SDL.Video.Palettes; with SDL.Video.Surfaces; with Ada.Directories; with Ada.Text_IO; with SDL.Rwops; procedure Coolgame1 is window_size : constant SDL.Positive_Sizes :=3D SDL.Positive_Sizes'(800,= 600); window : SDL.Video.Windows.Window; renderer : SDL.Video.Renderers.Renderer; texture : SDL.Video.Textures.Texture; font_path : constant String :=3D "resources/fonts/kunika_2.0/fonts/Open= Type-TT/Kunika-Regular.ttf"; font : SDL.TTFs.Fonts; text_surface : SDL.Video.Surfaces.Surface; begin if SDL.Initialise =3D True and then SDL.TTFs.Initialise =3D True then Ada.Text_IO.Put_Line("Ada directory:"); Ada.Text_IO.Put_Line(Ada.Directories.Current_Directory); Ada.Text_IO.Put_Line("SDL2 directory:"); Ada.Text_IO.Put_Line(SDL.Rwops.Base_Path); SDL.Video.Windows.Makers.Create( Win =3D> window, Title =3D> "HITBOXERS", Position =3D> SDL.Natural_Coordinates'(X =3D> 300, Y =3D> 300), Size =3D> window_size, Flags =3D> SDL.Video.Windows.Resizable ); SDL.Video.Renderers.Makers.Create(renderer, window); SDL.Video.Textures.Makers.Create( Tex =3D> texture, Renderer =3D> renderer, Format =3D> SDL.Video.Pixel_Formats.Pixel_Format_ARGB_8888, Kind =3D> SDL.Video.Textures.Streaming, Size =3D> window_size ); -- get font SDL.TTFs.Makers.Create(font, font_path, 1, 40); -- create surface for font text_surface :=3D SDL.TTFs.Render_Shaded( Self =3D> font, Text =3D> "Yolo", Colour =3D> SDL.Video.Palettes.Colour'(Red =3D> 98, Green =3D> 236, Blu= e =3D> 120, Alpha =3D> 255), Background_Colour =3D> SDL.Video.Palettes.Colour'(Red =3D> 236, Green = =3D> 203, Blue =3D> 98, Alpha =3D> 255) ); renderer.Clear; renderer.Copy(texture); renderer.Present; end loop; end; window.Finalize; SDL.TTFs.Finalise; SDL.Finalise; end if; end Coolgame1; Output: PS C:\Users\usernamehere\coolgame1> alr run Note: Building coolgame1/coolgame1.gpr... gprbuild: "coolgame1.exe" up to date Build finished successfully in 2.09 seconds. Ada directory: C:\Users\usernamehere\coolgame1 SDL2 directory: C:\Users\usernamehere\coolgame1\bin\ raised SDL.TTFS.TTF_ERROR : Couldn't load font file [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69aff0089 ??? at ??? [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69afeffbb ??? at ??? [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69afebf10 ??? at ??? [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69affffe9 ??? at ??? [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69af9143d ??? at ??? [C:\Users\usernamehere\coolgame1\bin\coolgame1.exe] 0x7ff69af91144 ??? at ??? [C:\WINDOWS\System32\KERNEL32.DLL] 0x7ffcf2397032 [C:\WINDOWS\SYSTEM32\ntdll.dll] 0x7ffcf384264f And before you ask, the problem is not the font being in the wrong director= y. I've confirmed this by moving the file around and reading the source cod= e for both SDLAda & SDL_ttf. I'll do my best to respond as much as I possibly can to questions. Thank yo= u to anyone who is able to help.