VB OpenGL Chinese characters display

zhaozj2021-02-16  64

These two days have a project to do three-dimensional use Esri's ArcScene, but the Chinese road name must be written with an extension module.

Esri is convenient for users and developers' angles and Microsoft very like, with new technologies, it is very close, providing a large number of sample programs, finding a text written, it is written by OpenGL. I have heard OpenGL only C interface, I didn't expect VB, I can write OpenGL to Dongdong. It turned out that some people have made an OpenGL type library vbogl.tlb, and there is no online search for this site to find this website http://home.pacific.net.hk/~edx/.

I originally thought that I didn't expect trouble until I didn't think of trouble. The source program provided by foreigners is of course written in Wen Wen, and I didn't expect to rewrite it into energy. I am not familiar with OpenGL, I have read several examples to write TrueType text. Create GLYPH and call a list (Display List), which is equivalent to a small vector graphics, then call GlcallLists to draw it. Every glyphone has a number when it is created, and it will be referenced by this number. This number is not a inevitable connection with the code of the text, such as ASCII or Chinese characters, because the Western character set is small, so many examples are GLYPH that can show the Western characters, then directly use these Glyphs. . This makes me understands a lot of trouble, and the Chinese character set is too big. All Chinese characters are generated. The corresponding GLYPH.

Later, I found a VC written code snippet to display the 3D Chinese character. It was a character handling. I felt very strange because the Western strings were batch, Chinese and Western or pure Chinese must be one deal with. Later, I finally understood that it turned out to be such a thing, generating a separate GLYPH for each character in the string. The VC can be, go to VB, it is originally thought that the problem is not very big, and I didn't expect to toss a day.

VB inside the string represents BSTR, encoding is Unicode. OpenGL has no Unicode version only Ansi version, it is coming. Thinking about the various ways, it will not come out of the Chinese characters, and later found that it is wrong. Unicode defaults in the VC is DBCS, and the Chinese environment is GBK encoding. For example, "China" Unicode is "0x4E2D56FD", while GBK coding is "0xD6D0B9FA". The Unicode in the VB must be converted to GBK can be displayed correctly. There are two ways to call the API function widechartomultibyte to turn, but there is a simpler way in VB is to call the global function StrConv (S, VBFRomunicode) Returns a GBK encoded byte array. that's it.

转载请注明原文地址:https://www.9cbs.com/read-15711.html

New Post(0)