First off I'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.
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'd also like to use the GLSL namely the vertex shader and fragment shaders. I've been using online tutorials and documentation such as: http://openglbook.com/ and http://www.swiftless.com/ But one uses GLUT (which I heard once, probably 3+ years ago that it shouldn't really be used anymore) and the other uses win32 + glew( http://glew.sourceforge.net/ ). I'd rather use allegro5 since I'm familiar with it and it's relatively easy to use.
So here are my questions:
1) Is there anything that I need to know about the combination or should everything just work like in the tutorials?
2) Are there functions in OpenGL that won't work with allegro? I have the following code:
cout<<"al opengl version: "<< al_get_opengl_version() << endl; int glVersion[] = { -1, -1}; glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]); glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]); cout<<"OpenGL Version: "<<glVersion[0]<<"."<<glVersion[1]<<endl;
the output looks as follows:
al opengl version: 0 OpenGL Version: -1.-1
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't got to the point of drawing anything yet.)
here is how I initialize the display (error free):
al_set_new_display_flags(ALLEGRO_OPENGL_3_0 | ALLEGRO_OPENGL_FORWARD_COMPATIBLE); disp = al_create_display(800, 600); if(!disp) { cout<<"There was an error creating the display."<<endl; return -1; }
3) Is there anything vertex/fragment shader specific that I need to know?
here is why I ask:
//vertexId is an unsigned int this->vertexId = glCreateShader(GL_VERTEX_SHADER);
Results in the following error:
Unhandled exception at 0x00000000 in program.exe: 0xC0000005: Access violation.
But this didn'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.
Any and all help is greatly appreciated.
-Adam.
Where things like the projection, view, and model matrices are handled by me.
There's nothing stopping you even in OpenGL 1.x.
void glLoadMatrixd(const GLdouble * m); void glLoadMatrixf(const GLfloat * m);
1) Is there anything that I need to know about the combination or should everything just work like in the tutorials?
OpenGL is OpenGL.
the output looks as follows:
al opengl version: 0
OpenGL Version: -1.-1
Have you created your display context before that code?
Is there anything that I need to know about the combination or should everything just work like in the tutorials?
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's own drawing functions will work right now as they use legacy OpenGL calls - but there's usually no reason to call any of them if you are using OpenGL yourself.
al_set_new_display_flags(ALLEGRO_OPENGL_3_0 | ALLEGRO_OPENGL_FORWARD_COMPATIBLE);
You forgot the ALLEGRO_OPENGL flag. Without it those other flags do nothing and you're actually using DirectX.
There's nothing stopping you even in OpenGL 1.x.
void glLoadMatrixd(const GLdouble * m); void glLoadMatrixf(const GLfloat * m);
That just goes to show how much I know about opengl!
You forgot the ALLEGRO_OPENGL flag. Without it those other flags do nothing and you're actually using DirectX.
That fixed it. Thanks.
-Adam.