Chinese character in OpenGL

Started by
9 comments, last by Kenny Ho 22 years, 7 months ago
Hello, I''m newbie in OpenGL. How can I display a chinese character in OpenGL? Could anyone give me a example please? Thank you .
Advertisement
Chinese characters are difficult, simply because there''s so many of them. Now, I''m no linguist, and I don''t know any chinese, so my assumptions about the characters may be wrong, but the way I do it is to have a "character cache". Say you store the last 100 characters drawn in some cache, and whenever you go to draw a new one, you check if it''s in the cache and just use that, if not, you flush one of the old characters and draw this one in (perhaps using GDI, or your own rendering function, or maybe even loading the glyph from disk). It''s not lightning fast, but I don''t think you''re going to find any lightning fast methods (that don''t use enormous amounts of memory).

This would work well if you have a few commonly used characters and the rest are only used now and then (even better if they''re usually used more than once in any given sentence/phrase).

Like I said, I don''t know Chinese, so I don''t know if those are valid assumptions.

If you''re new to OpenGL, though, I would recommend you forget about Chinese characters and just use English characters (or some other language where the actual management of the glyphs is not a concern). Come back to the problem when you know a bit more.

codeka.com - Just click it.
Create a character map in your favourite graphics program, with all the characters using an equal amount of space. Load it into opengl, and when writing the text out to the screen, bind to the character map texture, and set the texture coordinates to the character you wish to display.
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Maximus, you do realise that there''s around 14,000 chinese characters, don''t you?

codeka.com - Just click it.
That would be something cool.

I don''t think he wants to draw them BY HAND.

Isn''t there some way to display foreign True Type characters in Windows
using GDI? If there is, just use GDI to draw them on a bitmap and display
them.

But you did not specify if you wanted 2D or 3D extruded text. I think there
is a way to do both.
14,000 characters. Their keyboards must be big.

-SirKnight
No,they use Microsoft keyboard also.But they have many way to input Chinese character.
quote:Original post by Dean Harding
Maximus, you do realise that there''s around 14,000 chinese characters, don''t you?

codeka.com - Just click it.


You''re point being? If he is determined enough to do it, then he will do it. If it isnt too important or he isnt determined enough, he wont do it.

It just means that it will be one hell of a big character map.

And to answer your question, no. I dont speak chinese, only english, a little indoneasian, and very little japanese.
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
You can use wglUseFontOutlines function to create display lists and then use glCallLists to render the chinese words.
You can search the MSDN for a text3d screensaver sample code,I myself referenced this code
If you still can''t figure out how to do that,please feel free to contact me at xiangping@263.net,i''ll show you my code to handle that if you like.
*this is just flames and ranting, please ignore*
O my God are you guys ignorant... Frankly I really don''t even understand why I goto this website when the average IQ around here is room temperature... Although someone actually had a *gasp* good Idea of using the windows built in ''3D text'' charachters, 1.) It wouldn''t be support for full manderin chinese and 2.) Your talking about literally eating memory.

The obvious solution is to simply have a 32-bit texture (One containing the alpha channel) of the word roots, as well as phenitic hints. Then (although by hand) you could construct your various kanji from those radicals w/o the need to store a seperate graphic. Such as ''rest'' being composed ''man'' and ''tree'', simply have the two textures, then render them side by side with the alpha test enabled.

I am very dissapointed in the ''l33t''

CodeSmith the Pixel Pusher
www.cs.trinity.edu/~csmith8
CodeSmith the Pixel PusherCodeSmith Webpage

This topic is closed to new replies.

Advertisement