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

Added lib for draw and makefile modified

parent 26e9c0f9
Branches
Tags
1 merge request!2Hotfix : moved draw into a lib and added test
......@@ -9,8 +9,21 @@
*
*/
#include <math.h>
#include "draw.h"
#include "math.h"
/**
* @brief Create a coordinate
*
* @param row_ Row number
* @param column_ Column number
* @return coordinates_t
*/
coordinates_t coordinates_create(int row_, int column_)
{
coordinates_t c = {.row = row_, .column = column_};
return c;
}
/**
* @brief Bresenham's line algorithme.
......
......@@ -14,8 +14,23 @@
#include <stdlib.h>
#include <stdio.h>
#include "utils.h"
#include "gfx/gfx.h"
#include <stdint.h>
#include "../gfx/gfx.h"
typedef struct
{
uint32_t row;
uint32_t column;
} coordinates_t;
/**
* @brief Create a coordinate
*
* @param row_ Row number
* @param column_ Column number
* @return coordinates_t
*/
coordinates_t coordinates_create(int row_, int column_);
/**
* @brief Draw a line using the Bresenham's line algorithm
......
......@@ -9,8 +9,7 @@
*
*/
#include <stdlib.h>
#include "gfx/gfx.h"
#include "utils.h"
#include "../gfx/gfx.h"
#include "draw.h"
int main(void) {
......
......@@ -2,7 +2,6 @@
#include <time.h>
#include <math.h>
#include "gfx/gfx.h"
#include "draw.h"
int main(void) {
const int WINDOW_SIZE_X = 500;
......
......@@ -10,7 +10,7 @@ BIN = bin
RUN = ./$(BIN)/$(TARGET)
# Get source and object
SRCS = $(filter-out test%.c, $(wildcard *.c */*.c))
SRCS = $(filter-out $(wildcard */test.c), $(wildcard *.c */*.c))
OBJS = $(addprefix $(BIN)/, $(SRCS:.c=.o))
PHONY := $(TARGET)
......@@ -38,9 +38,9 @@ PHONY += clean
clean:
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)/$@
test-draw: draw/test.c
$(CC) $(CFLAGS) -o $(BIN)/draw/$@.o -c $< $(LDFLAGS)
$(CC) $(CFLAGS) -o $(BIN)/draw/$@ $(BIN)/draw/$@.o $(BIN)/draw/draw.o $(BIN)/gfx/gfx.o $(LIBS) $(LDFLAGS)
./$(BIN)/draw/$@
.PHONY: $(PHONY)
......@@ -3,12 +3,6 @@
#include "vector/vector.h"
#include "utils.h"
coordinates_t coordinates_create(int row_, int column_)
{
coordinates_t c = {.row = row_, .column = column_};
return c;
}
// Transform a position in the univers [x0,y0]x[x1,y1] to a screen position
coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos)
{
......
......@@ -6,12 +6,7 @@
#include <stdint.h>
#include "vector/vector.h"
typedef struct
{
uint32_t row;
uint32_t column;
} coordinates_t;
#include "draw/draw.h"
typedef struct
{
......@@ -19,8 +14,6 @@ typedef struct
vector pos;
} charge_t;
coordinates_t coordinates_create(int row_, int column_);
// Transform a position in the univers [x0,y0]x[x1,y1] to a screen position
coordinates_t position_to_coordinates(int width, int height, double x0, double x1, double y0, double y1, vector pos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment