English 中文(简体)
我的案文为什么在开放式GL的申请中被不当化?
原标题:Why is my texture rendered improperly in my OpenGL application?

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);
最佳回答

这对我来说是,如果你所使用机器的制图卡只支持两种文字(即16、32、64)。 800x16当然不会使用这种fx卡。

您可使用<glGet > >ARB_texture_non_power_of_2,以检查该x卡是否支持。

或利用GLEW对你进行检查。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签