• Advertisement
Sign in to follow this  

Surface Creation and wrong filling in?

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a particle system, and I have everything up and running. Only thing left is to make different particles different colors. However - it won't work:
SDL_FillRect(ThisSurface.pSurface,
                     NULL,
                     SDL_MapRGB(ThisSurface.pSurface->format,
                                0,//Random(256, -1),
                                255,//Random(256, -1),
                                255));//Random(256, -1)));

Normally, it should be 'Random', but even TRYING to make it another color doesn't work, like in the above code snippet. IT IS ALWAYS WHITE. I'm creating the surface with SDL_CreateRGBSurface and using all of my screen's flags and the screen's bpp. The width and height are either 1, 2, or 3... and the RMASK and so only are #defined according to the ... what do you call it? You know, the SDL_BIG_ENDIAN and SDL_LIL_ENDIAN (wow I seem stupid). Also, I'm putting in 25 more particles every frame, the speed is huge. Thanks to all.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Anyone? Please?

I really wan't to make my particles another color but it won't work... And I don't know why!

The CSurface (the ThisSurface variable) looks like this:

class Sprite::CSurface {
SDL_Surface *pSurface;
bool Load(const std::string &File);
};



Any help is GREATLY appreciated!

Share this post


Link to post
Share on other sites
Quote:
Maps the RGB color value to the specified pixel format and returns the pixel value as a 32-bit int.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

are you sure ThisSurface.pSurface->format != palette?

Share this post


Link to post
Share on other sites
Quote:
Original post by noof
Quote:
Maps the RGB color value to the specified pixel format and returns the pixel value as a 32-bit int.

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.

are you sure ThisSurface.pSurface->format != palette?


Well, it's 32-bit. Even if it does have a palette, it's:
Quote:

If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned.


FYI, I'm making the surfaces using SDL_CreateRGBSurface. Any other ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement