<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Waves, with sines but no ALLEGRO_FLIP_VERTICAL</title>
		<link>http://www.allegro.cc/forums/view/617556</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 11 Sep 2018 12:00:43 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Basically it&#39;s this; ALLEGRO_FLIP_VERTICAL does not work with this code. So I&#39;m doing something wrong.<br />I try to let the water stream any any direction needed. Water moving RtL is just the math for LtR then do ALLEGRO_FLIP_HORIZONTAL. That seems to be OK.<br />The horizontal sines move jerkily but the vertical movement is without any accelleration, which I did not expect.<br />If you&#39;re interested maybe you can compile to see what I mean. It&#39;s hard to explain.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A. van Patmos)</author>
		<pubDate>Mon, 10 Sep 2018 03:49:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can&#39;t compile it. All the == and other operators are missing. There are spaces where they used to be. Try saving as UTF-8.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 10 Sep 2018 04:12:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, /* and */ were missing too. Strange. Here&#39;s a new save in ASCII and one in UTF-8.</p><p>edit: You&#39;ll have to rename water.png to MAR0DST192.png or change the code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A. van Patmos)</author>
		<pubDate>Mon, 10 Sep 2018 11:13:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m too tired to look tonight. What exactly is the unintended behavior you&#39;re witnessing? Computers only do what you tell them to.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 10 Sep 2018 12:03:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Based on looking at the code only, I saw 2 things</p><p>1. I don&#39;t think you need <span class="source-code"><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a></span> - that&#39;s for when you want direct pixel access to the bitmap&#39;s memory (Edgar can confirm this, I can&#39;t remember!)<br />2. You&#39;re setting <span class="source-code">uitslag_y</span> and <span class="source-code">uitslag_x</span> to the same (lines 47 &amp; 48) - is this correct?</p><p>Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Mon, 10 Sep 2018 13:28:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, maybe I misunderstood how to use al_lock_bitmap.</p><p>Yes I set both amplitudes to 18.<br />If you set line 37 to be<br /><span class="source-code"><span class="k1">float</span> h_afstand <span class="k3">=</span> <span class="n">0</span>, h_snelheid <span class="k3">=</span> <span class="n">0</span>, v_afstand <span class="k3">=</span> <span class="n">0</span>, v_snelheid <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span><span class="c">// edit: snelheid is speed, afstand is distance</span></span><br />everything stays where it is.</p><p>You can see a few things:<br />The vertical sines move with a steady speed (no accelleration)<br />The horizontal sines move &#39;jerkily&#39;. sometimes the sine works with the flow (speed up) and sometimes against. (I meant that in my first post)<br />You can see why I made the png with a black graph on one end and red on the other: if black moves red stands still and vice versa. That makes sense.</p><p>I expected the vertical movement to be the same.</p><p>edit some more: I attached a pic.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (A. van Patmos)</author>
		<pubDate>Mon, 10 Sep 2018 20:07:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t understand what effect you&#39;re trying to achieve. It looks pretty cool to me. :?</p><p>EDIT<br />Yeah, you don&#39;t need to lock the bitmaps to draw them. That causes a memory transfer, and you don&#39;t want to leave them unlocked either. Lock, update, unlock.</p><p>EDIT2<br />This kind of program would be best with a shader. You could easily replicate the effect. All you&#39;re doing is adding sin(x) to the x and y coordinates in the proper direction.</p><p>EDIT3<br />I whipped up a simple shader program. It does mostly what you want, but doesn&#39;t &#39;keep flowing&#39; in the same direction. Maybe this will give you an idea on how to make it work the way you want it to.</p><p><a href="https://www.allegro.cc/files/attachment/611696">Download Wavy.7z here</a></p><p>Here&#39;s the fragment shader I used.
</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="p">#version 110</span>
<span class="number">  2</span>
<span class="number">  3</span>uniform sampler2D tex<span class="k2">;</span> <span class="c">// 0</span>
<span class="number">  4</span>uniform <span class="k1">float</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a><span class="k2">;</span> <span class="c">// effect elapsed time</span>
<span class="number">  5</span>
<span class="number">  6</span>uniform vec2 surface<span class="k2">;</span> <span class="c">// texture resolution</span>
<span class="number">  7</span>
<span class="number">  8</span><span class="k1">void</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="number">  9</span><span class="k2">{</span>
<span class="number"> 10</span>    <span class="k1">float</span> width <span class="k3">=</span> <span class="n">1</span>.<span class="n">0</span><span class="k3">/</span><span class="n">4</span>.<span class="n">0</span><span class="k2">;</span><span class="c">/// In texels</span>
<span class="number"> 11</span>    <span class="k1">float</span> factor <span class="k3">=</span> <span class="n">0</span>.<span class="n">05</span><span class="k2">;</span><span class="c">/// Factors from 0.01 to 0.1 seem okay</span>
<span class="number"> 12</span>    factor <span class="k3">=</span> factor<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>    vec2 uv <span class="k3">=</span> gl_TexCoord<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>.xy<span class="k2">;</span>
<span class="number"> 14</span>
<span class="number"> 15</span>    <span class="k1">float</span> power <span class="k3">=</span> <span class="n">1</span>.<span class="n">0</span><span class="k2">;</span>
<span class="number"> 16</span>    
<span class="number"> 17</span>    <span class="k1">float</span> xfact <span class="k3">=</span> <span class="k2">(</span><span class="n">1</span>.<span class="n">0</span> <span class="k3">+</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span><span class="k2">(</span><span class="n">2</span>.<span class="n">0</span><span class="k3">*</span><span class="n">3</span>.<span class="n">14159265</span><span class="k3">*</span>uv.x<span class="k3">/</span>width<span class="k2">)</span> <span class="k3">+</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a><span class="k2">)</span><span class="k2">)</span><span class="k3">/</span><span class="n">2</span>.<span class="n">0</span><span class="k2">;</span><span class="c">/// [0,1.0)</span>
<span class="number"> 18</span>    xfact <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_618.html" target="_blank">pow</a><span class="k2">(</span>xfact , power<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>
<span class="number"> 20</span>    <span class="k1">float</span> yfact <span class="k3">=</span> <span class="k2">(</span><span class="n">1</span>.<span class="n">0</span> <span class="k3">+</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_113.html" target="_blank">cos</a><span class="k2">(</span><span class="k2">(</span><span class="n">2</span>.<span class="n">0</span><span class="k3">*</span><span class="n">3</span>.<span class="n">14159265</span><span class="k3">*</span>uv.y<span class="k3">/</span>width<span class="k2">)</span> <span class="k3">+</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a><span class="k2">)</span><span class="k2">)</span><span class="k3">/</span><span class="n">2</span>.<span class="n">0</span><span class="k2">;</span><span class="c">/// [0,1.0)</span>
<span class="number"> 21</span>    yfact <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_618.html" target="_blank">pow</a><span class="k2">(</span>yfact , power<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>
<span class="number"> 23</span>    <span class="c">/// Modify x value by sin(2PI*x/50.0) and y value by sin(2PI*y/50.0)</span>
<span class="number"> 24</span>    uv <span class="k3">=</span> vec2<span class="k2">(</span>uv.x <span class="k3">+</span> factor<span class="k3">*</span>yfact , uv.y <span class="k3">+</span> factor<span class="k3">*</span>xfact<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>    gl_FragColor <span class="k3">=</span> texture2D<span class="k2">(</span>tex, uv<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 11 Sep 2018 12:00:43 +0000</pubDate>
	</item>
</rss>
