Giter VIP home page Giter VIP logo

ftgles's People

Contributors

cdave1 avatar davidp-icracked avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ftgles's Issues

EXC_BAD_ACCESS on device

I have downloaded ftgles 0.2.1 and tried to run the examples, but could only get them to work on the Simulator, not on the actual device (an iPad running iOS 3.2).

The examples crash on the first call of Render on an FTFont object. Putting a breakpoint and "stepping into" it with the debugger, I see that after the call to Render, two FTPoint objects are being initialised using the default constructor (I suppose because no position or offset points have been specified), and right after that the programs crash with an EXC_BAD_ACCESS exception and I'm thrown back to the Springboard. The stack trace is instantly lost so I could not get any more information, and enabling zombies did not yield any information either.

There is no change in the code or other build settings at all. It always works fine on the Simulator, but never runs on the device.

Extrusion support

Hi @cdave1, thanks for your work!

I guess this library no longer actively maintained, is it?

I was wondering if posting the extruded text rendering would be very complicated. Any thoughts?

compile on raspberrypi

Hi
Is it possible to compile ftgles on raspberry
I have try the normal build
but the header include seems is not compatible with RPi one's
thanks

Changing FTTextureFont color on gles2 branch

First off, thanks for writing this! I've been able get it to work on the Raspberry Pi by using the gles2 branch. However, I'm now having difficulty changing the color of the font, and I believe it's due to the change in FTTextureFont.cpp in this commit: https://github.com/cdave1/ftgles/blob/20a245ee569d5c08896b250d832729e0463ddfaa/ftgles/src/FTFont/FTTextureFont.cpp

I'm not an expert on GLES2, so I'm not sure why you're unable to use glGetFloatv to get the current color. Do you have a solution for changing the font color in some other fashion? My only through right now is to add a separate method to set the color.

Thanks!

Using in XCode9 Beta

I am receiving the following error in XCode9 Beta

Undefined symbols for architecture arm64:
  "FTTextureFont::FTTextureFont(char const*)", referenced from:
      -[ImageTargetsEAGLView renderFrameWithState:projectMatrix:] in ImageTargetsEAGLView.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any ideas?

improving display rate on iOS

HI Dave,

I am working on an iOS app that renders about 40 characters to form a sentence (think particle system), using the FTGLES library. While the app works just fine on the simulator, it runs nine (9) times slower on the actual device! I am using FTTextureFont, and was wondering if you had any thought to improve the rendering speed. Thanks in advance.

Best, George

Try to add to iOS project using proj refs, get "duplicate symbol _af_dummy_script_class"

I tried to duplicate the project settings in BasicDemo, but whatever I do, I still get this linker error:

ld: duplicate symbol _af_dummy_script_class in /Users/clay/ftgles/Xcode/ftgles/build/Debug-iphonesimulator/libFTGLES.a(autofit.o) and /Users/clay/ftgles/Xcode/ftgles/build/Debug-iphonesimulator/libFTGLES.a(afdummy.o)

Does this ring a bell with anyone?

Maintain backward compatibility so we can use your fantastic library on OSX as well as iPhone

Hi,
I just added two new targets to my downloaded version of the library, one for FTGL OSX and one for FreeType OSX.

Both use your openGLES glue layer in order to render out fonts when compiling for OSX. It took about 30 mins and is very useful since your code renders much faster than the original glBegin/glEnd render code.

I was wondering if you'd like to add this support at all? ;)

Keyboard demo crashes

Keyboard demo is missing mousePoint.png and TextureLoader.h from the project.
Copying them from the basic demo makes the project compilable, however crashes both on the simulator and on the device.

Scrolling crashes

I ahve text on the cells which sroll. but after some time the texture font crashes in glDrawElements with BAD EXCESS in ftglEnd function.

Issue with VBOs

I am following the "Basic Demo" very closely in my own application. I am using a FTTextureFont to render a "hello, world" string. It works flawlessly until I load vertices into a VBO, i.e. glGenBuffers(), glBindBuffer(), glBufferData().

I have singled it down to the glBufferData() call. If I make that call, the font stops rendering. It appears to go through the process of rendering, (iterating over all of the characters in the string, etc), it just does not display on the screen. As soon as I comment out glBufferData and recompile, the text shows up on screen again.

I am currently using the latest version of XCode and my engine is currently using OpenGLES 1.1 because I have an iPhone 3GS (no 2.0 for me, yet).

Any ideas?

Issue with storing cache in FTSimpleLayout

Hi.

There are two issues in cache realization in FTSimpleLayout:

  • store pointers to original string, but need to cached string - original can out of scope;
  • no cache invalidating after change layout parameters.

My patch to fix this:

From f33041e830d791cfaee2ef5847584429965efea8 Mon Sep 17 00:00:00 2001
From: Oleg aka Blake-R <[email protected]>
Date: Thu, 25 Aug 2011 09:09:13 +0400
Subject: [PATCH] Fix cache store and it's invalidation on change layout
 parameters.

---
 ftgles/src/FTLayout/FTSimpleLayout.cpp   |   60 ++++++++++++++++++++---------
 ftgles/src/FTLayout/FTSimpleLayoutImpl.h |    6 ++-
 2 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/ftgles/src/FTLayout/FTSimpleLayout.cpp b/ftgles/src/FTLayout/FTSimpleLayout.cpp
index ff2ec11..050d231 100755
--- a/ftgles/src/FTLayout/FTSimpleLayout.cpp
+++ b/ftgles/src/FTLayout/FTSimpleLayout.cpp
@@ -81,6 +81,7 @@ void FTSimpleLayout::Render(const wchar_t* string, const int len, FTPoint pos,
 void FTSimpleLayout::SetFont(FTFont *fontInit)
 {
     dynamic_cast<FTSimpleLayoutImpl*>(impl)->currentFont = fontInit;
+    dynamic_cast<FTSimpleLayoutImpl*>(impl)->invalidate();
 }


@@ -93,6 +94,7 @@ FTFont *FTSimpleLayout::GetFont()
 void FTSimpleLayout::SetLineLength(const float LineLength)
 {
     dynamic_cast<FTSimpleLayoutImpl*>(impl)->lineLength = LineLength;
+    dynamic_cast<FTSimpleLayoutImpl*>(impl)->invalidate();
 }


@@ -105,6 +107,7 @@ float FTSimpleLayout::GetLineLength() const
 void FTSimpleLayout::SetAlignment(const FTGL::TextAlignment Alignment)
 {
     dynamic_cast<FTSimpleLayoutImpl*>(impl)->alignment = Alignment;
+    dynamic_cast<FTSimpleLayoutImpl*>(impl)->invalidate();
 }


@@ -117,6 +120,7 @@ FTGL::TextAlignment FTSimpleLayout::GetAlignment() const
 void FTSimpleLayout::SetLineSpacing(const float LineSpacing)
 {
     dynamic_cast<FTSimpleLayoutImpl*>(impl)->lineSpacing = LineSpacing;
+    dynamic_cast<FTSimpleLayoutImpl*>(impl)->invalidate();
 }


@@ -137,6 +141,21 @@ FTSimpleLayoutImpl::FTSimpleLayoutImpl()
     lineLength = 100.0f;
     alignment = FTGL::ALIGN_LEFT;
     lineSpacing = 1.0f;
+   stringCache = NULL;
+   stringCacheCount = 0;
+}
+
+
+FTSimpleLayoutImpl::~FTSimpleLayoutImpl()
+{
+   free(stringCache);
+   stringCache = NULL;
+   stringCacheCount = 0;
+}
+
+
+inline void FTSimpleLayoutImpl::invalidate()
+{
    stringCacheCount = 0;
 }

@@ -209,6 +228,7 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
 {
     FTUnicodeStringItr<T> breakItr(buf);          // points to the last break character
     FTUnicodeStringItr<T> lineStart(buf);         // points to the line start
+   unsigned int new_stringCacheCount = 0;        // length of buffer
     float nextStart = 0.0;     // total width of the current line
     float breakWidth = 0.0;    // width of the line up to the last word break
     float currentWidth = 0.0;  // width of all characters on the current line
@@ -228,31 +248,33 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
     {
        bounds->Invalidate();
     }
-   
+
+   {
+       FTUnicodeStringItr<T> itr(buf);
+       for (; *itr; ++itr) {}
+       new_stringCacheCount = itr.getBufferFromHere() - buf + sizeof(T)/*terminator*/;
+   }
+
    // Check if the incoming string is different to the previously
    // cached string.
-   unsigned int i = 0;
-   for (FTUnicodeStringItr<T> itr(buf); *itr; itr++)
-   {
-       if (i >= stringCacheCount ||
-           stringCache[i++] != (unsigned int)*itr)
-       {
-           refresh = true;
-           break;
-       }
+   if (stringCache && stringCacheCount == new_stringCacheCount) refresh = !!memcmp(stringCache, buf, stringCacheCount);
+   else {
+       refresh = true;
+       stringCacheCount = new_stringCacheCount;
+       if (!stringCache) stringCache = (unsigned char *)malloc(stringCacheCount);
+       else stringCache = (unsigned char *)realloc(stringCache, stringCacheCount);
+       if (!stringCache) throw std::bad_alloc();
    }
-   
+
    if (refresh)
    {
-       stringCacheCount = 0;
+       memcpy(stringCache, buf, stringCacheCount);
         layoutGlyphCache.clear();

        // Scan the input for all characters that need output
        FTUnicodeStringItr<T> prevItr(buf);
        for (FTUnicodeStringItr<T> itr(buf); *itr; prevItr = itr++, charCount++)
-       {
-           stringCache[stringCacheCount++] = (unsigned int)*itr;
-           
+       {   
            // Find the width of the current glyph
            glyphBounds = currentFont->BBox(itr.getBufferFromHere(), 1);
            glyphWidth = glyphBounds.Upper().Xf() - glyphBounds.Lower().Xf();
@@ -296,7 +318,7 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
                }

                layoutGlyphCacheItem_t cacheItem;
-               cacheItem.buf = (T*)lineStart.getBufferFromHere();
+               cacheItem.buf = stringCache + ptrdiff_t(lineStart.getBufferFromHere() - buf);
                cacheItem.charCount = breakCharCount;
                cacheItem.position = FTPoint(position.X(), position.Y(), position.Z());
                cacheItem.remainingWidth = remainingWidth;
@@ -331,7 +353,7 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
                wordLength += advance;
            }
        }
-       
+
        float remainingWidth = lineLength - currentWidth;
        // Render any remaining text on the last line
        // Disable justification for the last row
@@ -339,7 +361,7 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
        {
            alignment = FTGL::ALIGN_LEFT;
            layoutGlyphCacheItem_t cacheItem;
-           cacheItem.buf = (T *)lineStart.getBufferFromHere();
+           cacheItem.buf = stringCache + ptrdiff_t(lineStart.getBufferFromHere() - buf);
            cacheItem.charCount = -1;
            cacheItem.position = FTPoint(position.X(), position.Y(), position.Z());
            cacheItem.penDiff = FTPoint(0,0,0);
@@ -350,7 +372,7 @@ inline void FTSimpleLayoutImpl::WrapTextI(const T *buf, const int len,
        else
        {
            layoutGlyphCacheItem_t cacheItem;
-           cacheItem.buf = (T *)lineStart.getBufferFromHere();
+           cacheItem.buf = stringCache + ptrdiff_t(lineStart.getBufferFromHere() - buf);
            cacheItem.charCount = -1;
            cacheItem.position = FTPoint(position.X(), position.Y(), position.Z());
            cacheItem.penDiff = FTPoint(0,0,0);
diff --git a/ftgles/src/FTLayout/FTSimpleLayoutImpl.h b/ftgles/src/FTLayout/FTSimpleLayoutImpl.h
index 63b56cc..dd84234 100755
--- a/ftgles/src/FTLayout/FTSimpleLayoutImpl.h
+++ b/ftgles/src/FTLayout/FTSimpleLayoutImpl.h
@@ -50,7 +50,7 @@ class FTSimpleLayoutImpl : public FTLayoutImpl
 protected:
    FTSimpleLayoutImpl();

-   virtual ~FTSimpleLayoutImpl() {};
+   virtual ~FTSimpleLayoutImpl();

    virtual FTBBox BBox(const char* string, const int len,
                        FTPoint position);
@@ -211,10 +211,12 @@ private:
     */
     std::list<layoutGlyphCacheItem_t> layoutGlyphCache;

-   unsigned int stringCache[4096];
+   unsigned char * stringCache;

    unsigned int stringCacheCount;
+

+   void invalidate();

    /* Internal generic BBox() implementation */
    template <typename T>
-- 
1.7.6.1

Main() is being compiled into freetype2 lib

Hi I think you may have just setup the freetype2 xcode project by putting all files into it?
Do a search in the freetype2 project for "main" as complete word. You'll find you are compiling into the freetype2 lib the source for a stand alone application, which cases a link error if one tries to use FTGLES.a with another lib like SDL on the iphone :(

Crash when loading STHeiti Medium.ttc

Hei.ttf is ok
Arial Unicode.ttf is also ok
but
when draw "STHeiti Medium.ttc" from mac system font
it crash

const FTGlyph* const FTGlyphContainer::Glyph(const unsigned int charCode) const
{
unsigned int index = charMap->GlyphListIndex(charCode);
return glyphs[index]; <-------------------
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.