Hey guys,
I've done a few small projects with Allegro before, nothing too intense, so it's quite possible that I'm missing a step or some info.
glGenBuffers is throwing a good ole 'memory access error'. The debug shows it to not be properly initialized. Which correct me if I'm wrong here but I'm using the ALLEGRO_OPENGL_3_0 flag and this required 3.0 or >. And 3 has VBOs.
So am I missing something to properly initialize the gl function calls. Something similar to glewInit perhaps?
Includes
#include <allegro5/allegro.h> #include <allegro5/allegro_opengl.h>
Which I believe is all I need to include for opengl support in allegro correct?
Display Creation (`al_init` is before this point and returns successfully)
al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_OPENGL_3_0); display = al_create_display(display_data.width, display_data.height);
Call to Generate a Buffer
GLuint vboNy; glGenBuffers(1, &vboNy);
The run time error occurs at the glGenBuffers call and using msvc's debugger shows that it isn't pointing to a valid location in memory where the function might exist.
What steps am I missing to make glGenBuffers defined?
Side note glGenBuffersARB is also not valid currently.
This page says the second parameter is supposed to be a GLuint pointer, not a pointer to an GLuint, which is what you have.
Thanks for the prompt reply.
Reference linked to:
void glGenBuffers(GLsizei n, GLuint * buffers);
They are one in the same(as far as a receiving function is concerned), GLuint x; &x; is equivalent to GLuint * x = new GLuint(); or GLuint x[] = {0}; x; They are all pointers to a GLuint/of type GLuint pointer.
However I tried anyway(pointer definitions):
GLuint * vboNy = new GLuint(); glGenBuffers(1, vboNy);
Result in the same errors.
Through msvc's debug again shows that glGenBuffers points to NULL.
(glGenBuffers == NULL) //true std::cout << glGenBuffers; //00000000
Thanks
edit clarified a statement.
Similar code works on my end. Does your graphics card support OpenGL 3? Are the drivers up to date?
Running a GTX 670, drivers are updated and I have had OpenGL 4 commands work outside of Allegro previously, in particular MultiDrawArraysIndirect.
I noticed al_get_opengl_version in the docs. (Which I believe returns an int meant to be read as hex)
And (what I believe to be odd) is this:
printf("VERSION %X", al_get_opengl_version()); //VERSION 0
However it can't be 0 because I've been successful in using opengl until trying to move over from using VertexArrays stored cpu side to Buffers stored GPU side.
Try and call al_set_current_opengl_context(display) before generating the VBO.
How did you compile Allegro? Are you using the proper compiler runtime and, similarly, the proper libraries for the compiler runtime?
This example works for me:
Result:
Version: 3000000 glGenBuffers == 5EEB4790
I downloaded the msvc 11 precompiled binaries from https://www.allegro.cc/files/ at the time it was 5.0.8 but I see now a new(stable) release is out.
Linking to the allegro-5.0.8-monolith-md-debug.lib and have the equivalent .dll.
I'll download source(5.0.9) from the http://alleg.sourceforge.net/download.html and build it and see if it remedies the situation and I'll update this post with the result.
Thanks
edit Also I tried your suggestion no luck and your example for me produces the same result as I've been having. I feel like you're onto something with the whole allegro setup thing, I thought I'd get away with being lazy and use some precompiled binaries. However something tells me building it locally will probably fix this.
UPDATE
I built 5.0.9 from source using the msvc 11 compiler.
Didn't resolve the issue it's still there.
Maybe I should try 5.1.X although I doubt that's the issue anymore.
Tried getting glew to play nice with Allegro(dirty I know but running out of options) couldn't get it to go.
Not sure where to go from here and help/ideas are appreciated.
Thanks
UPDATE 2
It looks like it does, but just to be sure, Allegro does manage OpenGl extensions in Windows correct?
UPDATE
I overwrote MS's GL*.h files, with new ones of the equivalent version and this solved it. I'm still not sure what happened(if they got corrupt or what) or how but at least it's a thing of the past now.
Thanks Guys
The man page on opengl with allegro 5 gives you several ways to check for supported opengl extensions. Is glGenBuffers an extension? (I wouldn't know as I have little experience with OpenGL).
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).
Also, the manual says you have to create an OpenGL context (read - opengl allegro display) BEFORE calling al_get_opengl_version. I assume the rest of the opengl functions may behave similarly.