English 中文(简体)
开放式GL文本协调会
原标题:Texture Coordinates for OpenGL
  • 时间:2012-04-24 00:59:56
  •  标签:
  • c++
  • opengl

我有一份作为案文装满的蒂尔什蒂特,我正试图使案文独一无二。

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, TileSheet);
float TY = (Tile / 16) * 0.0625;
float TX = (Tile % 16) * 0.0625;

glBegin(GL_QUADS);
    glTexCoord2f(TX, TY); glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
    glTexCoord2f(TX + 0.0625, TY); glVertex3f(X + TILE_SIZE, Y, 0);
    glTexCoord2f(TX + 0.0625, TY + 0.0625); glVertex3f(X + TILE_SIZE, Y + TILE_SIZE, 0);
    glTexCoord2f(TX, TY + 0.0625); glVertex3f(X, Y + TILE_SIZE, 0);
glEnd();

Tile is an int and represents what tile to render on the tilesheet 0.0625 being Width and Height of my Tilesheet / How many tiles per line (512 / 16)

因此,如果<代码>Tile<>>/code>是左边的16个tile子,从左上层的1个tile子,那么就等于16个tile。 但这是我获得的

因此,最左边是[0][0],最低权利为[0]。 我急切地看到,什么是错的。 非常感谢任何帮助。

感谢。

我还要提到,如果是<条码>。 Tile = 0,使之具有正确的作用,但很快就能成为。 Tile > 0 废墟如上。

最佳回答

页: 1 页: 1 这并不正确。

它希望:

glTexCoord2f(Rox, Y, 0);

应:

glTexCoord2f(HF, TY); glVertex3f(X,Y, 0);

问题回答

暂无回答




相关问题
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?