I m与SDL和开放式GL合作,形成一个相当简单的申请。 我设立了一个基本的文本功能,它把产生的文字绘制成每个特性的一块。 案文取自每一特性的对照图。
轨道图相当小,大约为800x16皮克。 该系统在我的台式和膝上型计算机上,在仪器内外(以及视窗和Windows)进行
Now, I m trying it on another computer, and the text becomes all garbled - it appears as though the computer can t handle a very basic thing like this. To see if it was due to the OS, I installed VirtualBox and tested it in the VM - but the result is even worse! Instead of rendering anything (albeit garbled), it just renders a plain white box.
Why is this occuring, and is there any way to solve it?
某些法典——我如何初步确定案文:
glGenTextures(1, &fontRef);
glBindTexture(GL_TEXTURE_2D, iFont);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, FNT_IMG_W, FNT_IMG_H, 0,
GL_RGB, GL_UNSIGNED_BYTE, MY_FONT);
Above, MY_FONT
is an unsigned char array (the raw image dump from GIMP). When I draw a character:
GLfloat ix = c * (GLfloat) FNT_CHAR_W;
// We just map each corner of the texture to a new vertex.
glTexCoord2d(ix, FNT_CHAR_H); glVertex3d(x, y, 0);
glTexCoord2d(ix + FNT_CHAR_W, FNT_CHAR_H); glVertex3d(x + iCharW, y, 0);
glTexCoord2d(ix + FNT_CHAR_W, 0); glVertex3d(x + iCharW, y + iCharH, 0);
glTexCoord2d(ix, 0); glVertex3d(x, y + iCharH, 0);