<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[Allegro 5.0.8] glGenBuffers not initialized? (Allegro noob)</title>
		<link>http://www.allegro.cc/forums/view/612666</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 27 May 2013 03:06:57 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey guys,</p><p>I&#39;ve done a few small projects with Allegro before, nothing too intense, so it&#39;s quite possible that I&#39;m missing a step or some info.</p><p><span class="source-code">glGenBuffers</span> is throwing a good ole &#39;memory access error&#39;. The debug shows it to not be properly initialized. Which correct me if I&#39;m wrong here but I&#39;m using the <span class="source-code">ALLEGRO_OPENGL_3_0</span> flag and this required 3.0 or &gt;. And 3 has VBOs.</p><p>So am I missing something to properly initialize the gl function calls. Something similar to <span class="source-code">glewInit</span> perhaps?</p><p><b>Includes</b>
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="p">#include &lt;allegro5/allegro_opengl.h&gt;</span>
</pre></div></div><p>
Which I believe is all I need to include for opengl support in allegro correct?</p><p><b>Display Creation</b> (`al_init` is before this point and returns successfully)
</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 <span class="k3">|</span> ALLEGRO_OPENGL_3_0<span class="k2">)</span><span class="k2">;</span>
display <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>display_data.width, display_data.height<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

<b>Call to Generate a Buffer</b>
</p><div class="source-code snippet"><div class="inner"><pre>GLuint vboNy<span class="k2">;</span>
glGenBuffers<span class="k2">(</span><span class="n">1</span>, <span class="k3">&amp;</span>vboNy<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

The run time error occurs at the <span class="source-code">glGenBuffers</span> call and using msvc&#39;s debugger shows that it isn&#39;t pointing to a valid location in memory where the function might exist.</p><p>What steps am I missing to make <span class="source-code">glGenBuffers</span> defined?</p><p><b>Side note</b> <span class="source-code">glGenBuffersARB</span> is also not valid currently.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dennmat)</author>
		<pubDate>Sun, 26 May 2013 22:48:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.opengl.org/sdk/docs/man/xhtml/glGenBuffers.xml">This page</a> says the second parameter is supposed to be a GLuint <i>pointer</i>, not a pointer to an GLuint, which is what you have.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 26 May 2013 23:19:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the prompt reply.</p><p>Reference linked to:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> glGenBuffers<span class="k2">(</span>GLsizei n,
   GLuint <span class="k3">*</span> buffers<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

They are one in the same(as far as a receiving function is concerned), <span class="source-code">GLuint x<span class="k2">;</span> <span class="k3">&amp;</span>x<span class="k2">;</span></span> is equivalent to <span class="source-code">GLuint <span class="k3">*</span> x <span class="k3">=</span> <span class="k1">new</span> GLuint<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></span> or <span class="source-code">GLuint x<span class="k2">[</span><span class="k2">]</span> <span class="k3">=</span> <span class="k2">{</span><span class="n">0</span><span class="k2">}</span><span class="k2">;</span> x<span class="k2">;</span></span> They are all pointers to a GLuint/of type GLuint pointer.</p><p>However I tried anyway(pointer definitions): 
</p><div class="source-code snippet"><div class="inner"><pre>GLuint <span class="k3">*</span> vboNy <span class="k3">=</span> <span class="k1">new</span> GLuint<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
glGenBuffers<span class="k2">(</span><span class="n">1</span>, vboNy<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Result in the same errors.<br />Through msvc&#39;s debug again shows that <span class="source-code">glGenBuffers</span> points to NULL.</p><div class="source-code snippet"><div class="inner"><pre><span class="k2">(</span>glGenBuffers <span class="k3">=</span><span class="k3">=</span> NULL<span class="k2">)</span>
<span class="c">//true</span>
std::cout <span class="k3">&lt;</span><span class="k3">&lt;</span> glGenBuffers<span class="k2">;</span>
<span class="c">//00000000</span>
</pre></div></div><p>

Thanks</p><p><b>edit</b> clarified a statement.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dennmat)</author>
		<pubDate>Mon, 27 May 2013 00:04:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Similar code works on my end. Does your graphics card support OpenGL 3? Are the drivers up to date?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Erin Maus)</author>
		<pubDate>Mon, 27 May 2013 00:12:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Running a GTX 670, drivers are updated and I have had OpenGL 4 commands work outside of Allegro previously, in particular <span class="source-code">MultiDrawArraysIndirect</span>.</p><p>I noticed <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_opengl_version"><span class="a">al_get_opengl_version</span></a></span> in the docs. (Which I believe returns an int meant to be read as hex)<br />And (what I believe to be odd) is this: 
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"VERSION %X"</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="k2">)</span><span class="k2">;</span>
<span class="c">//VERSION 0</span>
</pre></div></div><p>

However it can&#39;t be 0 because I&#39;ve been successful in using opengl until trying to move over from using VertexArrays stored cpu side to Buffers stored GPU side.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dennmat)</author>
		<pubDate>Mon, 27 May 2013 00:23:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try and call <span class="source-code"><a href="http://www.allegro.cc/manual/al_set_current_opengl_context"><span class="a">al_set_current_opengl_context</span></a><span class="k2">(</span>display<span class="k2">)</span></span> before generating the VBO.</p><p>How did you compile Allegro? Are you using the proper compiler runtime and, similarly, the proper libraries for the compiler runtime?</p><p>This example works for me:</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">#include &lt;allegro5/allegro.h&gt;</span>
<span class="number">  2</span><span class="p">#include &lt;allegro5/allegro_opengl.h&gt;</span>
<span class="number">  3</span><span class="p">#include &lt;stdio.h&gt;</span>
<span class="number">  4</span>
<span class="number">  5</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="number">  6</span><span class="k2">{</span>
<span class="number">  7</span>  <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>
<span class="number">  8</span>    <span class="k1">return</span> <span class="n">1</span><span class="k2">;</span>
<span class="number">  9</span>  
<span class="number"> 10</span>  <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 <span class="k3">|</span> ALLEGRO_OPENGL_3_0<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>  <a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a><span class="k3">*</span> display <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">640</span>, <span class="n">480</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 12</span>  
<span class="number"> 13</span>  GLuint vbo<span class="k2">;</span>
<span class="number"> 14</span>  glGenBuffers<span class="k2">(</span><span class="n">1</span>, <span class="k3">&amp;</span>vbo<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 15</span>  
<span class="number"> 16</span>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Version: %X\n"</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="k2">)</span><span class="k2">;</span>
<span class="number"> 17</span>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"glGenBuffers == %X"</span>, glGenBuffers<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 18</span>  
<span class="number"> 19</span>  glDeleteBuffers<span class="k2">(</span><span class="n">1</span>, <span class="k3">&amp;</span>vbo<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>  <a href="http://www.allegro.cc/manual/al_destroy_display"><span class="a">al_destroy_display</span></a><span class="k2">(</span>display<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 21</span>  
<span class="number"> 22</span>  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 23</span><span class="k2">}</span>
</div></div><p>

Result:</p><pre>Version: 3000000
glGenBuffers == 5EEB4790</pre><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Erin Maus)</author>
		<pubDate>Mon, 27 May 2013 00:38:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I downloaded the msvc 11 precompiled binaries from <a href="https://www.allegro.cc/files/">https://www.allegro.cc/files/</a> at the time it was 5.0.8 but I see now a new(stable) release is out.</p><p>Linking to the <span class="source-code">allegro-5.0.8-monolith-md-debug.lib</span> and have the equivalent .dll.</p><p>I&#39;ll download source(5.0.9) from the <a href="http://alleg.sourceforge.net/download.html">http://alleg.sourceforge.net/download.html</a> and build it and see if it remedies the situation and I&#39;ll update this post with the result.</p><p>Thanks</p><p><b>edit</b> Also I tried your suggestion no luck and your example for me produces the same result as I&#39;ve been having. I feel like you&#39;re onto something with the whole allegro setup thing, I thought I&#39;d get away with being lazy and use some precompiled binaries. However something tells me building it locally will probably fix this.</p><p><b>UPDATE</b><br />I built 5.0.9 from source using the msvc 11 compiler.<br />Didn&#39;t resolve the issue it&#39;s still there. <br />Maybe I should try 5.1.X although I doubt that&#39;s the issue anymore. </p><p>Tried getting glew to play nice with Allegro(dirty I know but running out of options) couldn&#39;t get it to go.</p><p>Not sure where to go from here and help/ideas are appreciated.<br />Thanks</p><p><b>UPDATE 2</b><br />It looks like it does, but just to be sure, Allegro does manage OpenGl extensions in Windows correct?</p><p><b>UPDATE</b><br />I overwrote MS&#39;s GL*.h files, with new ones of the equivalent version and this solved it. I&#39;m still not sure what happened(if they got corrupt or what) or how but at least it&#39;s a thing of the past now.</p><p>Thanks Guys
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (dennmat)</author>
		<pubDate>Mon, 27 May 2013 00:53:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The man page on <a href="https://www.allegro.cc/manual/5/opengl.html">opengl with allegro 5</a> gives you several ways to check for supported opengl extensions. Is glGenBuffers an extension? (I wouldn&#39;t know as I have little experience with OpenGL).</p><p>And I thought I heard once upon a time Allegro would give you the latest OpenGL just with the ALLEGRO_OPENGL flag, (ie... and not with ALLEGRO_OPENGL_3_0 needed).</p><p>Also, the manual says you have to create an OpenGL context (read - opengl allegro display) BEFORE calling <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_opengl_version"><span class="a">al_get_opengl_version</span></a></span>. I assume the rest of the opengl functions may behave similarly.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 27 May 2013 03:06:57 +0000</pubDate>
	</item>
</rss>
