From da346a5426c74a0ddb62913ad3a708418c8b8e46 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Sun, 4 Mar 2018 10:47:00 +0100 Subject: [PATCH 01/11] Update glez.h --- include/glez.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/glez.h b/include/glez.h index fb60432..01c160b 100644 --- a/include/glez.h +++ b/include/glez.h @@ -93,7 +93,7 @@ void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color, void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, glez_texture_t texture, float tx, float ty, float tw, - float th); + float th, float angle); void glez_string(float x, float y, const char *string, glez_font_t font, glez_rgba_t color, float *out_x, float *out_y); From 24e1b9da324413b63f2e0376a6c66397f8951015 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Sun, 4 Mar 2018 10:47:17 +0100 Subject: [PATCH 02/11] Update glez.c --- src/glez.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/glez.c b/src/glez.c index d6432ca..36918c1 100644 --- a/src/glez.c +++ b/src/glez.c @@ -142,7 +142,7 @@ void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color, void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, glez_texture_t texture, float tx, float ty, float tw, - float th) + float th, float angle) { internal_texture_t *tex = internal_texture_get(texture); internal_texture_bind(texture); @@ -162,29 +162,29 @@ void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, float t0 = ty / tex->height; float t1 = (ty + th) / tex->height; - vertices[0].position.x = x; - vertices[0].position.y = y; + vertices[0].position.x = x * cos(angle) - y * sin(angle); + vertices[0].position.y = y * sin(angle) + y * cos(angle); vertices[0].tex_coords.x = s0; vertices[0].tex_coords.y = t1; vertices[0].color = color; vertices[0].mode = DRAW_MODE_TEXTURED; - vertices[1].position.x = x; - vertices[1].position.y = y + h; + vertices[1].position.x = x * cos(angle) - y * sin(angle); + vertices[1].position.y = (y + h) * sin(angle) + y * cos(angle); vertices[1].tex_coords.x = s0; vertices[1].tex_coords.y = t0; vertices[1].color = color; vertices[1].mode = DRAW_MODE_TEXTURED; - vertices[2].position.x = x + w; - vertices[2].position.y = y + h; + vertices[2].position.x = (x + w) * cos(angle) - y * sin(angle); + vertices[2].position.y = (y + h) * sin(angle) + y * cos(angle); vertices[2].tex_coords.x = s1; vertices[2].tex_coords.y = t0; vertices[2].color = color; vertices[2].mode = DRAW_MODE_TEXTURED; - vertices[3].position.x = x + w; - vertices[3].position.y = y; + vertices[3].position.x = (x + w) * cos(angle) - y * sin(angle); + vertices[3].position.y = y * sin(angle) + y * cos(angle); vertices[3].tex_coords.x = s1; vertices[3].tex_coords.y = t1; vertices[3].color = color; From 216bdf9fd079a58e74731034ab1f49b76f537dcb Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Sun, 1 Apr 2018 14:39:12 +0200 Subject: [PATCH 03/11] fix --- .settings/language.settings.xml | 2 +- src/glez.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index aaa2b7b..8bbf096 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/src/glez.c b/src/glez.c index 36918c1..8bc357d 100644 --- a/src/glez.c +++ b/src/glez.c @@ -170,20 +170,20 @@ void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, vertices[0].mode = DRAW_MODE_TEXTURED; vertices[1].position.x = x * cos(angle) - y * sin(angle); - vertices[1].position.y = (y + h) * sin(angle) + y * cos(angle); + vertices[1].position.y = (y * sin(angle) + y * cos(angle)) + h; vertices[1].tex_coords.x = s0; vertices[1].tex_coords.y = t0; vertices[1].color = color; vertices[1].mode = DRAW_MODE_TEXTURED; - vertices[2].position.x = (x + w) * cos(angle) - y * sin(angle); - vertices[2].position.y = (y + h) * sin(angle) + y * cos(angle); + vertices[2].position.x = (x * cos(angle) - y * sin(angle)) + w; + vertices[2].position.y = (y * sin(angle) + y * cos(angle)) + h; vertices[2].tex_coords.x = s1; vertices[2].tex_coords.y = t0; vertices[2].color = color; vertices[2].mode = DRAW_MODE_TEXTURED; - vertices[3].position.x = (x + w) * cos(angle) - y * sin(angle); + vertices[3].position.x = (x * cos(angle) - y * sin(angle)) + w; vertices[3].position.y = y * sin(angle) + y * cos(angle); vertices[3].tex_coords.x = s1; vertices[3].tex_coords.y = t1; From 0eb53f0d4d54b9e7e69c5b56baa3c8b767f35a56 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Sun, 1 Apr 2018 14:45:54 +0200 Subject: [PATCH 04/11] tf is math --- src/glez.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glez.c b/src/glez.c index 8bc357d..dbc6fd4 100644 --- a/src/glez.c +++ b/src/glez.c @@ -163,28 +163,28 @@ void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, float t1 = (ty + th) / tex->height; vertices[0].position.x = x * cos(angle) - y * sin(angle); - vertices[0].position.y = y * sin(angle) + y * cos(angle); + vertices[0].position.y = x * sin(angle) + y * cos(angle); vertices[0].tex_coords.x = s0; vertices[0].tex_coords.y = t1; vertices[0].color = color; vertices[0].mode = DRAW_MODE_TEXTURED; vertices[1].position.x = x * cos(angle) - y * sin(angle); - vertices[1].position.y = (y * sin(angle) + y * cos(angle)) + h; + vertices[1].position.y = (x * sin(angle) + y * cos(angle)) + h; vertices[1].tex_coords.x = s0; vertices[1].tex_coords.y = t0; vertices[1].color = color; vertices[1].mode = DRAW_MODE_TEXTURED; vertices[2].position.x = (x * cos(angle) - y * sin(angle)) + w; - vertices[2].position.y = (y * sin(angle) + y * cos(angle)) + h; + vertices[2].position.y = (x * sin(angle) + y * cos(angle)) + h; vertices[2].tex_coords.x = s1; vertices[2].tex_coords.y = t0; vertices[2].color = color; vertices[2].mode = DRAW_MODE_TEXTURED; vertices[3].position.x = (x * cos(angle) - y * sin(angle)) + w; - vertices[3].position.y = y * sin(angle) + y * cos(angle); + vertices[3].position.y = x * sin(angle) + y * cos(angle); vertices[3].tex_coords.x = s1; vertices[3].tex_coords.y = t1; vertices[3].color = color; From e3bdf1c994da95544b84896efe8de0099dffe023 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Mon, 2 Apr 2018 09:51:11 +0200 Subject: [PATCH 05/11] Fix rotation --- src/glez.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/glez.c b/src/glez.c index dbc6fd4..ec6750e 100644 --- a/src/glez.c +++ b/src/glez.c @@ -11,6 +11,7 @@ #include "internal/draw.h" #include "internal/fonts.h" #include "internal/textures.h" +#include #include @@ -139,7 +140,6 @@ void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color, glez_line(x + w, y + h, -w, 0, color, thickness); glez_line(x, y + h, 0, -h, color, thickness); } - void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, glez_texture_t texture, float tx, float ty, float tw, float th, float angle) @@ -162,34 +162,64 @@ void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color, float t0 = ty / tex->height; float t1 = (ty + th) / tex->height; - vertices[0].position.x = x * cos(angle) - y * sin(angle); - vertices[0].position.y = x * sin(angle) + y * cos(angle); + vertices[0].position.x = x; + vertices[0].position.y = y; vertices[0].tex_coords.x = s0; vertices[0].tex_coords.y = t1; vertices[0].color = color; vertices[0].mode = DRAW_MODE_TEXTURED; - vertices[1].position.x = x * cos(angle) - y * sin(angle); - vertices[1].position.y = (x * sin(angle) + y * cos(angle)) + h; + vertices[1].position.x = x; + vertices[1].position.y = y + h; vertices[1].tex_coords.x = s0; vertices[1].tex_coords.y = t0; vertices[1].color = color; vertices[1].mode = DRAW_MODE_TEXTURED; - vertices[2].position.x = (x * cos(angle) - y * sin(angle)) + w; - vertices[2].position.y = (x * sin(angle) + y * cos(angle)) + h; + vertices[2].position.x = x + w; + vertices[2].position.y = y + h; vertices[2].tex_coords.x = s1; vertices[2].tex_coords.y = t0; vertices[2].color = color; vertices[2].mode = DRAW_MODE_TEXTURED; - vertices[3].position.x = (x * cos(angle) - y * sin(angle)) + w; - vertices[3].position.y = x * sin(angle) + y * cos(angle); + vertices[3].position.x = x + w; + vertices[3].position.y = y; vertices[3].tex_coords.x = s1; vertices[3].tex_coords.y = t1; vertices[3].color = color; vertices[3].mode = DRAW_MODE_TEXTURED; + if (angle) { + float v1[2] = {vertices[0].position.x, vertices[0].position.y}; + float v2[2] = {vertices[1].position.x, vertices[1].position.y}; + float v3[2] = {vertices[2].position.x, vertices[2].position.y}; + float v4[2] = {vertices[3].position.x, vertices[3].position.y}; + vertices[0].position.x = -tw; + vertices[1].position.x = -tw; + vertices[2].position.x = tw; + vertices[3].position.x = tw; + + vertices[0].position.y = -th; + vertices[1].position.y = th; + vertices[2].position.y = th; + vertices[3].position.y = -th; + for (int i = 0; i < 4; i++) { + float x = vertices[i].position.x; + float y = vertices[i].position.y; + vertices[i].position.x = x *cos(angle) - y *sin(angle); + vertices[i].position.y = x *sin(angle) + y *cos(angle); + } + vertices[0].position.x += v1[0]; + vertices[0].position.y += v1[1]; + vertices[1].position.x += v2[0]; + vertices[1].position.y += v2[1]; + vertices[2].position.x += v3[0]; + vertices[2].position.y += v3[1]; + vertices[3].position.x += v4[0]; + vertices[3].position.y += v4[1]; + } + vertex_buffer_push_back(program.buffer, vertices, 4, indices, 6); } From baf7afe6bd88b9c6f1e2037e2713f872ab8044a7 Mon Sep 17 00:00:00 2001 From: Jenny White Date: Fri, 27 Apr 2018 11:36:55 +0300 Subject: [PATCH 06/11] basic CMakeLists --- .gitignore | 3 ++- CMakeLists.txt | 24 ++++++++++++++++++++++++ ftgl/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ include/CMakeLists.txt | 4 ++++ include/internal/CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 6 ++++++ 6 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 ftgl/CMakeLists.txt create mode 100644 include/CMakeLists.txt create mode 100644 include/internal/CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/.gitignore b/.gitignore index df27c9b..28e1c94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin* *.o -.settings* \ No newline at end of file +.settings* +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..04f798b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +# This builds a 32-bit version of library, building 64 bit is not supported yet. + +cmake_minimum_required(VERSION 3.0) +project(glez VERSION 0.0.1 DESCRIPTION "Basic OpenGL primitive + text drawing using freetype-gl") + +find_package(Freetype REQUIRED) +find_package(PNG REQUIRED) +find_package(GLEW REQUIRED) + +add_library(glez SHARED "") + +set_target_properties(glez PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") + +target_include_directories(glez PUBLIC include) +target_include_directories(glez PRIVATE ftgl) +target_include_directories(glez PRIVATE ${FREETYPE_INCLUDE_DIRS} ${PNG_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) + +target_compile_definitions(glez PRIVATE ${PNG_DEFINITIONS}) + +target_link_libraries(glez ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${GLEW_LIBRARIES}) + +add_subdirectory(include) +add_subdirectory(src) +add_subdirectory(ftgl) \ No newline at end of file diff --git a/ftgl/CMakeLists.txt b/ftgl/CMakeLists.txt new file mode 100644 index 0000000..5352103 --- /dev/null +++ b/ftgl/CMakeLists.txt @@ -0,0 +1,32 @@ +target_sources(glez PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/distance-field.h" + "${CMAKE_CURRENT_LIST_DIR}/edtaa3func.h" + "${CMAKE_CURRENT_LIST_DIR}/font-manager.h" + "${CMAKE_CURRENT_LIST_DIR}/freetype-gl.h" + "${CMAKE_CURRENT_LIST_DIR}/markup.h" + "${CMAKE_CURRENT_LIST_DIR}/mat4.h" + "${CMAKE_CURRENT_LIST_DIR}/opengl.h" + "${CMAKE_CURRENT_LIST_DIR}/platform.h" + "${CMAKE_CURRENT_LIST_DIR}/text-buffer.h" + "${CMAKE_CURRENT_LIST_DIR}/texture-atlas.h" + "${CMAKE_CURRENT_LIST_DIR}/texture-font.h" + "${CMAKE_CURRENT_LIST_DIR}/utf8-utils.h" + "${CMAKE_CURRENT_LIST_DIR}/vec234.h" + "${CMAKE_CURRENT_LIST_DIR}/vector.h" + "${CMAKE_CURRENT_LIST_DIR}/vertex-attribute.h" + "${CMAKE_CURRENT_LIST_DIR}/vertex-buffer.h") + +target_sources(glez PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/distance-field.c" + "${CMAKE_CURRENT_LIST_DIR}/edtaa3func.c" + "${CMAKE_CURRENT_LIST_DIR}/font-manager.c" + "${CMAKE_CURRENT_LIST_DIR}/makefont.c" + "${CMAKE_CURRENT_LIST_DIR}/mat4.c" + "${CMAKE_CURRENT_LIST_DIR}/platform.c" + "${CMAKE_CURRENT_LIST_DIR}/text-buffer.c" + "${CMAKE_CURRENT_LIST_DIR}/texture-atlas.c" + "${CMAKE_CURRENT_LIST_DIR}/texture-font.c" + "${CMAKE_CURRENT_LIST_DIR}/utf8-utils.c" + "${CMAKE_CURRENT_LIST_DIR}/vector.c" + "${CMAKE_CURRENT_LIST_DIR}/vertex-attribute.c" + "${CMAKE_CURRENT_LIST_DIR}/vertex-buffer.c") \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..9869a07 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(glez PUBLIC + "${CMAKE_CURRENT_LIST_DIR}/glez.h") + +add_subdirectory(internal) \ No newline at end of file diff --git a/include/internal/CMakeLists.txt b/include/internal/CMakeLists.txt new file mode 100644 index 0000000..79ae3c8 --- /dev/null +++ b/include/internal/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(glez PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/draw.h" + "${CMAKE_CURRENT_LIST_DIR}/fonts.h" + "${CMAKE_CURRENT_LIST_DIR}/program.h" + "${CMAKE_CURRENT_LIST_DIR}/textures.h") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..bc1b40e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(glez PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/draw.c" + "${CMAKE_CURRENT_LIST_DIR}/fonts.c" + "${CMAKE_CURRENT_LIST_DIR}/glez.c" + "${CMAKE_CURRENT_LIST_DIR}/program.c" + "${CMAKE_CURRENT_LIST_DIR}/textures.c") \ No newline at end of file From f4eca944b28cf169448615e5bac63effaf33bbb6 Mon Sep 17 00:00:00 2001 From: Jenny White Date: Fri, 27 Apr 2018 11:43:28 +0300 Subject: [PATCH 07/11] fixed some warnings --- src/glez.c | 1 + src/textures.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/glez.c b/src/glez.c index 64366b7..75e17af 100644 --- a/src/glez.c +++ b/src/glez.c @@ -13,6 +13,7 @@ #include "internal/textures.h" #include +#include /* State functions */ diff --git a/src/textures.c b/src/textures.c index 6ea4369..8df8332 100644 --- a/src/textures.c +++ b/src/textures.c @@ -52,13 +52,14 @@ int internal_texture_load_png_rgba(const char *name, internal_texture_t *out) png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (pngstr == NULL) { + fclose(file); return -1; } png_infop pnginfo = png_create_info_struct(pngstr); png_infop pngend = png_create_info_struct(pngstr); if (setjmp(png_jmpbuf(pngstr))) { - png_destroy_read_struct(pngstr, pnginfo, pngend); + png_destroy_read_struct(&pngstr, &pnginfo, &pngend); return -1; } png_init_io(pngstr, file); @@ -71,7 +72,7 @@ int internal_texture_load_png_rgba(const char *name, internal_texture_t *out) int row_bytes; if (PNG_COLOR_TYPE_RGBA != png_get_color_type(pngstr, pnginfo)) { - png_destroy_read_struct(pngstr, pnginfo, pngend); + png_destroy_read_struct(&pngstr, &pnginfo, &pngend); fclose(file); return -1; } @@ -81,14 +82,14 @@ int internal_texture_load_png_rgba(const char *name, internal_texture_t *out) out->data = malloc(row_bytes * height * sizeof(png_byte)); if (out->data == NULL) { - png_destroy_read_struct(pngstr, pnginfo, pngend); + png_destroy_read_struct(&pngstr, &pnginfo, &pngend); fclose(file); return -1; } row_pointers = malloc(height * sizeof(png_bytep)); if (row_pointers == NULL) { - png_destroy_read_struct(pngstr, pnginfo, pngend); + png_destroy_read_struct(&pngstr, &pnginfo, &pngend); free(out->data); fclose(file); return -1; From 954dba2254fb62b021d7cbeb4c82da6205f5f62b Mon Sep 17 00:00:00 2001 From: Jenny White Date: Fri, 27 Apr 2018 13:18:31 +0300 Subject: [PATCH 08/11] [WIP] installation --- CMakeLists.txt | 24 +++++++++++++++++++----- glez-config.cmake | 2 ++ include/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 glez-config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f798b..e4e3492 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,11 @@ # This builds a 32-bit version of library, building 64 bit is not supported yet. cmake_minimum_required(VERSION 3.0) -project(glez VERSION 0.0.1 DESCRIPTION "Basic OpenGL primitive + text drawing using freetype-gl") +project(glez LANGUAGES C VERSION 0.0.1 DESCRIPTION "Basic OpenGL primitive + text drawing using freetype-gl") + +set(glez_dest "lib/glez-${glez_VERSION}") +set(include_dest "include/glez-${glez_VERSION}") +set(lib_dest "${glez_dest}/${CMAKE_BUILD_TYPE}") find_package(Freetype REQUIRED) find_package(PNG REQUIRED) @@ -11,9 +15,14 @@ add_library(glez SHARED "") set_target_properties(glez PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") -target_include_directories(glez PUBLIC include) -target_include_directories(glez PRIVATE ftgl) -target_include_directories(glez PRIVATE ${FREETYPE_INCLUDE_DIRS} ${PNG_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) +target_include_directories(glez PRIVATE + $ + $ + $ + $ + $ + $ +) target_compile_definitions(glez PRIVATE ${PNG_DEFINITIONS}) @@ -21,4 +30,9 @@ target_link_libraries(glez ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${GLEW_LIBRARI add_subdirectory(include) add_subdirectory(src) -add_subdirectory(ftgl) \ No newline at end of file +add_subdirectory(ftgl) + +install(TARGETS glez EXPORT glez DESTINATION "${lib_dest}") +install(FILES "include/glez.h" DESTINATION "${include_dest}") +install(EXPORT glez DESTINATION "${lib_dest}") +install(FILES glez-config.cmake DESTINATION ${glez_dest}) \ No newline at end of file diff --git a/glez-config.cmake b/glez-config.cmake new file mode 100644 index 0000000..4dce37c --- /dev/null +++ b/glez-config.cmake @@ -0,0 +1,2 @@ +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${SELF_DIR}/${CMAKE_BUILD_TYPE}/glez.cmake) \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 9869a07..c8f6547 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(glez PUBLIC +target_sources(glez PRIVATE "${CMAKE_CURRENT_LIST_DIR}/glez.h") add_subdirectory(internal) \ No newline at end of file From 323a21a21834a26d33bed8d88ce76304ec76d07f Mon Sep 17 00:00:00 2001 From: Jenny White Date: Fri, 27 Apr 2018 19:59:34 +0300 Subject: [PATCH 09/11] CMake --- CMakeLists.txt | 29 +++++++++---------- Makefile | 76 -------------------------------------------------- 2 files changed, 15 insertions(+), 90 deletions(-) delete mode 100644 Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e3492..73d4b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,38 +1,39 @@ # This builds a 32-bit version of library, building 64 bit is not supported yet. cmake_minimum_required(VERSION 3.0) -project(glez LANGUAGES C VERSION 0.0.1 DESCRIPTION "Basic OpenGL primitive + text drawing using freetype-gl") -set(glez_dest "lib/glez-${glez_VERSION}") -set(include_dest "include/glez-${glez_VERSION}") -set(lib_dest "${glez_dest}/${CMAKE_BUILD_TYPE}") +project(glez LANGUAGES C VERSION 0.0.1) + +set(export_dest "lib/${PROJECT_NAME}-${PROJECT_VERSION}") +set(include_dest "include/${PROJECT_NAME}-${PROJECT_VERSION}") +set(lib_dest "${export_dest}/${CMAKE_BUILD_TYPE}") find_package(Freetype REQUIRED) find_package(PNG REQUIRED) find_package(GLEW REQUIRED) -add_library(glez SHARED "") +add_library(${PROJECT_NAME} SHARED "") -set_target_properties(glez PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") +set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") -target_include_directories(glez PRIVATE - $ - $ +target_include_directories(${PROJECT_NAME} PRIVATE + $ + $ $ $ $ $ ) -target_compile_definitions(glez PRIVATE ${PNG_DEFINITIONS}) +target_compile_definitions(${PROJECT_NAME} PRIVATE ${PNG_DEFINITIONS}) -target_link_libraries(glez ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${GLEW_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${GLEW_LIBRARIES}) add_subdirectory(include) add_subdirectory(src) add_subdirectory(ftgl) -install(TARGETS glez EXPORT glez DESTINATION "${lib_dest}") +install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} DESTINATION "${lib_dest}") install(FILES "include/glez.h" DESTINATION "${include_dest}") -install(EXPORT glez DESTINATION "${lib_dest}") -install(FILES glez-config.cmake DESTINATION ${glez_dest}) \ No newline at end of file +install(EXPORT ${PROJECT_NAME} DESTINATION "${lib_dest}") +install(FILES ${PROJECT_NAME}-config.cmake DESTINATION ${export_dest}) \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index a598fa7..0000000 --- a/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -CC=$(shell sh -c "which gcc-7 || which gcc") -CFLAGS=-O3 -Wall -fPIC -fmessage-length=0 -D_GNU_SOURCE=1 -g3 -ggdb -Iinclude -isystemftgl -isystem/usr/local/include/freetype2 -isystem/usr/include/freetype2 -LDFLAGS=-shared -Wl,--no-undefined -LDLIBS=-lm -lrt -lGL -lfreetype -lGLEW -lpng -SRC_DIR=src -BIN32_DIR=bin32 -BIN64_DIR=bin64 -SOURCES=$(shell find $(SRC_DIR) -name "*.c" -print) -SOURCES+=$(shell find "ftgl" -name "*.c" -print) -OBJECTS=$(SOURCES:.c=.o) - -LIB32_PATH=/lib/i386-linux-gnu -LIB64_PATH=/lib/x86_64-linux-gnu - -TARGET32=$(BIN32_DIR)/libglez.so -TARGET64=$(BIN64_DIR)/libglez.so -TARGET=undefined - -.PHONY: clean clean_objects - -ifeq ($(ARCH),32) -CFLAGS+=-m32 -LDFLAGS+=-m32 -TARGET=$(TARGET32) -endif -ifeq ($(ARCH),64) -TARGET=$(TARGET64) -endif - -all: - mkdir -p $(BIN32_DIR) - mkdir -p $(BIN64_DIR) -ifndef ARCH - $(MAKE) clean_objects - $(MAKE) -e ARCH=32 - $(MAKE) clean_objects - $(MAKE) -e ARCH=64 -else - $(MAKE) clean_objects - $(MAKE) $(TARGET) -endif - -install: - cp $(TARGET32) $(LIB32_PATH) - cp $(TARGET64) $(LIB64_PATH) - cp -R include/. /usr/local/include/glez - -ftgl/distance-field.o : CFLAGS+=-w -ftgl/edtaa3func.o : CFLAGS+=-w -ftgl/font-manager.o : CFLAGS+=-w -ftgl/mat4.o : CFLAGS+=-w -ftgl/platform.o : CFLAGS+=-w -ftgl/shader.o : CFLAGS+=-w -ftgl/text-buffer.o : CFLAGS+=-w -ftgl/texture-atlas.o : CFLAGS+=-w -ftgl/utf8-utils.o : CFLAGS+=-w -ftgl/texture-font.o : CFLAGS+=-w -ftgl/vector.o : CFLAGS+=-w -ftgl/vertex-attribute.o : CFLAGS+=-w -ftgl/vertex-buffer.o : CFLAGS+=-w -ftgl/makefont.o : CFLAGS+=-w - -.c.o: - $(CC) $(CFLAGS) -c $< -o $@ - -$(TARGET): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@ - -clean_objects: - find . -type f -name '*.o' -delete - -clean: - find . -type f -name '*.o' -delete - find . -type f -name '*.d' -delete - rm -f bin32/*.so - rm -f bin64/*.so \ No newline at end of file From 14f71fcb810b839bac747fe8dd48d63f9a4ee3a5 Mon Sep 17 00:00:00 2001 From: Jenny White Date: Sat, 28 Apr 2018 18:03:22 +0300 Subject: [PATCH 10/11] install interface --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73d4b3f..ae87568 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,9 @@ target_include_directories(${PROJECT_NAME} PRIVATE $ $ $ +) + +target_include_directories(${PROJECT_NAME} PUBLIC $ ) From 373196717f3096728f48f4dcf3f2d2e496104caf Mon Sep 17 00:00:00 2001 From: Jenny White Date: Sat, 28 Apr 2018 19:27:30 +0300 Subject: [PATCH 11/11] Default build type --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae87568..b4f5317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,11 @@ # This builds a 32-bit version of library, building 64 bit is not supported yet. +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type") +endif() +set(CMAKE_BUILD_TYPE_VALUES "Debug;Release" CACHE INTERNAL "List of supported build") +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_BUILD_TYPE_VALUES}) + cmake_minimum_required(VERSION 3.0) project(glez LANGUAGES C VERSION 0.0.1)