![]() |
|
Depth bug (Allegro 5 + Opengl) |
Space cpp
Member #16,322
May 2016
|
Hello people. ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
You have to enable the depth buffer before it will work. https://liballeg.org/a5docs/trunk/display.html#al_set_new_display_option al_set_new_display_option(ALLEGRO_DEPTH_SIZE , 32 , ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_FLOAT_DEPTH , 1 , ALLEGRO_SUGGEST); The second is optional, but the first is necessary to enable the depth buffer. You must call these before creating your display. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
This actually worked.. in an older version that does use the fixed pipeline, which is not compatible with iOS. I guess I have to show some code 1if (!al_init() ) { printf("al_init Failed!\n"); return false; }
2 if (!al_install_mouse() ) { fprintf(stderr, "failed to initialize the mouse!\n"); return false; }
3 al_init_font_addon();
4 if (!al_init_ttf_addon() ) { fprintf(stderr, "failed to initialize the ttf addon!\n"); return false; }
5 if (!al_install_audio() ) { fprintf(stderr, "failed to initialize audio!\n"); return false; }
6 if (!al_init_acodec_addon() ) { fprintf(stderr, "failed to initialize audio codecs!\n"); return false; }
7 if (!al_reserve_samples(8) ) { fprintf(stderr, "failed to reserve samples!\n"); return false; }
8 if (!al_install_keyboard() ) { fprintf(stderr, "failed to initialize the keyboard!\n"); return false; }
9 timer = al_create_timer(1.0 / FPS); if (!timer) { fprintf(stderr, "failed to create timer!\n"); return false; }
10 if (!al_init_image_addon() ) { al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return false; }
11 if (!al_init_primitives_addon() ) { printf("al_init_primitives_addon Failed!\n"); return false; }
12 if (!al_install_touch_input() ) { printf("Could not init touch input.\n"); return false; }
13
14
15
16 if (!use_vsync)
17 al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE); // force off vsync to avoid high cpu usage
18
19 al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_OPENGL_ES_PROFILE | ALLEGRO_PROGRAMMABLE_PIPELINE);
20
21 al_set_new_display_option(ALLEGRO_DEPTH_SIZE, 32, ALLEGRO_SUGGEST);
22 al_set_new_display_option(ALLEGRO_FLOAT_DEPTH, 1, ALLEGRO_SUGGEST);
23
24
25 display = al_create_display(800, 600);
26 if (!display)
27 {
28 al_show_native_message_box(display, "Error", "", "al_create_display Failed!", NULL, ALLEGRO_MESSAGEBOX_ERROR);
29 return false;
30 }
At the beginning of the draw routine: 1glViewport(0, 0, al_get_display_width(display), al_get_display_height(display));
2
3 glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
4 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
5 glEnable(GL_DEPTH_TEST);
6 glEnable(GL_CULL_FACE);
For every object to be drawn I store the vertices on a std::vector then use glVertexAttribPointer, glEnableVertexAttribArray and glDrawArrays. ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Well, since you know how to set the new display options, you should know how to get them after they've been set to see what they are. https://liballeg.org/a5docs/trunk/display.html#al_get_display_option See what they return for ALLEGRO_DEPTH_SIZE and ALLEGRO_FLOAT_DEPTH. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
On iOS simulator it returns 0 and 0. Edit: ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Well, then that means the depth buffer is either not available, or didn't score well in allegro's display testing phase. Run a debug build and check allegro.log. There will be a 'depth' entry for every display configuration scored. See if there are even any available. You can also set ALLEGRO_DEPTH_SIZE to ALLEGRO_REQUIRE and test several values. If the driver comes back null, it's just not available. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
By debug build you mean I have to recompile the allegro static library with some different configuration? Now that I thought about it just saw the following on README_iphone.txt: "Can use either OpenGL ES 1 or 2 for graphics, by default OpenGL ES 1 is I`m guessing the problem is not the code but how the library file was compiled. Before I forget: using ALLEGRO_REQUIRE does not seen to be doing any difference, the display is still created, with depth size 0. ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Space cpp said: By debug build you mean I have to recompile the allegro static library with some different configuration? Generally, yes. But you can enable the allegro.log in release mode as well. (Don't ask me how I can never remember)... Space cpp said:
"Can use either OpenGL ES 1 or 2 for graphics, by default OpenGL ES 1 is The manual for al_set_new_display_flags says this : al_set_new_display_flags said:
ALLEGRO_OPENGL_ES_PROFILE
I'm guessing you enable GL ES 2 by requesting the major opengl version to be 2. I don't know for sure. Try this : The manual entry for al_set_new_display_option doesn't explain much about this part of things. Space cpp said: Before I forget: using ALLEGRO_REQUIRE does not seen to be doing any difference, the display is still created, with depth size 0. If you use ALLEGRO_REQUIRE and a non zero depth size, creating the display should fail if it can't find a display mode with the requested depth. Check your code, and if it's okay, then that's a bug in allegro. But first, enable the log and check the display scores. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
I'm stuck at the log part. ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Okay, first did you download binaries? Or build allegro yourself? If you're building allegro yourself, all you have to do is set the CMAKE_BUILD_TYPE to 'Debug' or 'RelWithDebInfo' and then rebuild. A quick google search reveals how SiegeLord enables the log : Allegro 5.1.11 released said: Call that line before you call al_init() and the log should be enabled if support was compiled in. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
Edgar Reynaldo said: Okay, first did you download binaries? Or build allegro yourself? Since I'm compilling for iOS now I used the included pre-built xcode project to build the static library. Edgar Reynaldo said: al_set_config_value(al_get_system_config(), "trace", "level", "debug"); To make sure I wasn't doing anything wrong I tested this on windows first and it worked. On iOS by other hand, the filesystem seems to be a bit different, I couldn't find the allegro.log file inside the app file / folder. Maybe, is there a way to dump the log contents on console instead? ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Yes. See al_register_trace_handler. void printme(const char* cstr) { fprintf(stdout , "%s\n" , cstr); } al_register_trace_handler(printme);
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Space cpp
Member #16,322
May 2016
|
Uh oh, it seems my build was compiled without support for it. So, I'm going to rebuild it and report here later. ---------- |
Space cpp
Member #16,322
May 2016
|
My apologies for taking long to respond. ---------- |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
The log is there somewhere. You just have to find it. There are different directories allegro uses on OSX. See al_get_standard_path for an idea of where to search. SiegeLord or anyone else - if you're listening, where do you guys store allegro.log on OSX? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|