Browse Source

* implemented c# header and example
* added debug output
* refactored docu

Bergmann89 3 years ago
parent
commit
4818c720f9
56 changed files with 43638 additions and 33103 deletions
  1. 14 14
      .gitignore
  2. 9 9
      .gitmodules
  3. 17 0
      README.md
  4. 42 18
      build_release.sh
  5. 7589 0
      doc/docu.html
  6. 1422 0
      doc/docu.md
  7. 0 1347
      doc/documentation.xhtml
  8. 11 11
      header/examples/c/Makefile
  9. 178 178
      header/examples/c/example.c
  10. 9 9
      header/examples/c/example.h
  11. 15 15
      header/examples/c/helper.h
  12. 56 56
      header/examples/c/main-gnuc.c
  13. 158 158
      header/examples/c/main-mingw.c
  14. 11 11
      header/examples/cpp/Makefile
  15. 126 126
      header/examples/cpp/example.cpp
  16. 9 9
      header/examples/cpp/example.h
  17. 15 15
      header/examples/cpp/helper.h
  18. 73 73
      header/examples/cpp/main-gnuc.cpp
  19. 181 181
      header/examples/cpp/main-mingw.cpp
  20. 19 0
      header/examples/cs/.gitignore
  21. 6 0
      header/examples/cs/App.config
  22. 9 0
      header/examples/cs/App.xaml
  23. 13 0
      header/examples/cs/App.xaml.cs
  24. 20 0
      header/examples/cs/MainWindow.xaml
  25. 168 0
      header/examples/cs/MainWindow.xaml.cs
  26. 55 0
      header/examples/cs/Properties/AssemblyInfo.cs
  27. 63 0
      header/examples/cs/Properties/Resources.Designer.cs
  28. 117 0
      header/examples/cs/Properties/Resources.resx
  29. 26 0
      header/examples/cs/Properties/Settings.Designer.cs
  30. 7 0
      header/examples/cs/Properties/Settings.settings
  31. 129 0
      header/examples/cs/libTextSuiteExample.csproj
  32. 22 0
      header/examples/cs/libTextSuiteExample.sln
  33. 20638 20638
      header/examples/fpc/dglOpenGL.pas
  34. 92 92
      header/examples/fpc/example.lpi
  35. 31 31
      header/examples/fpc/example.lpr
  36. 13 13
      header/examples/fpc/uMainForm.lfm
  37. 874 874
      header/examples/fpc/uMainForm.pas
  38. 1819 0
      header/libTextSuite.cs
  39. 819 819
      header/libTextSuite.h
  40. 2348 2341
      header/libTextSuite.hpp
  41. 2584 2584
      header/ulibTextSuite.pas
  42. 4 4
      inc/utsTextSuite.inc
  43. 542 460
      libTextSuite.lpi
  44. 116 117
      libTextSuite.lpr
  45. 1 1
      src/TextSuite
  46. 83 77
      src/ultsChar.pas
  47. 200 187
      src/ultsContext.pas
  48. 336 306
      src/ultsFont.pas
  49. 207 196
      src/ultsFontCreator.pas
  50. 120 77
      src/ultsGeneral.pas
  51. 496 458
      src/ultsImage.pas
  52. 304 284
      src/ultsPostProcessor.pas
  53. 452 394
      src/ultsRenderer.pas
  54. 530 482
      src/ultsTextBlock.pas
  55. 89 89
      src/ultsTypes.pas
  56. 351 349
      src/ultsUtils.pas

+ 14 - 14
.gitignore

@@ -1,14 +1,14 @@
1
-lib/
2
-bin/
3
-debug/
4
-inc/utsTextSuiteVersion.inc
5
-*.so
6
-*.lps
7
-*.exe
8
-*.res
9
-*.ico
10
-*.dbg
11
-*.dll
12
-*.zip
13
-*.heaptrc
14
-*.heaptrace
1
+lib/
2
+bin/
3
+debug/
4
+inc/utsTextSuiteVersion.inc
5
+*.so
6
+*.lps
7
+*.exe
8
+*.res
9
+*.ico
10
+*.dbg
11
+*.dll
12
+*.zip
13
+*.heaptrc
14
+*.heaptrace

+ 9 - 9
.gitmodules

@@ -1,9 +1,9 @@
1
-[submodule "src/TextSuite"]
2
-	path = src/TextSuite
3
-	url = b3rgmann@git.bergmann89.de:opengl/TextSuite.git
4
-[submodule "src/OpenGLCore"]
5
-	path = src/OpenGLCore
6
-	url = b3rgmann@git.bergmann89.de:opengl/OpenGLCore.git
7
-[submodule "src/Utils"]
8
-	path = src/Utils
9
-	url = b3rgmann@git.bergmann89.de:freepascal/utils.git
1
+[submodule "src/TextSuite"]
2
+	path = src/TextSuite
3
+	url = b3rgmann@git.bergmann89.de:opengl/TextSuite.git
4
+[submodule "src/OpenGLCore"]
5
+	path = src/OpenGLCore
6
+	url = b3rgmann@git.bergmann89.de:opengl/OpenGLCore.git
7
+[submodule "src/Utils"]
8
+	path = src/Utils
9
+	url = b3rgmann@git.bergmann89.de:freepascal/utils.git

+ 17 - 0
README.md

@@ -0,0 +1,17 @@
1
+# Overview
2
+
3
+libTextSuite is a dynamic library that encapsulate the [TextSuite](https://git.bergmann89.de/opengl/TextSuite) project to be able to use it on different platforms and programming languages. Out of the box the following platforms and languages are supported.
4
+
5
+- __supported platforms__
6
+    - i386-win32
7
+    - x64_64-win64
8
+    - i386-linux
9
+    - x86_64-linux
10
+- __supported languages__
11
+    - C
12
+    - C++
13
+    - C#
14
+    - FPC
15
+    - (Delphi)
16
+
17
+A detailed [Documentation](./doc/docu.md) is shipped with every copy of libTextSuite.

+ 42 - 18
build_release.sh

@@ -12,6 +12,7 @@ DOCU_DIR="$SCRIPTDIR/doc"
12 12
 INC_MAJOR=false
13 13
 INC_MINOR=false
14 14
 INC_BUGFIX=false
15
+ALLZIPDIR="$SCRIPTDIR/TextSuite-all"
15 16
 
16 17
 if [ -z "$FIRST_VERSION" ]; then
17 18
   FIRST_VERSION="0.0.0.0"
@@ -133,7 +134,7 @@ printf "const Version = 'v$NEWVERSION $HASH';" > inc/utsTextSuiteVersion.inc
133 134
 function BuildConfig()
134 135
 {
135 136
   CONFIG=$1
136
-  POSTFIX=$2
137
+  TARGET=$2
137 138
   FILEEXT=$3
138 139
   DBGEXT=".dbg"
139 140
 
@@ -144,36 +145,47 @@ function BuildConfig()
144 145
     cleaupAndExit 1
145 146
   fi
146 147
 
147
-  ZIPDIR="bin/$POSTFIX"
148
-  BINDIR="$ZIPDIR"
149
-  ZIPPATH="$SCRIPTDIR/libTextSuite-$POSTFIX.zip"
148
+  BINDIR="$SCRIPTDIR/bin"
149
+  ZIPDIR="$SCRIPTDIR/TextSuite-$TARGET"
150
+  ZIPPATH="$SCRIPTDIR/TextSuite-$TARGET.zip"
150 151
   if [ -n "$TAGNAME" ]; then
151 152
     mkdir -p "$SCRIPTDIR/$TAGNAME/"
152
-    ZIPPATH="$SCRIPTDIR/$TAGNAME/libTextSuite-$POSTFIX.zip"
153
+    ZIPPATH="$SCRIPTDIR/$TAGNAME/TextSuite-$TARGET.zip"
153 154
   fi
154
-  BINNAME="libTextSuite-$POSTFIX$FILEEXT"
155
-  DBGNAME="libTextSuite-$POSTFIX$DBGEXT"
155
+  TARGETDIR="$BINDIR/$TARGET"
156
+  BINNAME="$TARGETDIR/libtextsuite$FILEEXT"
157
+  DBGNAME="$TARGETDIR/libtextsuite$DBGEXT"
156 158
   if [ ! -f $BINNAME ]; then
157
-    echo "file not found: $EXENAME"
159
+    echo "file not found: $BINNAME"
158 160
     cleaupAndExit 2
159 161
   fi
160
-
162
+    
163
+  # extract debug infos
161 164
   cp "$BINNAME" "$DBGNAME" || { log "unable to copy binary to *.dbg"; cleaupAndExit 3; }
162 165
   objcopy --only-keep-debug "$DBGNAME" || { log "unable to strip $DBGNAME"; cleaupAndExit 3; }
163 166
   objcopy --strip-debug --strip-unneeded "$BINNAME" || { log "unable to copy binary to $BINNAME"; cleaupAndExit 3; }
164 167
   objcopy --add-gnu-debuglink "$DBGNAME" "$BINNAME" || { log "unable to create debug link"; cleaupAndExit 3; }
168
+  
169
+  if [ ! -f $DBGNAME ]; then
170
+    echo "file not found: $DBGNAME"
171
+    cleaupAndExit 2
172
+  fi
165 173
 
166
-  mkdir -p $BINDIR
167
-  mv "$BINNAME" "$BINDIR/" || { log "unable to copy linked binary"; cleaupAndExit 3; }
168
-  mv "$DBGNAME" "$BINDIR/" || { log "unable to copy linked debug infos"; cleaupAndExit 3; }
169
-  # use this to copy data folder instead of data archive: cp -R --preserve=links data $BINDIR || { log "unable to copy data folder"; cleaupAndExit 4; }
170
-  cp -r "$HEADER_DIR" "$BINDIR" || { log "unable to copy header files"; cleaupAndExit 4; }
171
-  cp -r "$DOCU_DIR" "$BINDIR/docu" || { log "unable to copy documentation files"; cleaupAndExit 5; }
174
+  # copy header and docu
175
+  mkdir -p "$ZIPDIR/bin"
176
+  cp -r "$TARGETDIR" "$ZIPDIR/bin" || { log "unable to copy binaries"; cleaupAndExit 3; }
177
+  cp -r "$HEADER_DIR" "$ZIPDIR" || { log "unable to copy header files"; cleaupAndExit 4; }
178
+  cp -r "$DOCU_DIR" "$ZIPDIR/docu" || { log "unable to copy documentation files"; cleaupAndExit 5; }
172 179
   
173
-  pushd $ZIPDIR 
174
-  rm -rf $ZIPPATH
175
-  zip -r $ZIPPATH ./* || { log "unable to create zip archive"; cleaupAndExit 6; }
180
+  pushd "$ZIPDIR"
181
+  rm -rf "$ZIPPATH"
182
+  zip -r "$ZIPPATH" "." || { log "unable to create zip archive"; cleaupAndExit 6; }
176 183
   popd
184
+  
185
+  mkdir -p "$ALLZIPDIR"
186
+  echo "mv $ZIPDIR/* $ALLZIPDIR/"
187
+  cp -rf $ZIPDIR/* $ALLZIPDIR/ || { log "unable to copy binaries to all directory"; cleaupAndExit 3; }
188
+  rm -rf "$ZIPDIR"
177 189
 }
178 190
 
179 191
 while [[ $# -gt 0 ]]; do
@@ -218,5 +230,17 @@ BuildConfig "Win64Release" "x86_64-win64" ".dll"
218 230
 BuildConfig "Linux32Release" "i386-linux" ".so"
219 231
 BuildConfig "Linux64Release" "x86_64-linux" ".so"
220 232
 
233
+ALLZIPPATH="$SCRIPTDIR/TextSuite-all.zip"
234
+if [ -n "$TAGNAME" ]; then
235
+  mkdir -p "$SCRIPTDIR/$TAGNAME/"
236
+  ALLZIPPATH="$SCRIPTDIR/$TAGNAME/TextSuite-all.zip"
237
+fi
238
+
239
+pushd "$ALLZIPDIR"
240
+  rm -rf "$ALLZIPPATH"
241
+  zip -r "$ALLZIPPATH" "." || { log "unable to create zip archive"; cleaupAndExit 6; }
242
+popd
243
+rm -rf "$ALLZIPDIR"
244
+
221 245
 cleaupAndExit 0
222 246
 

File diff suppressed because it is too large
+ 7589 - 0
doc/docu.html


File diff suppressed because it is too large
+ 1422 - 0
doc/docu.md


File diff suppressed because it is too large
+ 0 - 1347
doc/documentation.xhtml


+ 11 - 11
header/examples/c/Makefile

@@ -1,12 +1,12 @@
1
-all:
2
-	$(info call one of the following rules to build for a specific compiler: mingw, gnuc)
3
-
4
-mingw:
5
-	gcc -DWIN32 example.c main-mingw.c -lopengl32 -mwindows -o example.exe
6
-
7
-gnuc:
8
-	gcc -DLINUX -o example main-gnuc.c example.c -lGL -lGLU -lglut -ldl
9
-
10
-clean:
11
-	rm -rf example
1
+all:
2
+	$(info call one of the following rules to build for a specific compiler: mingw, gnuc)
3
+
4
+mingw:
5
+	gcc -DWIN32 example.c main-mingw.c -lopengl32 -mwindows -o example.exe
6
+
7
+gnuc:
8
+	gcc -DLINUX -o example main-gnuc.c example.c -lGL -lGLU -lglut -ldl
9
+
10
+clean:
11
+	rm -rf example
12 12
 	rm -rf example.exe

+ 178 - 178
header/examples/c/example.c

@@ -1,179 +1,179 @@
1
-#include <stdio.h>
2
-#include <GL/gl.h>
3
-
4
-#include "example.h"
5
-#include "helper.h"
6
-#ifdef LINUX
7
-#  include "../../libTextSuite.h"
8
-#else
9
-#  include "..\..\libTextSuite.h"
10
-#endif
11
-
12
-#if _WIN64
13
-#  define LIB_NAME "..\\..\\..\\libTextSuite-x86_64-win64.dll"
14
-#elif _WIN32
15
-#  define LIB_NAME "..\\..\\..\\libTextSuite-i386-win32.dll"
16
-#elif __linux__ && (__amd64 || __x86_64 || _M_AMD64 || __ppc64__)
17
-#  define LIB_NAME "../../../libTextSuite-x86_64-linux.so"
18
-#elif __linux__ && (__i386 || _X86_)
19
-#  define LIB_NAME "../../../libTextSuite-i386-linux.so"
20
-#else
21
-#  error 'unknown operation system'
22
-#endif
23
-
24
-#ifdef LINUX
25
-#   define FontCreator ltsFontCreatorFreeType
26
-#else
27
-#   define FontCreator ltsFontCreatorGDI
28
-#endif
29
-
30
-lts_context_handle_t            context;
31
-lts_font_creator_handle_t       creator;
32
-lts_renderer_handle_t           renderer;
33
-lts_font_handle_t               font;
34
-lts_post_processor_handle_t     pp;
35
-lts_post_processor_handle_t     ppFillPattern;
36
-lts_post_processor_handle_t     ppFillColor;
37
-lts_post_processor_handle_t     ppBorder;
38
-
39
-const char*         TEST_TEXT           = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
40
-const lts_wchar_t   CHAR_RANGE_LOREM[]  = { 'L', 'o', 'r', 'e', 'm', 0 };
41
-const lts_wchar_t   CHAR_RANGE_E[]      = { 'e', 0 };
42
-
43
-const uint8_t PATTER_DATA[] = {
44
-    0xFF, 0xBF, 0x7F, 0xBF,
45
-    0xBF, 0xFF, 0xBF, 0x7F,
46
-    0x7F, 0xBF, 0xFF, 0xBF,
47
-    0xBF, 0x7F, 0xBF, 0xFF
48
-};
49
-
50
-void WINAPI execute_post_proc(lts_char_handle_t charHandle, lts_image_handle_t imageHandle)
51
-{
52
-    lts_post_processor_execute(ppFillPattern, charHandle, imageHandle);
53
-    lts_post_processor_execute(ppFillColor,   charHandle, imageHandle);
54
-    lts_post_processor_execute(ppBorder,      charHandle, imageHandle);
55
-}
56
-
57
-bool exampleInit()
58
-{
59
-    if (lts_initialize(LIB_NAME) != ltsErrNone)
60
-    {
61
-        showMessage("unable to initialize library");
62
-        return false;
63
-    }
64
-    
65
-    context = lts_context_create();
66
-    if (!context)
67
-    {
68
-        showMessage("unable to create text suite context");
69
-        return false;
70
-    }
71
-    
72
-    renderer = lts_renderer_create(context, ltsRendererOpenGL, ltsFormatRGBA8);
73
-    if (!renderer)
74
-    {
75
-        showMessage("unable to create text suite renderer");
76
-        return false;
77
-    }
78
-    
79
-    creator = lts_font_creator_create(context, FontCreator);
80
-    if (!creator)
81
-    {
82
-        showMessage("unable to create text suite creator");
83
-        return false;
84
-    }
85
-    
86
-    lts_post_processor_custom_data_t ppData;
87
-    ppData.args    = NULL;
88
-    ppData.execute = &execute_post_proc;
89
-    pp = lts_post_processor_custom_create(context, &ppData);
90
-    if (!pp)
91
-    {
92
-        showMessage("unable to create custom post processor");
93
-        return false;
94
-    }
95
-    
96
-    lts_image_handle_t img = lts_image_create(context);
97
-    lts_image_create_empty(img, ltsFormatAlpha8, 4, 4);
98
-    void* imgData = lts_image_get_data(img);
99
-    if (img) memcpy(imgData, &PATTER_DATA[0], 16);
100
-    ppFillPattern = lts_post_processor_fill_pattern_create(context, img, true, ltsPosition(0, 0), LTS_IMAGE_MODES_MODULATE_ALL, LTS_COLOR_CHANNELS_RGBA);
101
-    lts_post_processor_add_chars(ppFillPattern, ltsUsageInclude, &CHAR_RANGE_LOREM[0]);
102
-    
103
-    ppFillColor = lts_post_processor_fill_color_create(context, ltsColor4f(0.0, 0.0, 0.5, 1.0), LTS_IMAGE_MODES_REPLACE_ALL, LTS_COLOR_CHANNELS_RGB);
104
-    lts_post_processor_add_chars(ppFillColor, ltsUsageExclude, &CHAR_RANGE_E[0]);
105
-    
106
-    ppBorder = lts_post_processor_border_create(context, 3.0, 0.5, ltsColor4f(0.0, 0.5, 0.0, 1.0), true);
107
-    lts_post_processor_add_chars(ppBorder, ltsUsageInclude, &CHAR_RANGE_E[0]);
108
-    
109
-    font = lts_font_creator_get_font_by_file(creator, "../Prototype.ttf", 40, 0, ltsAANormal);
110
-    if (!font)
111
-    {
112
-        showMessage("unable to create text suite font");
113
-        return false;
114
-    }
115
-    if (lts_font_set_post_processor(font, pp) != ltsErrNone)
116
-    {
117
-        showMessage("unable to set post processor");
118
-        return false;
119
-    }
120
-    
121
-    return true;
122
-}
123
-
124
-bool exampleRender(int width, int height)
125
-{
126
-    const lts_color4f_t color = { 1.0, 1.0, 1.0, 1.0 };
127
-    glEnable(GL_BLEND);
128
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
129
-    lts_block_flags_t flags = 0;
130
-    FLAGS_SET(flags, ltsBlockFlagWordWrap);
131
-    lts_text_block_handle_t textBlock = lts_renderer_begin_block(renderer, 10, 10, width-20, height-20, flags);
132
-    if (!textBlock)
133
-    {
134
-        showMessage(lts_get_last_error_msg());
135
-        return false;
136
-    }
137
-    if (lts_text_block_set_horz_align(textBlock, ltsHorzAlignJustify) != ltsErrNone)
138
-    {
139
-        showMessage("unable to set horizontal alignment");
140
-        return false;
141
-    }
142
-    if (lts_text_block_set_font(textBlock, font) != ltsErrNone)
143
-    {
144
-        showMessage("unable to set font");
145
-        return false;
146
-    }
147
-    if (lts_text_block_set_color(textBlock, color) != ltsErrNone)
148
-    {
149
-        showMessage("unable to set font");
150
-        return false;
151
-    }
152
-    if (lts_text_block_text_out_a(textBlock, TEST_TEXT) != ltsErrNone)
153
-    {
154
-        showMessage("unable to print text");
155
-        return false;
156
-    }
157
-    if (lts_renderer_end_block(renderer, textBlock) != ltsErrNone)
158
-    {
159
-        showMessage("unable to finish text block");
160
-        return false;
161
-    }
162
-    //lts_text_block_destroy(textBlock);
163
-    glDisable(GL_BLEND);
164
-    
165
-    return true;
166
-}
167
-
168
-void exampleFinish()
169
-{
170
-    lts_font_destroy(font);
171
-    lts_post_processor_destroy(ppBorder);
172
-    lts_post_processor_destroy(ppFillColor);
173
-    lts_post_processor_destroy(ppFillPattern);
174
-    lts_post_processor_destroy(pp);
175
-    lts_font_creator_destroy(creator);
176
-    lts_renderer_destroy(creator);
177
-    lts_context_destroy(context);
178
-    lts_finalize();
1
+#include <stdio.h>
2
+#include <GL/gl.h>
3
+
4
+#include "example.h"
5
+#include "helper.h"
6
+#ifdef LINUX
7
+#  include "../../libTextSuite.h"
8
+#else
9
+#  include "..\..\libTextSuite.h"
10
+#endif
11
+
12
+#if _WIN64
13
+#  define LIB_NAME "..\\..\\..\\bin\\x86_64-win64\\libtextsuite.dll"
14
+#elif _WIN32
15
+#  define LIB_NAME "..\\..\\..\\bin\\i386-win32\\libtextsuite.dll"
16
+#elif __linux__ && (__amd64 || __x86_64 || _M_AMD64 || __ppc64__)
17
+#  define LIB_NAME "../../../bin/x86_64-linux/libtextsuite.so"
18
+#elif __linux__ && (__i386 || _X86_)
19
+#  define LIB_NAME "../../../bin/i386-linux/libtextsuite.so"
20
+#else
21
+#  error 'unknown operation system'
22
+#endif
23
+
24
+#ifdef LINUX
25
+#   define FontCreator ltsFontCreatorFreeType
26
+#else
27
+#   define FontCreator ltsFontCreatorGDI
28
+#endif
29
+
30
+lts_context_handle_t            context;
31
+lts_font_creator_handle_t       creator;
32
+lts_renderer_handle_t           renderer;
33
+lts_font_handle_t               font;
34
+lts_post_processor_handle_t     pp;
35
+lts_post_processor_handle_t     ppFillPattern;
36
+lts_post_processor_handle_t     ppFillColor;
37
+lts_post_processor_handle_t     ppBorder;
38
+
39
+const char*         TEST_TEXT           = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
40
+const lts_wchar_t   CHAR_RANGE_LOREM[]  = { 'L', 'o', 'r', 'e', 'm', 0 };
41
+const lts_wchar_t   CHAR_RANGE_E[]      = { 'e', 0 };
42
+
43
+const uint8_t PATTER_DATA[] = {
44
+    0xFF, 0xBF, 0x7F, 0xBF,
45
+    0xBF, 0xFF, 0xBF, 0x7F,
46
+    0x7F, 0xBF, 0xFF, 0xBF,
47
+    0xBF, 0x7F, 0xBF, 0xFF
48
+};
49
+
50
+void WINAPI execute_post_proc(lts_char_handle_t charHandle, lts_image_handle_t imageHandle)
51
+{
52
+    lts_post_processor_execute(ppFillPattern, charHandle, imageHandle);
53
+    lts_post_processor_execute(ppFillColor,   charHandle, imageHandle);
54
+    lts_post_processor_execute(ppBorder,      charHandle, imageHandle);
55
+}
56
+
57
+bool exampleInit()
58
+{
59
+    if (lts_initialize(LIB_NAME) != ltsErrNone)
60
+    {
61
+        showMessage("unable to initialize library");
62
+        return false;
63
+    }
64
+    
65
+    context = lts_context_create();
66
+    if (!context)
67
+    {
68
+        showMessage("unable to create text suite context");
69
+        return false;
70
+    }
71
+    
72
+    renderer = lts_renderer_create(context, ltsRendererOpenGL, ltsFormatRGBA8);
73
+    if (!renderer)
74
+    {
75
+        showMessage("unable to create text suite renderer");
76
+        return false;
77
+    }
78
+    
79
+    creator = lts_font_creator_create(context, FontCreator);
80
+    if (!creator)
81
+    {
82
+        showMessage("unable to create text suite creator");
83
+        return false;
84
+    }
85
+    
86
+    lts_post_processor_custom_data_t ppData;
87
+    ppData.args    = NULL;
88
+    ppData.execute = &execute_post_proc;
89
+    pp = lts_post_processor_custom_create(context, &ppData);
90
+    if (!pp)
91
+    {
92
+        showMessage("unable to create custom post processor");
93
+        return false;
94
+    }
95
+    
96
+    lts_image_handle_t img = lts_image_create(context);
97
+    lts_image_create_empty(img, ltsFormatAlpha8, 4, 4);
98
+    void* imgData = lts_image_get_data(img);
99
+    if (img) memcpy(imgData, &PATTER_DATA[0], 16);
100
+    ppFillPattern = lts_post_processor_fill_pattern_create(context, img, true, ltsPosition(0, 0), LTS_IMAGE_MODES_MODULATE_ALL, LTS_COLOR_CHANNELS_RGBA);
101
+    lts_post_processor_add_chars(ppFillPattern, ltsUsageInclude, &CHAR_RANGE_LOREM[0]);
102
+    
103
+    ppFillColor = lts_post_processor_fill_color_create(context, ltsColor4f(0.0, 0.0, 0.5, 1.0), LTS_IMAGE_MODES_REPLACE_ALL, LTS_COLOR_CHANNELS_RGB);
104
+    lts_post_processor_add_chars(ppFillColor, ltsUsageExclude, &CHAR_RANGE_E[0]);
105
+    
106
+    ppBorder = lts_post_processor_border_create(context, 3.0, 0.5, ltsColor4f(0.0, 0.5, 0.0, 1.0), true);
107
+    lts_post_processor_add_chars(ppBorder, ltsUsageInclude, &CHAR_RANGE_E[0]);
108
+    
109
+    font = lts_font_creator_get_font_by_file(creator, "../Prototype.ttf", 40, 0, ltsAANormal);
110
+    if (!font)
111
+    {
112
+        showMessage("unable to create text suite font");
113
+        return false;
114
+    }
115
+    if (lts_font_set_post_processor(font, pp) != ltsErrNone)
116
+    {
117
+        showMessage("unable to set post processor");
118
+        return false;
119
+    }
120
+    
121
+    return true;
122
+}
123
+
124
+bool exampleRender(int width, int height)
125
+{
126
+    const lts_color4f_t color = { 1.0, 1.0, 1.0, 1.0 };
127
+    glEnable(GL_BLEND);
128
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
129
+    lts_block_flags_t flags = 0;
130
+    FLAGS_SET(flags, ltsBlockFlagWordWrap);
131
+    lts_text_block_handle_t textBlock = lts_renderer_begin_block(renderer, 10, 10, width-20, height-20, flags);
132
+    if (!textBlock)
133
+    {
134
+        showMessage(lts_get_last_error_msg());
135
+        return false;
136
+    }
137
+    if (lts_text_block_set_horz_align(textBlock, ltsHorzAlignJustify) != ltsErrNone)
138
+    {
139
+        showMessage("unable to set horizontal alignment");
140
+        return false;
141
+    }
142
+    if (lts_text_block_set_font(textBlock, font) != ltsErrNone)
143
+    {
144
+        showMessage("unable to set font");
145
+        return false;
146
+    }
147
+    if (lts_text_block_set_color(textBlock, color) != ltsErrNone)
148
+    {
149
+        showMessage("unable to set font");
150
+        return false;
151
+    }
152
+    if (lts_text_block_text_out_a(textBlock, TEST_TEXT) != ltsErrNone)
153
+    {
154
+        showMessage("unable to print text");
155
+        return false;
156
+    }
157
+    if (lts_renderer_end_block(renderer, textBlock) != ltsErrNone)
158
+    {
159
+        showMessage("unable to finish text block");
160
+        return false;
161
+    }
162
+    //lts_text_block_destroy(textBlock);
163
+    glDisable(GL_BLEND);
164
+    
165
+    return true;
166
+}
167
+
168
+void exampleFinish()
169
+{
170
+    lts_font_destroy(font);
171
+    lts_post_processor_destroy(ppBorder);
172
+    lts_post_processor_destroy(ppFillColor);
173
+    lts_post_processor_destroy(ppFillPattern);
174
+    lts_post_processor_destroy(pp);
175
+    lts_font_creator_destroy(creator);
176
+    lts_renderer_destroy(creator);
177
+    lts_context_destroy(context);
178
+    lts_finalize();
179 179
 }

+ 9 - 9
header/examples/c/example.h

@@ -1,10 +1,10 @@
1
-#ifndef EXAMPLE_H
2
-#define EXAMPLE_H
3
-
4
-#include <stdbool.h>
5
-
6
-bool exampleInit();
7
-bool exampleRender(int width, int height);
8
-void exampleFinish();
9
-
1
+#ifndef EXAMPLE_H
2
+#define EXAMPLE_H
3
+
4
+#include <stdbool.h>
5
+
6
+bool exampleInit();
7
+bool exampleRender(int width, int height);
8
+void exampleFinish();
9
+
10 10
 #endif /* EXAMPLE_H */

+ 15 - 15
header/examples/c/helper.h

@@ -1,16 +1,16 @@
1
-#ifndef HELPER_H
2
-#define HELPER_H
3
-
4
-#if defined(WIN32)
5
-#include <windows.h>
6
-extern HWND hwnd;
7
-static inline void showMessage(const char* msg)
8
-    { MessageBox(hwnd, msg, "TextSuiteExample Error", MB_OK); };
9
-    
10
-#elif defined(LINUX)
11
-#include <stdio.h>
12
-static inline void showMessage(const char* msg)
13
-    { printf("%s\n", msg); };
14
-#endif
15
-
1
+#ifndef HELPER_H
2
+#define HELPER_H
3
+
4
+#if defined(WIN32)
5
+#include <windows.h>
6
+extern HWND hwnd;
7
+static inline void showMessage(const char* msg)
8
+    { MessageBox(hwnd, msg, "TextSuiteExample Error", MB_OK); };
9
+    
10
+#elif defined(LINUX)
11
+#include <stdio.h>
12
+static inline void showMessage(const char* msg)
13
+    { printf("%s\n", msg); };
14
+#endif
15
+
16 16
 #endif /* HELPER_H */

+ 56 - 56
header/examples/c/main-gnuc.c

@@ -1,57 +1,57 @@
1
-#include <GL/gl.h>
2
-#include <GL/glut.h>
3
-
4
-#include "example.h"
5
-#include "helper.h"
6
-
7
-static int windowId;
8
-static int screenw, screenh;
9
-
10
-static void Resize(int width, int height)
11
-{
12
-    screenw = width;
13
-    screenh = height;
14
-    
15
-    glViewport(0, 0, screenw, screenh);
16
-    
17
-    glMatrixMode(GL_PROJECTION);
18
-    glLoadIdentity();
19
-    glOrtho(0, screenw, screenh, 0, -10, 10);
20
-    
21
-    glMatrixMode(GL_MODELVIEW);
22
-    glLoadIdentity();
23
-}
24
-
25
-static void Render(void)
26
-{
27
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
28
-    
29
-    if (!exampleRender(screenw, screenh))
30
-    {
31
-        glutDestroyWindow(windowId);
32
-        return;
33
-    }
34
-    
35
-    glutSwapBuffers();
36
-}
37
-
38
-int main(int argc, char** argv)
39
-{
40
-    glutInit(&argc, argv);
41
-
42
-    glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
43
-    glutInitWindowSize(640, 480);
44
-    windowId = glutCreateWindow("libTextSuite example");
45
-
46
-    glClearColor(1.0, 1.0, 1.0, 1.0);
47
-    
48
-    if (!exampleInit())
49
-        return 1;
50
-    
51
-    glutReshapeFunc(Resize);
52
-    glutDisplayFunc(Render);
53
-
54
-    glutMainLoop();
55
-    
56
-    exampleFinish();
1
+#include <GL/gl.h>
2
+#include <GL/glut.h>
3
+
4
+#include "example.h"
5
+#include "helper.h"
6
+
7
+static int windowId;
8
+static int screenw, screenh;
9
+
10
+static void Resize(int width, int height)
11
+{
12
+    screenw = width;
13
+    screenh = height;
14
+    
15
+    glViewport(0, 0, screenw, screenh);
16
+    
17
+    glMatrixMode(GL_PROJECTION);
18
+    glLoadIdentity();
19
+    glOrtho(0, screenw, screenh, 0, -10, 10);
20
+    
21
+    glMatrixMode(GL_MODELVIEW);
22
+    glLoadIdentity();
23
+}
24
+
25
+static void Render(void)
26
+{
27
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
28
+    
29
+    if (!exampleRender(screenw, screenh))
30
+    {
31
+        glutDestroyWindow(windowId);
32
+        return;
33
+    }
34
+    
35
+    glutSwapBuffers();
36
+}
37
+
38
+int main(int argc, char** argv)
39
+{
40
+    glutInit(&argc, argv);
41
+
42
+    glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
43
+    glutInitWindowSize(640, 480);
44
+    windowId = glutCreateWindow("libTextSuite example");
45
+
46
+    glClearColor(1.0, 1.0, 1.0, 1.0);
47
+    
48
+    if (!exampleInit())
49
+        return 1;
50
+    
51
+    glutReshapeFunc(Resize);
52
+    glutDisplayFunc(Render);
53
+
54
+    glutMainLoop();
55
+    
56
+    exampleFinish();
57 57
 }

+ 158 - 158
header/examples/c/main-mingw.c

@@ -1,159 +1,159 @@
1
-#include <windows.h>
2
-#include <Wingdi.h>
3
-#include <GL/gl.h>
4
-
5
-#include "example.h"
6
-
7
-const char g_szClassName[] = "OpenGLWindowClass";
8
-
9
-HDC hdc;
10
-HGLRC hglrc;
11
-HWND hwnd;
12
-int done = 0;
13
-
14
-int screenw, screenh;
15
-
16
-void SysShutdown (void)
17
-{
18
-    done = 1;
19
-    exampleFinish();
20
-    wglMakeCurrent(hdc, NULL);
21
-    wglDeleteContext(hglrc);
22
-    PostQuitMessage(0);
23
-}
24
-
25
-void setPixelFormat()
26
-{
27
-    PIXELFORMATDESCRIPTOR pfd =
28
-    {
29
-        sizeof(PIXELFORMATDESCRIPTOR),
30
-        1,
31
-        PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
32
-        PFD_TYPE_RGBA,
33
-        32,
34
-        0,0,0,0,0,0,0,0,0,0,0,0,0, // useles parameters
35
-        16,
36
-        0,0,0,0,0,0,0
37
-    };
38
-    int indexPixelFormat = ChoosePixelFormat(hdc, &pfd);
39
-    SetPixelFormat(hdc, indexPixelFormat, &pfd);
40
-}
41
-
42
-LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
43
-{
44
-    switch(msg)
45
-    {
46
-        case WM_CREATE:
47
-            if ((hdc = GetDC(hwnd)) == NULL)	// get device context
48
-            {
49
-                MessageBox(hwnd, "Failed to Get the Window Device Context", "Device Context Error", MB_OK);
50
-                SysShutdown();
51
-                break;
52
-            }
53
-            setPixelFormat();
54
-            if ((hglrc = wglCreateContext(hdc)) == NULL)
55
-            {
56
-                MessageBox(hwnd, "Failed to Create the OpenGL Rendering Context", "OpenGL Rendering Context Error", MB_OK);
57
-                SysShutdown();
58
-                break;
59
-            }
60
-            if (!wglMakeCurrent(hdc, hglrc))
61
-            {
62
-                MessageBox(hwnd, "Failed to make OpenGL Rendering Context current", "OpenGL Rendering Context Error", MB_OK);
63
-                SysShutdown();
64
-                break;
65
-            }
66
-            glDisable(GL_DEPTH_TEST);
67
-            glDisable(GL_CULL_FACE);
68
-            if (!exampleInit())
69
-            {
70
-                SysShutdown();
71
-                break;
72
-            }
73
-            break;
74
-        
75
-        case WM_SIZE:
76
-            screenw = LOWORD(lParam);
77
-            screenh = HIWORD(lParam);
78
-            break;
79
-        
80
-        case WM_PAINT:
81
-            glClearColor(1.0, 1.0, 1.0, 1.0);
82
-            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
83
-            glViewport(0, 0, screenw, screenh);
84
-            
85
-            glMatrixMode(GL_PROJECTION);
86
-            glLoadIdentity();
87
-            glOrtho(0, screenw, screenh, 0, -10, 10);
88
-            glMatrixMode(GL_MODELVIEW);
89
-            glLoadIdentity();
90
-            
91
-            if (!exampleRender(screenw, screenh))
92
-                SysShutdown();
93
-            
94
-            SwapBuffers(hdc);
95
-            break;
96
-        
97
-        case WM_CLOSE:
98
-            SysShutdown();
99
-            DestroyWindow(hwnd);
100
-            break;
101
-            
102
-        case WM_DESTROY:
103
-            SysShutdown();
104
-            PostQuitMessage(0);
105
-            break;
106
-            
107
-        default:
108
-            return DefWindowProc(hwnd, msg, wParam, lParam);
109
-    }
110
-    return 0;
111
-}
112
-
113
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
114
-{
115
-    WNDCLASSEX wc;
116
-    MSG Msg;
117
-
118
-    wc.cbSize        = sizeof(WNDCLASSEX);
119
-    wc.style         = 0;
120
-    wc.lpfnWndProc   = WndProc;
121
-    wc.cbClsExtra    = 0;
122
-    wc.cbWndExtra    = 0;
123
-    wc.hInstance     = hInstance;
124
-    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
125
-    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
126
-    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
127
-    wc.lpszMenuName  = NULL;
128
-    wc.lpszClassName = g_szClassName;
129
-    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
130
-
131
-    if(!RegisterClassEx(&wc))
132
-    {
133
-        MessageBox(NULL, "Window Registration Failed!", "Error!",
134
-            MB_ICONEXCLAMATION | MB_OK);
135
-        return 0;
136
-    }
137
-
138
-    if ((hwnd = CreateWindowEx(
139
-        WS_EX_CLIENTEDGE,
140
-        g_szClassName,
141
-        "libTextSuite example",
142
-        WS_OVERLAPPEDWINDOW,
143
-        CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
144
-        NULL, NULL, hInstance, NULL)) == NULL)
145
-    {
146
-        MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
147
-        return 0;
148
-    }
149
-    
150
-    ShowWindow(hwnd, nCmdShow);
151
-    UpdateWindow(hwnd);
152
-        
153
-    while(GetMessage(&Msg, NULL, 0, 0) > 0 && done == 0)
154
-    {
155
-        TranslateMessage(&Msg);
156
-        DispatchMessage(&Msg);
157
-    }
158
-    return Msg.wParam;
1
+#include <windows.h>
2
+#include <Wingdi.h>
3
+#include <GL/gl.h>
4
+
5
+#include "example.h"
6
+
7
+const char g_szClassName[] = "OpenGLWindowClass";
8
+
9
+HDC hdc;
10
+HGLRC hglrc;
11
+HWND hwnd;
12
+int done = 0;
13
+
14
+int screenw, screenh;
15
+
16
+void SysShutdown (void)
17
+{
18
+    done = 1;
19
+    exampleFinish();
20
+    wglMakeCurrent(hdc, NULL);
21
+    wglDeleteContext(hglrc);
22
+    PostQuitMessage(0);
23
+}
24
+
25
+void setPixelFormat()
26
+{
27
+    PIXELFORMATDESCRIPTOR pfd =
28
+    {
29
+        sizeof(PIXELFORMATDESCRIPTOR),
30
+        1,
31
+        PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
32
+        PFD_TYPE_RGBA,
33
+        32,
34
+        0,0,0,0,0,0,0,0,0,0,0,0,0, // useles parameters
35
+        16,
36
+        0,0,0,0,0,0,0
37
+    };
38
+    int indexPixelFormat = ChoosePixelFormat(hdc, &pfd);
39
+    SetPixelFormat(hdc, indexPixelFormat, &pfd);
40
+}
41
+
42
+LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
43
+{
44
+    switch(msg)
45
+    {
46
+        case WM_CREATE:
47
+            if ((hdc = GetDC(hwnd)) == NULL)	// get device context
48
+            {
49
+                MessageBox(hwnd, "Failed to Get the Window Device Context", "Device Context Error", MB_OK);
50
+                SysShutdown();
51
+                break;
52
+            }
53
+            setPixelFormat();
54
+            if ((hglrc = wglCreateContext(hdc)) == NULL)
55
+            {
56
+                MessageBox(hwnd, "Failed to Create the OpenGL Rendering Context", "OpenGL Rendering Context Error", MB_OK);
57
+                SysShutdown();
58
+                break;
59
+            }
60
+            if (!wglMakeCurrent(hdc, hglrc))
61
+            {
62
+                MessageBox(hwnd, "Failed to make OpenGL Rendering Context current", "OpenGL Rendering Context Error", MB_OK);
63
+                SysShutdown();
64
+                break;
65
+            }
66
+            glDisable(GL_DEPTH_TEST);
67
+            glDisable(GL_CULL_FACE);
68
+            if (!exampleInit())
69
+            {
70
+                SysShutdown();
71
+                break;
72
+            }
73
+            break;
74
+        
75
+        case WM_SIZE:
76
+            screenw = LOWORD(lParam);
77
+            screenh = HIWORD(lParam);
78
+            break;
79
+        
80
+        case WM_PAINT:
81
+            glClearColor(1.0, 1.0, 1.0, 1.0);
82
+            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
83
+            glViewport(0, 0, screenw, screenh);
84
+            
85
+            glMatrixMode(GL_PROJECTION);
86
+            glLoadIdentity();
87
+            glOrtho(0, screenw, screenh, 0, -10, 10);
88
+            glMatrixMode(GL_MODELVIEW);
89
+            glLoadIdentity();
90
+            
91
+            if (!exampleRender(screenw, screenh))
92
+                SysShutdown();
93
+            
94
+            SwapBuffers(hdc);
95
+            break;
96
+        
97
+        case WM_CLOSE:
98
+            SysShutdown();
99
+            DestroyWindow(hwnd);
100
+            break;
101
+            
102
+        case WM_DESTROY:
103
+            SysShutdown();
104
+            PostQuitMessage(0);
105
+            break;
106
+            
107
+        default:
108
+            return DefWindowProc(hwnd, msg, wParam, lParam);
109
+    }
110
+    return 0;
111
+}
112
+
113
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
114
+{
115
+    WNDCLASSEX wc;
116
+    MSG Msg;
117
+
118
+    wc.cbSize        = sizeof(WNDCLASSEX);
119
+    wc.style         = 0;
120
+    wc.lpfnWndProc   = WndProc;
121
+    wc.cbClsExtra    = 0;
122
+    wc.cbWndExtra    = 0;
123
+    wc.hInstance     = hInstance;
124
+    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
125
+    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
126
+    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
127
+    wc.lpszMenuName  = NULL;
128
+    wc.lpszClassName = g_szClassName;
129
+    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
130
+
131
+    if(!RegisterClassEx(&wc))
132
+    {
133
+        MessageBox(NULL, "Window Registration Failed!", "Error!",
134
+            MB_ICONEXCLAMATION | MB_OK);
135
+        return 0;
136
+    }
137
+
138
+    if ((hwnd = CreateWindowEx(
139
+        WS_EX_CLIENTEDGE,
140
+        g_szClassName,
141
+        "libTextSuite example",
142
+        WS_OVERLAPPEDWINDOW,
143
+        CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
144
+        NULL, NULL, hInstance, NULL)) == NULL)
145
+    {
146
+        MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
147
+        return 0;
148
+    }
149
+    
150
+    ShowWindow(hwnd, nCmdShow);
151
+    UpdateWindow(hwnd);
152
+        
153
+    while(GetMessage(&Msg, NULL, 0, 0) > 0 && done == 0)
154
+    {
155
+        TranslateMessage(&Msg);
156
+        DispatchMessage(&Msg);
157
+    }
158
+    return Msg.wParam;
159 159
 }

+ 11 - 11
header/examples/cpp/Makefile

@@ -1,12 +1,12 @@
1
-all:
2
-	$(info call one of the following rules to build for a specific compiler: mingw, gnuc)
3
-
4
-mingw:
5
-	g++ -std=c++11 -DWIN32 -static-libgcc -static-libstdc++ main-mingw.cpp example.cpp -lopengl32 -mwindows -o example.exe
6
-
7
-gnuc:
8
-	g++ -std=c++11 -DLINUX -o example main-gnuc.cpp example.cpp -lGL -lGLU -lglut -ldl
9
-
10
-clean:
11
-	rm -rf example
1
+all:
2
+	$(info call one of the following rules to build for a specific compiler: mingw, gnuc)
3
+
4
+mingw:
5
+	g++ -std=c++11 -DWIN32 -static-libgcc -static-libstdc++ main-mingw.cpp example.cpp -lopengl32 -mwindows -o example.exe
6
+
7
+gnuc:
8
+	g++ -g -std=c++11 -DLINUX -o example main-gnuc.cpp example.cpp -lGL -lGLU -lglut -ldl
9
+
10
+clean:
11
+	rm -rf example
12 12
 	rm -rf example.exe

+ 126 - 126
header/examples/cpp/example.cpp

@@ -1,127 +1,127 @@
1
-#include <stdio.h>
2
-#include <GL/gl.h>
3
-#include <string.h>
4
-
5
-#include "example.h"
6
-#include "helper.h"
7
-#ifdef LINUX
8
-#  include "../../libTextSuite.hpp"
9
-#else
10
-#  include "..\..\libTextSuite.hpp"
11
-#endif
12
-
13
-#if _WIN64
14
-    static const std::string LibName("..\\..\\..\\libTextSuite-x86_64-win64.dll");
15
-#elif _WIN32
16
-    static const std::string LibName("..\\..\\..\\libTextSuite-i386-win32.dll");
17
-#elif __linux__ && (__amd64 || __x86_64 || _M_AMD64 || __ppc64__)
18
-    static const std::string LibName("../../../libTextSuite-x86_64-linux.so");
19
-#elif __linux__ && (__i386 || _X86_)
20
-    static const std::string LibName("../../../libTextSuite-i386-linux.so");
21
-#else
22
-#  error 'unknown operation system'
23
-#endif
24
-
25
-#ifdef LINUX
26
-#   define FontCreatorExample FontCreatorFreeType
27
-#else
28
-#   define FontCreatorExample FontCreatorGDI
29
-#endif
30
-
31
-typedef std::unique_ptr<lts::PostProcessor> PostProcessorPtrU;
32
-
33
-std::shared_ptr<lts::Library>       library;
34
-std::shared_ptr<lts::Context>       context;
35
-std::shared_ptr<lts::FontCreator>   creator;
36
-std::shared_ptr<lts::Renderer>      renderer;
37
-std::shared_ptr<lts::Image>         pattern;
38
-std::shared_ptr<lts::Font>          font;
39
-
40
-std::shared_ptr<lts::PostProcessorList<PostProcessorPtrU>> ppList;
41
-
42
-const char*         TEST_TEXT           = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
43
-const lts::WideChar CHAR_RANGE_LOREM[]  = { 'L', 'o', 'r', 'e', 'm', 0 };
44
-const lts::WideChar CHAR_RANGE_E[]      = { 'e', 0 };
45
-
46
-const uint8_t PATTER_DATA[] = {
47
-    0xFF, 0xBF, 0x7F, 0xBF,
48
-    0xBF, 0xFF, 0xBF, 0x7F,
49
-    0x7F, 0xBF, 0xFF, 0xBF,
50
-    0xBF, 0x7F, 0xBF, 0xFF
51
-};
52
-
53
-bool exampleInit()
54
-{
55
-    library.reset(new lts::Library(LibName));
56
-    context.reset(new lts::Context(*library));
57
-    creator.reset(new lts::FontCreatorExample(*context));
58
-    renderer.reset(new lts::RendererOpenGL(*context, lts::Format::RGBA8));
59
-    ppList.reset(new lts::PostProcessorList<PostProcessorPtrU>(*context));
60
-    
61
-    pattern.reset(new lts::Image(*context));
62
-    pattern->createEmpty(lts::Format::Alpha8, 4, 4);
63
-    memcpy(pattern->getData(), &PATTER_DATA[0], 16);
64
-    
65
-    PostProcessorPtrU ppFillPattern(new lts::PostProcessorFillPattern(
66
-        *context,
67
-        *pattern,
68
-        lts::Position{0, 0},
69
-        lts::ImageModeModulateAll,
70
-        lts::ColorChannelsRGBA));
71
-    ppFillPattern->addChars(lts::CharRangeUsage::Include, &CHAR_RANGE_LOREM[0]);
72
-    ppList->push_back(std::move(ppFillPattern));
73
-    
74
-    PostProcessorPtrU ppFillColor(new lts::PostProcessorFillColor(
75
-        *context,
76
-        lts::Color4f{ 0.0, 0.0, 0.5, 1.0 },
77
-        lts::ImageModeReplaceAll,
78
-        lts::ColorChannelsRGB));
79
-    ppFillColor->addChars(lts::CharRangeUsage::Exclude, &CHAR_RANGE_E[0]);
80
-    ppList->push_back(std::move(ppFillColor));
81
-    
82
-    PostProcessorPtrU ppBorder(new lts::PostProcessorBorder(
83
-        *context,
84
-        3.0,
85
-        0.5,
86
-        lts::Color4f{ 0.0, 0.5, 0.0, 1.0 },
87
-        true));
88
-    ppBorder->addChars(lts::CharRangeUsage::Include, &CHAR_RANGE_E[0]);
89
-    ppList->push_back(std::move(ppBorder));
90
-    
91
-    font = creator->getFontByFile(
92
-        "../Prototype.ttf",
93
-        40,
94
-        lts::FontStyles(),
95
-        lts::AntiAliasing::Normal);
96
-    font->setPostProcessor(ppList.get());
97
-    
98
-    return true;
99
-}
100
-
101
-bool exampleRender(int width, int height)
102
-{
103
-    glEnable(GL_BLEND);
104
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
105
-    
106
-    auto textBlock = renderer->beginBlock(10, 10, width-20, height-20, lts::BlockFlags({ lts::BlockFlag::WordWrap }));
107
-    textBlock->setHorzAlign(lts::HorzAlign::Justify);
108
-    textBlock->setFont(font.get());
109
-    textBlock->setColor(lts::Color4f{ 1.0, 1.0, 1.0, 1.0 });
110
-    textBlock->textOutA(TEST_TEXT);
111
-    renderer->endBlock(std::move(textBlock));
112
-    
113
-    glDisable(GL_BLEND);
114
-    
115
-    return true;
116
-}
117
-
118
-void exampleFinish()
119
-{
120
-    font.reset();
121
-    ppList.reset();
122
-    pattern.reset();
123
-    renderer.reset();
124
-    creator.reset();
125
-    context.reset();
126
-    library.reset();
1
+#include <stdio.h>
2
+#include <GL/gl.h>
3
+#include <string.h>
4
+
5
+#include "example.h"
6
+#include "helper.h"
7
+#ifdef LINUX
8
+#  include "../../libTextSuite.hpp"
9
+#else
10
+#  include "..\..\libTextSuite.hpp"
11
+#endif
12
+
13
+#if _WIN64
14
+    static const std::string LibName("..\\..\\..\\bin\\x86_64-win64\\libtextsuite.dll");
15
+#elif _WIN32
16
+    static const std::string LibName("..\\..\\..\\bin\\i386-win32\\libtextsuite.dll");
17
+#elif __linux__ && (__amd64 || __x86_64 || _M_AMD64 || __ppc64__)
18
+    static const std::string LibName("../../../bin/x86_64-linux/libtextsuite.so");
19
+#elif __linux__ && (__i386 || _X86_)
20
+    static const std::string LibName("../../../bin/i386-linux/libtextsuite.so");
21
+#else
22
+#  error 'unknown operation system'
23
+#endif
24
+
25
+#ifdef LINUX
26
+#   define FontCreatorExample FontCreatorFreeType
27
+#else
28
+#   define FontCreatorExample FontCreatorGDI
29
+#endif
30
+
31
+typedef std::unique_ptr<lts::PostProcessor> PostProcessorPtrU;
32
+
33
+std::shared_ptr<lts::Library>       library;
34
+std::shared_ptr<lts::Context>       context;
35
+std::shared_ptr<lts::FontCreator>   creator;
36
+std::shared_ptr<lts::Renderer>      renderer;
37
+std::shared_ptr<lts::Image>         pattern;
38
+std::shared_ptr<lts::Font>          font;
39
+
40
+std::shared_ptr<lts::PostProcessorList<PostProcessorPtrU>> ppList;
41
+
42
+const char*         TEST_TEXT           = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
43
+const lts::WideChar CHAR_RANGE_LOREM[]  = { 'L', 'o', 'r', 'e', 'm', 0 };
44
+const lts::WideChar CHAR_RANGE_E[]      = { 'e', 0 };
45
+
46
+const uint8_t PATTER_DATA[] = {
47
+    0xFF, 0xBF, 0x7F, 0xBF,
48
+    0xBF, 0xFF, 0xBF, 0x7F,
49
+    0x7F, 0xBF, 0xFF, 0xBF,
50
+    0xBF, 0x7F, 0xBF, 0xFF
51
+};
52
+
53
+bool exampleInit()
54
+{
55
+    library.reset(new lts::Library(LibName));
56
+    context.reset(new lts::Context(*library));
57
+    creator.reset(new lts::FontCreatorExample(*context));
58
+    renderer.reset(new lts::RendererOpenGL(*context, lts::Format::RGBA8));
59
+    ppList.reset(new lts::PostProcessorList<PostProcessorPtrU>(*context));
60
+    
61
+    pattern.reset(new lts::Image(*context));
62
+    pattern->createEmpty(lts::Format::Alpha8, 4, 4);
63
+    memcpy(pattern->getData(), &PATTER_DATA[0], 16);
64
+    
65
+    PostProcessorPtrU ppFillPattern(new lts::PostProcessorFillPattern(
66
+        *context,
67
+        *pattern,
68
+        lts::Position{0, 0},
69
+        lts::ImageModeModulateAll,
70
+        lts::ColorChannelsRGBA));
71
+    ppFillPattern->addChars(lts::CharRangeUsage::Include, &CHAR_RANGE_LOREM[0]);
72
+    ppList->push_back(std::move(ppFillPattern));
73
+    
74
+    PostProcessorPtrU ppFillColor(new lts::PostProcessorFillColor(
75
+        *context,
76
+        lts::Color4f{ 0.0, 0.0, 0.5, 1.0 },
77
+        lts::ImageModeReplaceAll,
78
+        lts::ColorChannelsRGB));
79
+    ppFillColor->addChars(lts::CharRangeUsage::Exclude, &CHAR_RANGE_E[0]);
80
+    ppList->push_back(std::move(ppFillColor));
81
+    
82
+    PostProcessorPtrU ppBorder(new lts::PostProcessorBorder(
83
+        *context,
84
+        3.0,
85
+        0.5,
86
+        lts::Color4f{ 0.0, 0.5, 0.0, 1.0 },
87
+        true));
88
+    ppBorder->addChars(lts::CharRangeUsage::Include, &CHAR_RANGE_E[0]);
89
+    ppList->push_back(std::move(ppBorder));
90
+    
91
+    font = creator->getFontByFile(
92
+        "../Prototype.ttf",
93
+        40,
94
+        lts::FontStyles(),
95
+        lts::AntiAliasing::Normal);
96
+    font->setPostProcessor(ppList.get());
97
+    
98
+    return true;
99
+}
100
+
101
+bool exampleRender(int width, int height)
102
+{
103
+    glEnable(GL_BLEND);
104
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
105
+    
106
+    auto textBlock = renderer->beginBlock(10, 10, width-20, height-20, lts::BlockFlags({ lts::BlockFlag::WordWrap }));
107
+    textBlock->setHorzAlign(lts::HorzAlign::Justify);
108
+    textBlock->setFont(font.get());
109
+    textBlock->setColor(lts::Color4f{ 1.0, 1.0, 1.0, 1.0 });
110
+    textBlock->textOutA(TEST_TEXT);
111
+    renderer->endBlock(std::move(textBlock));
112
+    
113
+    glDisable(GL_BLEND);
114
+    
115
+    return true;
116
+}
117
+
118
+void exampleFinish()
119
+{
120
+    font.reset();
121
+    ppList.reset();
122
+    pattern.reset();
123
+    renderer.reset();
124
+    creator.reset();
125
+    context.reset();
126
+    library.reset();
127 127
 }

+ 9 - 9
header/examples/cpp/example.h

@@ -1,10 +1,10 @@
1
-#ifndef EXAMPLE_H
2
-#define EXAMPLE_H
3
-
4
-#include <stdbool.h>
5
-
6
-bool exampleInit();
7
-bool exampleRender(int width, int height);
8
-void exampleFinish();
9
-
1
+#ifndef EXAMPLE_H
2
+#define EXAMPLE_H
3
+
4
+#include <stdbool.h>
5
+
6
+bool exampleInit();
7
+bool exampleRender(int width, int height);
8
+void exampleFinish();
9
+
10 10
 #endif /* EXAMPLE_H */

+ 15 - 15
header/examples/cpp/helper.h

@@ -1,16 +1,16 @@
1
-#ifndef HELPER_H
2
-#define HELPER_H
3
-
4
-#if defined(WIN32)
5
-#include <windows.h>
6
-extern HWND hwnd;
7
-static inline void showMessage(const char* msg)
8
-    { MessageBox(hwnd, msg, "TextSuiteExample Error", MB_OK); };
9
-    
10
-#elif defined(LINUX)
11
-#include <stdio.h>
12
-static inline void showMessage(const char* msg)
13
-    { printf("%s\n", msg); };
14
-#endif
15
-
1
+#ifndef HELPER_H
2
+#define HELPER_H
3
+
4
+#if defined(WIN32)
5
+#include <windows.h>
6
+extern HWND hwnd;
7
+static inline void showMessage(const char* msg)
8
+    { MessageBox(hwnd, msg, "TextSuiteExample Error", MB_OK); };
9
+    
10
+#elif defined(LINUX)
11
+#include <stdio.h>
12
+static inline void showMessage(const char* msg)
13
+    { printf("%s\n", msg); };
14
+#endif
15
+
16 16
 #endif /* HELPER_H */

+ 73 - 73
header/examples/cpp/main-gnuc.cpp

@@ -1,74 +1,74 @@
1
-#include <iostream>
2
-#include <GL/gl.h>
3
-#include <GL/glut.h>
4
-#include <exception>
5
-
6
-#include "example.h"
7
-#include "helper.h"
8
-
9
-static int windowId;
10
-static int screenw, screenh;
11
-
12
-static void Resize(int width, int height)
13
-{
14
-    screenw = width;
15
-    screenh = height;
16
-    
17
-    glViewport(0, 0, screenw, screenh);
18
-    
19
-    glMatrixMode(GL_PROJECTION);
20
-    glLoadIdentity();
21
-    glOrtho(0, screenw, screenh, 0, -10, 10);
22
-    
23
-    glMatrixMode(GL_MODELVIEW);
24
-    glLoadIdentity();
25
-}
26
-
27
-static void Render(void)
28
-{
29
-    try
30
-    {
31
-        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
32
-        
33
-        if (!exampleRender(screenw, screenh))
34
-        {
35
-            glutDestroyWindow(windowId);
36
-            return;
37
-        }
38
-        
39
-        glutSwapBuffers();
40
-    }
41
-    catch(const std::exception& ex)
42
-    {
43
-        std::cout << "Exception: " << ex.what() << std::endl;
44
-        glutDestroyWindow(windowId);
45
-    }
46
-}
47
-
48
-int main(int argc, char** argv)
49
-{
50
-    try
51
-    {
52
-        glutInit(&argc, argv);
53
-
54
-        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
55
-        glutInitWindowSize(640, 480);
56
-        windowId = glutCreateWindow("libTextSuite example");
57
-
58
-        glClearColor(1.0, 1.0, 1.0, 1.0);
59
-        
60
-        if (!exampleInit())
61
-            return 1;
62
-        
63
-        glutReshapeFunc(Resize);
64
-        glutDisplayFunc(Render);
65
-
66
-        glutMainLoop();
67
-        
68
-        exampleFinish();
69
-    }
70
-    catch(const std::exception& ex)
71
-    {
72
-        std::cout << "Exception: " << ex.what() << std::endl;
73
-    }
1
+#include <iostream>
2
+#include <GL/gl.h>
3
+#include <GL/glut.h>
4
+#include <exception>
5
+
6
+#include "example.h"
7
+#include "helper.h"
8
+
9
+static int windowId;
10
+static int screenw, screenh;
11
+
12
+static void Resize(int width, int height)
13
+{
14
+    screenw = width;
15
+    screenh = height;
16
+    
17
+    glViewport(0, 0, screenw, screenh);
18
+    
19
+    glMatrixMode(GL_PROJECTION);
20
+    glLoadIdentity();
21
+    glOrtho(0, screenw, screenh, 0, -10, 10);
22
+    
23
+    glMatrixMode(GL_MODELVIEW);
24
+    glLoadIdentity();
25
+}
26
+
27
+static void Render(void)
28
+{
29
+    try
30
+    {
31
+        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
32
+        
33
+        if (!exampleRender(screenw, screenh))
34
+        {
35
+            glutDestroyWindow(windowId);
36
+            return;
37
+        }
38
+        
39
+        glutSwapBuffers();
40
+    }
41
+    catch(const std::exception& ex)
42
+    {
43
+        std::cout << "Exception: " << ex.what() << std::endl;
44
+        glutDestroyWindow(windowId);
45
+    }
46
+}
47
+
48
+int main(int argc, char** argv)
49
+{
50
+    try
51
+    {
52
+        glutInit(&argc, argv);
53
+
54
+        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
55
+        glutInitWindowSize(640, 480);
56
+        windowId = glutCreateWindow("libTextSuite example");
57
+
58
+        glClearColor(1.0, 1.0, 1.0, 1.0);
59
+        
60
+        if (!exampleInit())
61
+            return 1;
62
+        
63
+        glutReshapeFunc(Resize);
64
+        glutDisplayFunc(Render);
65
+
66
+        glutMainLoop();
67
+        
68
+        exampleFinish();
69
+    }
70
+    catch(const std::exception& ex)
71
+    {
72
+        std::cout << "Exception: " << ex.what() << std::endl;
73
+    }
74 74
 }

+ 181 - 181
header/examples/cpp/main-mingw.cpp

@@ -1,182 +1,182 @@
1
-#include <iostream>
2
-#include <exception>
3
-#include <windows.h>
4
-#include <Wingdi.h>
5
-#include <GL/gl.h>
6
-#include <stdio.h>
7
-
8
-#include "helper.h"
9
-#include "example.h"
10
-
11
-const char g_szClassName[] = "OpenGLWindowClass";
12
-
13
-HDC hdc;
14
-HGLRC hglrc;
15
-HWND hwnd;
16
-int done = 0;
17
-bool canRender = false;
18
-
19
-int screenw, screenh;
20
-
21
-void SysShutdown (void)
22
-{
23
-    done = 1;
24
-    exampleFinish();
25
-    wglMakeCurrent(hdc, NULL);
26
-    wglDeleteContext(hglrc);
27
-    PostQuitMessage(0);
28
-}
29
-
30
-void setPixelFormat()
31
-{
32
-    PIXELFORMATDESCRIPTOR pfd =
33
-    {
34
-        sizeof(PIXELFORMATDESCRIPTOR),
35
-        1,
36
-        PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
37
-        PFD_TYPE_RGBA,
38
-        32,
39
-        0,0,0,0,0,0,0,0,0,0,0,0,0, // useles parameters
40
-        16,
41
-        0,0,0,0,0,0,0
42
-    };
43
-    int indexPixelFormat = ChoosePixelFormat(hdc, &pfd);
44
-    SetPixelFormat(hdc, indexPixelFormat, &pfd);
45
-}
46
-
47
-LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
48
-{
49
-    try
50
-    {
51
-        switch(msg)
52
-        {
53
-            case WM_CREATE:
54
-                if ((hdc = GetDC(hwnd)) == NULL)	// get device context
55
-                {
56
-                    MessageBox(hwnd, "Failed to Get the Window Device Context", "Device Context Error", MB_OK);
57
-                    SysShutdown();
58
-                    break;
59
-                }
60
-                setPixelFormat();
61
-                if ((hglrc = wglCreateContext(hdc)) == NULL)
62
-                {
63
-                    MessageBox(hwnd, "Failed to Create the OpenGL Rendering Context", "OpenGL Rendering Context Error", MB_OK);
64
-                    SysShutdown();
65
-                    break;
66
-                }
67
-                if (!wglMakeCurrent(hdc, hglrc))
68
-                {
69
-                    MessageBox(hwnd, "Failed to make OpenGL Rendering Context current", "OpenGL Rendering Context Error", MB_OK);
70
-                    SysShutdown();
71
-                    break;
72
-                }
73
-                glDisable(GL_DEPTH_TEST);
74
-                glDisable(GL_CULL_FACE);
75
-                if (!exampleInit())
76
-                {
77
-                    SysShutdown();
78
-                    break;
79
-                }
80
-                canRender = true;
81
-                break;
82
-            
83
-            case WM_SIZE:
84
-                screenw = LOWORD(lParam);
85
-                screenh = HIWORD(lParam);
86
-                break;
87
-            
88
-            case WM_PAINT:
89
-                if (!canRender)
90
-                    break;
91
-                glClearColor(1.0, 1.0, 1.0, 1.0);
92
-                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
93
-                glViewport(0, 0, screenw, screenh);
94
-                
95
-                glMatrixMode(GL_PROJECTION);
96
-                glLoadIdentity();
97
-                glOrtho(0, screenw, screenh, 0, -10, 10);
98
-                glMatrixMode(GL_MODELVIEW);
99
-                glLoadIdentity();
100
-                
101
-                if (!exampleRender(screenw, screenh))
102
-                    SysShutdown();
103
-                
104
-                SwapBuffers(hdc);
105
-                break;
106
-            
107
-            case WM_CLOSE:
108
-                SysShutdown();
109
-                DestroyWindow(hwnd);
110
-                break;
111
-                
112
-            case WM_DESTROY:
113
-                SysShutdown();
114
-                PostQuitMessage(0);
115
-                break;
116
-                
117
-            default:
118
-                return DefWindowProc(hwnd, msg, wParam, lParam);
119
-        }
120
-        return 0;
121
-    }
122
-    catch(const std::exception& ex)
123
-    {
124
-        MessageBox(hwnd, ex.what(), "Exception", MB_OK);
125
-        SysShutdown();
126
-    }
127
-}
128
-
129
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
130
-{
131
-    try
132
-    {
133
-        WNDCLASSEX wc;
134
-        MSG Msg;
135
-
136
-        wc.cbSize        = sizeof(WNDCLASSEX);
137
-        wc.style         = 0;
138
-        wc.lpfnWndProc   = WndProc;
139
-        wc.cbClsExtra    = 0;
140
-        wc.cbWndExtra    = 0;
141
-        wc.hInstance     = hInstance;
142
-        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
143
-        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
144
-        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
145
-        wc.lpszMenuName  = NULL;
146
-        wc.lpszClassName = g_szClassName;
147
-        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
148
-
149
-        if(!RegisterClassEx(&wc))
150
-        {
151
-            MessageBox(NULL, "Window Registration Failed!", "Error!",
152
-                MB_ICONEXCLAMATION | MB_OK);
153
-            return 0;
154
-        }
155
-
156
-        if ((hwnd = CreateWindowEx(
157
-            WS_EX_CLIENTEDGE,
158
-            g_szClassName,
159
-            "libTextSuite example",
160
-            WS_OVERLAPPEDWINDOW,
161
-            CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
162
-            NULL, NULL, hInstance, NULL)) == NULL)
163
-        {
164
-            MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
165
-            return 0;
166
-        }
167
-        
168
-        ShowWindow(hwnd, nCmdShow);
169
-        UpdateWindow(hwnd);
170
-            
171
-        while(GetMessage(&Msg, NULL, 0, 0) > 0 && done == 0)
172
-        {
173
-            TranslateMessage(&Msg);
174
-            DispatchMessage(&Msg);
175
-        }
176
-        return Msg.wParam;
177
-    }
178
-    catch(const std::exception& ex)
179
-    {
180
-        std::cout << "Exception: " << ex.what() << std::endl;
181
-    }
1
+#include <iostream>
2
+#include <exception>
3
+#include <windows.h>
4
+#include <Wingdi.h>
5
+#include <GL/gl.h>
6
+#include <stdio.h>
7
+
8
+#include "helper.h"
9
+#include "example.h"
10
+
11
+const char g_szClassName[] = "OpenGLWindowClass";
12
+
13
+HDC hdc;
14
+HGLRC hglrc;
15
+HWND hwnd;
16
+int done = 0;
17
+bool canRender = false;
18
+
19
+int screenw, screenh;
20
+
21
+void SysShutdown (void)
22
+{
23
+    done = 1;
24
+    exampleFinish();
25
+    wglMakeCurrent(hdc, NULL);
26
+    wglDeleteContext(hglrc);
27
+    PostQuitMessage(0);
28
+}
29
+
30
+void setPixelFormat()
31
+{
32
+    PIXELFORMATDESCRIPTOR pfd =
33
+    {
34
+        sizeof(PIXELFORMATDESCRIPTOR),
35
+        1,
36
+        PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
37
+        PFD_TYPE_RGBA,
38
+        32,
39
+        0,0,0,0,0,0,0,0,0,0,0,0,0, // useles parameters
40
+        16,
41
+        0,0,0,0,0,0,0
42
+    };
43
+    int indexPixelFormat = ChoosePixelFormat(hdc, &pfd);
44
+    SetPixelFormat(hdc, indexPixelFormat, &pfd);
45
+}
46
+
47
+LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
48
+{
49
+    try
50
+    {
51
+        switch(msg)
52
+        {
53
+            case WM_CREATE:
54
+                if ((hdc = GetDC(hwnd)) == NULL)	// get device context
55
+                {
56
+                    MessageBox(hwnd, "Failed to Get the Window Device Context", "Device Context Error", MB_OK);
57
+                    SysShutdown();
58
+                    break;
59
+                }
60
+                setPixelFormat();
61
+                if ((hglrc = wglCreateContext(hdc)) == NULL)
62
+                {
63
+                    MessageBox(hwnd, "Failed to Create the OpenGL Rendering Context", "OpenGL Rendering Context Error", MB_OK);
64
+                    SysShutdown();
65
+                    break;
66
+                }
67
+                if (!wglMakeCurrent(hdc, hglrc))
68
+                {
69
+                    MessageBox(hwnd, "Failed to make OpenGL Rendering Context current", "OpenGL Rendering Context Error", MB_OK);
70
+                    SysShutdown();
71
+                    break;
72
+                }
73
+                glDisable(GL_DEPTH_TEST);
74
+                glDisable(GL_CULL_FACE);
75
+                if (!exampleInit())
76
+                {
77
+                    SysShutdown();
78
+                    break;
79
+                }
80
+                canRender = true;
81
+                break;
82
+            
83
+            case WM_SIZE:
84
+                screenw = LOWORD(lParam);
85
+                screenh = HIWORD(lParam);
86
+                break;
87
+            
88
+            case WM_PAINT:
89
+                if (!canRender)
90
+                    break;
91
+                glClearColor(1.0, 1.0, 1.0, 1.0);
92
+                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
93
+                glViewport(0, 0, screenw, screenh);
94
+                
95
+                glMatrixMode(GL_PROJECTION);
96
+                glLoadIdentity();
97
+                glOrtho(0, screenw, screenh, 0, -10, 10);
98
+                glMatrixMode(GL_MODELVIEW);
99
+                glLoadIdentity();
100
+                
101
+                if (!exampleRender(screenw, screenh))
102
+                    SysShutdown();
103
+                
104
+                SwapBuffers(hdc);
105
+                break;
106
+            
107
+            case WM_CLOSE:
108
+                SysShutdown();
109
+                DestroyWindow(hwnd);
110
+                break;
111
+                
112
+            case WM_DESTROY:
113
+                SysShutdown();
114
+                PostQuitMessage(0);
115
+                break;
116
+                
117
+            default:
118
+                return DefWindowProc(hwnd, msg, wParam, lParam);
119
+        }
120
+        return 0;
121
+    }
122
+    catch(const std::exception& ex)
123
+    {
124
+        MessageBox(hwnd, ex.what(), "Exception", MB_OK);
125
+        SysShutdown();
126
+    }
127
+}
128
+
129
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
130
+{
131
+    try
132
+    {
133
+        WNDCLASSEX wc;
134
+        MSG Msg;
135
+
136
+        wc.cbSize        = sizeof(WNDCLASSEX);
137
+        wc.style         = 0;
138
+        wc.lpfnWndProc   = WndProc;
139
+        wc.cbClsExtra    = 0;
140
+        wc.cbWndExtra    = 0;
141
+        wc.hInstance     = hInstance;
142
+        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
143
+        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
144
+        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
145
+        wc.lpszMenuName  = NULL;
146
+        wc.lpszClassName = g_szClassName;
147
+        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
148
+
149
+        if(!RegisterClassEx(&wc))
150
+        {
151
+            MessageBox(NULL, "Window Registration Failed!", "Error!",
152
+                MB_ICONEXCLAMATION | MB_OK);
153
+            return 0;
154
+        }
155
+
156
+        if ((hwnd = CreateWindowEx(
157
+            WS_EX_CLIENTEDGE,
158
+            g_szClassName,
159
+            "libTextSuite example",
160
+            WS_OVERLAPPEDWINDOW,
161
+            CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
162
+            NULL, NULL, hInstance, NULL)) == NULL)
163
+        {
164
+            MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
165
+            return 0;
166
+        }
167
+        
168
+        ShowWindow(hwnd, nCmdShow);
169
+        UpdateWindow(hwnd);
170
+            
171
+        while(GetMessage(&Msg, NULL, 0, 0) > 0 && done == 0)
172
+        {
173
+            TranslateMessage(&Msg);
174
+            DispatchMessage(&Msg);
175
+        }
176
+        return Msg.wParam;
177
+    }
178
+    catch(const std::exception& ex)
179
+    {
180
+        std::cout << "Exception: " << ex.what() << std::endl;
181
+    }
182 182
 }

+ 19 - 0
header/examples/cs/.gitignore

@@ -0,0 +1,19 @@
1
+Thumbs.db
2
+*.obj
3
+*.user
4
+*.aps
5
+*.pch
6
+*.vspscc
7
+*.ncb
8
+*.suo
9
+*.sln.docstates
10
+*.bak
11
+*.cache
12
+*.ilk
13
+*.log
14
+*.lib
15
+*.sbr
16
+*.vssscc
17
+obj/
18
+bin/
19
+.vs/

+ 6 - 0
header/examples/cs/App.config

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<configuration>
3
+    <startup> 
4
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
5
+    </startup>
6
+</configuration>

+ 9 - 0
header/examples/cs/App.xaml

@@ -0,0 +1,9 @@
1
+<Application x:Class="libTextSuiteExample.App"
2
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+             xmlns:local="clr-namespace:libTextSuiteExample"
5
+             StartupUri="MainWindow.xaml">
6
+    <Application.Resources>
7
+         
8
+    </Application.Resources>
9
+</Application>

+ 13 - 0
header/examples/cs/App.xaml.cs

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.IO;
3
+using System.Reflection;
4
+using System.Windows;
5
+
6
+namespace libTextSuiteExample
7
+{
8
+    /// <summary>
9
+    /// Interaktionslogik für "App.xaml"
10
+    /// </summary>
11
+    public partial class App : Application
12
+    {    }
13
+}

+ 20 - 0
header/examples/cs/MainWindow.xaml

@@ -0,0 +1,20 @@
1
+<Window x:Class="libTextSuiteExample.MainWindow"
2
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
+        xmlns:sharpGL="clr-namespace:SharpGL.WPF;assembly=SharpGL.WPF"
7
+        xmlns:local="clr-namespace:libTextSuiteExample"
8
+        mc:Ignorable="d"
9
+        Title="libTextSuite exmple" Height="480" Width="640"
10
+        Closing="Window_Closing">
11
+    <Grid>
12
+        <sharpGL:OpenGLControl
13
+            x:Name="oglControl"
14
+            OpenGLDraw="oglControl_OpenGLDraw"
15
+            OpenGLInitialized="oglControl_OpenGLInitialized"
16
+            Resized="oglControl_Resized"
17
+            RenderContextType="FBO"
18
+            />
19
+    </Grid>
20
+</Window>

+ 168 - 0
header/examples/cs/MainWindow.xaml.cs

@@ -0,0 +1,168 @@
1
+using SharpGL;
2
+using SharpGL.SceneGraph;
3
+using System;
4
+using System.IO;
5
+using System.Reflection;
6
+using System.Runtime.InteropServices;
7
+using System.Windows;
8
+
9
+namespace libTextSuiteExample
10
+{
11
+    public partial class MainWindow : Window
12
+    {
13
+        private static readonly string TEST_TEXT = @"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
14
+
15
+        private lts.Context _context;
16
+        private lts.FontCreator _fontCreator;
17
+        private lts.Renderer _renderer;
18
+        private lts.Font _font;
19
+        private lts.Image _pattern;
20
+        private lts.PostProcessorList _ppList;
21
+
22
+        private static readonly string LibTextSuiteDllName = "libtextsuite.dll";
23
+
24
+        [DllImport("kernel32.dll")]
25
+        private static extern IntPtr LoadLibrary(string dllToLoad);
26
+
27
+        public MainWindow()
28
+        {
29
+            InitializeComponent();
30
+
31
+            // load libtextsuite depending on architecture
32
+            string exeDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
33
+            string archDir = Environment.Is64BitProcess ? "x64" : "x86";
34
+            string dllPath = Path.Combine(exeDir, "resources", archDir, LibTextSuiteDllName);
35
+            var handle = LoadLibrary(dllPath);
36
+            if (handle == IntPtr.Zero)
37
+            { 
38
+                MessageBox.Show("Unable to load libtextsuite.dll", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
39
+                Application.Current.Shutdown();
40
+            }
41
+        }
42
+        
43
+        private void oglControl_OpenGLInitialized(object sender, OpenGLEventArgs args)
44
+        {
45
+            var gl = args.OpenGL;
46
+            gl.Disable(OpenGL.GL_DEPTH_TEST);
47
+            gl.Disable(OpenGL.GLU_CULLING);
48
+            gl.Enable(OpenGL.GL_BLEND);
49
+            gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
50
+            gl.MakeCurrent();
51
+
52
+            string exeDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
53
+            string fontPath = Path.Combine(exeDir, "resources", "Prototype.ttf");
54
+
55
+            _context = new lts.Context();
56
+            _renderer = new lts.RendererOpenGl(_context, lts.Format.RGBA8);
57
+            _fontCreator = new lts.FontCreatorGdi(_context);
58
+            _font = _fontCreator.GetFontByFile(fontPath, 40, lts.FontStyles.Empty, lts.AntiAliasing.Normal);
59
+
60
+            _ppList = new lts.PostProcessorList(_context);
61
+            _font.PostProcessor = _ppList;
62
+
63
+            _pattern = new lts.Image(_context);
64
+            _pattern.CreateEmpty(lts.Format.Alpha8, 4, 4);
65
+            _pattern.Data = new byte[] {
66
+                0xFF, 0xBF, 0x7F, 0xBF,
67
+                0xBF, 0xFF, 0xBF, 0x7F,
68
+                0x7F, 0xBF, 0xFF, 0xBF,
69
+                0xBF, 0x7F, 0xBF, 0xFF
70
+            };
71
+            
72
+            lts.PostProcessor pp = new lts.PostProcessorFillPattern(
73
+                _context,
74
+                _pattern,
75
+                new lts.Position() { x = 0, y = 0 },
76
+                lts.Constants.ImageModeModulateAll,
77
+                lts.Constants.ColorChannelsRGBA);
78
+            pp.AddChars(lts.CharRangeUsage.Include, "Lorem");
79
+            _ppList.Add(pp);
80
+
81
+            pp = new lts.PostProcessorFillColor(
82
+                _context,
83
+                new lts.Color() { R = 0.0f, G = 0.0f, B = 0.5f, A = 1.0f },
84
+                lts.Constants.ImageModeReplaceAll,
85
+                lts.Constants.ColorChannelsRGB);
86
+            pp.AddChars(lts.CharRangeUsage.Exclude, "e");
87
+            _ppList.Add(pp);
88
+
89
+            pp = new lts.PostProcessorBorder(
90
+                _context,
91
+                3.0f,
92
+                0.5f,
93
+                new lts.Color() { R = 0.0f, G = 0.5f, B = 0.0f, A = 1.0f },
94
+                true);
95
+            pp.AddChars(lts.CharRangeUsage.Include, "e");
96
+            _ppList.Add(pp);
97
+        }
98
+
99
+        private void oglControl_OpenGLDraw(object sender, OpenGLEventArgs args)
100
+        {
101
+            var gl = args.OpenGL;
102
+            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
103
+            gl.BlendFunc(OpenGL.GL_SRC_ALPHA, OpenGL.GL_ONE_MINUS_SRC_ALPHA);
104
+            using (var textBlock = _renderer.BeginBlock(10, 10, (Int32)oglControl.ActualWidth - 20, (Int32)oglControl.ActualHeight - 20, lts.BlockFlags.WordWrap))
105
+            {
106
+                textBlock.HorzAlign = lts.HorzAlign.Justify;
107
+                textBlock.Font = _font;
108
+                textBlock.Color = new lts.Color() { R = 1.0f, G = 1.0f, B = 1.0f, A = 1.0f };
109
+                textBlock.TextOut(TEST_TEXT);
110
+                _renderer.EndBlock(textBlock);
111
+            }
112
+            gl.Flush();
113
+        }
114
+
115
+        private void oglControl_Resized(object sender, OpenGLEventArgs args)
116
+        {
117
+            var gl = args.OpenGL;
118
+            gl.MatrixMode(OpenGL.GL_PROJECTION);
119
+            gl.LoadIdentity();
120
+            gl.Ortho(0, gl.RenderContextProvider.Width, gl.RenderContextProvider.Height, 0, 10, -10);
121
+
122
+            gl.MatrixMode(OpenGL.GL_MODELVIEW);
123
+            gl.LoadIdentity();
124
+        }
125
+
126
+        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
127
+        {
128
+            if (_ppList != null)
129
+            {
130
+                foreach (var pp in _ppList)
131
+                    pp.Dispose();
132
+                _ppList.Dispose();
133
+                _ppList.Clear();
134
+                _ppList = null;
135
+            }
136
+
137
+            if (_pattern != null)
138
+            {
139
+                _pattern.Dispose();
140
+                _pattern = null;
141
+            }
142
+
143
+            if (_font != null)
144
+            {
145
+                _font.Dispose();
146
+                _font = null;
147
+            }
148
+
149
+            if (_fontCreator != null)
150
+            {
151
+                _fontCreator.Dispose();
152
+                _fontCreator = null;
153
+            }
154
+
155
+            if (_renderer != null)
156
+            {
157
+                _renderer.Dispose();
158
+                _renderer = null;
159
+            }
160
+
161
+            if (_context != null)
162
+            {
163
+                _context.Dispose();
164
+                _context = null;
165
+            }
166
+        }
167
+    }
168
+}

+ 55 - 0
header/examples/cs/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
1
+using System.Reflection;
2
+using System.Resources;
3
+using System.Runtime.CompilerServices;
4
+using System.Runtime.InteropServices;
5
+using System.Windows;
6
+
7
+// Allgemeine Informationen über eine Assembly werden über die folgenden
8
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
9
+// die einer Assembly zugeordnet sind.
10
+[assembly: AssemblyTitle("libTextSuiteExample")]
11
+[assembly: AssemblyDescription("")]
12
+[assembly: AssemblyConfiguration("")]
13
+[assembly: AssemblyCompany("")]
14
+[assembly: AssemblyProduct("libTextSuiteExample")]
15
+[assembly: AssemblyCopyright("Copyright ©  2017")]
16
+[assembly: AssemblyTrademark("")]
17
+[assembly: AssemblyCulture("")]
18
+
19
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
20
+// für COM-Komponenten unsichtbar.  Wenn Sie auf einen Typ in dieser Assembly von
21
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
22
+[assembly: ComVisible(false)]
23
+
24
+//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
25
+//<UICulture>ImCodeVerwendeteKultur</UICulture> in der .csproj-Datei
26
+//in einer <PropertyGroup> fest.  Wenn Sie in den Quelldateien beispielsweise Deutsch
27
+//(Deutschland) verwenden, legen Sie <UICulture> auf \"de-DE\" fest.  Heben Sie dann die Auskommentierung
28
+//des nachstehenden NeutralResourceLanguage-Attributs auf.  Aktualisieren Sie "en-US" in der nachstehenden Zeile,
29
+//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.
30
+
31
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32
+
33
+
34
+[assembly: ThemeInfo(
35
+    ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
36
+                                     //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
37
+                                     // oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
38
+    ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
39
+                                              //(wird verwendet, wenn eine Ressource auf der Seite nicht gefunden wird,
40
+                                              // designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
41
+)]
42
+
43
+
44
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
45
+//
46
+//      Hauptversion
47
+//      Nebenversion
48
+//      Buildnummer
49
+//      Revision
50
+//
51
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
52
+// übernehmen, indem Sie "*" eingeben:
53
+// [assembly: AssemblyVersion("1.0.*")]
54
+[assembly: AssemblyVersion("1.0.0.0")]
55
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 63 - 0
header/examples/cs/Properties/Resources.Designer.cs

@@ -0,0 +1,63 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     Dieser Code wurde von einem Tool generiert.
4
+//     Laufzeitversion:4.0.30319.42000
5
+//
6
+//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7
+//     der Code erneut generiert wird.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace libTextSuiteExample.Properties {
12
+    using System;
13
+    
14
+    
15
+    /// <summary>
16
+    ///   Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
17
+    /// </summary>
18
+    // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
19
+    // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
20
+    // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
21
+    // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
22
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
+    internal class Resources {
26
+        
27
+        private static global::System.Resources.ResourceManager resourceMan;
28
+        
29
+        private static global::System.Globalization.CultureInfo resourceCulture;
30
+        
31
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32
+        internal Resources() {
33
+        }
34
+        
35
+        /// <summary>
36
+        ///   Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
37
+        /// </summary>
38
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39
+        internal static global::System.Resources.ResourceManager ResourceManager {
40
+            get {
41
+                if (object.ReferenceEquals(resourceMan, null)) {
42
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("libTextSuiteExample.Properties.Resources", typeof(Resources).Assembly);
43
+                    resourceMan = temp;
44
+                }
45
+                return resourceMan;
46
+            }
47
+        }
48
+        
49
+        /// <summary>
50
+        ///   Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
51
+        ///   Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
52
+        /// </summary>
53
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54
+        internal static global::System.Globalization.CultureInfo Culture {
55
+            get {
56
+                return resourceCulture;
57
+            }
58
+            set {
59
+                resourceCulture = value;
60
+            }
61
+        }
62
+    }
63
+}

+ 117 - 0
header/examples/cs/Properties/Resources.resx

@@ -0,0 +1,117 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:element name="root" msdata:IsDataSet="true">
64
+      <xsd:complexType>
65
+        <xsd:choice maxOccurs="unbounded">
66
+          <xsd:element name="metadata">
67
+            <xsd:complexType>
68
+              <xsd:sequence>
69
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
+              </xsd:sequence>
71
+              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="type" type="xsd:string" />
73
+              <xsd:attribute name="mimetype" type="xsd:string" />
74
+            </xsd:complexType>
75
+          </xsd:element>
76
+          <xsd:element name="assembly">
77
+            <xsd:complexType>
78
+              <xsd:attribute name="alias" type="xsd:string" />
79
+              <xsd:attribute name="name" type="xsd:string" />
80
+            </xsd:complexType>
81
+          </xsd:element>
82
+          <xsd:element name="data">
83
+            <xsd:complexType>
84
+              <xsd:sequence>
85
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
+              </xsd:sequence>
88
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91
+            </xsd:complexType>
92
+          </xsd:element>
93
+          <xsd:element name="resheader">
94
+            <xsd:complexType>
95
+              <xsd:sequence>
96
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97
+              </xsd:sequence>
98
+              <xsd:attribute name="name" type="xsd:string" use="required" />
99
+            </xsd:complexType>
100
+          </xsd:element>
101
+        </xsd:choice>
102
+      </xsd:complexType>
103
+    </xsd:element>
104
+  </xsd:schema>
105
+  <resheader name="resmimetype">
106
+    <value>text/microsoft-resx</value>
107
+  </resheader>
108
+  <resheader name="version">
109
+    <value>2.0</value>
110
+  </resheader>
111
+  <resheader name="reader">
112
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
+  </resheader>
114
+  <resheader name="writer">
115
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+</root>

+ 26 - 0
header/examples/cs/Properties/Settings.Designer.cs

@@ -0,0 +1,26 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     Dieser Code wurde von einem Tool generiert.
4
+//     Laufzeitversion:4.0.30319.42000
5
+//
6
+//     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
7
+//     der Code erneut generiert wird.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace libTextSuiteExample.Properties {
12
+    
13
+    
14
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
16
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17
+        
18
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19
+        
20
+        public static Settings Default {
21
+            get {
22
+                return defaultInstance;
23
+            }
24
+        }
25
+    }
26
+}

+ 7 - 0
header/examples/cs/Properties/Settings.settings

@@ -0,0 +1,7 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
3
+  <Profiles>
4
+    <Profile Name="(Default)" />
5
+  </Profiles>
6
+  <Settings />
7
+</SettingsFile>

+ 129 - 0
header/examples/cs/libTextSuiteExample.csproj

@@ -0,0 +1,129 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+  <PropertyGroup>
5
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+    <ProjectGuid>{09D8B134-1C53-43C0-8AB1-B1553F561483}</ProjectGuid>
8
+    <OutputType>WinExe</OutputType>
9
+    <RootNamespace>libTextSuiteExample</RootNamespace>
10
+    <AssemblyName>libTextSuiteExample</AssemblyName>
11
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
12
+    <FileAlignment>512</FileAlignment>
13
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14
+    <WarningLevel>4</WarningLevel>
15
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16
+    <TargetFrameworkProfile>
17
+    </TargetFrameworkProfile>
18
+  </PropertyGroup>
19
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20
+    <PlatformTarget>AnyCPU</PlatformTarget>
21
+    <DebugSymbols>true</DebugSymbols>
22
+    <DebugType>full</DebugType>
23
+    <Optimize>false</Optimize>
24
+    <OutputPath>bin\Debug\</OutputPath>
25
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
26
+    <ErrorReport>prompt</ErrorReport>
27
+    <WarningLevel>4</WarningLevel>
28
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
29
+    <Prefer32Bit>false</Prefer32Bit>
30
+  </PropertyGroup>
31
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
32
+    <PlatformTarget>AnyCPU</PlatformTarget>
33
+    <DebugType>pdbonly</DebugType>
34
+    <Optimize>true</Optimize>
35
+    <OutputPath>bin\Release\</OutputPath>
36
+    <DefineConstants>TRACE</DefineConstants>
37
+    <ErrorReport>prompt</ErrorReport>
38
+    <WarningLevel>4</WarningLevel>
39
+    <Prefer32Bit>false</Prefer32Bit>
40
+  </PropertyGroup>
41
+  <ItemGroup>
42
+    <Reference Include="SharpGL">
43
+      <HintPath>lib\SharpGL.dll</HintPath>
44
+    </Reference>
45
+    <Reference Include="SharpGL.SceneGraph">
46
+      <HintPath>lib\SharpGL.SceneGraph.dll</HintPath>
47
+    </Reference>
48
+    <Reference Include="SharpGL.WPF">
49
+      <HintPath>lib\SharpGL.WPF.dll</HintPath>
50
+    </Reference>
51
+    <Reference Include="System" />
52
+    <Reference Include="System.Data" />
53
+    <Reference Include="System.Design" />
54
+    <Reference Include="System.Xml" />
55
+    <Reference Include="Microsoft.CSharp" />
56
+    <Reference Include="System.Core" />
57
+    <Reference Include="System.Xml.Linq" />
58
+    <Reference Include="System.Data.DataSetExtensions" />
59
+    <Reference Include="System.Xaml">
60
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
61
+    </Reference>
62
+    <Reference Include="WindowsBase" />
63
+    <Reference Include="PresentationCore" />
64
+    <Reference Include="PresentationFramework" />
65
+  </ItemGroup>
66
+  <ItemGroup>
67
+    <ApplicationDefinition Include="App.xaml">
68
+      <Generator>MSBuild:Compile</Generator>
69
+      <SubType>Designer</SubType>
70
+    </ApplicationDefinition>
71
+    <Page Include="MainWindow.xaml">
72
+      <Generator>MSBuild:Compile</Generator>
73
+      <SubType>Designer</SubType>
74
+    </Page>
75
+    <Compile Include="..\..\libTextSuite.cs">
76
+      <Link>libTextSuite.cs</Link>
77
+    </Compile>
78
+    <Compile Include="App.xaml.cs">
79
+      <DependentUpon>App.xaml</DependentUpon>
80
+      <SubType>Code</SubType>
81
+    </Compile>
82
+    <Compile Include="MainWindow.xaml.cs">
83
+      <DependentUpon>MainWindow.xaml</DependentUpon>
84
+      <SubType>Code</SubType>
85
+    </Compile>
86
+  </ItemGroup>
87
+  <ItemGroup>
88
+    <Compile Include="Properties\AssemblyInfo.cs">
89
+      <SubType>Code</SubType>
90
+    </Compile>
91
+    <Compile Include="Properties\Resources.Designer.cs">
92
+      <AutoGen>True</AutoGen>
93
+      <DesignTime>True</DesignTime>
94
+      <DependentUpon>Resources.resx</DependentUpon>
95
+    </Compile>
96
+    <Compile Include="Properties\Settings.Designer.cs">
97
+      <AutoGen>True</AutoGen>
98
+      <DependentUpon>Settings.settings</DependentUpon>
99
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
100
+    </Compile>
101
+    <EmbeddedResource Include="Properties\Resources.resx">
102
+      <Generator>ResXFileCodeGenerator</Generator>
103
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
104
+    </EmbeddedResource>
105
+    <Content Include="..\Prototype.ttf">
106
+      <Link>resources\Prototype.ttf</Link>
107
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
108
+    </Content>
109
+    <None Include="Properties\Settings.settings">
110
+      <Generator>SettingsSingleFileGenerator</Generator>
111
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
112
+    </None>
113
+  </ItemGroup>
114
+  <ItemGroup>
115
+    <None Include="App.config" />
116
+  </ItemGroup>
117
+  <ItemGroup />
118
+  <ItemGroup>
119
+    <Content Include="..\..\..\bin\i386-win32\libtextsuite.dll">
120
+      <Link>resources\x86\libtextsuite.dll</Link>
121
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
122
+    </Content>
123
+    <Content Include="..\..\..\bin\x86_64-win64\libtextsuite.dll">
124
+      <Link>resources\x64\libtextsuite.dll</Link>
125
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
126
+    </Content>
127
+  </ItemGroup>
128
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
129
+</Project>

+ 22 - 0
header/examples/cs/libTextSuiteExample.sln

@@ -0,0 +1,22 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio 15
4
+VisualStudioVersion = 15.0.26403.3
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libTextSuiteExample", "libTextSuiteExample.csproj", "{09D8B134-1C53-43C0-8AB1-B1553F561483}"
7
+EndProject
8
+Global
9
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+		Debug|Any CPU = Debug|Any CPU
11
+		Release|Any CPU = Release|Any CPU
12
+	EndGlobalSection
13
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+		{09D8B134-1C53-43C0-8AB1-B1553F561483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+		{09D8B134-1C53-43C0-8AB1-B1553F561483}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+		{09D8B134-1C53-43C0-8AB1-B1553F561483}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+		{09D8B134-1C53-43C0-8AB1-B1553F561483}.Release|Any CPU.Build.0 = Release|Any CPU
18
+	EndGlobalSection
19
+	GlobalSection(SolutionProperties) = preSolution
20
+		HideSolutionNode = FALSE
21
+	EndGlobalSection
22
+EndGlobal

File diff suppressed because it is too large
+ 20638 - 20638
header/examples/fpc/dglOpenGL.pas


+ 92 - 92
header/examples/fpc/example.lpi

@@ -1,92 +1,92 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<CONFIG>
3
-  <ProjectOptions>
4
-    <Version Value="10"/>
5
-    <PathDelim Value="\"/>
6
-    <General>
7
-      <SessionStorage Value="InProjectDir"/>
8
-      <MainUnit Value="0"/>
9
-      <Title Value="example"/>
10
-      <ResourceType Value="res"/>
11
-      <UseXPManifest Value="True"/>
12
-    </General>
13
-    <i18n>
14
-      <EnableI18N LFM="False"/>
15
-    </i18n>
16
-    <BuildModes Count="1">
17
-      <Item1 Name="Default" Default="True"/>
18
-    </BuildModes>
19
-    <PublishOptions>
20
-      <Version Value="2"/>
21
-    </PublishOptions>
22
-    <RunParams>
23
-      <local>
24
-        <FormatVersion Value="1"/>
25
-      </local>
26
-    </RunParams>
27
-    <RequiredPackages Count="1">
28
-      <Item1>
29
-        <PackageName Value="LCL"/>
30
-      </Item1>
31
-    </RequiredPackages>
32
-    <Units Count="3">
33
-      <Unit0>
34
-        <Filename Value="example.lpr"/>
35
-        <IsPartOfProject Value="True"/>
36
-      </Unit0>
37
-      <Unit1>
38
-        <Filename Value="uMainForm.pas"/>
39
-        <IsPartOfProject Value="True"/>
40
-        <ComponentName Value="MainForm"/>
41
-        <HasResources Value="True"/>
42
-        <ResourceBaseClass Value="Form"/>
43
-      </Unit1>
44
-      <Unit2>
45
-        <Filename Value="..\..\ulibTextSuite.pas"/>
46
-        <IsPartOfProject Value="True"/>
47
-      </Unit2>
48
-    </Units>
49
-  </ProjectOptions>
50
-  <CompilerOptions>
51
-    <Version Value="11"/>
52
-    <PathDelim Value="\"/>
53
-    <Target>
54
-      <Filename Value="example"/>
55
-    </Target>
56
-    <SearchPaths>
57
-      <IncludeFiles Value="$(ProjOutDir)"/>
58
-      <OtherUnitFiles Value="..\.."/>
59
-      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
60
-    </SearchPaths>
61
-    <Linking>
62
-      <Debugging>
63
-        <UseHeaptrc Value="True"/>
64
-        <UseExternalDbgSyms Value="True"/>
65
-      </Debugging>
66
-      <Options>
67
-        <Win32>
68
-          <GraphicApplication Value="True"/>
69
-        </Win32>
70
-      </Options>
71
-    </Linking>
72
-    <Other>