<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://forum.ubuntu-fr.org/extern.php?action=feed&amp;tid=1166891&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Forum Ubuntu-fr.org / [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
		<link>http://forum.ubuntu-fr.org/viewtopic.php?id=1166891</link>
		<description><![CDATA[Les sujets les plus récents dans [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU].]]></description>
		<lastBuildDate>Tue, 15 Jan 2013 17:17:46 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12219551#p12219551</link>
			<description><![CDATA[<p>C&#039;est dommage :S<br />Je vais suivre ton conseil.<br />Merci. <img src="http://forum.ubuntu-fr.org/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Tue, 15 Jan 2013 17:17:46 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12219551#p12219551</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12212921#p12212921</link>
			<description><![CDATA[<p>Salut,</p><div class="quotebox"><cite>grim7reaper a écrit&#160;:</cite><blockquote><div><p>Donc voilà, ça semble faisable (<strong>et encore, là je sors la doc de la SFML 2, si tu es encore sur la 1.6 je ne sais pas…</strong>) mais même si tu y arrives ça sera pas portable.<br />Maintenant, c’est toi qui vois.</p></div></blockquote></div><p>Après tests, je confirme : ça fonctionne avec SFML 2 (si tu ajoute bien un appel à <em>XInitThreads</em>), mais pas avec la 1.6.</p><br /><p>Mais bon, de manière générale je ne pense pas que tu partes sur une bonne piste (même si ça passe sous Linux, il y a peu de chance que àa tourne sous Windows et Mac apparemment).<br />Les bibliothèques genre SFML et SDL sont pas spécialement conçu pour gérer plusieurs fenêtres (elles peuvent, mais c’est pas simple comme tu peux le voir), donc le mieux serait de tout faire dans la fenêtre principale je pense.<br />Regarde les jeux vidéos, ils n’utilisent qu’une seule fenêtre.</p><p>Si tu à vraiment besoin d’ouvrir plusieurs sous-fenêtre, alors il vaudrait peut-être mieux partir sur du GTK, Qt, WxWidget, …</p>]]></description>
			<author><![CDATA[dummy@example.com (grim7reaper)]]></author>
			<pubDate>Tue, 15 Jan 2013 05:54:49 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12212921#p12212921</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12208501#p12208501</link>
			<description><![CDATA[<div class="codebox"><pre class="vscroll"><code>#include&lt;boost/thread/thread.hpp&gt;
#include&lt;SFML/Graphics.hpp&gt;



void opt(bool *eteindre,)
{
	while(*eteindre==false)
	{	
		
			sf::RenderWindow option_wind(sf::VideoMode(250,350),&quot;Hero-Options&quot;);
			sf::Event evenement;
			while(option_wind.IsOpened())
			{
                                option_wind.Clear();
				while(option_wind.GetEvent(evenement))
				{
					if(evenement.Type==sf::Event::Closed)
					{
						option_wind.Close();
					}
				}
                        option_wind.Display();
			}
	}
}



int main()
{
sf::RenderWindow wind(sf::VideoMode(950,660),&quot;Hero&quot;);
sf::Event evenement;
bool eteindre=false;

boost::thread t_option(opt,&amp;eteindre,);

		while(wind.IsOpened)
		{
                        option_wind.Clear();
			while(wind.GetEvent(evenement))
			{
				if(evenement.Type==sf::Event::Closed)
				{
					wind.Close();
					eteindre=true;
				}	
			}
                        option_wind.Display();
		}
eteindre=true;
t_option.join();
return 0;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Mon, 14 Jan 2013 18:28:18 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12208501#p12208501</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12208331#p12208331</link>
			<description><![CDATA[<p>Je ne comprend pas...<br />Je crée déjà la fenêtre dans le même thread que la gestion des événements ...</p><p>Toutes les conditions énoncées dans la doc sont respectées dans mon programme.</p>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Mon, 14 Jan 2013 18:15:47 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12208331#p12208331</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12199691#p12199691</link>
			<description><![CDATA[<p>Salut, tu devrait lire la <a href="http://www.sfml-dev.org/tutorials/2.0/window-window.php">doc de SFML</a>.<br />Genre :</p><div class="quotebox"><cite>http://www.sfml-dev.org/tutorials/2.0/window-window.php a écrit&#160;:</cite><blockquote><div><p>You can create multiple windows<br />SFML allows you to create multiple windows, and to handle them either all in the main thread, or each one in its own thread (but... see below). <strong>In this case, don&#039;t forget to have an event loop for each window.</strong><br />[…]<br />Events must be polled in the window&#039;s thread<br />This is an important limitation of most OSes: <strong>the event loop (more precisely, the pollEvent or waitEvent function) must be called in the same thread that created the window. This means that if you want to create a dedicated thread for event handling, you&#039;ll have to make sure that the window is created in this thread too.</strong> If you really want to split things between threads, it is more convient to keep event handling in the main thread and move the rest (rendering, physics, logic, ...) to a separate thread instead. This configuration will also be compatible with the other limitation described below. <br />[…]<br /><strong>On OS X, windows and events must be managed in the main thread</strong><br />Yep, that&#039;s true. Mac OS X just won&#039;t agree if you try to create a window or handle events in a thread other than the main one.</p></div></blockquote></div><p>Donc voilà, ça semble faisable (et encore, là je sors la doc de la SFML 2, si tu es encore sur la 1.6 je ne sais pas…) mais même si tu y arrives ça sera pas portable.<br />Maintenant, c’est toi qui vois.</p>]]></description>
			<author><![CDATA[dummy@example.com (grim7reaper)]]></author>
			<pubDate>Mon, 14 Jan 2013 04:19:02 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12199691#p12199691</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12196161#p12196161</link>
			<description><![CDATA[<p>j&#039;ai trouvé quelques autres infos complémentaires :<br /><a href="http://tronche.com/gui/x/xlib/display/XInitThreads.html">http://tronche.com/gui/x/xlib/display/XInitThreads.html</a></p><p>J&#039;ai beau mettre la fonction XInitThreads(); au tout début du main, ça ne règle pas le problème, j&#039;ai la même erreur.</p>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Sun, 13 Jan 2013 19:59:26 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12196161#p12196161</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195901#p12195901</link>
			<description><![CDATA[<p><a href="http://www.sfml-dev.org/old-forum/viewtopic.php?p=46545&amp;sid=534ac04adbc8b8ae0a4ed29eb68bead7">Essaye ca par exemple</a></p><p>Tu peux aussi essaye d&#039;utiliser XInitThreads en incluant les headers xlib</p>]]></description>
			<author><![CDATA[dummy@example.com (Haleth)]]></author>
			<pubDate>Sun, 13 Jan 2013 19:35:26 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195901#p12195901</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195751#p12195751</link>
			<description><![CDATA[<p>Je compile avec g++, j&#039;utilise boost-thread et la SFML. il n&#039;existe pas de fonction XInitThreads (ou alors je n&#039;en ai pas connaissance, je ne l&#039;utilise pas)<br />J&#039;ai déjà regardé les docs, pas de solutions :S</p>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Sun, 13 Jan 2013 19:27:46 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195751#p12195751</guid>
		</item>
		<item>
			<title><![CDATA[Réponse à&#160;:  [C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195721#p12195721</link>
			<description><![CDATA[<p>J&#039;suis pas expert dans la techno que tu n&#039;as pas nommé, mais j&#039;imagine que tu doit utilisé la fonction XInitThreads.<br />Regarde la doc de ladite techno.</p>]]></description>
			<author><![CDATA[dummy@example.com (Haleth)]]></author>
			<pubDate>Sun, 13 Jan 2013 19:25:47 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195721#p12195721</guid>
		</item>
		<item>
			<title><![CDATA[[C++] Gérer l'ouverture d'une fenêtre dans thread secondaire [RESOLU]]]></title>
			<link>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195691#p12195691</link>
			<description><![CDATA[<p>Bonjour à tous.<br />Ma question est dans le titre:<br />comment gérer l&#039;ouverture d&#039;une fenêtre dans un thread secondaire ?</p><p>J&#039;ai certainement trouvé quelques réponses potentielles sur:<br /><a href="http://www.google.fr/url?sa=t&amp;rct=j&amp;q=g%C3%A9rer%20l%27ouverture%20d%27une%20fen%C3%AAtre%20dans%20un%20thread%20secondaire&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CDwQFjAA&amp;url=http%3A%2F%2Fdoc.pcsoft.fr%2Ffr-fr%2F%3F3077015&amp;ei=WgfzUNm2LOmM0AXn1IGICw&amp;usg=AFQjCNFSUAOHCehmwNr-A1sRAwD2Dz5FaA&amp;bvm=bv.1357700187,d.d2k">http://www.google.fr/url?sa=t&amp;rct=j&amp;q=g … 0187,d.d2k</a></p><p>Cependant, je n&#039;arrive pas a aller sur ce site ...</p><p>Je m&#039;adresse donc à vous <img src="http://forum.ubuntu-fr.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>J&#039;ai programmé un jeu, une fenêtre s&#039;ouvre, et quand je clique sur un bouton &quot;option&quot;, une deuxième fenêtre s&#039;ouvre dans un thread pour afficher les options.<br />Ça compile, aucune erreur, aucun&#160; avertissements, les oiseaux chantent...</p><p>Je lance l’exécutable dans une console, le jeu fonctionne, jusqu&#039;à ce que je clique sur le bouton options:</p><div class="codebox"><pre><code>denis@denis:~/programmation/C++/alpha/hero$ ./hero
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
hero: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq&#039; failed.
Abandon (core dumped)</code></pre></div><p>Et le programme est avorté.</p><p>Merci des solutions que vous m&#039;apporterez <img src="http://forum.ubuntu-fr.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Destroyers)]]></author>
			<pubDate>Sun, 13 Jan 2013 19:23:06 +0000</pubDate>
			<guid>http://forum.ubuntu-fr.org/viewtopic.php?pid=12195691#p12195691</guid>
		</item>
	</channel>
</rss>
