|
Allegro 5 + OpenGL 3.x + GLSL |
adamk kromm
Member #5,432
January 2005
|
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: 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.) 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? //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. ---------- |
gnolam
Member #2,030
March 2002
|
adamk kromm said: 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);
Quote: 1) Is there anything that I need to know about the combination or should everything just work like in the tutorials? OpenGL is OpenGL. Quote: the output looks as follows: Have you created your display context before that code? -- |
Elias
Member #358
May 2000
|
adamk kromm said: 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. Quote: 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. -- |
adamk kromm
Member #5,432
January 2005
|
gnolam said: 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! Elias said: You forgot the ALLEGRO_OPENGL flag. Without it those other flags do nothing and you're actually using DirectX. That fixed it. Thanks. -Adam. ---------- |
|