123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|587|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Text in C++

Sun, 12 Aug 2007, 00:05
irondirgible
I recently started programming in C++ from a book and an online SDL tutorial. As many of you may know, basic SDL does not have font- or text-related functions. I spent several days looking for solutions, trying FreeType2 and SDL_ttf. Even with the proper header (ft2header.h), I couldn't get the functions to work (the defined structures were allowed, though). I am using Code::Blocks. I believe that all of the libraries are in the right places. Have other people experienced similar problems? Should I switch to OpenGL? I am using Code::Blocks.

Here is what I coded (FreeType stuff is commented out). It uses SDL.



There is still some of the "SDL Application" stuff in there.
Please criticize/make suggestions. Does the collision function that I wrote (Rect_Collision) work?
Sun, 12 Aug 2007, 03:13
Jayenkai
In terms of your Rect_Collision code, that seems insanely complex for what it's doing!


As always, the easiest way to check a function, is to do it in Blitz first.
The Rect_Collide check is the same as a standard "MouseIn" function, except that you add width and height to the checks.
Nice and simple.

-=-=-
''Load, Next List!''
Sun, 12 Aug 2007, 06:49
mike_g
Heres a pretty crude bitmap font loader I coded for SDL, I'll be working on something a bit better when I have the time:

The code requires an SDL surface called 'font' to be set up. and FONT_WIDTH, and HEIGHT, are constants. Oh yeah and th if statement checks if the letter is in the font. For the one I was using I had ASCII chars from ! to Z.