Rendering Text on the screen in real time

shinn497 wrote:

I don’t care about complex or confusing! I actually prefer it since I find the more difficult things are the more powerful they become. I’m also really passionate about learning and solving from first principles. This is why my day job is a theoretical physicist :b (although I took a day off to figure this shit out). I was just a little frustrated since this caught me off guard. I thought it would be really easy.

Hey everyone thanks for your help! I solved the problem. The issue was that I was passing the font as a NULL pointer which was causing a segfault in the TTF font DLL. Not out of the clear though since, while I can update things on the screen, I’m having an issue converting ints to strings. I’ll figure it out though.

Btw thanks everyone for helping me! I’ve learned a lot. I will use this solution for the time being but will go through all of your suggestions. I’m a little time constraned since I’m developing on the off hours. But I will definately go through this thread in the future! Sorry my noobishness.

Well if you think that its worth the time/amount of work for what you are trying to do then nothing stopping you :slight_smile:

Also

int a = 10;
char *intStr = itoa(a);

OR

int a = 10;
stringstream ss;
ss << a;
string str = ss.str();

I like using snprintf(), personally. It’s nice and flexible with a
printf-style format. Visual Studio might have poor support for it until
version 2014, but you can find snippets online to implement it.

int a = 10;
char buffer[20];
snprintf(buffer, 20, “%d”, a);

Jonny D

The full SDL 2 game example I posted turns ints into strings and a lot of
stuff. It is a full game that loads file data, does TTF, makes log files,
puts thousands of enemy bugs crawling on the screen, and more. Plus its
only 859 lines. I hope to finish in under one k without too much clutter.
Wait till you see it finished. If you missed it scroll back and take a look
at the zip

SDL provides SDL_snprintf in SDL_stdinc.h.

-EricOn 2/4/14, Jonathan Dearborn wrote:

I like using snprintf(), personally. It’s nice and flexible with a
printf-style format. Visual Studio might have poor support for it until
version 2014, but you can find snippets online to implement it.

int a = 10;
char buffer[20];
snprintf(buffer, 20, “%d”, a);

Jonny D


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

Right. That makes it nice and easy.

Jonny DOn Tue, Feb 4, 2014 at 5:13 PM, Eric Wing wrote:

On 2/4/14, Jonathan Dearborn <@Jonathan_Dearborn> wrote:

I like using snprintf(), personally. It’s nice and flexible with a
printf-style format. Visual Studio might have poor support for it until
version 2014, but you can find snippets online to implement it.

int a = 10;
char buffer[20];
snprintf(buffer, 20, “%d”, a);

Jonny D

SDL provides SDL_snprintf in SDL_stdinc.h.

-Eric

Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You guys are awesome! Thank you.

R Manard wrote:

The full SDL 2 game example I posted turns ints into strings and a lot of stuff. It is a full game that loads file data, does TTF, makes log files, puts thousands of enemy bugs crawling on the screen, and more. Plus its only 859 lines. I hope to finish in under one k without too much clutter. Wait till you see it finished. If you missed it scroll back and take a look at the zip

I don’t think you posted the link. There are several games on your website, whisper 8. which one do you recommend?

By the way, services like pastebin make this much easier and we even get
syntax highlights :)On Sat, Feb 8, 2014 at 9:00 PM, shinn497 wrote:

R Manard wrote:

The full SDL 2 game example I posted turns ints into strings and a lot
of stuff. It is a full game that loads file data, does TTF, makes log
files, puts thousands of enemy bugs crawling on the screen, and more. Plus
its only 859 lines. I hope to finish in under one k without too much
clutter. Wait till you see it finished. If you missed it scroll back and
take a look at the zip

I don’t think you posted the link. There are several games on your
website, whisper 8. which one do you recommend?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I put the zip in my webspace now. I think this mail list or peoples clients
maybe cut the attachment off. Any, enjoy :slight_smile:

whisper8.com/data/TWINDRAGON_SDL2_GAME_EXAMPLE.zip

sure hope it works nowOn Sat, Feb 8, 2014 at 6:00 PM, shinn497 wrote:

R Manard wrote:

The full SDL 2 game example I posted turns ints into strings and a lot
of stuff. It is a full game that loads file data, does TTF, makes log
files, puts thousands of enemy bugs crawling on the screen, and more. Plus
its only 859 lines. I hope to finish in under one k without too much
clutter. Wait till you see it finished. If you missed it scroll back and
take a look at the zip

I don’t think you posted the link. There are several games on your
website, whisper 8. which one do you recommend?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If you’re only displaying ascii characters, and only in one size, the answer is easy: blit every ascii character into a single surface, turn that into a texture, and treat it as you would a bitmap font.------------------------
Nate Fries