PDA

View Full Version : Easy C typecast/SDL problem...


sealfin
2003.10.10, 12:53 PM
I'm just trying to plot one pixel directly to a surface (which has already been locked, et al) with...
theSurface->pixels[ (( 640 * ( y - 1 )) + x ) ] = SDL_MapRGB( theSurface->format, 255, 0, 0 );
...unfortunately, I just get reported the error "invalid use of void expression" - I've tried to typecast the plot, but this merely changes the error reported - any suggestions?

hams
2003.10.10, 01:35 PM
theSurface->pixels[ (( 640 * ( y - 1 )) + x ) ] = SDL_MapRGB( theSurface->format, 255, 0, 0 );
...unfortunately, I just get reported the error "invalid use of void expression" - I've tried to typecast the plot, but this merely changes the error reported - any suggestions?

based on that, it would seem SDL_MapRGB returns void.
check the prototype for SDL_MapRGB.

kevin

sealfin
2003.10.10, 02:04 PM
No, the pixels member of SDL_Surface is the void pointer - which is where the plot/assignment falls apart...

hams
2003.10.10, 04:06 PM
if pixels is void* then you have to cast it first.

int *pix_ptr = theSurface->pixels;

pix_ptr[ blah] = SDL_MapRGB (...)

sealfin
2003.10.10, 04:39 PM
Thanks, I'd completely overlooked that... :blush: Thanks!