Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate a texture #3

Open
hominlinx opened this issue Aug 25, 2014 · 3 comments
Open

How to generate a texture #3

hominlinx opened this issue Aug 25, 2014 · 3 comments

Comments

@hominlinx
Copy link

hi
thanks your project, and I want to know how to generate a texture?
there are two methods:

  1. Each sentence to generate a texture. such as "Hello china" and "Hello usa" are two textures.
    2.Using a large texture. such as "Hello china" and "Hello usa" are one texture. this texture contains all of the characters

I think 2 is better. and which one in your pro. thanks very much
BR

@arielm
Copy link
Owner

arielm commented Aug 26, 2014

Hominlinx,

I was lucky to stumble upon the question you asked at the Harfbuzz repo, otherwise it would have been difficult to focus...

So, in order to display abc中国ป็, proceed as follow:

  1. Install whatever necessary to use the Unicode test suite for Cinder & C++ 11, as described in the README.

  2. Open the latest version of the Rendering project from the develop branch (and install the required additional Cinder blocks.)

  3. Replace the following lines with drawTextLine(*font, "abc中国ป็", y, left, right);

In short, the Rendering project contains the "overall wisdom" of this repository, which consists of an evolving series of projects focusing on a particular topic.

If you want to understand some key features like script itemization and BIDI, you can refer to some of the relevant projects. But again: take in count that the code is deprecated except in the the latest project...

@hominlinx
Copy link
Author

thank you very much for your reply, And From your pro ,I know how “how to display two languages(or more) in one string?"
but I question is ”How to generate a texture“, from your Reloadable , I find "textureData" is only one glyph, that will have lots of textures, right??

@arielm
Copy link
Owner

arielm commented Aug 29, 2014

Sorry for the delay. I'm a bit swamped these days...

First, let's refer to the latest / up-to-date version of the Unicode text engine, which has been integrated to the new-chronotext-toolkit.

From now on, the Unicode text engine will be called the ZFont system. It co-exists side-by-side with an older, non-unicode text engine (the XFont system.)

The ReloadableTexture class you mentioned is outdated. It has evolved into FontTexture, but in essence, and as you already discovered: one single OpenGL texture is used for each glyph.

Why not using a large texture containing many glyphs instead?

  1. The ZFont system is dynamic: you don't need to define in advance which glyphs are going to be used.
  2. The ZFont system must support texture mip-mapping.
  3. The ZFont system must perform well under limited memory conditions.

In the future, the following enhancements are planned:

  • Handling a dynamic set of texture-atlases when mip-mapping is not necessary.
  • Finding a way to perform mip-mapping on a dynamic set of texture-atlases.
  • Finding a way to manage a dynamic set of texture-atlases in term of memory usage (i.e. ability to regenerate the sets when some least-used-glyphs are flushed...)

Meanwhile, and performance-wise: a batching system allows to minimize texture switching when rendering a lot of text...

If you are interested in the technical side-of-things: you can check how the font-texture-atlas is implemented in the old XFont system (reminder: this is an older text-engine, not adapted to Unicode text rendering...)

You can also check the code samples. Some of them are demonstrating how to work either with the ZFont or XFont systems...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants