Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Vulcans believe peace should not depend on force. -- Amanda, "Journey to Babel", stardate 3842.3


devel / comp.lang.ada / Struggling to use fonts in SDLAda

SubjectAuthor
* Struggling to use fonts in SDLAdaTroy Jacobs
`- Re: Struggling to use fonts in SDLAdaTroy Jacobs

1
Struggling to use fonts in SDLAda

<e276156a-0079-4873-97f8-afcb66a5e560n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8737&group=comp.lang.ada#8737

  copy link   Newsgroups: comp.lang.ada
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: i2pn2.org!i2pn.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: <e276156a-0079-4873-97f8-afcb66a5e560n@googlegroups.com>
Subject: Struggling to use fonts in SDLAda
From: tmj9001@gmail.com (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
 by: Troy Jacobs - Mon, 12 Sep 2022 22:43 UTC

I'm relatively new to programming with Ada, and as I've been learning the language I decided to try making a simple 2D game with it to apply what I learn about Ada. After unsuccessfully attempting to make my own binding to SDL2, I decided to simply use the SDLAda package because it seemed well put together.

However, I've been running into this issue while trying to render text where the program fails at runtime because it failed to load the font. I've been desperately scouring the web & my code for a solution ever since to no avail. As I am newish to Ada, I don't know the GNAT tools well enough to pinpoint 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 := SDL.Positive_Sizes'(800, 600);

window : SDL.Video.Windows.Window;

renderer : SDL.Video.Renderers.Renderer;

texture : SDL.Video.Textures.Texture;

font_path : constant String := "resources/fonts/kunika_2.0/fonts/OpenType-TT/Kunika-Regular.ttf";

font : SDL.TTFs.Fonts;

text_surface : SDL.Video.Surfaces.Surface;

begin

if SDL.Initialise = True and then SDL.TTFs.Initialise = 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 => window,

Title => "HITBOXERS",

Position => SDL.Natural_Coordinates'(X => 300, Y => 300),

Size => window_size,

Flags => SDL.Video.Windows.Resizable

);

SDL.Video.Renderers.Makers.Create(renderer, window);

SDL.Video.Textures.Makers.Create(

Tex => texture,

Renderer => renderer,

Format => SDL.Video.Pixel_Formats.Pixel_Format_ARGB_8888,

Kind => SDL.Video.Textures.Streaming,

Size => window_size

);

-- get font

SDL.TTFs.Makers.Create(font, font_path, 1, 40);

-- create surface for font

text_surface := SDL.TTFs.Render_Shaded(

Self => font,

Text => "Yolo",

Colour => SDL.Video.Palettes.Colour'(Red => 98, Green => 236, Blue => 120, Alpha => 255),

Background_Colour => SDL.Video.Palettes.Colour'(Red => 236, Green => 203, Blue => 98, Alpha => 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 directory. I've confirmed this by moving the file around and reading the source code for both SDLAda & SDL_ttf.

I'll do my best to respond as much as I possibly can to questions. Thank you to anyone who is able to help.

Re: Struggling to use fonts in SDLAda

<7e57ba34-f1fb-4f3c-b380-5f6a8ce677acn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8738&group=comp.lang.ada#8738

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5f92:0:b0:344:9d67:ff70 with SMTP id j18-20020ac85f92000000b003449d67ff70mr27565989qta.96.1663062751947;
Tue, 13 Sep 2022 02:52:31 -0700 (PDT)
X-Received: by 2002:a05:620a:4450:b0:6bb:c19a:c022 with SMTP id
w16-20020a05620a445000b006bbc19ac022mr21462119qkp.240.1663062751740; Tue, 13
Sep 2022 02:52:31 -0700 (PDT)
Path: i2pn2.org!i2pn.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: Tue, 13 Sep 2022 02:52:31 -0700 (PDT)
In-Reply-To: <e276156a-0079-4873-97f8-afcb66a5e560n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=173.44.80.176; posting-account=IXTsPgoAAAAN-Due6ITniBLUa_e3nCQf
NNTP-Posting-Host: 173.44.80.176
References: <e276156a-0079-4873-97f8-afcb66a5e560n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7e57ba34-f1fb-4f3c-b380-5f6a8ce677acn@googlegroups.com>
Subject: Re: Struggling to use fonts in SDLAda
From: tmj9001@gmail.com (Troy Jacobs)
Injection-Date: Tue, 13 Sep 2022 09:52:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1487
 by: Troy Jacobs - Tue, 13 Sep 2022 09:52 UTC

Note: This post was originally posted on r/Ada, but I copied it here when the post I made was removed automatically. I didn't realized that they block your post before letting it go up (I assume so someone can review it first.) You may wish to join the discussion there instead. Apologies for this.


devel / comp.lang.ada / Struggling to use fonts in SDLAda

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor