<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Transparancy Difference on windows and ubuntu</title>
		<link>http://www.allegro.cc/forums/view/616777</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 03 Mar 2017 18:12:28 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>I&#39;m developing a game and, while i&#39;m not new to game development, its the first time I&#39;m using allegro5.</p><p>There seems to be a weird difference between Windows and Ubuntu though:</p><p>I&#39;m building an image using a few layers. Each layer can have transparency and this is defined in the image (.png files with a transparency channel).</p><p>It is working without any weird issues on windows:<br /><a href="https://www.dropbox.com/s/6cx492ihw4fxrwk/windows1.png?dl=0">https://www.dropbox.com/s/6cx492ihw4fxrwk/windows1.png?dl=0</a></p><p>But, on ubuntu - the transparency is replaced with, I think, random memory:<br /><a href="https://www.dropbox.com/s/v60czqmfnimj4sv/ubuntu1.png?dl=0">https://www.dropbox.com/s/v60czqmfnimj4sv/ubuntu1.png?dl=0</a></p><p>Does anybody have any hints as to what this could be? I&#39;ve run out of ideas :-(
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dratone)</author>
		<pubDate>Thu, 02 Mar 2017 17:36:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Drawing order and z-buffer issue? Transparency doesn&#39;t modify the pixels from what they were when uninitialised, but does preclude further drawing in those areas?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Thu, 02 Mar 2017 19:27:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How are you loading your images? Windows usually sets uninitialized memory to 0 - so you may simply not initialize something, but on Windows you don&#39;t notice as easily.</p><p>[edit:] Specifically, al_create_bitmap() will create an uninitialized bitmap, you have to clear it for it to become 0 and not random memory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 02 Mar 2017 20:50:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616777/1028753#target">Elias</a> said:</div><div class="quote"><p> [edit:] Specifically, al_create_bitmap() will create an uninitialized bitmap, you have to clear it for it to become 0 and not random memory. </p></div></div><p>That was indeed the issue. Thanks!</p><p>What I was doing was load the image file and then cut out the tile i needed so I didn&#39;t have to calculate that every time.. Meaning I did indeed create a new bitmap that way.</p><p>After adding an initialization it worked like a treat. Thanks!</p><p>BTW: Is there any better way then doing this:
</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><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> newtile <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span>width, height<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 2</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a><span class="k3">*</span> old <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_target_bitmap"><span class="a">al_get_target_bitmap</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 3</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>newtile<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 4</span><a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgba_f"><span class="a">al_map_rgba_f</span></a><span class="k2">(</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 class="k2">)</span><span class="k2">;</span>
<span class="number"> 5</span><a href="http://www.allegro.cc/manual/al_draw_bitmap_region"><span class="a">al_draw_bitmap_region</span></a><span class="k2">(</span>Sheet, tOffset.x, tOffset.y, Size.x, Size.y, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 6</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a><span class="k2">(</span>old<span class="k2">)</span><span class="k2">;</span>
</div></div><p>

If not I&#39;ll probably just create a utility function for it, but I was wondering if I was missing something.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dratone)</author>
		<pubDate>Fri, 03 Mar 2017 15:38:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You might find <span class="source-code"><a href="http://www.allegro.cc/manual/al_create_sub_bitmap"><span class="a">al_create_sub_bitmap</span></a></span> useful here. It has GPU advantages since internally Allegro can tell the GPU to do loads of draw operations from the same texture instead of many different ones.</p><p>By the way, Elias, wouldn&#39;t all platforms initialise memory to zero upon first handing it to a process, for security reasons? And then all platforms would leave it uninitialised if reallocating it when it already belonged to the process in the past (since the OS isn&#39;t even involved at this stage)?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Fri, 03 Mar 2017 15:47:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the tip. I&#39;ll try to keep that in mind and use sub bitmaps where possible.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dratone)</author>
		<pubDate>Fri, 03 Mar 2017 16:42:47 +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/616777/1028753#target">Elias</a> said:</div><div class="quote"><p>
[edit:] Specifically, al_create_bitmap() will create an uninitialized bitmap, you have to clear it for it to become 0 and not random memory.
</p></div></div><p>
Even if that&#39;s the OS case, that doesn&#39;t seem like it should be Allegro&#39;s case. If it&#39;s not a huge performance reason, we should probably default to calling clear_to_color inside al_create_bitmap. Returning a completely different bitmap state on a different OS sounds like it should be a different function name.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Fri, 03 Mar 2017 18:12:28 +0000</pubDate>
	</item>
</rss>
