<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Mixing bitmaps</title>
		<link>http://www.allegro.cc/forums/view/617480</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sat, 30 Jun 2018 09:58:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I was trying to mix different terrain bitmaps to make mixed terrains. But however, it is not working. Every time I render it, it turns out to be white. But when I try the same with individual bitmaps it&#39;s working fine.<br />I tried different transparency for different terrains bitmaps - but it&#39;s not working.</p><p>What would I be doing wrong - is it even possible? <br /><a href="https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp">https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 01:05:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>

<a href="https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp#L39-L42">https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp#L39-L42</a></p><p>Well, your colors are wrong. :/ You&#39;re tinting white at full and zero alpha. Of course its white.</p><p>Allegro uses pre-multiplied alpha. That means you need to use <span class="source-code"><a href="http://www.allegro.cc/manual/al_map_rgba"><span class="a">al_map_rgba</span></a><span class="k2">(</span>r<span class="k3">*</span>a , g<span class="k3">*</span>a , b<span class="k3">*</span>a , a<span class="k2">)</span></span> for your color values.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 29 Jun 2018 01:15:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you, Edgar Reynaldo, for replaying<br />I didn&#39;t quite get the idea. You meant every time I have to tint a bitmap while I draw it, I must multiply the alpha with the RGB value?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 13:31:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>At first, I found it difficult to understand why Allegro 5 uses premultiplied alpha. &quot;Surely this&#39;ll just make my textures unnecessarily darker when drawn&quot; was my first thought.</p><p>Have a look at <a href="https://blogs.msdn.microsoft.com/shawnhar/2009/11/07/premultiplied-alpha-and-image-composition/">this article</a> for some explanation as to why it&#39;s useful. Funnily enough, it&#39;s written by a guy called Shawn Hargreaves - same name as the guy who wrote the original Allegro! (no idea whether it&#39;s the same person.)</p><p><b>EDIT</b> well I&#39;ll be damned, <a href="http://www.shawnhargreaves.com/">it is</a>. Guess he&#39;s still useful after all these years. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dthompson)</author>
		<pubDate>Fri, 29 Jun 2018 14:07:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you dthompson, <br />So tinting is way more complex than I thought. <img src="http://www.allegro.cc/forums/smileys/cry.gif" alt=":&#39;(" /><img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /><img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /><br />I am a little alien to premultiplies alphas and hardcode graphics terms. RGB and Alpha are the farthest I have gone.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 14:28:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not too complex if you&#39;re using Allegro, most of the time. In this instance you just need to set your alpha value to <span class="source-code"><span class="n">1</span></span>.</p><p>A word of advice on this: Allegro&#39;s blenders make it easy to tint your textures if you want to remove colour (ie. make them darker). If you want to &quot;tint them brighter&quot;, you&#39;ll probably need to write a shader.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dthompson)</author>
		<pubDate>Fri, 29 Jun 2018 14:36:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you dthompson, <br />I will keep that in mind.<br /><a href="https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp">https://github.com/ThinkalVB/NearEarth/blob/master/RenderingEngine/Texture.cpp</a><br />Can you suggest some improvements to my project? I am planning to include a spotlight type light. But I need some instructions to start.<br />I am planning to make an MMO 2D top-down shooter game and a framework along with it - for others to make their own game if they want. Custom made for MMO&#39;s.<br />I am planning to start developing the Network Engine the next month using ASIO, as I have some previous experience with ASIO during a failed attempt while making a similar game.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 15:10:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ll have to get back to you once I&#39;ve written a proper engine myself. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>It&#39;s an admirable undertaking - be warned that this will without <i>any doubt</i> be a huge amount of work for you, though. Frameworks are not easy to write!</p><p>You mention that you&#39;ve had some experience with this, but I&#39;d have to warn you to be careful that you&#39;re not <a href="http://wiki.c2.com/?PrematureOptimization">optimising prematurely</a>. The page I&#39;ve linked to mainly talks about code <i>speed</i>, though it applies just as much to code <i>organisation</i>.</p><p>Have you written an entire MMO before? If not, it might be worth doing that first, identifying the patterns that your framework could address, then stripping down the source of your game to create the framework.</p><p>Sorry if this sounds boring, but it could save you a lot of time <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dthompson)</author>
		<pubDate>Fri, 29 Jun 2018 15:32:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you dthompson, <br />No, it&#39;s not at all boring. In fact, it&#39;s really enlightening - I need opinions from peoples because I believe there is always something I can learn from everyone whether it be a kid or an adult with a good programming experience. <br />No, I had never made an MMO before - but I have made attempts to do so. Once I was really close but had to step back due to academic reasons and time carried away and the project was lost in time. But this time I am more determined to make it because I have a 2-month vacation before my college starts and I am intending to do it as my final year project. I am not behind big blockbuster games but a simple one as a proof of concept like a prototype model.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 15:50:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Building a prototype would be a great idea - even moreso if you&#39;re attempting to submit it academically, as {prototypes, failed attempts, previous projects} are useful in demonstrating your thinking process.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dthompson)</author>
		<pubDate>Fri, 29 Jun 2018 16:00:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you dthompson, <br />But in Kerala you need a working thing to get a pass mark on project 😂. But in my class of computer engineers 39 out of 45 have not even the slightest idea about programming.<br />So mostly they do is buy a project from some companies and submit it as thier project - and it&#39;s been going on like that for centuries here. 😂
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Fri, 29 Jun 2018 18:54:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can change the blender and use non-pm alpha if you want, but you might as well get used to it. It&#39;s pretty much the norm. OpenGL uses it too I think.</p><p>Here is some example code :
</p><div class="source-code snippet"><div class="inner"><pre>   <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> red_full_alpha <span class="k3">=</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">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="n">1</span>.<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/ALLEGRO_COLOR"><span class="a">ALLEGRO_COLOR</span></a> white_half_alpha <span class="k3">=</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">1</span>.<span class="n">0</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5</span> , <span class="n">1</span>.<span class="n">0</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5</span> , <span class="n">1</span>.<span class="n">0</span><span class="k3">*</span><span class="n">0</span>.<span class="n">5</span> , <span class="n">0</span>.<span class="n">5</span><span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap"><span class="a">al_draw_tinted_bitmap</span></a><span class="k2">(</span>sprite1 , red_full_alpha , <span class="n">0</span> , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
   <a href="http://www.allegro.cc/manual/al_draw_tinted_bitmap"><span class="a">al_draw_tinted_bitmap</span></a><span class="k2">(</span>sprite2 , white_half_alpha , <span class="n">0</span> , <span class="n">0</span> , <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Here&#39;s some sample blender code :
</p><div class="source-code snippet"><div class="inner"><pre>   <a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD , ALLEGRO_ONE , ALLEGRO_ZERO<span class="k2">)</span><span class="k2">;</span><span class="c">/// Overwrite blender</span>
   <a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD , ALLEGRO_ONE , ALLEGRO_INVERSE_ALPHA<span class="k2">)</span><span class="k2">;</span><span class="c">/// Default Pre Multiplied Alpha blender</span>
   <a href="http://www.allegro.cc/manual/al_set_blender"><span class="a">al_set_blender</span></a><span class="k2">(</span>ALLEGRO_ADD , ALLEGRO_ALPHA , ALLEGRO_INVERSE_ALPHA<span class="k2">)</span><span class="k2">;</span><span class="c">/// Regular alpha blender, non-pm</span>
</pre></div></div><p>

EDIT<br />Before you get too far into this sort of thing, why don&#39;t you check out Mark Oates <a href="https://github.com/MarkOates/allegro_flare">Allegro FLARE framework</a>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 29 Jun 2018 20:05:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you Edgar Reynaldo, <br />Oh my goodness, Where was allegro flare all these years?<br />Allegro Flare is promising. It&#39;s abstracting a lot of low-level details from us making the development more hassle-free. But there is no tutorial for it to get started. The main reason I chose Allegro is that it had a lot of tutorials on youtube and a good and active community to support it. Also, VCPKG doesn&#39;t have allegro flare - so even if I try to port it to allegro flare - I will be having a hard time integrating it to my IDE - because it&#39;s hard for me, most of the time something goes wrong.</p><p>I personally think allegro must support more features like the allegro flare - inbuilt support for light, animation, shadow, 3D objects etc... So that if we want we can create one, or for those who want the hard way around can go for it (building things from scratch).</p><p>T think until I have a prototype I should move forward with allegro, Before porting it to other frameworks - else I never hit the finish line. In future working with Ogre would be nice. But I need to have a clear understanding before moving on to 3D. So Allegro is good for now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thinkal VB)</author>
		<pubDate>Sat, 30 Jun 2018 09:58:40 +0000</pubDate>
	</item>
</rss>
