Jump to content

  • Log In with Google      Sign In   
  • Create Account


guadrians

Member Since 31 Aug 2012
Offline Last Active Sep 30 2012 07:31 AM
-----

Topics I've Started

Asylum Master Press Release

28 September 2012 - 12:17 PM

Hello! My name is Adrian Scheff and I wish to let you know that I am currently developing a strategy game about a 19th century Asylum, set in a timeline closely resembling the Victorian England.
Here's the development blog (I also posted 2 screenshots there):
http://asylum-master.blogspot.ro/
Thank you for your time!

Useful SDL_Library for download- Text Formating and rendering

31 August 2012 - 11:47 AM

Hello! This is my first post here, hi all!
I was in need of a basic text formater for my project. So I searched the internet. I stumbled upon this post:
http://www.gamedev.n...ng-text-in-sdl/
Sadly, there was no solution for a pure SDL text formating. The solution offered involved the use of OpenGL:
http://www.gamedev.n...tf-with-opengl/

So I made my own library for text formatting.

What it does? It takes as an argument, among other things, a SDL_rect and renders text in that rect.
The text is left aligned. It's quite a raw thing but it works ( it works only with 32bit surfaces). Also, acts as a basic text formatter, removing all spaces if they are at the begining of a line and all but one space if it is between words.
Here's the declaration:

bool TR_render_text(char * font,char * file,SDL_Color font_color,int font_size, SDL_Rect * rect,SDL_Surface * screen, SDL_Surface * destination)


font-font to be loaded. it uses SDL_ttf library
file-text file to be rendered
Color-color of the text
font_size-desired font size
rect-rendering box
screen-this is your main screen SDL_surface(the one you obtained with SDL_SetVideoMode
destination-sdl_surface where you want your text rendered(you can also put screen here). This surface should be create with SDL_CreateRGBSurface like so:
destination=SDL_CreateRGBSurface(SDL_HWSURFACE, screen->w,screen->h,32,screen->format->Rmask,screen->format->Gmask, screen->format->Bmask, screen->format->Amask);


Here's a screenshot of the TR_render_text in action.

Known bugs(so far):
-if the width of the rect is smaller than the actual size of the largest word(rendered word that is) program crashes
-not a bug per se but I noticed that SDL_ttf does not render well some characters, namely an apostroph with a ASCII code 0x92

Also to use this library you will have to install both SDL and SDL_ttf libraries.


If you don't know how to install a library check out Lazy foo tutorial here:
http://lazyfoo.net/S...son03/index.php


Let me know how it works for you!

PARTNERS