allegroflare / allegro_flare

Application toolkit for Allegro 5
https://clubcatt.com/allegroflare
MIT License
35 stars 6 forks source link

Camera3D projection setup not working on Windows #277

Closed MarkOates closed 2 months ago

MarkOates commented 5 months ago

In some cases, projection is not changing the context as expected. The exact case has not been isolated, but in Camera3D::setup_projection_on, commenting out these two lines:

   al_set_render_state(ALLEGRO_DEPTH_TEST, 1);
   al_set_render_state(ALLEGRO_WRITE_MASK, ALLEGRO_MASK_DEPTH | ALLEGRO_MASK_RGBA);

...has shown to restore the rendering (without testing for any side-effects).

Some other ideas

Not there is a similar setup_dimensional_projection that is used in Camera2D and seems to work fine.

There has not yet been an isolated minimal test made. It also could be related to the framework, backgrounds.

MarkOates commented 2 months ago

More detailed doc here: https://docs.google.com/document/d/1V-q_qlUhvK6aAT9Y78ZOZsWUCzlB9mdENM4GxU47DsE/edit

Solution was identified:

SOLUTION: The problem appears to have been related to Frameworks/Full, when the primary_render_surface is rendered to the display backbuffer. At that point, the depth buffer content is unknown, but ALLEGRO_DEPTH_TEST at 0 still allows it to render, while ALLEGRO_DEPTH_TEST at 1 would check for depth, causing it not to render. The problem was fixed by having ALLEGRO_DEPTH_TEST set to 0 in Frameworks/Full before drawing the primary_render_surface to the backbuffer. This appears to have fixed the problem on Windows and the behavior now appears to be aligned.