fxengine/render/zbuffer.c

42 lines
1.1 KiB
C

#include "zbuffer.h"
#include "parameters.h"
#include <stdbool.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
#include <gint/defs/attributes.h>
static const int size_uint32 = render_width * render_height;
static const int size_char = size_uint32 * sizeof(uint32_t);
// zbuffer et clear val sont 32B alignés pour ajouter éventuellement le DMA
static int32_t *zbuffer = (void *)0x88080000 - ((size_char / 32) * 32 + 1);
GALIGNED(32) GSECTION(".rodata") static const int32_t clearval[8]={render_max_dist,render_max_dist,render_max_dist,render_max_dist,render_max_dist,render_max_dist,render_max_dist,render_max_dist};
void render_zbuffer_clear()
{
uint32_t indice = 0;
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = render_max_dist;
}
bool render_zbuffer_set_px(uint32_t x, uint32_t y, uint32_t dist)
{
const int indice = x * render_height + y;
if (zbuffer[indice]>dist && dist>=render_min_dist && dist<=render_max_dist)
{
zbuffer[indice] = dist;
return true;
}
return false;
}