<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>openGL texture filters and the mystery of the clueless programmer</title>
		<link>http://www.allegro.cc/forums/view/591262</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 06 May 2007 13:43:34 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So i&#39;m following NeHe&#39;s tutorials on openGL i&#39;ve reached texture filters and simple lightning (lesson 7) and not very surprisingly stumbled upon a problem (even if i&#39;m the problem, whatever), in the tutorial he uses glaux to load his bitmaps, i use allegro and not necessarily the problem, it&#39;s probably related, anyway, here&#39;s the code i think is wrong(i don&#39;t think, i guess, because i don&#39;t have any facts): 
</p><div class="source-code snippet"><div class="inner"><pre>glBindTexture<span class="k2">(</span>GL_TEXTURE_2D, tex<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
glTexParameteri<span class="k2">(</span>GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR<span class="k2">)</span><span class="k2">;</span>
glTexParameteri<span class="k2">(</span>GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR<span class="k2">)</span><span class="k2">;</span>
glTexImage2D<span class="k2">(</span>GL_TEXTURE_2D, <span class="n">0</span>, <span class="n">3</span>, <span class="n">256</span>, <span class="n">256</span>, <span class="n">0</span>, GL_RGB, GL_UNSIGNED_BYTE, test01<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p> Note that i have no real knowledge of what these functions do, but i guess i&#39;m just stating the obvious <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.</p><p>tex = GLuint<br />test01 = allegro bitmap</p><p>My second guess is that the initialization code sucks, i&#39;m attaching a picture which should prove more of a clue than anything else. i think... thanks!!</p><p>edit: btw, i forgot to do a thing before i took a picture of the &quot;working&quot; version, if anyone wonders why it looks so retared..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Fri, 04 May 2007 07:09:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you&#39;re using AllegroGL, use the normal BITMAP loading function, then use AllegroGL&#39;s <b>allegro_gl_make_bitmap</b> functions with that BITMAP.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
glBindTexture(GL_TEXTURE_2D, tex[0]);<br />glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);<br />glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);<br />glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, test01);<br /> Note that i have no real knowledge of what these functions do, but i guess i&#39;m just stating the obvious <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.
</p></div></div><p>
glBindTexture says &quot;use/set this texture&quot;.</p><p>glTexParameter says &quot;set some parameters for this texture (one that is currently glBindTexture-ed)&quot;. You&#39;re just setting the magnification/minification to linear which is blending the pixels on the screen when the texture on the <i>screen</i> is smaller or larger than the texture in <i>memory</i>. The other option is GL_NEAREST which just gets the nearest texel (texture pixel) and draws that pixel rather than blending it.</p><p>glTexImage2D says &quot;set the texture&#39;s <i>pixels</i>&quot;. You supply the dimensions, whether it&#39;s RGB, BGR, RGBA etc, the data type etc...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Fri, 04 May 2007 13:34:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thank you <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />. allegro_gl_make_bitmap doesn&#39;t seem to exist so i guessed you meant allegro_gl_make_texture, also, should i use the allegro_gl functions instead when creating a texture, they felt limited compared to the ones i mentioned in my main post but i don&#39;t think i need anything else. thanks for the description but i still can&#39;t get those functions to work, just in case i&#39;d want to use them it could be good to know how.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sat, 05 May 2007 08:17:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
allegro_gl_make_bitmap doesn&#39;t seem to exist so i guessed you meant allegro_gl_make_texture
</p></div></div><p>
My mistake - it was an oversight (I don&#39;t use AllegroGL anyways).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
should i use the allegro_gl functions instead when creating a texture, they felt limited compared to the ones i mentioned in my main post
</p></div></div><p>
allegro_gl_make_texture creates a texture from a bitmap that is loaded into the allegro library.</p><p>You should be able to use the other image libraries for Allegro and then allegro_gl_make_texture on those.</p><p>However, you can change the values of the glTexParameter-s after you bind the texture even after the texture has been loaded... So you could do something like:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> myTexture <span class="k3">=</span> allegro_gl_make_texture<span class="k2">(</span>myBitmap,...<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/destroy_bitmap" target="_blank"><span class="a">destroy_bitmap</span></a><span class="k2">(</span>myBitmap<span class="k2">)</span><span class="k2">;</span>

glBindTexture<span class="k2">(</span>GL_TEXTURE_2D, myTexture<span class="k2">)</span><span class="k2">;</span>
glTexParameteri<span class="k2">(</span>GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR<span class="k2">)</span><span class="k2">;</span>
glTexParameteri<span class="k2">(</span>GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

glTexParameter/glTex***** affect what texture is currently glBindTextured-ed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Sat, 05 May 2007 09:36:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use allegro_gl_make_texture_ex(), since the non-ex version is deprecated. And there are so many things to care about when uploading the bitmap to the texture that you should let AGL do it. It is not just a few lines of code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Milan Mimica)</author>
		<pubDate>Sat, 05 May 2007 13:17:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Archon said:</div><div class="quote"><p>
glTexParameter/glTex***** affect what texture is currently glBindTextured-ed.
</p></div></div><p> sweet, thanks! wait.. don&#39;t you mean &quot;affect the currently glBindTextured-ed texture&quot; or am i getting it wrong?</p><div class="quote_container"><div class="title">Archon said:</div><div class="quote"><p>
Use allegro_gl_make_texture_ex(), since the non-ex version is deprecated. And there are so many things to care about when uploading the bitmap to the texture that you should let AGL do it. It is not just a few lines of code.
</p></div></div><p> <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Sun, 06 May 2007 08:43:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
wait.. don&#39;t you mean &quot;affect the currently glBindTextured-ed texture&quot; or am i getting it wrong?
</p></div></div><p>
It&#39;s the same meaning but worded differently.</p><p>Also, I didn&#39;t say that last quote <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>Take note of that GL_TEXTURE_2D that is the first parameter for all of those functions. It is because you can use 1D and 3D textures as well (but not at the same time AFAIK). If you want to use multiple textures on the same polygon (eg. a character who is bleeding or is covered in slime) then you&#39;ll need to use the Multi-texture extensions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Sun, 06 May 2007 13:43:34 +0000</pubDate>
	</item>
</rss>
