0

Well, I believe the answer/problem is in these few lines:

SDL_Surface* thing;
SDL_LockSurface(thing);
put_pixel32(thing,2,2,SDLred);
SDL_UnlockSurface(thing);
apply_surface(0,0,thing,screen);
SDL_Flip(screen);

The locking/unlocking dosn't seem to do much, if I delete the lines the same thing happens, and if I check if it must lock before, the program still returns 3, etc.

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by daviddoria
0
#include<SDL.h>
#include<windows.h>


void apply_surface(int x,int y,SDL_Surface* source,SDL_Surface* dest)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_BlitSurface(source,NULL,dest,&offset);
}


int main( int argc, char** argv )
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface* screen = SDL_SetVideoMode(500,500,32,0);

SDL_Surface* thing;
SDL_LockSurface(thing);
//put_pixel32(thing,2,2,SDLred);
SDL_UnlockSurface(thing);
apply_surface(0,0,thing,screen);

SDL_Flip(screen);

SDL_Delay(1000);

SDL_Quit();
return 0;
}
0

Why are you trying to lock an uninitialized surface? This seems to work fine:

int main( int argc, char** argv )
{
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_Surface* screen = SDL_SetVideoMode(500,500,32,0);
	
	SDL_LockSurface(screen);
	SDL_UnlockSurface(screen);

	SDL_Flip(screen);

	SDL_Delay(1000);

	SDL_Quit();
	return 0;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.