Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - the problem about create windows by thread: (4 Items)
   
the problem about create windows by thread  
I wroten a App On Qnx.I want to create three windows.
Process 1:
(1)In KdMain:
    ①init the windows info(three windows).win_size/win_name and so on
    ②init EGL (three times)
      a.Get the display by eglGetDisplay()
      b.init EGL by eglInitialize()
      c.eglBindAPI()
      d.kdCreateWindow()
      e.kdRealizeWindow()
      f.eglCreateWindowSurface()
      g.kdSetWindowPropertyiv()
      h.eglCreateContext()
    ③create three threads by kdThreadCreate()
(2)In each thread:
    ①Draw the picture on each window by vgImageDraw()
  the result is:
    Three windows work OK.But,if any other thread sents event to the three windows,they all receive the event by 
KdMain().

Process 2:
(1)In KdMain
   ①create three threads
(2)In each thread:
   ①init the windows info
   ②init EGL( the steps the same as above )
   ③create three threads by kdThreadCreate()
   ④draw the picture on window by vgImageDraw()
the result is:
   Three thread work OK,each thread can receive event.But the picture is not displayed on the windows.

So ,my question is :
①Must I init EGL in KdMain?
②Is there any problem with my process?

I excepting your responses,Thanks a lot.
Re: the problem about create windows by thread  
> I wroten a App On Qnx.I want to create three windows.
> Process 1:
> (1)In KdMain:
>     ①init the windows info(three windows).win_size/win_name and so on
>     ②init EGL (three times)
>       a.Get the display by eglGetDisplay()
>       b.init EGL by eglInitialize()
>       c.eglBindAPI()
>       d.kdCreateWindow()
>       e.kdRealizeWindow()
>       f.eglCreateWindowSurface()
>       g.kdSetWindowPropertyiv()
>       h.eglCreateContext()
>     ③create three threads by kdThreadCreate()
> (2)In each thread:
>     ①Draw the picture on each window by vgImageDraw()
>   the result is:
>     Three windows work OK.But,if any other thread sents event to the three 
> windows,they all receive the event by KdMain().
> 
> Process 2:
> (1)In KdMain
>    ①create three threads
> (2)In each thread:
>    ①init the windows info
>    ②init EGL( the steps the same as above )
>    ③create three threads by kdThreadCreate()
>    ④draw the picture on window by vgImageDraw()
> the result is:
>    Three thread work OK,each thread can receive event.But the picture is not 
> displayed on the windows.
> 
> So ,my question is :
> ①Must I init EGL in KdMain?
> ②Is there any problem with my process?
> 
> I excepting your responses,Thanks a lot.


PS:in vgImageDraw():
     eglMakeCurrent()→vgSeti()→vgCreateImage()→vgImageSubData()
     →vgDrawImage()→eglSwapBuffers()
Re: the problem about create windows by thread  
The first approach doesn't work because events are sent to the thread that created the window. In this case, it is the 
main thread.

The second approach should work, both in terms of graphics and events. I am not sure I understand #3 in Process 2. Do 
you have 3 threads (created in step #1) or 6 (3 created in step #1 and 3 in step #3) ? In any case, look for any errors 
in eglMakeCurrent and/or eglSwapBuffers.
Re: the problem about create windows by thread  
> The first approach doesn't work because events are sent to the thread that 
> created the window. In this case, it is the main thread.
> 
> The second approach should work, both in terms of graphics and events. I am 
> not sure I understand #3 in Process 2. Do you have 3 threads (created in step 
> #1) or 6 (3 created in step #1 and 3 in step #3) ? In any case, look for any 
> errors in eglMakeCurrent and/or eglSwapBuffers.


I am sorry.I made a mistake when i wrote this .
In Process 2
In (2) I don't used ③step.
I create three thread in KdMain.
but why the picture did not displayed on screen??

I except your response.
Thanks a lot.