Sign in to follow this  
ShyAngel

SDL show image font problem

Recommended Posts

i'm making menu for my game and i got annoying error, just say there are 2 classes, first class to store font that made from image (since SDL_TTF don't know newline) and the second is button class. my problem is second class can't access first class then i tried using inheritance it got no error but my font still not shown. any idea?
thanks :)
Quote:

class BitmapFont
{
private:
SDL_Surface *bitmap;
SDL_Rect chars[ 256 ];
int newLine, space;
public:
BitmapFont();
BitmapFont( SDL_Surface *surface );
void build_font( SDL_Surface *surface );
void show_text( int x, int y, std::string text, SDL_Surface *surface );
//friend class Button;
};

Quote:

class Button : public BitmapFont
{
...
...
}

void Button::OptionClick()
{
bool endOpti = false;
if( quit == false )
{
show_text( 100, 100, "Bitmap Font:\nABDCEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n0123456789", screen );
apply_surface( 0, 0, optionBG,screen );
//update_screen();
SDL_Flip( screen );
}

both class i use are from SDL tutorial site :).

[Edited by - ShyAngel on December 9, 2010 6:22:27 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Net-Ninja
Try not using newline (\n), i think the font size is the height in pixels of the font. Try drawing it each new line that far below the preceding line.


umm.. SDL_TFF or my bitmap font?,and since i copied this code from tutor site i'm pretty sure there are nothing wrong with it, i tried it too before copy it to mine.

Quote:
Original post by Toadhead
You have to declare the button class first so the BitmapFont class knows of its existence.


don't you mean declare BitmapFont first, since Button need BitmapFont so.., and it's still not working.

[Edited by - ShyAngel on December 9, 2010 6:09:00 PM]

Share this post


Link to post
Share on other sites
There is a difference between declaration and definition. At the moment you have two definitions. You define a class by writing down all the members and functions. When you declare a class you just write down its header so the compiler knows of the class' existence. It's called a forward declaration.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this