Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Setting up Modern OpenGL with allegro 5

This thread is locked; no one can reply to it. rss feed Print
Setting up Modern OpenGL with allegro 5
Ariesnl
Member #2,902
November 2002
avatar

hello,
I'm trying to follow this tutorial https://learnopengl.com/Getting-started/Hello-Triangle

With allegro 5 as a framework. I did include #include <allegro5/allegro_opengl.h>
but still a lot of openGL stuff is not found

||=== Build: Release in OpenGL_Demo (compiler: GNU GCC Compiler) ===|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp||In constructor 'CustomProgram::CustomProgram(int, int, bool)':|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp|50|error: 'glGenBuffers' was not declared in this scope|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp|51|error: 'GL_ARRAY_BUFFER' was not declared in this scope|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp|51|error: 'glBindBuffer' was not declared in this scope|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp|52|error: 'GL_STATIC_DRAW' was not declared in this scope|
D:\Development\Code\OpenGL_Alleg\CustomProgram.cpp|52|error: 'glBufferData' was not declared in this scope|
D:\Development\Code\OpenGL_Alleg\A5Program.cpp||In constructor 'A5Program::A5Program(int, int, bool, bool)':|
D:\Development\Code\OpenGL_Alleg\A5Program.cpp|96|warning: unused variable 'm_nWidth' [-Wunused-variable]|
D:\Development\Code\OpenGL_Alleg\A5Program.cpp|97|warning: unused variable 'm_nHeight' [-Wunused-variable]|
||=== Build finished: 5 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|

Any tips on how to set it up correctly >
I attached my project so you can see what I'm trying to do

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Ariesnl
Member #2,902
November 2002
avatar

I tought Allegro would already take care of that, since it uses OpenGL itself...

Annyway what would be the easiest way to do it ?
I tried to compile with glew once bu I gave up after getting a lot of undefined references ::)

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Undefined references are caused by not linking to the correct libraries. If you want to be a good programmer, you're going to have to learn how to link properly. Link or swim.

Extensions are not defined because they're extensions. Read the manual link I posted that tells you exactly how to define an extension pointer and call it.

https://www.opengl.org/discussion_boards/showthread.php/172481-glGenBuffer-was-not-declared

Your project wasn't linking opengl so even if it compiled, it would still give undefined references. -lglu32 -lopengl32

Elias
Member #358
May 2000

Allegro already loads all the extensions (i.e. it does the same thing GLEW does already). If some newer extension is missing from Allegro we should add it. It also might make sense to replace Allegro's extension code with GLEW (as a new dependency for Allegro) since they are probably doing a better job. (If we can do so without breaking old Allegro code at least.)

--
"Either help out or stop whining" - Evert

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I discovered something with gdb today. If you do 'info variables', it will print out EVERY variable in existence. That means every single global defined in any file anywhere.

If you do 'info variables glGenBuffer' inside gdb while running an allegro program, you get this back :

(gdb) info variables glGenBuffer
All variables matching regular expression "glGenBuffer":

File E:/LIBS/LIBS81Build/allegro5/include/allegro5/opengl/GLext/gl_ext_api.h:
_ALLEGRO_glGenBuffers_t _al_glGenBuffers;
_ALLEGRO_glGenBuffersARB_t _al_glGenBuffersARB;
(gdb)

So allegro 5 knows about glGenBuffer, it's just hiding it from you.

The Manual said:

al_get_opengl_proc_address
void *al_get_opengl_proc_address(const char *name)
Source Code

Helper to get the address of an OpenGL symbol

Example:

How to get the function glMultiTexCoord3fARB that comes with ARB's Multitexture extension:

// define the type of the function
ALLEGRO_DEFINE_PROC_TYPE(void, MULTI_TEX_FUNC,
(GLenum, GLfloat, GLfloat, GLfloat));
// declare the function pointer
MULTI_TEX_FUNC glMultiTexCoord3fARB;
// get the address of the function
glMultiTexCoord3fARB = (MULTI_TEX_FUNC) al_get_opengl_proc_address(
"glMultiTexCoord3fARB");
If glMultiTexCoord3fARB is not NULL then it can be used as if it has been defined in the OpenGL core library.

Note: Under Windows, OpenGL functions may need a special calling convention, so it's best to always use the ALLEGRO_DEFINE_PROC_TYPE macro when declaring function pointer types for OpenGL functions.

Parameters:

name - The name of the symbol you want to link to.

Return value:

A pointer to the symbol if available or NULL otherwise.

Go to: