Easy C typecast/SDL problem...

Moderator
Posts: 680
Joined: 2002.04
Post: #1
I'm just trying to plot one pixel directly to a surface (which has already been locked, et al) with...
Code:
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?

Mark Bishop
Quote this message in a reply
hams
Unregistered
 
Post: #2
Quote:
Code:
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
Quote this message in a reply
Moderator
Posts: 680
Joined: 2002.04
Post: #3
No, the pixels member of SDL_Surface is the void pointer - which is where the plot/assignment falls apart...

Mark Bishop
Quote this message in a reply
hams
Unregistered
 
Post: #4
if pixels is void* then you have to cast it first.

int *pix_ptr = theSurface->pixels;

pix_ptr[ blah] = SDL_MapRGB (...)
Quote this message in a reply
Moderator
Posts: 680
Joined: 2002.04
Post: #5
Thanks, I'd completely overlooked that... Blush Thanks!

Mark Bishop
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Easy AudioServicesDisposeSystemSoundID question :D the_wandering_monster 0 2,583 Oct 20, 2009 02:18 AM
Last Post: the_wandering_monster
  very simple and easy bmp loading for openGL c_young 9 7,922 Jan 20, 2007 11:08 AM
Last Post: Skorche
  Easy 3d engines DudetheCreator 1 2,310 Oct 16, 2004 10:42 AM
Last Post: AnotherJake