Hello,
I've been working out event loop in a program I'm writing. I'd like to use threads to do some of the drawing for my program. I'm not super familiar with programming with them, so have setup a test program to play around with them. I have the simple hello world console example and have played with that for a bit. I've also created a directfb program that uses the threads in the loop, for example:


while(!quit)
{
        DFBInputEvent event;
        buffer->WaitForEvent(buffer);
        while(buffer->GetEvent(buffer,DFB_EVENT(&event)) == DFB_OK)
        {
                if(event.type == DIET_KEYPRESS)
                {
                        if(event.key_id == DIKI_UP)
                        {
                                char *message = "hello";
                                
pthread_create(&thread1,NULL,(void*)&ScaleUp,(void*)message);
                        }
                }
        }
}

the ScaleUp function simply loops through a stretch blit. Which worked if I simply call the function... Now what happens is I get a seg fault on the call of flip I verified this by printing out the message string before every function call in the function ScaleUp.. Any ideas?

void ScaleUp(void *ptr)
{
DFBCHECK(primary->SetColor(primary,0x00,0x00,0x00,0xFF));
DFBCHECK(primary- >FillRectangle(primary,0,0,screen_width,screen_height));
for( ; x < max ; x+=3)
{
DFBRectangle rect = {screen_width/2,screen_height/2,x,x};
DFBCHECK(primary->StretchBlit(primary,s_image,NULL,&rect)); DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
}
pthread_exit(0);
}


I realize that this whole thing has a race condition if I were to press another key before it was completed the loop, I'm not worried about that at the moment, I just want to get this working. I will add the mutexes and such once I can do this one key at a time... Any help would be appreciated.

--
Nathanael Noblet
Gnat Solutions
4604 Monterey Ave NW
Calgary, AB
T3B 5K4

T/F 403.288.5360
C 403.809.5368

http://www.gnat.ca/



--
Info: To unsubscribe send a mail to [EMAIL PROTECTED] with "unsubscribe directfb-users" as subject.




Reply via email to