Skip to content

Commit

Permalink
Remove freetype from public header files
Browse files Browse the repository at this point in the history
  • Loading branch information
cjhoward committed Sep 13, 2017
1 parent 6f375a7 commit f8ca678
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
28 changes: 11 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.7)

if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif()

project("emergent"
VERSION "0.0.0")

Expand Down Expand Up @@ -31,15 +27,16 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)

# Configure, build and install freetype
set(FREETYPE_BUILD_DIR ${PROJECT_BINARY_DIR}/deps/build/freetype)
set(FREETYPE_INSTALL_DIR ${PROJECT_BINARY_DIR}/deps/install/freetype)
set(FREETYPE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
set(FREETYPE_INCLUDE_DIR ${FREETYPE_INSTALL_DIR}/include/freetype2)
set(FREETYPE_LIBRARY ${FREETYPE_INSTALL_DIR}/lib/freetyped.lib)
set(FREETYPE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/freetyped.lib)
ExternalProject_Add(freetype
SOURCE_DIR ${PROJECT_SOURCE_DIR}/lib/freetype-2.8
CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=${FREETYPE_INSTALL_DIR}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
BINARY_DIR ${FREETYPE_BUILD_DIR}
INSTALL_DIR ${FREETYPE_INSTALL_DIR})
INSTALL_DIR ${CMAKE_INSTALL_PREFIX})

# Setup configuration variables
set(EMERGENT_VERSION ${PROJECT_VERSION})
Expand Down Expand Up @@ -175,15 +172,15 @@ set(emergent_HEADERS
include/emergent/font/kerning-table.hpp
include/emergent/font/texture-atlas.hpp)

# Set linked libraries
set(emergent_LIBRARIES
m
stdc++
# Set dependencies
set(emergent_DEPENDENCIES
#m
#stdc++
${FREETYPE_LIBRARY}
)

# Build library
add_library(emergent ${emergent_SOURCES} ${emergent_HEADERS})
add_library(emergent STATIC ${emergent_SOURCES} ${emergent_HEADERS})

# Set library dependencies
add_dependencies(emergent freetype)
Expand All @@ -196,10 +193,7 @@ target_include_directories(emergent PUBLIC
${PROJECT_SOURCE_DIR}/lib/stb
${FREETYPE_INCLUDE_DIR})

# Link library
target_link_libraries(emergent ${emergent_LIBRARIES})

# Install library
# Install emergent library and dependency libraries
install(TARGETS emergent DESTINATION lib)

# Install public headers
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Emergent is a C++ framework for real-time 3D applications.

### Windows

Building on Windows requires Visual Studio 2017 and CMake. Open the Visual Studio Command Prompt (VsDevCmd.bat) and run the following commands:
Building on Windows requires CMake and Visual Studio 2017. Open the Visual Studio Command Prompt (`VsDevCmd.bat`) and run the following commands:

cd emergent\build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=<...>
Expand All @@ -15,7 +15,7 @@ Building on Windows requires Visual Studio 2017 and CMake. Open the Visual Studi

### GNU/Linux

Building on GNU/Linux requires CMake and Make. Open a terminal and run the following commands:
Building on GNU/Linux requires CMake, GCC, G++, and GNU Make. Open a terminal and run the following commands:

cd emergent/build
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=<...>
Expand Down
4 changes: 1 addition & 3 deletions include/emergent/font/font-loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#define EMERGENT_FONT_FONT_LOADER_HPP

#include <string>
#include <ft2build.h>
#include FT_FREETYPE_H

namespace Emergent
{
Expand All @@ -43,7 +41,7 @@ class FontLoader
bool load(const std::string& filename, int size, Font* font);

private:
FT_Library library;
void* library;
};

} // namespace Emergent
Expand Down
1 change: 1 addition & 0 deletions include/emergent/graphics/billboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class BillboardBatch: public SceneObject
struct Range
{
Range();
Range(const Range& range);

Material* material;
std::size_t start;
Expand Down
9 changes: 6 additions & 3 deletions src/emergent/font/font-loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
#include <emergent/font/glyph-metrics.hpp>
#include <iostream>

#include <ft2build.h>
#include FT_FREETYPE_H

namespace Emergent
{

FontLoader::FontLoader()
{
FT_Error error = FT_Init_FreeType(&library);
FT_Error error = FT_Init_FreeType(&static_cast<FT_Library>(library));

if (error != 0)
{
Expand All @@ -39,14 +42,14 @@ FontLoader::FontLoader()

FontLoader::~FontLoader()
{
FT_Done_FreeType(library);
FT_Done_FreeType(static_cast<FT_Library>(library));
}

bool FontLoader::load(const std::string& filename, int size, Font* font)
{
// Create typeface
FT_Face face;
FT_Error error = FT_New_Face(library, filename.c_str(), 0, &face);
FT_Error error = FT_New_Face(static_cast<FT_Library>(library), filename.c_str(), 0, &face);
if (0 != error)
{
std::cerr << "Failed to load FreeType font: error code (" << error << ")" << std::endl;
Expand Down
6 changes: 6 additions & 0 deletions src/emergent/graphics/billboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ BillboardBatch::Range::Range():
length(0)
{}

BillboardBatch::Range::Range(const BillboardBatch::Range& range):
material(range.material),
start(range.start),
length(range.length)
{}

BillboardBatch::BillboardBatch():
vertexSize(0),
vertexCount(0),
Expand Down

0 comments on commit f8ca678

Please sign in to comment.