Page 1 of 1

SDL_Color Problem :)

Posted: Fri Jul 31, 2009 2:54 am
by RandomDever
Code:

Code: Select all

SDL_Color textColor {255, 255, 255};
Error:
'textColor' : looks like a function definition, but there is no parameter list; skipping apparent body

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 4:10 am
by Panama
I believe it should be

Code: Select all

SDL_Color textColor (255, 255, 255);

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 4:47 am
by RyanPridgeon
What exactly are you trying to do?

I dont think you can even use a constructor for SDL_Color. It is simply this struct;

Code: Select all

typedef struct{
  Uint8 r;
  Uint8 g;
  Uint8 b;
  Uint8 unused;
} SDL_Color;

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 4:48 am
by RandomDever
Panama wrote:I believe it should be

Code: Select all

SDL_Color textColor (255, 255, 255);
That's what I thought at first but it gives me a too many initizlizations error so i guess not :roll:

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 6:11 am
by Panama
Hmmm, then im not sure what to suggest mate, ive never used SDL but im sure someone will be along soon who can fix your problem.

EDIT: Cant you use

Code: Select all

SDL_Color textColour = {255, 255, 255};

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 7:44 am
by RandomDever
All I want to do is render some text like this:
message = TTF_RenderText_Solid(georgia, "message XD", textColor);
SDL_Flip....
Etc.

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 11:08 am
by RyanPridgeon
Well you could always do this

Code: Select all

SDL_Color somecolor;
somecolor.r = 255;
somecolor.g = 255;
somecolor.b = 255;

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 11:11 am
by short

Code: Select all

SDL_Color textColor = {255,255,255};
	message = TTF_RenderText_Solid(font, "message XD", textColor);
where

Code: Select all

TTF_Font *font = NULL; // font is initialized a little later, but you get the idea 
This code compiles fine for me.

Re: SDL_Color Problem :)

Posted: Fri Jul 31, 2009 11:12 am
by short
RandomDever wrote:
Panama wrote:I believe it should be

Code: Select all

SDL_Color textColor (255, 255, 255);
That's what I thought at first but it gives me a too many initizlizations error so i guess not :roll:
lol i missed it.

Your missing an equals sign :)