diff --git a/src/Makefile b/src/Makefile index 3203241..2ceb1f6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,8 +15,8 @@ CFLAGS += -O0 -g3 endif TARGET = drow-engine -HEADERS = err.h parser.h types.h print.h filereader.h gl_draw.h vec_math.h -OBJECTS = main.o parser.o print.o filereader.o gl_draw.o vec_math.c +HEADERS = err.h parser.h common.h print.h filereader.h gl_draw.h vector.h half_edge.h +OBJECTS = main.o parser.o print.o filereader.o gl_draw.o vector.o INCS = -I. CFLAGS += $(shell $(PKG_CONFIG) --cflags gl glu glib-2.0) diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..c31f25b --- /dev/null +++ b/src/common.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011-2014 hasufell + * + * This file is part of a hasufell project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License only. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @file common.h + * Header for common types, macros and constants + * shared amongst the codebase. Error macros go in err.h. + * @brief common.h common types, macros, constants + */ + +#ifndef _DROW_ENGINE_TYPES_H +#define _DROW_ENGINE_TYPES_H + + +#include + + +/** + * Standard file buffer + */ +#define STD_FILE_BUF 4096 + + +#endif /* _DROW_ENGINE_TYPES_H */ diff --git a/src/filereader.c b/src/filereader.c index 4a5692c..11fbf3c 100644 --- a/src/filereader.c +++ b/src/filereader.c @@ -19,7 +19,7 @@ #include "err.h" #include "filereader.h" #include "parser.h" -#include "types.h" +#include "common.h" #include #include diff --git a/src/filereader.h b/src/filereader.h index 1e1d66b..220b996 100644 --- a/src/filereader.h +++ b/src/filereader.h @@ -20,7 +20,7 @@ #define _DROW_ENGINE_FILEREADER_H -#include "types.h" +#include "half_edge.h" HE_obj *read_obj_file(char const * const filename); diff --git a/src/gl_draw.c b/src/gl_draw.c index d9e12ff..12bd4b5 100644 --- a/src/gl_draw.c +++ b/src/gl_draw.c @@ -18,7 +18,7 @@ #include "err.h" #include "filereader.h" -#include "types.h" +#include "half_edge.h" #include #include @@ -363,6 +363,17 @@ void init(char const * const filename) glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); glShadeModel(GL_FLAT); + + /* vector *array = malloc(sizeof(vector) * obj->vc); */ + /* vector vec; */ + + /* vec.x = obj->vertices->x; */ + /* vec.y = obj->vertices->y; */ + /* vec.z = obj->vertices->z; */ + + /* for (uint32_t i = 0; i < obj->vc; i++) { */ + + /* } */ } /** diff --git a/src/gl_draw.h b/src/gl_draw.h index 37d8100..2840b1a 100644 --- a/src/gl_draw.h +++ b/src/gl_draw.h @@ -20,8 +20,6 @@ #define _DROW_ENGINE_DRAW_H -#include "types.h" - #include #include #include diff --git a/src/types.h b/src/half_edge.h similarity index 86% rename from src/types.h rename to src/half_edge.h index 96e7402..ca6925f 100644 --- a/src/types.h +++ b/src/half_edge.h @@ -16,34 +16,18 @@ * along with this program. If not, see . */ -#ifndef _DROW_ENGINE_TYPES_H -#define _DROW_ENGINE_TYPES_H +#ifndef _DROW_ENGINE_HE_OPERATIONS_H +#define _DROW_ENGINE_HE_OPERATIONS_H #include -/** - * Standard file buffer - */ -#define STD_FILE_BUF 4096 - -typedef uint32_t** FACE; - -typedef struct vector vector; typedef struct HE_edge HE_edge; typedef struct HE_vert HE_vert; typedef struct HE_face HE_face; typedef struct HE_obj HE_obj; -/** - * Represents a 3-dimensional vector. - */ -struct vector { - float x; - float y; - float z; -}; /** * Represents a half-edge. @@ -125,4 +109,7 @@ struct HE_obj { }; -#endif /* _DROW_ENGINE_TYPES_H */ +HE_edge **get_all_emanating_edges(HE_vert *vertice); + + +#endif /* _DROW_ENGINE_HE_OPERATIONS_H */ diff --git a/src/main.c b/src/main.c index 877b98a..2377745 100644 --- a/src/main.c +++ b/src/main.c @@ -17,8 +17,9 @@ */ #include "gl_draw.h" +#include "half_edge.h" #include "print.h" -#include "types.h" +#include "vector.h" #include #include diff --git a/src/parser.c b/src/parser.c index fa699d8..249c54d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -18,7 +18,7 @@ #include "err.h" #include "filereader.h" -#include "types.h" +#include "parser.h" #include #include diff --git a/src/parser.h b/src/parser.h index 4fb4b02..6d97ea9 100644 --- a/src/parser.h +++ b/src/parser.h @@ -19,10 +19,17 @@ #ifndef _DROW_ENGINE_PARSER_H #define _DROW_ENGINE_PARSER_H +#include "half_edge.h" -#include "types.h" +#include +/** + * Typedef for the plain faces + * that are not yet converted to real HE_face. + */ +typedef uint32_t** FACE; + HE_obj *parse_obj(char const * const filename); diff --git a/src/print.c b/src/print.c index 7a80078..d4f1e25 100644 --- a/src/print.c +++ b/src/print.c @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -#include "types.h" +#include "half_edge.h" +#include "parser.h" +#include "vector.h" #include diff --git a/src/print.h b/src/print.h index bed9ee9..614a6fb 100644 --- a/src/print.h +++ b/src/print.h @@ -20,7 +20,9 @@ #define _DROW_ENGINE_PRINT_H -#include "types.h" +#include "half_edge.h" +#include "parser.h" +#include "vector.h" void print_edges(HE_obj *obj); diff --git a/src/vec_math.c b/src/vector.c similarity index 98% rename from src/vec_math.c rename to src/vector.c index cb482b9..d1b6138 100644 --- a/src/vec_math.c +++ b/src/vector.c @@ -17,8 +17,7 @@ */ #include "err.h" -#include "types.h" -#include "vec_math.h" +#include "vector.h" #include #include diff --git a/src/vec_math.h b/src/vector.h similarity index 88% rename from src/vec_math.h rename to src/vector.h index ba3bbed..9e2acc4 100644 --- a/src/vec_math.h +++ b/src/vector.h @@ -20,11 +20,22 @@ #define _DROW_ENGINE_VEC_MATH_H -#include "types.h" - #include +typedef struct vector vector; + + +/** + * Represents a 3-dimensional vector. + */ +struct vector { + float x; + float y; + float z; +}; + + bool vector_product(vector *a, vector *b, vector *c); bool normalize_vector(vector *a, vector *b); bool copy_vector(vector *a, vector *b);