PDA

View Full Version : Why won't it do what I want it to?



Crisp_N_Dry
05-01-2005, 06:01 PM
After spending the last few days getting to grips with SDL I decided to give the 8 bit palettised mode a go. I set up my window at 640*480*8 and initialised my pallette using an array of TSDL_Color and the SDL_SetColor function. To my annoyance I found that it is doing the same thing as DirectDraw when using palettised mode i.e: Changing the index of all colours to one that suits the original colour better. If I use red at index 100 on the original palette for the bitmap, when I come to load the bitmap into my program and use a new palette, the program will find the index of the new palette that has the closest thing to red and will switch the index of the pixel to fit. I do not want this to happen, I don't want the program to automatically fiddle with my indices. I just want it to display the pixels in whatever colour the palette dictates. This is exactly the same thing as what happened with DirectDraw, half the reason I migrated over to SDL. Anyone know what's going on?

EDIT: After yet more experimenting I've narrowed the problem down to the SDL_BlitSurface routine. This is where the color matching takes place. I used the putpixel to draw the same tile to screen and this works perfectly and uses the specified palette whereas the SDL_BlitSurface seems to want to find the closest match for each colour which is not what I want. This is really starting to get on my nerves. I'm back to square one, with the same problems I was having with DirectDraw.

EDIT2: Success!!! I finally worked it out after a late night lie down in the dark. The wonders that a good think can produce. For anyone that's interested, I was using SDL_SetColors on my screen surface instead of my tile image surface. May seem obvious but hey, I'm new to this SDL business. Hooray for me!

savage
06-01-2005, 10:55 AM
Well Done. I was going to suggest you look @ the Palette demo that went out with v0.5. but since you worked it out, I will leave you alone.