diff --git a/Makefile b/Makefile index 9a2ed5b..16d3f34 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc -CFLAGS = -g +CFLAGS = -pg -O2 +LDFLAGS = -pg LDLIBS = -lraylib -lm - objects = c3d.o c3d: $(objects) diff --git a/c3d.c b/c3d.c index 2baff56..44f7c67 100644 --- a/c3d.c +++ b/c3d.c @@ -74,17 +74,17 @@ struct Tri2DArray { }; typedef struct Tri2DArray Tri2DArray; -float Sign(Vector2 v1, Vector2 v2, Vector2 v3) { - return (v1.x - v3.x) * (v2.y - v3.y) - (v2.x - v3.x) * (v1.y - v3.y); +float Sign(Vector2* v1, Vector2* v2, Vector2* v3) { + return (v1->x - v3->x) * (v2->y - v3->y) - (v2->x - v3->x) * (v1->y - v3->y); } -bool IsInTri(Tri2D tri, Vector2 p) { +inline bool IsInTri(Tri2D tri, Vector2 p) { float d1, d2, d3; bool has_neg, has_pos; - d1 = Sign(p, tri.a, tri.b); - d2 = Sign(p, tri.b, tri.c); - d3 = Sign(p, tri.c, tri.a); + d1 = Sign(&p, &tri.a, &tri.b); + d2 = Sign(&p, &tri.b, &tri.c); + d3 = Sign(&p, &tri.c, &tri.a); has_neg = (d1 < 0) || (d2 < 0) || (d3 < 0); has_pos = (d1 > 0) || (d2 > 0) || (d3 > 0); @@ -381,6 +381,11 @@ int main() { BeginDrawing(); DrawTexturePro(renderTexture.texture, (Rectangle){0,0,renderTexture.texture.width,-renderTexture.texture.height},(Rectangle){0,0,SCREENWIDTH,SCREENHEIGHT},(Vector2){0,0},0,WHITE); + + char fpstext[40]; + sprintf(fpstext,"%d",GetFPS()); + DrawText( fpstext ,0,0,20,WHITE); + EndDrawing(); }