From e4fe5d696f18aab340619bde9e093b88c9ada0b0 Mon Sep 17 00:00:00 2001 From: milang Date: Sun, 1 Sep 2019 13:23:26 +0200 Subject: [PATCH] change object files' folder, ignore Doxygen configuration, and add key word on some functions --- .gitignore | 4 ++++ Makefile | 14 +++++++------- include/fxengine/render/triangle.h | 5 ----- include/fxengine/render/zbuffer.h | 2 +- libfxengine.a | Bin 9696 -> 9112 bytes src/render/triangle.c | 23 +++++++++++------------ src/render/zbuffer.c | 2 +- 7 files changed, 24 insertions(+), 26 deletions(-) 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 850b3a591f6d034d72025ff2ccdb76830c3152fe..9cdf5ce914636ef6fd85d5bcf57cef11ad890c76 100644 GIT binary patch delta 953 zcmaFhJ;Qy19E+KSk;z7-Fjh8WV-Rz59cvbx{f=uJH&lFb9jn;p17b?dU=5SsafvgV zm{?4b(qiJ!*sLR!%gDHA@+@gr;XU4hz5LFCz2aViy<#4M^)B@;lRrsoGp?H~CnM`T zDdn>VcZo^L=dej70Uq3`Kt7O_75DuDTSl-VVqByxuMy5VDIM?~9y={0m!(02*By)*uBNK@nCF_VlC7Xz_ByRU$ zBg2eaMaCIyQtZd&#Tcc`Bp&d~o2Djval7z76Dsyai=sZaP;#+`2k>lJx4z)R3HZ=Fnd+j=R4t5Cf0w_K9?D! zF7^Ry>SYP~9r(vcpr6f1yh_G;LH`FZU%a0&OF2sz7(R?f!mk*58FQ3#gdf)1i1#yD z9e-1Ab-bHz{oV>j3vp&m6LA(zWlv=bpi1#h#`QjdLF;uGI1?w;Coc~8p5B}!blcKc zBgr^ekU>3A$lM~}2b+|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r~w zzm{x%DSU_*>Cj7sn3CUZgA*rsljcc*zN2r2Z4W?ZKg~+WH2%p*k(|~EBM!*lFV7FJ z2_`zN-xEI-iezo5cC9e-D)vA5eVADJEdZ#`iu!+KLR}`mohQl=%}5z{edaNhtpQp6 z!zz7!mHus&{&SUH_`fD70Ei|4)I&N9_}&0ewj#42!LDl9C!5Nr_6GuD==H7>{k^;h z0)fEsfeokTm!%)|80>})RgQfW(wA9!)fK?I*lAEM#Q{)F3%u;pe|HV^YS0eCgtHM d-K5dr5@K4mTNzE>FBsi&r+D 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;