[XForms] Threads and OpenGL --- again ! ;-)

Nicolas Castagné nicolas.castagne at imag.fr
Wed Jun 18 07:54:15 EDT 2003


	Hi all,

	I have worked again a bit on a small demo program running a gl CANVAS 
drawn through a THREAD. You will find attached the sources.

-----
I - description of the program
	The code assumes:
		1) that each thread has its own current GLXContext
		2) that concurrent calls to glXMakeCurrent and glXSwapBuffer can be 
made, provided the context used for each one is possessed by the 
calling thread.

	The program shows in a form two canvas with a rotating cube.
	The main process creates and display the form.
	The "MainCanvas" and its GLXcontext are created by the Main Proces.  
The "MainCanvas"  drawn through an idle callback.
	The ThreadCanvas is created by the Thread and drawn by it. Its 
GLXcontext is also created by the thread, through the call to 
fl_add_object(Form, ThreadCanvas).
	A communication process ensures that Expose Events on the 
"ThreadCanvas" (handled by the XForms main loop in the Main Process) 
are communicated to the Thread. As an evidence, this communication 
process could be improved. However, it is not the problem today.
	


-----
II - results and problem

	 When rendering is made in DIRECT mode, every thing runs correctly on 
every SGI engine I was able to test. The call to XinitThread() even 
does not seem to be necessary.
	
	On the contrary, the program ALWAYS CRASHES when rendering is made 
through the X Server. This happens in two cases:
		1) when the constant DIRECT, at the beginning of the sources, is set 
to 0;
		2) when distant execution is performed (direct rendering is then 
impossible).


	The error messages I get from the X server are various. Mainly :
X Error of failed request:  GLXBadContextTag
   Major opcode of failed request:  146 (GLX)
   Minor opcode of failed request:  11 (X_GLXSwapBuffers)
   Serial number of failed request:  667
   Current serial number in output stream:  681

	or :
X Error of failed request:  GLXBadContextTag
   Major opcode of failed request:  146 (GLX)
   Minor opcode of failed request:  1 (X_GLXRender)
   Serial number of failed request:  651
   Current serial number in output stream:  656


	Note that the GLXBadContextTag error is not well documented. As an 
example, it does not appear in the GL man pages. I don't really 
understand what it means.
	

-----
II - help ! ;-)

	I have worked quite a lot around the problem, trying various 
solutions... But without success.

	It would be really helpful if one of you could have a look on the 
problem: Numerous mails concerning threads and GLcanvas have been 
posted for the past years on the list, but never a definitive answer. 
As a matter of fact, it could be of interest to :
		1) propose a valid small demo program within the XForms examples.
		2) by the end, add to the library an API for threaded Gl canvas.
	
	I may work on these points... But i need help today !
	
	You may help in different ways :
		1) trying to compile and run my program on other platforms, to see 
what happens;
		2) debugging my program, showing what is wrong;
		2) sending other pieces of code with threaded Glcanvas that run 
properly, what ever the rendering mode is, so that I could make the 
previous jobs on my own.


	Thx in advance !

	Nicolas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ThreadGL.c
Type: application/applefile
Size: 70 bytes
Desc: not available
Url : attachments/20030618/b8eff1b5/attachment-0010.bin 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ThreadGL.c
Url: attachments/20030618/b8eff1b5/attachment-0010.c 
-------------- next part --------------




------------------------------------------------------------------------ 
--------------------------
Nicolas CASTAGNE
Chercheur, IR de l'ACROE/ICA,

Association pour la Cr?ation et la Recherche
	sur les Outils d'Expression
Laboratoire Informatique et Cr?ation Artistique
INPG,
46 av. F. Viallet, 38000 Grenoble, France.

pro : (33) 4 76 57 46 60
fax : (33) 4 76 57 48 89
------------------------------------------------------------------------ 
--------------------------


More information about the Xforms mailing list