一个SDL的问题
发表于 : 2009-06-16 0:54
高手们帮我解释一下,我在一个线程里面生成了一个surface 然后用另一个线程 blitsurface 然后就SIGSEGV 为什么啊~~
难道不能够这样 ,解决的办法是?
小弟多谢各位了~
难道不能够这样 ,解决的办法是?
小弟多谢各位了~
代码: 全选
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL_thread.h>
SDL_Surface* disp;
TTF_Font* font;
SDL_Thread* thread;
SDL_Surface* text;
int proc( void * parm)
{
SDL_Color color = {255,255,255};
text = TTF_RenderText_Solid( font , "test" , color );
while(1);
}
int main()
{
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
disp = SDL_SetVideoMode(800,600,32,SDL_SWSURFACE);
font = TTF_OpenFont("font.ttf",15);
thread = SDL_CreateThread(proc ,NULL );
while(1)
{
if(text)
{
SDL_BlitSurface( text , NULL , disp , NULL );
text = NULL;
}
}
return 0;
}