Allegro 5 + OpenGL setup
KirbyDS11

Hi
My question is how would I get opengl to work with allegro? How would I set up the opengl libraries so that allegro could use them? ???
By the way I set up a program already to see if opengl functions would work but they did not.

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/allegro_opengl.h> 3#include <iostream> 4 5using namespace std; 6 7int main() 8{ 9 al_init(); 10 al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_WINDOWED); 11 ALLEGRO_DISPLAY *display = al_create_display(screenwidth,screenheight); 12 al_set_window_position(display,100,100); 13 al_set_window_title(display,"OpenGL test"); 14 cout << al_get_opengl_version() << endl; 15 return 0; 16}

67305216 is the output from al_get_opengl_version() so something is wrong here.
What could I do to fix this problem? :-/

Arthur Kalliokoski
KirbyDS11 said:

67305216 is the output from al_get_opengl_version() so something is wrong here.

Looking at it as a hex number, it's 0x402FF00, which breaks down to version 4.2.255, as explained in the documentation.

KirbyDS11

Okay so that explains that but when I use this code...

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/allegro_opengl.h> 3#include <iostream> 4 5using namespace std; 6 7int main() 8{ 9 al_init(); 10 al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_WINDOWED); 11 ALLEGRO_DISPLAY *display = al_create_display(screenwidth,screenheight); 12 al_set_window_position(display,100,100); 13 al_set_window_title(display,"OpenGL test"); 14 al_set_current_opengl_context(display); 15 glEnable(GL_DEPTH_TEST); 16 return 0; 17}

I get an undefined reference to glEnable. So how could I get this to work?

Arthur Kalliokoski

You didn't say what compiler you're using, just at a guess MSVC would want opengl32.lib (and possibly glu32.lib if you use any of those functions in the future) and Mingw would want -lopengl32 and -lglu32.

KirbyDS11

oh sorry
I'm using MinGW version 4.7.1 with Code::Blocks

Arthur Kalliokoski

I don't use Code::Blocks, but if it wants the literal names of the libraries, they'd be libopengl32.a and libglu32.a.

KirbyDS11

Okay I linked the libraries and it works
Thank you very much ;D

Thread #612976. Printed from Allegro.cc