Attached is demo-font-gles2.c to demo the use EGL and GLES2 (OpenGL ES 2.0).
It's a simplified version of demo-font.c.
The Makefile (attached) had to be adjusted a little, bellow is the
diff against svn.
Build on Ubuntu. On this system glew is name GLEW. It add also the
phony target
demo-font-gles2.o so that Make stop using normal rules while building
demo-font-gles2.
Thanks,
Sylvain.
---------------------------------------------------------------------------------------------------------
$ svn diff Makefile
Index: Makefile
===================================================================
--- Makefile (revision 107)
+++ Makefile (working copy)
@@ -33,7 +33,7 @@
PLATFORM = $(shell uname)
CC = gcc
CFLAGS = -Wall `freetype-config --cflags` -I/usr/X11/include -g -O0
-LIBS = -lGL -lglut -lGLU -lglew \
+LIBS = -lGL -lglut -lGLU -lGLEW \
`freetype-config --libs` -lfontconfig
ifeq ($(PLATFORM), Darwin)
LIBS = -framework OpenGL -framework GLUT -lglew \
@@ -51,7 +51,7 @@
SOURCES := $(filter-out makefont.c, $(SOURCES))
OBJECTS := $(SOURCES:.c=.o)
-.PHONY: all clean distclean
+.PHONY: all clean distclean demo-font-gles2.o
all: $(DEMOS) makefont demo-atb-agg $(TESTS)
demos: $(DEMOS)
@@ -87,6 +87,11 @@
@echo "Building $@... "
@$(CC) $(OBJECTS) $@.o $(LIBS) -o $@
+demo-font-gles2: demo-font-gles2.c
+ @echo "Building $@... "
+ @$(CC) -DEGL_X11 demo-font-gles2.c texture-atlas.o texture-font.o vector.o \
+ `freetype-config --libs` -lm -lEGL -lGLESv2 -o $@
+
clean:
@-rm -f $(DEMOS) $(DEMOS_ATB) makefont *.o
@-rm -f $(TESTS) *.o
> Sorry for the late answer and thanks a lot for the code. I will
> include it in the trunk sometime soon.
OK .. it is a very simple demo. In fact its all boilerplate code pulled
from various (open) source. What is cool is how it show GLES2 fit
nicely with your code.
The rest is just small modification to your Makefile to build this demo.
> Also, you might want to have a look at the freetype-gl issue page
> where someone asked about compatibility with OpenGL 3.3.
Thanks, I didn't see that. I don't know about GL3. Font rendering is
quite a challenge
on small machine (ARM). These machines use GLES2 because of its low resources
requirement compare to OpenGL base profile (OpenGL 2.0, 3.0, 4.0).
On big machine that have a normal GL, I would look first at various
existing libs
(eg. pango+cairo+freetype+fontconfig) that already handle GL font
rendering in a user
friendly way (ie no need to talk to GL directly).
Cheers,
Sylvain.
My GLES2 demo fit in GL2 as is. But I can't tell about GL3 and GL4.
Sylvain.