SDL TTF HELP

Jun 25, 2014 at 3:16pm
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
Jun 25, 2014 at 7:31pm
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.
Jun 25, 2014 at 10:56pm
it is, i pm because i did post before and no one answered
Last edited on Jun 25, 2014 at 10:56pm
Jun 25, 2014 at 11:19pm
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 Jun 25, 2014 at 11:49pm
Jun 26, 2014 at 11:32am
no, do not use files that is not in the makefile, there is makefile there use it.
Last edited on Jun 26, 2014 at 11:32am
Jun 26, 2014 at 1:37pm
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.
Jun 26, 2014 at 3:10pm
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 Jun 26, 2014 at 3:18pm
Jun 26, 2014 at 6:27pm
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
Jun 26, 2014 at 7:06pm
@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 Jun 26, 2014 at 7:07pm
Jun 26, 2014 at 7:07pm
im sorry. i misread what you wrote. i thought you said what is ttf_init. my bad
Jun 26, 2014 at 11:32pm
@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).

Jun 27, 2014 at 10:14am
i'll fix it...
Jun 29, 2014 at 12:44pm
Can you upload the project somewhere else, such as mediafire?
Last edited on Jun 29, 2014 at 12:45pm
Jun 29, 2014 at 1:46pm
Why do you keep posting the code to different sites if you have a github for it?
Jun 29, 2014 at 8:08pm
because i am hurry =)
Jun 29, 2014 at 8:23pm
then just link to the github...
Jun 29, 2014 at 8:54pm
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.
Jun 30, 2014 at 2:56pm
Jul 1, 2014 at 7:29pm
Now my class to render text on sdl window is working.
Topic archived. No new replies allowed.