mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-18 23:21:37 +00:00
- Added support for enabling FreeType Support (make USE_FREETYPE=1).
- Fixed compiling tr_font.c for dynamic renderer.
This commit is contained in:
parent
33d66c8034
commit
ea0102d403
3 changed files with 43 additions and 17 deletions
25
Makefile
25
Makefile
|
@ -177,6 +177,10 @@ ifndef USE_VOIP
|
||||||
USE_VOIP=1
|
USE_VOIP=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef USE_FREETYPE
|
||||||
|
USE_FREETYPE=0
|
||||||
|
endif
|
||||||
|
|
||||||
ifndef USE_INTERNAL_SPEEX
|
ifndef USE_INTERNAL_SPEEX
|
||||||
USE_INTERNAL_SPEEX=1
|
USE_INTERNAL_SPEEX=1
|
||||||
endif
|
endif
|
||||||
|
@ -248,6 +252,7 @@ ifneq ($(BUILD_CLIENT),0)
|
||||||
OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal)
|
OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal)
|
||||||
SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
|
SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl|sed 's/-Dmain=SDL_main//')
|
||||||
SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl)
|
SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl)
|
||||||
|
FREETYPE_CFLAGS=$(shell pkg-config --silence-errors --cflags freetype2)
|
||||||
endif
|
endif
|
||||||
# Use sdl-config if all else fails
|
# Use sdl-config if all else fails
|
||||||
ifeq ($(SDL_CFLAGS),)
|
ifeq ($(SDL_CFLAGS),)
|
||||||
|
@ -380,6 +385,10 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
|
||||||
CLIENT_CFLAGS += -I$(SDLHDIR)/include
|
CLIENT_CFLAGS += -I$(SDLHDIR)/include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_FREETYPE),1)
|
||||||
|
BASE_CFLAGS += $(FREETYPE_CFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(ARCH),i386)
|
ifeq ($(ARCH),i386)
|
||||||
# linux32 make ...
|
# linux32 make ...
|
||||||
BASE_CFLAGS += -m32
|
BASE_CFLAGS += -m32
|
||||||
|
@ -434,6 +443,10 @@ ifeq ($(PLATFORM),darwin)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_FREETYPE),1)
|
||||||
|
BASE_CFLAGS += $(FREETYPE_CFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(USE_CODEC_VORBIS),1)
|
ifeq ($(USE_CODEC_VORBIS),1)
|
||||||
CLIENT_LIBS += -lvorbisfile -lvorbis -logg
|
CLIENT_LIBS += -lvorbisfile -lvorbis -logg
|
||||||
endif
|
endif
|
||||||
|
@ -523,6 +536,10 @@ ifeq ($(PLATFORM),mingw32)
|
||||||
CLIENT_LIBS = -lgdi32 -lole32
|
CLIENT_LIBS = -lgdi32 -lole32
|
||||||
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32
|
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32
|
||||||
|
|
||||||
|
ifeq ($(USE_FREETYPE),1)
|
||||||
|
BASE_CFLAGS += -Ifreetype2
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(USE_CURL),1)
|
ifeq ($(USE_CURL),1)
|
||||||
CLIENT_CFLAGS += $(CURL_CFLAGS)
|
CLIENT_CFLAGS += $(CURL_CFLAGS)
|
||||||
ifneq ($(USE_CURL_DLOPEN),1)
|
ifneq ($(USE_CURL_DLOPEN),1)
|
||||||
|
@ -830,6 +847,10 @@ endif
|
||||||
|
|
||||||
TARGETS =
|
TARGETS =
|
||||||
|
|
||||||
|
ifeq ($(USE_FREETYPE),1)
|
||||||
|
BASE_CFLAGS += -DBUILD_FREETYPE
|
||||||
|
endif
|
||||||
|
|
||||||
ifndef FULLBINEXT
|
ifndef FULLBINEXT
|
||||||
FULLBINEXT=.$(ARCH)$(BINEXT)
|
FULLBINEXT=.$(ARCH)$(BINEXT)
|
||||||
endif
|
endif
|
||||||
|
@ -938,6 +959,10 @@ else
|
||||||
RENDERER_LIBS += -ljpeg
|
RENDERER_LIBS += -ljpeg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_FREETYPE),1)
|
||||||
|
RENDERER_LIBS += -lfreetype
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
|
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
|
||||||
BASE_CFLAGS += -Qunused-arguments
|
BASE_CFLAGS += -Qunused-arguments
|
||||||
endif
|
endif
|
||||||
|
|
1
README
1
README
|
@ -103,6 +103,7 @@ Makefile.local:
|
||||||
USE_VOIP - enable built-in VoIP support
|
USE_VOIP - enable built-in VoIP support
|
||||||
USE_INTERNAL_SPEEX - build internal speex library instead of dynamically
|
USE_INTERNAL_SPEEX - build internal speex library instead of dynamically
|
||||||
linking against system libspeex
|
linking against system libspeex
|
||||||
|
USE_FREETYPE - enable FreeType support for rendering fonts
|
||||||
USE_OLD_VM64 - use Ludwig Nussel's old JIT compiler implementation
|
USE_OLD_VM64 - use Ludwig Nussel's old JIT compiler implementation
|
||||||
for x86_64
|
for x86_64
|
||||||
USE_INTERNAL_ZLIB - build and link against internal zlib
|
USE_INTERNAL_ZLIB - build and link against internal zlib
|
||||||
|
|
|
@ -116,14 +116,14 @@ FT_Bitmap *R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t* glyphOut) {
|
||||||
if ( glyph->format == ft_glyph_format_outline ) {
|
if ( glyph->format == ft_glyph_format_outline ) {
|
||||||
size = pitch*height;
|
size = pitch*height;
|
||||||
|
|
||||||
bit2 = Z_Malloc(sizeof(FT_Bitmap));
|
bit2 = ri.Malloc(sizeof(FT_Bitmap));
|
||||||
|
|
||||||
bit2->width = width;
|
bit2->width = width;
|
||||||
bit2->rows = height;
|
bit2->rows = height;
|
||||||
bit2->pitch = pitch;
|
bit2->pitch = pitch;
|
||||||
bit2->pixel_mode = ft_pixel_mode_grays;
|
bit2->pixel_mode = ft_pixel_mode_grays;
|
||||||
//bit2->pixel_mode = ft_pixel_mode_mono;
|
//bit2->pixel_mode = ft_pixel_mode_mono;
|
||||||
bit2->buffer = Z_Malloc(pitch*height);
|
bit2->buffer = ri.Malloc(pitch*height);
|
||||||
bit2->num_grays = 256;
|
bit2->num_grays = 256;
|
||||||
|
|
||||||
Com_Memset( bit2->buffer, 0, size );
|
Com_Memset( bit2->buffer, 0, size );
|
||||||
|
@ -149,7 +149,7 @@ void WriteTGA (char *filename, byte *data, int width, int height) {
|
||||||
byte *buffer;
|
byte *buffer;
|
||||||
int i, c;
|
int i, c;
|
||||||
|
|
||||||
buffer = Z_Malloc(width*height*4 + 18);
|
buffer = ri.Malloc(width*height*4 + 18);
|
||||||
Com_Memset (buffer, 0, 18);
|
Com_Memset (buffer, 0, 18);
|
||||||
buffer[2] = 2; // uncompressed type
|
buffer[2] = 2; // uncompressed type
|
||||||
buffer[12] = width&255;
|
buffer[12] = width&255;
|
||||||
|
@ -174,7 +174,7 @@ void WriteTGA (char *filename, byte *data, int width, int height) {
|
||||||
//fwrite (buffer, 1, c, f);
|
//fwrite (buffer, 1, c, f);
|
||||||
//fclose (f);
|
//fclose (f);
|
||||||
|
|
||||||
Z_Free (buffer);
|
ri.Free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, int *yOut, int *maxHeight, FT_Face face, const unsigned char c, qboolean calcHeight) {
|
static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, int *yOut, int *maxHeight, FT_Face face, const unsigned char c, qboolean calcHeight) {
|
||||||
|
@ -200,8 +200,8 @@ static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, in
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calcHeight) {
|
if (calcHeight) {
|
||||||
Z_Free(bitmap->buffer);
|
ri.Free(bitmap->buffer);
|
||||||
Z_Free(bitmap);
|
ri.Free(bitmap);
|
||||||
return &glyph;
|
return &glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +222,8 @@ static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, in
|
||||||
if (*yOut + *maxHeight + 1 >= 255) {
|
if (*yOut + *maxHeight + 1 >= 255) {
|
||||||
*yOut = -1;
|
*yOut = -1;
|
||||||
*xOut = -1;
|
*xOut = -1;
|
||||||
Z_Free(bitmap->buffer);
|
ri.Free(bitmap->buffer);
|
||||||
Z_Free(bitmap);
|
ri.Free(bitmap);
|
||||||
return &glyph;
|
return &glyph;
|
||||||
} else {
|
} else {
|
||||||
*xOut = 0;
|
*xOut = 0;
|
||||||
|
@ -232,8 +232,8 @@ static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, in
|
||||||
} else if (*yOut + *maxHeight + 1 >= 255) {
|
} else if (*yOut + *maxHeight + 1 >= 255) {
|
||||||
*yOut = -1;
|
*yOut = -1;
|
||||||
*xOut = -1;
|
*xOut = -1;
|
||||||
Z_Free(bitmap->buffer);
|
ri.Free(bitmap->buffer);
|
||||||
Z_Free(bitmap);
|
ri.Free(bitmap);
|
||||||
return &glyph;
|
return &glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,8 +288,8 @@ static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, in
|
||||||
*xOut += scaled_width + 1;
|
*xOut += scaled_width + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_Free(bitmap->buffer);
|
ri.Free(bitmap->buffer);
|
||||||
Z_Free(bitmap);
|
ri.Free(bitmap);
|
||||||
|
|
||||||
return &glyph;
|
return &glyph;
|
||||||
}
|
}
|
||||||
|
@ -435,9 +435,9 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
|
||||||
// make a 256x256 image buffer, once it is full, register it, clean it and keep going
|
// make a 256x256 image buffer, once it is full, register it, clean it and keep going
|
||||||
// until all glyphs are rendered
|
// until all glyphs are rendered
|
||||||
|
|
||||||
out = Z_Malloc(1024*1024);
|
out = ri.Malloc(1024*1024);
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
ri.Printf(PRINT_ALL, "RE_RegisterFont: Z_Malloc failure during output image creation.\n");
|
ri.Printf(PRINT_ALL, "RE_RegisterFont: ri.Malloc failure during output image creation.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Com_Memset(out, 0, 1024*1024);
|
Com_Memset(out, 0, 1024*1024);
|
||||||
|
@ -465,7 +465,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
|
||||||
|
|
||||||
scaledSize = 256*256;
|
scaledSize = 256*256;
|
||||||
newSize = scaledSize * 4;
|
newSize = scaledSize * 4;
|
||||||
imageBuff = Z_Malloc(newSize);
|
imageBuff = ri.Malloc(newSize);
|
||||||
left = 0;
|
left = 0;
|
||||||
max = 0;
|
max = 0;
|
||||||
satLevels = 255;
|
satLevels = 255;
|
||||||
|
@ -503,7 +503,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
|
||||||
Com_Memset(out, 0, 1024*1024);
|
Com_Memset(out, 0, 1024*1024);
|
||||||
xOut = 0;
|
xOut = 0;
|
||||||
yOut = 0;
|
yOut = 0;
|
||||||
Z_Free(imageBuff);
|
ri.Free(imageBuff);
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));
|
Com_Memcpy(&font->glyphs[i], glyph, sizeof(glyphInfo_t));
|
||||||
|
@ -519,7 +519,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
|
||||||
ri.FS_WriteFile(va("fonts/fontImage_%i.dat", pointSize), font, sizeof(fontInfo_t));
|
ri.FS_WriteFile(va("fonts/fontImage_%i.dat", pointSize), font, sizeof(fontInfo_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_Free(out);
|
ri.Free(out);
|
||||||
|
|
||||||
ri.FS_FreeFile(faceData);
|
ri.FS_FreeFile(faceData);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue