Skip to content
Snippets Groups Projects
Commit d05ad22f authored by tanguy.cavagna's avatar tanguy.cavagna :desktop:
Browse files

Modification to do tests

parent b68dc12b
Branches
Tags
No related merge requests found
......@@ -7,18 +7,16 @@ LIBS = -lSDL2
TARGET = main
BIN = bin
SUBDIR = vector
RUN = ./$(BIN)/$(TARGET)
# Get source and object
SRCS = $(wildcard *.c */*.c)
SRCS = $(filter-out test%.c, $(wildcard *.c */*.c))
OBJS = $(addprefix $(BIN)/, $(SRCS:.c=.o))
PHONY := $(TARGET)
# Create the target
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(BIN)/$@ $(OBJS) $(LIBS) $(LDFLAGS)
$(RUN)
# Convert the source in object, but before all, run `$(BIN)` aka mkdir
$(BIN)/%.o: %.c
......@@ -29,7 +27,6 @@ PHONY += help
# Echo the source and object values
help:
@echo "src: $(SRCS)"
@echo "inc: $(INCS)"
@echo "obj: $(OBJS)"
PHONY += run
......@@ -39,6 +36,11 @@ run:
PHONY += clean
clean:
rm -rf bin
rm -rf $(BIN)
test-draw: test-draw.c
$(CC) $(CFLAGS) -o $(BIN)/$@.o -c $< $(LDFLAGS)
$(CC) $(CFLAGS) -o $(BIN)/$@ $(BIN)/$@.o $(BIN)/draw.o $(BIN)/gfx/gfx.o $(BIN)/utils.o $(LIBS) $(LDFLAGS)
./$(BIN)/$@
.PHONY: $(PHONY)
/**
* @file test.c
* @author Tanguy Cavagna (tanguy.cavagna@etu.hesge.ch)
* @brief Test file for the draw functions
* @version 0.1
* @date 2021-07-12
*
* @copyright Copyright (c) 2021
*
*/
#include <stdlib.h>
#include "gfx/gfx.h"
#include "utils.h"
#include "draw.h"
int main(void) {
const int WINDOW_WIDTH = 100;
const int WINDOW_HEIGHT = 100;
struct gfx_context_t *ctxt = gfx_create("draw", WINDOW_WIDTH, WINDOW_HEIGHT);
if (!ctxt) {
fprintf(stderr, "Graphics initialization failed !\n");
return EXIT_FAILURE;
}
coordinates_t p0 = {50, 50};
coordinates_t p1 = {62, 72};
coordinates_t p2 = {72, 62};
coordinates_t p3 = {75, 50};
coordinates_t p4 = {50, 75};
coordinates_t p5 = {36, 72};
coordinates_t p6 = {28, 62};
coordinates_t p7 = {25, 50};
coordinates_t p8 = {28, 38};
coordinates_t p9 = {37, 28};
coordinates_t p10 = {50, 25};
coordinates_t p11 = {62, 28};
coordinates_t p12 = {72, 37};
gfx_draw_line(ctxt, p0, p3, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p2, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p1, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p4, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p5, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p6, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p7, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p8, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p9, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p10, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p11, COLOR_WHITE);
gfx_draw_line(ctxt, p0, p12, COLOR_WHITE);
while (gfx_keypressed() != SDLK_ESCAPE){
gfx_present(ctxt);
}
gfx_destroy(ctxt);
return EXIT_SUCCESS;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment