<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5 + OpenGL 3.x + GLSL</title>
		<link>http://www.allegro.cc/forums/view/607724</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 01 Jul 2011 06:04:07 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>First off I&#39;d just like to say the allegro community is pretty awesome.  It seems what ever my current endeavours are, allegro.cc seems to be the place I go to to get good advice.  Whether it be allegro, or opengl, or windows or linux specific I almost always find the answer here. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>So here goes.  I want to Learn OpenGL (like so many other people). But I want to learn 4.0 (or at least 3.3)  Where things like the projection, view, and model matrices are handled by me.  I&#39;d also like to use the GLSL namely the vertex shader and fragment shaders.  I&#39;ve been using online tutorials and documentation such as: <a href="http://openglbook.com/">http://openglbook.com/</a>  and  <a href="http://www.swiftless.com/">http://www.swiftless.com/</a>  But one uses GLUT (which I heard once, probably 3+ years ago that it shouldn&#39;t really be used anymore)  and the other uses win32 + glew( <a href="http://glew.sourceforge.net/">http://glew.sourceforge.net/</a> ).  I&#39;d rather use allegro5 since I&#39;m familiar with it and it&#39;s relatively easy to use.  </p><p>So here are my questions:<br />1) Is there anything that I need to know about the combination or should everything just work like in the tutorials?</p><p>2) Are there functions in OpenGL that won&#39;t work with allegro?  I have the following code:
</p><div class="source-code snippet"><div class="inner"><pre>cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"al opengl version: "</span><span class="k3">&lt;</span><span class="k3">&lt;</span> <a href="http://www.allegro.cc/manual/al_get_opengl_version"><span class="a">al_get_opengl_version</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> endl<span class="k2">;</span>

<span class="k1">int</span> glVersion<span class="k2">[</span><span class="k2">]</span> <span class="k3">=</span> <span class="k2">{</span> <span class="k3">-</span><span class="n">1</span>, <span class="k3">-</span><span class="n">1</span><span class="k2">}</span><span class="k2">;</span>
glGetIntegerv<span class="k2">(</span>GL_MAJOR_VERSION, <span class="k3">&amp;</span>glVersion<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
glGetIntegerv<span class="k2">(</span>GL_MINOR_VERSION, <span class="k3">&amp;</span>glVersion<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"OpenGL Version: "</span><span class="k3">&lt;</span><span class="k3">&lt;</span>glVersion<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"."</span><span class="k3">&lt;</span><span class="k3">&lt;</span>glVersion<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
</pre></div></div><p>

the output looks as follows:
</p><div class="source-code snippet"><div class="inner"><pre>al opengl version: <span class="n">0</span>
OpenGL Version: <span class="k3">-</span><span class="n">1</span>.<span class="k3">-</span><span class="n">1</span>
</pre></div></div><p>

The part that has me puzzled is that the display is being created, and the program runs and is able to display a blank screen (haven&#39;t got to the point of drawing anything yet.)<br />here is how I initialize the display (error free):
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_set_new_display_flags"><span class="a">al_set_new_display_flags</span></a><span class="k2">(</span>ALLEGRO_OPENGL_3_0 <span class="k3">|</span> ALLEGRO_OPENGL_FORWARD_COMPATIBLE<span class="k2">)</span><span class="k2">;</span>

disp <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_display"><span class="a">al_create_display</span></a><span class="k2">(</span><span class="n">800</span>, <span class="n">600</span><span class="k2">)</span><span class="k2">;</span>
<span class="k1">if</span><span class="k2">(</span><span class="k3">!</span>disp<span class="k2">)</span> <span class="k2">{</span>
  cout<span class="k3">&lt;</span><span class="k3">&lt;</span><span class="s">"There was an error creating the display."</span><span class="k3">&lt;</span><span class="k3">&lt;</span>endl<span class="k2">;</span>
  <span class="k1">return</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

3) Is there anything vertex/fragment shader specific that I need to know?<br />here is why I ask:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//vertexId is an unsigned int</span>
this-&gt;vertexId <span class="k3">=</span> glCreateShader<span class="k2">(</span>GL_VERTEX_SHADER<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Results in the following error:
</p><div class="source-code snippet"><div class="inner"><pre>Unhandled exception at <span class="n">0x00000000</span> in program.exe: <span class="n">0xC0000005</span><span class="k2">:</span> Access violation.
</pre></div></div><p>
But this didn&#39;t happen before when I was using Win32 + glew.  It looks like something somewhere is trying to access an uninitialized pointer, AFAIK there are no pointers being used on that line.</p><p>Any and all help is greatly appreciated.<br />-Adam.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Thu, 30 Jun 2011 12:56:22 +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/607724/923165#target">adamk kromm</a> said:</div><div class="quote"><p>Where things like the projection, view, and model matrices are handled by me.</p></div></div><p>
There&#39;s nothing stopping you even in OpenGL 1.x.
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> glLoadMatrixd<span class="k2">(</span><span class="k1">const</span> GLdouble <span class="k3">*</span>  m<span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> glLoadMatrixf<span class="k2">(</span><span class="k1">const</span> GLfloat <span class="k3">*</span>  m<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>1) Is there anything that I need to know about the combination or should everything just work like in the tutorials?</p></div></div><p>
OpenGL is OpenGL.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>the output looks as follows:<br />al opengl version: 0<br />OpenGL Version: -1.-1</p></div></div><p>
Have you created your display context before that code?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 30 Jun 2011 15:45:15 +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/607724/923165#target">adamk kromm</a> said:</div><div class="quote"><p>
Is there anything that I need to know about the combination or should everything just work like in the tutorials?
</p></div></div><p>

Should just work, just remember to call al_flip_display() to make things visible. (You could also call the corresponding WGL command instead but that will only work under Windows.) Also, none of Allegro&#39;s own drawing functions will work right now as they use legacy OpenGL calls - but there&#39;s usually no reason to call any of them if you are using OpenGL yourself.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
al_set_new_display_flags(ALLEGRO_OPENGL_3_0 | ALLEGRO_OPENGL_FORWARD_COMPATIBLE);
</p></div></div><p>

You forgot the ALLEGRO_OPENGL flag. Without it those other flags do nothing and you&#39;re actually using DirectX.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Thu, 30 Jun 2011 16:06:31 +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/607724/923172#target">gnolam</a> said:</div><div class="quote"><p>
There&#39;s nothing stopping you even in OpenGL 1.x.
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> glLoadMatrixd<span class="k2">(</span><span class="k1">const</span> GLdouble <span class="k3">*</span>  m<span class="k2">)</span><span class="k2">;</span>
<span class="k1">void</span> glLoadMatrixf<span class="k2">(</span><span class="k1">const</span> GLfloat <span class="k3">*</span>  m<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
</p></div></div><p>
That just goes to show how much I know about opengl!</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/607724/923174#target">Elias</a> said:</div><div class="quote"><p>
You forgot the ALLEGRO_OPENGL flag. Without it those other flags do nothing and you&#39;re actually using DirectX.
</p></div></div><p>

That fixed it. Thanks.</p><p>-Adam.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (adamk kromm)</author>
		<pubDate>Fri, 01 Jul 2011 06:04:07 +0000</pubDate>
	</item>
</rss>
