<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Problems with mouse flicker</title>
		<link>http://www.allegro.cc/forums/view/585497</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 23 May 2006 03:31:10 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, been playing with this for a couple days now and I have the mouse working in my menu, but there is an awful flicker. </p><p>All im doing is using double buffering. I read in the manual that you need to hide the mouse when drawing and then show it again when your done or &#39;bad stuff will happen&#39; but this doesnt help. Im using a custom bitmap, it loads and displays ok.</p><p>Here is some pseudo showing how Im doing it:</p><p>show_mouse(screen);<br />Do {<br />scare_mouse();<br />// insert drawing routines for menu, check for mouseovers, etc<br />// blit to screen<br />unscare_mouse();</p><p>This causes a horrid flicker tho. Ive checked the exmouse example and they are using it the same way, except when they show their custom mouse cursor its not in a loop, it just waits for a readkey() . </p><p>I&#39;ve also tried showing the mouse on the buffer, and still got the flicker. Im tempted to just draw my cursor as a sprite and set x &amp; y via the mouse_x &amp; y instead of using allegros routines.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cdxrd)</author>
		<pubDate>Sat, 20 May 2006 00:34:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I alway use the hardwere mouse now to avoid that problem.<br />I also think the hardwere mouse looks better, why isn&#39;t it the default?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spunit262)</author>
		<pubDate>Sat, 20 May 2006 07:02:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I also think the hardwere mouse looks better, why isn&#39;t it the default?
</p></div></div><p>
Because then the mouse mickeys won&#39;t work.</p><p>But basically what you have to do is eith er use a hardware cursor, or double-buffer the mouse. Like so:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">/* Try to enable a hardware cursor */</span></td></tr><tr><td class="number">2</td><td><a href="http://www.allegro.cc/manual/enable_hardware_cursor" target="_blank"><span class="a">enable_hardware_cursor</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">3</td><td><a href="http://www.allegro.cc/manual/show_mouse" target="_blank"><span class="a">show_mouse</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td><span class="c">/* If not, fall back to double-buffering */</span></td></tr><tr><td class="number">5</td><td><span class="k1">if</span><span class="k2">(</span><span class="k3">!</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/gfx_capabilities" target="_blank"><span class="a">gfx_capabilities</span></a><span class="k3">&amp;</span>GFX_HW_CURSOR<span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">6</td><td>    <a href="http://www.allegro.cc/manual/show_mouse" target="_blank"><span class="a">show_mouse</span></a><span class="k2">(</span>NULL<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td><span class="k1">while</span><span class="k2">(</span>game_loop<span class="k2">)</span></td></tr><tr><td class="number">9</td><td><span class="k2">{</span></td></tr><tr><td class="number">10</td><td>    logic<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>    draw<span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>&#160;</td></tr><tr><td class="number">13</td><td>    <span class="k1">if</span><span class="k2">(</span><span class="k3">!</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/gfx_capabilities" target="_blank"><span class="a">gfx_capabilities</span></a><span class="k3">&amp;</span>GFX_HW_CURSOR<span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">14</td><td>        <a href="http://www.allegro.cc/manual/draw_sprite" target="_blank"><span class="a">draw_sprite</span></a><span class="k2">(</span>buffer, <a href="http://www.allegro.cc/manual/mouse_sprite" target="_blank"><span class="a">mouse_sprite</span></a>, <a href="http://www.allegro.cc/manual/mouse_x" target="_blank"><span class="a">mouse_x</span></a>, <a href="http://www.allegro.cc/manual/mouse_y" target="_blank"><span class="a">mouse_y</span></a><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>    <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>buffer, <a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, buffer-&gt;w, buffer-&gt;h<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>    <a href="http://www.allegro.cc/manual/clear_bitmap" target="_blank"><span class="a">clear_bitmap</span></a><span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Sat, 20 May 2006 08:58:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Because then the mouse mickeys won&#39;t work.
</p></div></div><p>
May not work as you expect. The mouse mickeys will work, but you won&#39;t get an infinate range of movement in, say, X11.<br />For this reason we couldn&#39;t make the hardware mouse the default behavior (it would break existing programmes).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 20 May 2006 14:58:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, thanx for the help, I think I am going to do it like you suggested Kitty Cat. I was drawing the mouse as a sprite, I was trying to use allegro&#39;s routines:</p><p>	set_mouse_sprite(mouse_cursor);<br />	set_mouse_sprite_focus(3, 3);</p><p>And using the scare, unscare(); </p><p>But that way is giving way too much flicker, and I really dont want to use the hardware mouse, so displaying it as a sprite will probably be the easiest solution.. </p><p>See how it is? The one time I go and do my reasearch and look it up in the manual and it turns out to be a horrid way of doing it.. =)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cdxrd)</author>
		<pubDate>Sun, 21 May 2006 10:01:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I really dont want to use the hardware mouse
</p></div></div><p>
Why? It&#39;s by far the best way of displaying the mouse if your OS supports it.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The one time I go and do my reasearch and look it up in the manual and it turns out to be a horrid way of doing it
</p></div></div><p>
Meaning?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sun, 21 May 2006 13:14:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Meaning exactly what I said.. </p><p>When I use allegro&#39;s mouse routines for a custom cursor, I get a horrid flicker, and nothing I have done so far is eliminating it. If I use the hardware cursor, will it still show me the custom cursor I have chosen or does it limit me to the stock OS default one?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cdxrd)</author>
		<pubDate>Sun, 21 May 2006 19:31:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It will show the one you select, as long as the OS supports it (eg. isn&#39;t larger than 32x32 in Windows). Can&#39;t hurt to try.. it&#39;s only a few lines of code. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 22 May 2006 05:43:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If I use the hardware cursor, will it still show me the custom cursor I have chosen or does it limit me to the stock OS default one?
</p></div></div><p>
There wouldn&#39;t be much point if all you could get were the default OS cursors.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Mon, 22 May 2006 10:37:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Even after enabling the hardware cursor, the flicker is just as horrid as before. So I just resorted to a good old standby. Move the sprite to Mouse_x &amp; y.. No flicker, etc... Really no difference there except how its drawn, I&#39;m still detecting clicks and setting my bounding boxes, only difference is I gotta remember to blit the cursor.. big deal.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (cdxrd)</author>
		<pubDate>Mon, 22 May 2006 23:11:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Even after enabling the hardware cursor, the flicker is just as horrid as before.
</p></div></div><p>
Did you check you actually get a hardware cursor? Can you post your code?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
only difference is I gotta remember to blit the cursor.. big deal.
</p></div></div><p>
The update rate of your on-screen mouse pointer is also limited to your framerate, and if you don&#39;t redraw frames unless things have changed (which is normally a good idea) it won&#39;t update either (basically forcing you to do the update whenever you can).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Tue, 23 May 2006 03:31:10 +0000</pubDate>
	</item>
</rss>
