Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaakman committed Oct 5, 2018
1 parent 45caaba commit 66026f4
Show file tree
Hide file tree
Showing 20 changed files with 11,712 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# vim swap files
*.swp

# Prerequisites
*.d

Expand All @@ -12,7 +15,7 @@
*.pch

# Compiled Dynamic libraries
*.so
*.so*
*.dylib
*.dll

Expand All @@ -27,6 +30,7 @@
*.lib

# Executables
bin/test_*
*.exe
*.out
*.app
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CXX = g++
CFLAGS = -std=c++17
VERSION=1.0.0
LIB_NAME=text-gl


all: lib/lib$(LIB_NAME).so.$(VERSION)

clean:
rm -f bin/test_visual bin/test_encoding lib/lib$(LIB_NAME).so.$(VERSION) obj/*.o core


test: bin/test_visual bin/test_encoding
bin/test_encoding
bin/test_visual data/sample1.svg
bin/test_visual data/sample2.svg


bin/test_visual: tests/visual.cpp lib/lib$(LIB_NAME).so.$(VERSION)
mkdir -p bin
$(CXX) $(CFLAGS) -I include $^ -lboost_filesystem -lboost_system -lGL -lGLEW -lSDL2 -o $@


bin/test_encoding: tests/encoding.cpp lib/lib$(LIB_NAME).so.$(VERSION)
mkdir -p bin
$(CXX) $(CFLAGS) -I include -fexec-charset=UTF-8 $^ -lboost_unit_test_framework -o $@


lib/lib$(LIB_NAME).so.$(VERSION): obj/parse.o obj/image.o obj/utf8.o obj/error.o obj/tex.o obj/text.o
mkdir -p lib
$(CXX) $(CFLAGS) $^ -lGL -lxml2 -lcairo -o $@ -fPIC -shared


obj/%.o: src/%.cpp include/text-gl/font.h include/text-gl/text.h include/text-gl/utf8.h
mkdir -p obj
$(CXX) $(CFLAGS) -I include/text-gl -c $< -o $@ -fPIC

install:
/usr/bin/install -d -m755 /usr/local/lib
/usr/bin/install -d -m755 /usr/local/include/text-gl
/usr/bin/install -m644 lib/lib$(LIB_NAME).so.$(VERSION) /usr/local/lib/lib$(LIB_NAME).so.$(VERSION)
ln -sf /usr/local/lib/lib$(LIB_NAME).so.$(VERSION) /usr/local/lib/lib$(LIB_NAME).so
/usr/bin/install -D include/xml-mesh/*.h /usr/local/include/xml-mesh/

uninstall:
rm -f /usr/local/lib/lib$(LIB_NAME).so* /usr/local/include/text-gl/*.h
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Text GL 1.0.0
A libray that facilitates working with text rendering in OpenGL.

The only supported input font format is SVG. (for now)
See: https://www.w3.org/TR/SVG11/fonts.html

See also the wiki at https://github.com/cbaakman/text-gl/wiki to find out how to import fonts and render text.

## Contents
* An include dir with headers for the library
* A src dir, containing the implementation
* A test dir, containing a unit test and a visual test

## Dependencies
* GNU/MinGW C++ compiler 4.7 or higher.
* LibXML 2.0 or higher: http://xmlsoft.org/
* cairo 1.10.2 or higher: https://cairographics.org/
* OpenGL 3.2 or higher, should be installed on your OS by default, if the hardware supports it.

For the tests, also:
* Boost 1.68.0 or higher: https://www.boost.org/
* GLM 0.9.9.2 or higher: https://glm.g-truc.net/0.9.9/index.html
* GLEW 2.1.0 or higher: http://glew.sourceforge.net/
* LibSDL 2.0.8 or higher: https://www.libsdl.org/download-2.0.php

## Building the Library
On linux, run 'make'. It will generate a .so file under 'lib'.

On Windows run 'build.cmd'. It will generate a .dll file under 'bin' and an import .a under 'lib'.

## Running the Tests
On Linux, run 'make test'.

On Windows, the test is executed automatically when you build the library.

## Installing
On Linux, run 'make install'. Or run 'make uninstall' to undo the installation.

On Windows, add the .dll under 'bin', the import .a under 'lib' and the headers under 'include' to your build path.
37 changes: 37 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set CXX=g++
set CFLAGS=-std=c++17
set VERSION=1.0.0
set LIB_NAME=text-gl


if not exist obj (mkdir obj)
if not exist bin (mkdir bin)
if not exist lib (mkdir lib)

del /Q /F /S obj\* bin\%LIB_NAME%-%VERSION%.dll lib\lib%LIB_NAME%.a

:: Make the library.

@for %%m in (parse image tex utf8 error text) do (
%CXX% %CFLAGS% -I include\text-gl -c src\%%m.cpp -o obj\%%m.o -fPIC

@if %ERRORLEVEL% neq 0 (
goto end
)
)

%CXX% obj\parse.o obj\image.o obj\tex.o obj\utf8.o obj\error.o obj\text.o -lxml2 -lcairo -lopengl32 ^
-o bin\%LIB_NAME%-%VERSION%.dll -shared -fPIC -Wl,--out-implib,lib\lib%LIB_NAME%.a
@if %ERRORLEVEL% neq 0 (
goto end
)

:: Make the tests.

%CXX% %CFLAGS% -I include -fexec-charset=UTF-8 tests\encoding.cpp lib\lib%LIB_NAME%.a ^
-lboost_unit_test_framework -o bin\test_encoding.exe && bin\test_encoding.exe

%CXX% %CFLAGS% -I include tests\visual.cpp lib\lib%LIB_NAME%.a ^
-lxml2 -lcairo -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -o bin\test_visual.exe && bin\test_visual.exe data\sample1.svg

:end
Loading

0 comments on commit 66026f4

Please sign in to comment.