diff --git a/.gitignore b/.gitignore index f7576aa..48a2ab8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ *.c.o *.c.d + +Doxyfile + +*.tar.xz diff --git a/Makefile b/Makefile index 02e3cbb..ea2437e 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ arflags := target := libfxengine.a # Automatic names for object and dependency files -src2obj = $(1:../src/%=src/%).o -src2dep = $(1:../src/%=src/%).d +src2obj = $(1:src/%=build/%).o +src2dep = $(1:src/%=build/%).d # Source files src := $(shell find src \ @@ -64,15 +64,15 @@ $(target): $(obj) $(call cmd_l,ar,$@) $(ar) rcs $(arflags) $@ $^ # Assembler sources -src/%.s.o: src/%.s src/%.s.d +build/%.s.o: src/%.s build/%.s.d @ mkdir -p $(dir $@) $(call cmd_b,as,$*.s) $(gcc) -c $< -o $@ $(sflags) -src/%.S.o: src/%.S src/%.S.d +build/%.S.o: src/%.S build/%.S.d @ mkdir -p $(dir $@) $(call cmd_b,as,$*.S) $(gcc) -c $< -o $@ $(sflags) # C sources -src/%.c.o: src/%.c src/%.c.d +build/%.c.o: src/%.c build/%.c.d @ mkdir -p $(dir $@) $(call cmd_b,gcc,$*.c) $(gcc) -c $< -o $@ $(dflags) $(cflags) @@ -124,8 +124,8 @@ uninstall: # Dependency information -include $(shell [ -d src ] && find src -name *.d) -src/%.d: ; -.PRECIOUS: src/%.d +build/%.d: ; +.PRECIOUS: build/%.d .PHONY: all clean distclean diff --git a/include/fxengine/render/triangle.h b/include/fxengine/render/triangle.h index dc97bf7..42ae493 100644 --- a/include/fxengine/render/triangle.h +++ b/include/fxengine/render/triangle.h @@ -5,11 +5,6 @@ #include #include -/** - * @brief Regulates the maximum fps count to 30 fps - */ -#define MINIMUM_FRAME_DELAY 3333 - /** * @brief Triangle struct used to render fonctions * @param[out] part choose the used texture half diff --git a/include/fxengine/render/zbuffer.h b/include/fxengine/render/zbuffer.h index 47371f9..34beee6 100644 --- a/include/fxengine/render/zbuffer.h +++ b/include/fxengine/render/zbuffer.h @@ -16,6 +16,6 @@ void render_zbuffer_clear(); * retourne true si il faut dessiner le pixel * retourne false si le pixel est déjà existant **/ -bool render_zbuffer_set_px(uint32_t x, uint32_t y, uint32_t dist); // if you are allowed to draw the pixel on vram +bool render_zbuffer_set_px(const uint32_t x, const uint32_t y, const uint32_t dist); // if you are allowed to draw the pixel on vram #endif diff --git a/libfxengine.a b/libfxengine.a index 850b3a5..9cdf5ce 100644 Binary files a/libfxengine.a and b/libfxengine.a differ diff --git a/src/render/triangle.c b/src/render/triangle.c index 85f4f34..94bd5d7 100644 --- a/src/render/triangle.c +++ b/src/render/triangle.c @@ -192,24 +192,23 @@ void render_display_triangle(const render_triangle * face) for (int32_t x=txmin; x<=txmax; x++) { - double vx, vy, z; - const double xcalc = x - face->s1->x, ycalc = y - face->s1->y; - // calcul de vx, vy - vx=(xcalc*fact_1-ycalc*fact_2); // 0 s1->z + (vx * zAB + vy * zAC) / 32768.0; - vx /= 32768.0; - vy /= 32768.0; + int32_t vx, vy, z; - double vx2= ( vx/face->s2->z ) / ((1-vx)/face->s1->z + vx/face->s2->z); - double vy2= ( vy/face->s3->z ) / ((1-vy)/face->s1->z + vy/face->s3->z); + const int32_t xcalc = x - face->s1->x, ycalc = y - face->s1->y; + // calcul de vx, vy + vx = (xcalc*fact_1 - ycalc*fact_2); + vy = (ycalc*fact_3 - xcalc*fact_4); + z = face->s1->z + (vx * zAB + vy * zAC)/32768; + + + int32_t vx2= ( vx*face->texture->size_px_x/face->s2->z ) / ((32768-vx)/face->s1->z + vx/face->s2->z); + int32_t vy2= ( vy*face->texture->size_px_y/face->s3->z ) / ((32768-vy)/face->s1->z + vy/face->s3->z); /* Perspective correction vx /= (double) face->s2->z / ((1 - vx) / face->s1->z + vx / (double) face->s2->z); vy /= (double) face->s3->z / ((1 - vy) / face->s1->z + vy / (double) face->s3->z); */ // Affichage du point - const uint8_t color = bitmap_get_pixel_r(face->texture, face->texture->size_px_x * vx2, - face->texture->size_px_y * vy2); + const uint8_t color = bitmap_get_pixel_r(face->texture, vx2, vy2); if (color >> 1) { diff --git a/src/render/zbuffer.c b/src/render/zbuffer.c index e186483..c4b3e76 100644 --- a/src/render/zbuffer.c +++ b/src/render/zbuffer.c @@ -36,7 +36,7 @@ void render_zbuffer_clear() } -bool render_zbuffer_set_px(uint32_t x, uint32_t y, uint32_t dist) +bool render_zbuffer_set_px(const uint32_t x, const uint32_t y, const uint32_t dist) { const int indice = x * render_height + y;