@Piccolo,
I just went through the source code to get layering formulas. Hopefully didn't miss anything. First, I was mistaken above. The Background (and bglayers) are hardcoded to the minimum possible integer value (so
@O Ilusionista is correct, you can't go behind the background). Technically, you can match the background, but it will still always appear behind due to the drawing routine (see below). Also, fglayers default in front of the frontpanel, not behind it.
These are the constants used to apply adjustment. PLAYER_MIN_Z and PLAYER_MAX_Z are the walkable Z areas creators can set per level.
C:
int PLAYER_MIN_Z = 160;
int PLAYER_MAX_Z = 232;
#define MIN_INT (int)0x80000000
#define MAX_INT (int)0x7fffffff
#define FRONTPANEL_Z (PLAYER_MAX_Z+50)
#define HUD_Z (FRONTPANEL_Z+10000)
#define HOLE_Z (PLAYER_MIN_Z-46)
#define SHADOW_Z (PLAYER_MIN_Z-47)
#define NEONPANEL_Z (PLAYER_MIN_Z-48)
#define SCREENPANEL_Z (PLAYER_MIN_Z-49)
#define PANEL_Z (PLAYER_MIN_Z-50)
#define MIRROR_Z (PLAYER_MIN_Z-5)
Z layering adjustments (in default order back to front):
| Background | MIN_INT |
| bglayer | MIN_INT |
| Water | MIN_INT+1 |
| Panel | PANEL_Z |
| Screen (Alpha Panel) | SCREENPANEL_Z |
| Neon | NEONPANEL_Z |
| Mirror | MIRROR_Z |
| Shadows | SHADOW_Z |
| Holes | HOLE_Z |
| Object Layer | PLAYER_MIN_Z to PLAYER_MAX_Z |
| Frontpanel | FRONTPANEL_Z |
| fglayer | {z argument} + FRONTPANEL_Z |
| HUD | HUD_Z |
As you can see, the Background and bglayers all occupy the same Z layer by design, and unless you adjust them, all fglayers are on the same Z layer as well. As with most drawing routines, OpenBOR's caches objects in order of existence, so the last one always "wins". There's a lot of stuff going on and it's really old code, but far as I can tell at glance, background and panels read first, then everything else in order of definition.
All objects are part of the same layering. Entity Z layer is based on their current Z axis position. Entities also have a manual Z adjustment (default 0), and a couple of other internal adjustments (ex. binding layer). These all combined control where entities fall in the above table. If two entities somehow occupy the exact same Z position, the last one wins as usual. However, since the entity cache is constantly rotating, the last one drawn differ one update to another, causing flicker.
HTH,
DC