<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_draw_line failure</title>
		<link>http://www.allegro.cc/forums/view/611460</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 19 Nov 2012 11:53:23 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi everyone, it&#39;s my first post here. 
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 1</span><span class="k1">for</span><span class="k2">(</span><span class="k1">int</span> i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> i<span class="k3">&lt;</span><span class="k2">(</span>n-1<span class="k2">)</span><span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
<span class="number"> 2</span><span class="k2">{</span>
<span class="number"> 3</span>    <span class="k1">for</span><span class="k2">(</span><span class="k1">int</span> j <span class="k3">=</span> <span class="k2">(</span>i<span class="k3">+</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span> j<span class="k3">&lt;</span>n<span class="k2">;</span> j<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span>
<span class="number"> 4</span>    <span class="k2">{</span>
<span class="number"> 5</span>        <a href="http://www.allegro.cc/manual/al_draw_line"><span class="a">al_draw_line</span></a><span class="k2">(</span>pX<span class="k2">[</span>i<span class="k2">]</span>, pY<span class="k2">[</span>i<span class="k2">]</span>, pX<span class="k2">[</span>j<span class="k2">]</span>, pY<span class="k2">[</span>j<span class="k2">]</span>, red, <span class="n">2</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 6</span>        file<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"Line between "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>pX<span class="k2">[</span>i<span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>pY<span class="k2">[</span>i<span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" and "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>pX<span class="k2">[</span>j<span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">" "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>pY<span class="k2">[</span>j<span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span> endl<span class="k2">;</span>
<span class="number"> 7</span>    <span class="k2">}</span>
<span class="number"> 8</span><span class="k2">}</span>
</div></div><p>
The code above is supposed to draw lines between points &quot;i&quot; and &quot;j&quot; described by coordinates stored in &quot;float&quot; type vectors, f.e. pX[1] and pY[1] are coordinates of &quot;Point 2&quot;.</p><p>Problem is, lines are <b>not</b> drawn, and I don&#39;t know, why. As a part of crude debugging, notifications of supposed drawings are saved in .txt file in pattern shown below. In result, I get properly filled file:
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 2</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">411</span>.<span class="n">355</span> <span class="n">280</span>.<span class="n">674</span>
<span class="number"> 3</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">400</span>.<span class="n">902</span> <span class="n">298</span>.<span class="n">778</span>
<span class="number"> 4</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">386</span>.<span class="n">913</span> <span class="n">314</span>.<span class="n">314</span>
<span class="number"> 5</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">370</span> <span class="n">326</span>.<span class="n">602</span>
<span class="number"> 6</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">350</span>.<span class="n">902</span> <span class="n">335</span>.<span class="n">106</span>
<span class="number"> 7</span>Line between <span class="n">417</span>.<span class="n">815</span> <span class="n">260</span>.<span class="n">791</span> <span class="k1">and</span> <span class="n">330</span>.<span class="n">453</span> <span class="n">339</span>.<span class="n">452</span>
<span class="number"> 8</span><span class="k1">and</span> so on...
</div></div><p>
which means numerical input is all right. I get no errors nor warnings. It&#39;s not the first time this function is acting weird - not drawing when code seems to be all-OK. There&#39;s an possibility that I&#39;m missing something little yet essential about the usage of this function, but right now, I&#39;m clueless.<br />Ideas, anyone? </p><p>Full listing of fuction using this code : <a href="http://pastebin.com/JvsGVrTM">http://pastebin.com/JvsGVrTM</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ponyman)</author>
		<pubDate>Sun, 18 Nov 2012 15:50:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did you  <a href="http://www.allegro.cc/manual/5/al_init_primitives_addon">initialize primitives?</a>  Also try substituting <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgb_f"><span class="a">al_map_rgb_f</span></a><span class="k2">(</span><span class="n">1</span>.<span class="n">0</span>,<span class="n">0</span>.<span class="n">0</span>,<span class="n">0</span>.<span class="n">0</span><span class="k2">)</span></span> for red.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 18 Nov 2012 15:58:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@Arthur - I&#39;ve changed the drawing colour with your suggestion and it works! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /><br />&quot;red&quot; was defined like this<br /><span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> red <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">255</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span></span><br />outside the functions in the file (as a file-global variable) and it worked in other functions, yet it failed here.<br />Care to explain, what is the difference in this case?<br />I would be really helpful for me, just to avoid mistakes like this one in the future. This one gave a lot of stress.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ponyman)</author>
		<pubDate>Sun, 18 Nov 2012 16:14:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can&#39;t call functions such as al_map_rgb() outside of main() or another function, I&#39;d guess it loaded &quot;red&quot; with the address of al_map_rgb().  Try to find out how to increase the error reporting of your compiler.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 18 Nov 2012 16:21:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Good old DevC++ does not report this as an error. Well, I&#39;ll be wiser now.<br />Thanks a lot! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ponyman)</author>
		<pubDate>Sun, 18 Nov 2012 16:35:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611460/970474#target">ponyman</a> said:</div><div class="quote"><p> Good old DevC++</p></div></div><p>IIRC, DevC++ uses MinGW and the gcc compiler, right?  You can turn up the errors and warnings with </p><pre>-O2 -Wall -Wextra</pre><p> in the compiler options (whereever those are).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 18 Nov 2012 16:38:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re right, I&#39;ll try it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ponyman)</author>
		<pubDate>Sun, 18 Nov 2012 17:11:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611460/970473#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>You can&#39;t call functions such as al_map_rgb() outside of main() or another function, I&#39;d guess it loaded &quot;red&quot; with the address of al_map_rgb(). Try to find out how to increase the error reporting of your compiler.</p></div></div><p>Calling functions outside of main like that is valid in C++.</p><p>However, it is not normally valid to call allegro functions before you&#39;ve called <span class="source-code"><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a></span> or after <span class="source-code"><a href="http://www.allegro.cc/manual/al_uninstall_system"><span class="a">al_uninstall_system</span></a></span> has been called. Many also don&#39;t like it if there isn&#39;t a current display or target bitmap. It&#39;s something that is easy to trip up on when using C++ &quot;as normal&quot;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 19 Nov 2012 11:53:23 +0000</pubDate>
	</item>
</rss>
