demo-font-gles2

229 views
Skip to first unread message

sduclos

unread,
Jan 22, 2012, 12:23:32 PM1/22/12
to freetype-gl
Hi,

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

demo-font-gles2.c
Makefile

Nicolas Rougier

unread,
Feb 6, 2012, 2:43:07 AM2/6/12
to freetype-gl

Hi Sylvain,

Sorry for the late answer and thanks a lot for the code. I will
include it in the trunk sometime soon.
Also, you might want to have a look at the freetype-gl issue page
where someone asked about compatibility with OpenGL 3.3.


Nicolas
>  demo-font-gles2.c
> 27KViewDownload
>
>  Makefile
> 5KViewDownload

sduclos

unread,
Feb 6, 2012, 9:20:11 AM2/6/12
to freet...@googlegroups.com
Hi Nicolas,

> 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.

sduclos

unread,
Feb 6, 2012, 10:34:35 AM2/6/12
to freet...@googlegroups.com
On second thought, having a demo on various OpenGL base profile
would certainly be a good thing.

My GLES2 demo fit in GL2 as is. But I can't tell about GL3 and GL4.


Sylvain.

Stephen Damm

unread,
Aug 9, 2012, 3:12:00 PM8/9/12
to freet...@googlegroups.com
At least with GL3 your GLES2.0 demo basically is the same.  The big change in GL3.X is removal of the fixed function pipeline. 

To support GL4.X only a few changes to the GLES2.0 demo you posted would have to be made.  It should already work as it stands however the shaders will require the more modern syntax now.

sduclos

unread,
Aug 10, 2012, 9:51:32 AM8/10/12
to freet...@googlegroups.com
Hi Stephen,

Thanks for the input.

Sylvain.
Reply all
Reply to author
Forward
0 new messages