ALLEGRO_DIRECT3D not defined in this scope
Arthur Kalliokoski

I tried using
as per this page in the manual, with the MinGW 4.6.2 download, and it says it can't find ALLEGRO_DIRECT3D. I tried ALLEGRO_DIRECT3D_INTERNAL, and it seems to work, although Linux accepts it and creates a display regardless. Perhaps an oversight?

Aaron Bolyard

I'm pretty sure you need to add this include:

#include <allegro5/allegro_direct3d.h>

Arthur Kalliokoski

I just tried that (in Linux) and it complains now about

/usr/local/include/allegro5/allegro_direct3d.h:20:18: fatal error: d3d9.h: No such file or directory

. I'm trying to differentiate between which graphic library is in effect without too many #ifdefs.


It used to be so that you had to include "allegro_direct3d.h" for the ALLEGRO_DIRECT3D and "allegro_opengl.h" for ALLEGRO_OPENGL. Then, for some reason, ALLEGRO_OPENGL was moved into the main allegro include, which left ALLEGRO_DIRECT3D inexplicably in its own header.

EDIT: Incidentally, the reason why those were originally hidden away was to make it a tiny bit harder to write non-portable code. The thinking was that if you used the code in non-platform specific headers you'd automatically get portable code. Now with ALLEGRO_OPENGL being in the non-platform specific header, this is sort of moot...

Arthur Kalliokoski

OTOH, I looked at <allegro5/allegro_direct3d.h> on the Mingw includes and it says

/* Display creation flag. */

which would seem to indicate that Linux should fail to create a display when ALLEGRO_DIRECT3D_INTERNAL was passed to al_set_new_display_flags(). Just a small error, though.
On second thought, that's why it's labeled "INTERNAL". :-/


ALLEGRO_DIRECT3D_INTERNAL is internal though. It's not documented, and you're not supposed to use it.

Thomas Fjellstrom

Not to mention that D3D is the default, and you shouldn't need to explicitly specify it.

Arthur Kalliokoski

Well, now I have this (no idea what would happen on OSX or Android)

  active_gl = al_get_display_flags(display) & ALLEGRO_OPENGL;
  if(active_gl & ALLEGRO_OPENGL)
    zz_draw_focus = &zz_draw_ogl_focus;
  else  //fall through to direct3d
    zz_draw_focus = &zz_draw_d3d_focus;

I'll probably replace it with some private defines instead of putting the code directly in there.

Thomas Fjellstrom

Everything but Windows is GL. That is a decent way of doing it.


ALLEGRO_OPENGL always was public. And using Allegro to write a (platform-independent) OpenGL game is one of the use cases, it makes a lot of sense to do, including under Windows.

Elias said:

ALLEGRO_OPENGL always was public.

No, it wasn't:

git diff -r 17ccbaa{^,} -- include/allegro5/display_new.h
diff --git a/include/allegro5/display_new.h b/include/allegro5/display_new.h
index ee111c9..8302dc9 100644
--- a/include/allegro5/display_new.h
+++ b/include/allegro5/display_new.h
@@ -12,21 +12,20 @@
 /* Possible bit combinations for the flags parameter of al_create_display. */
-#define ALLEGRO_WINDOWED     1
-// moved to allegro_opengl.h
-//#define ALLEGRO_OPENGL       4
-// moved to allegro_direct3d.h
-//#define ALLEGRO_DIRECT3D     8
-#define ALLEGRO_RESIZABLE    16
-#define ALLEGRO_NOFRAME      64
-//is something using 256? didn't seem to work...
+enum {
+   ALLEGRO_WINDOWED                    = 1 << 0,
+   ALLEGRO_FULLSCREEN                  = 1 << 1,
+   ALLEGRO_OPENGL                      = 1 << 2,
+   ALLEGRO_DIRECT3D_INTERNAL           = 1 << 3,
+   ALLEGRO_RESIZABLE                   = 1 << 4,
+   ALLEGRO_NOFRAME                     = 1 << 5,
+   ALLEGRO_OPENGL_3_0                  = 1 << 7,
+   ALLEGRO_FULLSCREEN_WINDOW           = 1 << 9,
 /* This is set to mark a display used only internally. */
-#define ALLEGRO_INTERNAL 1024
+   ALLEGRO_INTERNAL                    = 1 << 10
 /* Possible parameters for al_set_display_option.
  * Make sure to update ALLEGRO_EXTRA_DISPLAY_SETTINGS if you modify

git show 17ccbaa
commit 17ccbaa2b3e7c4230971495c5e10e531c1bc4679
Author: Elias Pschernig <>
Date:   Sun Apr 4 20:58:11 2010 +0000

    Fixed display flags which were in various #defines across several headers.

git diff -r 2f8d56{^,} -- include/allegro5/display_new.h
diff --git a/include/allegro5/display_new.h b/include/allegro5/display_new.h
index 55550cc..7617c6a 100644
--- a/include/allegro5/display_new.h
+++ b/include/allegro5/display_new.h
@@ -15,7 +15,8 @@
 #define ALLEGRO_WINDOWED     1
-#define ALLEGRO_OPENGL       4
+// moved to a5_opengl.h
+//#define ALLEGRO_OPENGL       4
 #define ALLEGRO_DIRECT3D     8
 #define ALLEGRO_RESIZABLE    16

git show 2f8d56
commit 2f8d565525fef076a31494dd71ef0b4b0884709c
Author: Milan Mimica <>
Date:   Sun Oct 12 11:23:08 2008 +0000

    To prevent namespce pollution, and accidental usage of OpenGL-specific
    functions, programs using OpenGL must include allegro5/a5_opengl.h from
    now on.


And using Allegro to write a (platform-independent) OpenGL game is one of the use cases, it makes a lot of sense to do, including under Windows.

Pretty sure Allegro can be compiled without OpenGL support on Windows.

Sebastian Steinhauer

Having ALLEGRO_OPENGL in the "default" headers while ALLEGRO_DIRECT3D needs to have allegro_direct3d.h included is a bit irritating. To have no problems with that I wrote some lines to work around this problem.

1#ifdef ALLEGRO_WINDOWS 2#include <allegro5/allegro_direct3d.h> 3#else 4#define ALLEGRO_DIRECT3D 0 /* dummy define for non Win systems */ 5#endif /* ALLEGRO_WINDOWS */

This helps me having D3D on Unix systems, too. (In my project the user can choose the renderer if he wants to).8-)

Peter Wang

Please don't do that. At worst, alias ALLEGRO_DIRECT3D to ALLEGRO_DIRECT3D_INTERNAL.

Thomas Fjellstrom

Or don't include the D3D stuff on systems that don't have D3D... Doesn't really make sense to provide the user an option to select between D3D and OpenGL on linux for example.

Thread #611563. Printed from