SDL_Color Problem :)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

SDL_Color Problem :)

Post 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
Panama
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 21
Joined: Fri Jun 05, 2009 12:37 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++ and C#
Location: Great Britain, although I don't understand what's so great about it

Re: SDL_Color Problem :)

Post by Panama »

I believe it should be

Code: Select all

SDL_Color textColor (255, 255, 255);
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: SDL_Color Problem :)

Post 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;
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: SDL_Color Problem :)

Post 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:
Panama
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 21
Joined: Fri Jun 05, 2009 12:37 pm
Favorite Gaming Platforms: PC
Programming Language of Choice: C++ and C#
Location: Great Britain, although I don't understand what's so great about it

Re: SDL_Color Problem :)

Post 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};
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: SDL_Color Problem :)

Post by RandomDever »

All I want to do is render some text like this:
message = TTF_RenderText_Solid(georgia, "message XD", textColor);
SDL_Flip....
Etc.
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: SDL_Color Problem :)

Post by RyanPridgeon »

Well you could always do this

Code: Select all

SDL_Color somecolor;
somecolor.r = 255;
somecolor.g = 255;
somecolor.b = 255;
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: SDL_Color Problem :)

Post 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.
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: SDL_Color Problem :)

Post 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 :)
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
Post Reply