summaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'text.c')
-rw-r--r--text.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/text.c b/text.c
new file mode 100644
index 0000000..60d6e4c
--- /dev/null
+++ b/text.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+
+#include <GL/glc.h>
+
+#include "text.h"
+
+static GLuint font;
+
+int
+GLPong_TextInit(void) {
+#ifdef DEBUG
+ int count, i;
+#endif
+ GLuint context = glcGenContext();
+ glcContext(context);
+
+
+ if (!glcIsContext(context)) {
+ return -1;
+ }
+ glcAppendCatalog("/usr/share/fonts/dejavu/");
+
+#ifdef DEBUG
+ count = glcGeti(GLC_CATALOG_COUNT);
+ for (i = 0; i < count; i++) {
+ printf("%s\n", (char *)glcGetListc(GLC_CATALOG_LIST, i));
+ }
+#endif
+
+ font = glcGenFontID();
+ glcNewFontFromFamily(font, "Deja Vu Sans");
+ glcFontFace(font, "Normal");
+/* glcRenderStyle(GLC_TEXTURE);*/
+ glcRenderStyle(GLC_TRIANGLE);
+ if (glcIsFont(font)) {
+ glcFont(font);
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+GLPong_TextDeinit(void) {
+ glcDeleteFont(font);
+}
+
+void
+GLPong_TextDrawFPS(GLfloat fps) {
+ char buffer[10];
+
+ sprintf(buffer, "%.0f FPS", fps);
+#ifdef DEBUG
+ printf("%s frames per second\n", buffer);
+#endif
+
+ glLoadIdentity();
+ glTranslatef(40.0f, 400.0f, 0.0f);
+ glScalef(25.0f, 25.0f, 0.0f);
+ glColor3f(1.0f, 0.0f, 0.0f);
+ glcRenderString(buffer);
+}
+