diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index 8906cf86..5c9cb165 100644 --- a/examples/10-font/font.cpp +++ b/examples/10-font/font.cpp @@ -12,7 +12,38 @@ #include #include + static const char* s_shaderPath = NULL; +long int fsize(FILE* _file) +{ + long int pos = ftell(_file); + fseek(_file, 0L, SEEK_END); + long int size = ftell(_file); + fseek(_file, pos, SEEK_SET); + return size; +} + +static const bgfx::Memory* loadShader(const char* _shaderPath, const char* _shaderName) +{ + char out[512]; + strcpy(out, _shaderPath); + strcat(out, _shaderName); + strcat(out, ".bin"); + + FILE* file = fopen(out, "rb"); + if (NULL != file) + { + uint32_t size = (uint32_t)fsize(file); + const bgfx::Memory* mem = bgfx::alloc(size+1); + /*size_t ignore =*/ fread(mem->data, 1, size, file); + /*BX_UNUSED(ignore);*/ + fclose(file); + mem->data[mem->size-1] = '\0'; + return mem; + } + + return NULL; +} int _main_(int /*_argc*/, char** /*_argv*/) { diff --git a/examples/common/font/text_buffer_manager.cpp b/examples/common/font/text_buffer_manager.cpp index 4d0b9b13..1891d9ca 100644 --- a/examples/common/font/text_buffer_manager.cpp +++ b/examples/common/font/text_buffer_manager.cpp @@ -13,37 +13,6 @@ #define MAX_TEXT_BUFFER_COUNT 64 #define MAX_BUFFERED_CHARACTERS 8192 -long int fsize(FILE* _file) -{ - long int pos = ftell(_file); - fseek(_file, 0L, SEEK_END); - long int size = ftell(_file); - fseek(_file, pos, SEEK_SET); - return size; -} - -static const bgfx::Memory* loadShader(const char* _shaderPath, const char* _shaderName) -{ - char out[512]; - strcpy(out, _shaderPath); - strcat(out, _shaderName); - strcat(out, ".bin"); - - FILE* file = fopen(out, "rb"); - if (NULL != file) - { - uint32_t size = (uint32_t)fsize(file); - const bgfx::Memory* mem = bgfx::alloc(size+1); - /*size_t ignore =*/ fread(mem->data, 1, size, file); - /*BX_UNUSED(ignore);*/ - fclose(file); - mem->data[mem->size-1] = '\0'; - return mem; - } - - return NULL; -} - // Table from Flexible and Economical UTF-8 Decoder // Copyright (c) 2008-2009 Bjoern Hoehrmann // See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.