<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Need some help with the Shader addon</title>
		<link>http://www.allegro.cc/forums/view/603307</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 08 Mar 2010 08:02:15 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve been coding these days the ALLEGRO_SHADER add-on, but I&#39;ve come to realise something. My ignorance is working against me too much here, and I&#39;ve spent two days trying to figure out the problem, failing miserably.</p><p>I&#39;m pretty sure that anyone here with barely a grasp of Direct3D and OpenGL might know the solution to my problem.</p><p>What&#39;s the problem? I&#39;ve got everything working, except 1 feature common to all shaders... Setting textures. They refuse to change, and nothing I change will make them behave otherwise. I hope that the problem isn&#39;t related to Allegro resetting some needed parameters when drawing, and it&#39;s surely my fault of how I set them.</p><p>The question is, would anybody help me on this one? I don&#39;t want to delay the shader addon because of my ignorance. I&#39;ll make my best on documenting and cleaning it, and leave handy TODOs in the functions needed.</p><p>That&#39;s the only thing that isn&#39;t working. If only 1 would work, maybe I could figure out the rest. But the answer evades me <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /></p><p>If the devs give me the OK with it, I&#39;ll post it here and let you take care of it. I&#39;m just frustrating myself over something that could be easily solved by anyone with more experience in this.</p><h4>UPDATE:</h4><p>

Ok, I&#39;m gonna post it here. I don&#39;t know if it&#39;s good by the coding standards of Allegro, but that can be fixed. I didn&#39;t take the time to make it an add-on or something because setting textures doesn&#39;t work, so just build the files.</p><p><a href="http://www.allegro.cc/files/attachment/600675">Download source with example</a><br /><s><a href="http://www.allegro.cc/files/attachment/600614">Download source with example</a></s> Seems like this one is corrupted.</p><p>You&#39;ll need to link to the following libs:<br />opengl32<br />d3dx9</p><p>And for using CG Support:<br />cg<br />cggl<br />cgd3d9</p><p>There&#39;s an AL_SHADER_SUPPORT_CG define in case you don&#39;t have CG and want to build it anyways. BUT, you&#39;d be left wiht GLSL support only.</p><p>Check out first ex_shader.cpp. It shows how the API is used, and I left commented various options for loading different types of shaders.</p><p>Second, al_shader.h has explations for every method, how it&#39;s used, but not how it works internally.</p><p>What I need done is left in &quot;TODO:&quot; (Just search for it, there&#39;s only two). It&#39;s just two functions for setting the textures.</p><p>Any comments in improving the API, the coding or something are welcome. Any help would be really appreciated. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dario ff)</author>
		<pubDate>Sat, 27 Feb 2010 19:05:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sure, post it when you think it&#39;s ready.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sat, 27 Feb 2010 19:58:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, it&#39;s attached. Check the first post.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dario ff)</author>
		<pubDate>Sat, 27 Feb 2010 21:52:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, I only had a really superficial look at it so far but thought this required a reply.</p><p>Have you considered looking at Ogre to see how they do it?</p><p>As far as the API is concerned, the first thing that sticks out is the maximum line length parameter to al_load_shader(). It shouldn&#39;t be required.</p><p>(more later)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Tue, 02 Mar 2010 14:33:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Didn&#39;t notice your answer until today Peter, I had given up hope about this. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/603307/853985#target">Peter Wang</a> said:</div><div class="quote"><p>As far as the API is concerned, the first thing that sticks out is the maximum line length parameter to al_load_shader(). It shouldn&#39;t be required.</p></div></div><p>

Ah, forgot to take it out. I should use fread and look for the line carriages to separate the lines(GLSL needs a 2 dimensional array, while CG uses a single string separated by line carriages).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Have you considered looking at Ogre to see how they do it?</p></div></div><p>

CG comes already with a good handful of examples about setting the textures, so I based myself mostly on that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dario ff)</author>
		<pubDate>Mon, 08 Mar 2010 04:41:45 +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/603307/854855#target">dario ff</a> said:</div><div class="quote"><p>I should use fread and look for the line carriages to separate the lines(GLSL needs a 2 dimensional array, while CG uses a single string separated by line carriages).</p></div></div><p>
While glShaderSource() takes a double pointer, and you <i>may</i> use that to separate the shader source into an array of strings, you don&#39;t actually have to. Using a single C string is perfectly legal. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Mon, 08 Mar 2010 07:46:56 +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/603307/854871#target">gnolam</a> said:</div><div class="quote"><p>While glShaderSource() takes a double pointer, and you may use that to separate the shader source into an array of strings, you don&#39;t actually have to. Using a single C string is perfectly legal. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p></div></div><p>

Then that makes a chunk of my code useless and would make it look much cleaner, and I can easily simplify everything with a single string. Thanks for the detail gnolam, I should&#39;ve tried that in the first place. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dario ff)</author>
		<pubDate>Mon, 08 Mar 2010 08:02:15 +0000</pubDate>
	</item>
</rss>
