SDL TTF HELP

iam trying to draw a text using sdl ttf on a window, but it won't work
http://www.4shared.com/zip/u1UA5wFLce/rpg.html
First, if you are going to post to the forums, don't PM me the same question. Second, is that code the most up to date code? I tried to build in order to help and had to spend 2+ hours fixing errors in the code before giving up on it.
it is, i pm because i did post before and no one answered
Last edited on
legendarysnake wrote:
it is, i pm because i did post before and no one answered

Doing that is a quick way to be ignored.

I don't see how you are getting it to compile, let alone get it to the point of knowing that drawing font is an issue. When I first downloaded and compiled it I got errors in CAppStateGame.h and CAppStateGame.cpp:
1
2
3
void OnKeyDown(SDLKey sym, SDLMod mod, uint16 unicode);

void OnKeyUp(SDLKey sym, SDLMod mod, uint16 unicode);

Errors were for SDLKey, SDLMod not being declared as well as an error for unicode. I had to change it to (which I can only assume you meant to do):
1
2
3
void OnKeyDown(SDL_Keycode sym, SDL_Keymod mod, uint16_t unicode);

void OnKeyUp(SDL_Keycode sym, SDL_Keymod mod, uint16_t unicode);

Now the errors I got to have fun fixing while being distracted were:

CAppStateGame.cpp|58|error: no matching function for call to ‘CArea::OnLoad(const char [14])’|
CAppStateGame.cpp|62|error: no matching function for call to ‘CPlayer::OnLoad(const char [10], int, int, int)’|
CAppStateGame.cpp|66|error: no matching function for call to ‘CPlayer::OnLoad(const char [10], int, int, int)’|
CAppStateGame.cpp|122|error: no matching function for call to ‘CArea::OnRender(SDL_Surface*&, int, int)’|
CAppStateGame.cpp|127|error: no matching function for call to ‘CEntity::OnRender(SDL_Surface*&)’|

I'm going to take a wild guess that there are more after that one seeing as it says you are loading Yoshi.png and yet the assets have no yoshi.png in it.
Last edited on
no, do not use files that is not in the makefile, there is makefile there use it.
Last edited on
I'm not going to worry about getting it to build. Since you said it was text, I started sifting through the code and the first thing that popped out was, where is TTF_Init();? I don't see it anywhere and from what I recall from SDL you have to call it first when dealing with TTF and SDL.
CApp_Oninit.cpp ln69
there is no error in the code, if you run the make, it will compile, the only is happening is, i can not draw text using this class or any other way on the Surf_Display.
Last edited on
i havent done sdl in forever so im not going to be much more help than this:
@bhx: sdl has many errr plugin type libraries for dealing with things, and one such is ttf. as a result, sdl's initialization functions dont do anything for it. thats why the library ttf has its own init function
@Little Bobby Tables
I know. I thought he had missed it because the IDE I was using couldn't find it, but I changed to Geany and it found it right before legendarysnake said where it was. I was getting errors from other parts of his code. I'm curious why make is compiling fine (though giving a lot of warning, which is still bad), but doing a project in all my IDEs return errors for so much of his code.
legendarysnake wrote:
there is no error in the code,

Then it would be printing ergo there is an error somewhere in the code. Could be something as simple as drawing in the wrong order or something more.
Last edited on
im sorry. i misread what you wrote. i thought you said what is ttf_init. my bad
@Little Bobby Tables
It's alright.

@legendarysnake
Trying to wrap my head around why you did the code the way you did. Honestly, I think you are doing a lot of things that may be considered bad habits. The way I was taught was to name the header file after the class that was in it and then in a C++ source file of the same name you define all of the methods. I was also taught to give int main() its own file (in my case I always do main.cpp).

i'll fix it...
Can you upload the project somewhere else, such as mediafire?
Last edited on
Why do you keep posting the code to different sites if you have a github for it?
because i am hurry =)
then just link to the github...
In a hurry? The amount of time it took you to zip and upload that to that site you could have easily done a commit of the code to your github and linked to it.
Now my class to render text on sdl window is working.
Topic archived. No new replies allowed.