Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro 5 + OpenGL setup

This thread is locked; no one can reply to it. rss feed Print
Allegro 5 + OpenGL setup
KirbyDS11
Member #15,167
June 2013
avatar

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? :-/

Woops

Arthur Kalliokoski
Second in Command
February 2005
avatar

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.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

KirbyDS11
Member #15,167
June 2013
avatar

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?

Woops

Arthur Kalliokoski
Second in Command
February 2005
avatar

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.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

KirbyDS11
Member #15,167
June 2013
avatar

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

Woops

Arthur Kalliokoski
Second in Command
February 2005
avatar

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

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

KirbyDS11
Member #15,167
June 2013
avatar

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

Woops

Go to: