GL glNewList 渲染列表似乎不理会我重新设置的比例。

huangapple go评论64阅读模式
英文:

GL glNewList Render list seemingly ignoring me resetting the scale

问题

正如标题所说,我在重置GL列表的比例时遇到了一些麻烦,所以当渲染代码使用列表调用下一个列表时,它比应该小,这导致它不断变小,直到消失。

这是我的代码,不包含渲染命令。为了充分演示我尝试过的内容,我会先简化代码。我正在为Minecraft Beta 1.7.3制作自定义字体代码修改,除了这一个部分之外,其他部分都完美运行... 也就是使用多个图像正确缩放字体。无论如何,我们开始吧。

for(int i1 = 0; i1 < ChatAllowedCharacters.allowedCharacters.length(); i1++)
{
    updateFontImage(i1, renderengine, tex);
    fontTextureName = getTextureId(i1, renderengine);
    GL11.glNewList(fontDisplayLists + i1 + (i1 > 256 ? 512 : 0), 4864 /*GL_COMPILE*/);
    GL11.glBindTexture(3553, fontTextureName);
    tessellator.startDrawingQuads();
    int l1 = (i1 % 16) * (textureWidth/16);
    int k2 = (i1 / 16) * (textureWidth/16);
    float f = (float)(textureWidth/16);
    float f1 = 0.0F;
    float f2 = 0.0F;
    tessellator.addVertexWithUV(0.0D, 0.0F + f, 0.0D, (float)l1 / (float)(textureWidth) + f1, ((float)k2 + f) / (float)(textureWidth) + f2);
    tessellator.addVertexWithUV(0.0F + f, 0.0F + f, 0.0D, ((float)l1 + f) / (float)(textureWidth) + f1, ((float)k2 + f) / (float)(textureWidth) + f2);
    tessellator.addVertexWithUV(0.0F + f, 0.0D, 0.0D, ((float)l1 + f) / (float)(textureWidth) + f1, (float)k2 / (float)(textureWidth) + f2);
    tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (float)l1 / (float)(textureWidth) + f1, (float)k2 / (float)(textureWidth) + f2);
    tessellator.draw();
    GL11.glTranslatef(charWidth[i1], 0.0F, 0.0F);
    GL11.glEndList();
}

如果你不了解Minecraft的代码是什么样的,让我解释一下。tessellator代码是指示Tesselator绘制的内容,据我理解,它本质上是一个简化使用OpenGL绘图的OpenGL助手。我认为这非常聪明。
updateFontImage和fontTextureName只是我用来获取字体纹理图像的内容。

我确定所有的代码都在渲染列表的开始和结束命令之间,而不是之前或之后。是的,不同的值应该出现,但是为了测试我需要放置命令的位置,现在我只是使用0.5,以确保无论使用什么图像,所有代码都是相同的,作为测试的对照组。

所以,我尝试过:

  • 在列表开头放置了GL11.glScaled(1, 1, 1),在tessellator.draw之后放置了0.5, 0.5, 0.5。
  • 在列表开头放置了GL11.glScaled(1, 1, 1),在tessellator.draw之前放置了0.5, 0.5, 0.5。
  • 做与上述相同的事情,但是将0.5, 0.5, 0.5放在开头,将1, 1, 1放在末尾。
  • 做与上述相同的事情,但是将第一个glScaled命令放在startDrawingQuads之后,而不是之前。
  • 我甚至尝试通过在0.5, 0.5, 0.5之后紧接着放置1.5, 1.5, 1.5来“抵消”0.5, 0.5, 0.5... 但没有成功!怎么办!?
  • 我确保尝试在底部的平移之前和之后放置结束命令。仍然没有效果。

无论我如何努力,加载游戏后,每个渲染的字母都比上一个要小,就好像我从未尝试过重置比例一样。我该如何解决这个问题?我完全被难住了。我知道每个字母都能正确地单独渲染,因为每个字母都可以分配自己的字体图像。

提前感谢您的答复。我会尝试任何人告诉我的方法,或者告诉他们我已经尝试过,只是忘记将其放在上面的列表中。

供参考,这里是几乎所有我尝试过的方法产生的愚蠢结果。Silly Text

英文:

As the title says, I'm having a bit of trouble resetting the scale on my GL List, so when the next one is called by the rendering code using the list, it's smaller than it should be, this causes it to keep getting smaller until it fades out of existence.

Here's my code, without the render commands. To fully demonstrate what I've tried I'll simplify the code first. I'm making custom font code modifications for Minecraft Beta 1.7.3, which works perfectly except this ONE part... which is scaling the font correctly with multiple images. Anyways, let's go.

<!-- begin snippet: java hide: false console: true babel: false -->

<!-- language: lang-java -->

        for(int i1 = 0; i1 &lt; ChatAllowedCharacters.allowedCharacters.length(); i1++)
{
updateFontImage(i1, renderengine, tex);
fontTextureName = getTextureId(i1, renderengine);
GL11.glNewList(fontDisplayLists + i1 + (i1 &gt; 256 ? 512 : 0), 4864 /*GL_COMPILE*/);
GL11.glBindTexture(3553, fontTextureName);
tessellator.startDrawingQuads();
int l1 = (i1 % 16) * (textureWidth/16);
int k2 = (i1 / 16) * (textureWidth/16);
float f = (float)(textureWidth/16);
float f1 = 0.0F;
float f2 = 0.0F;
tessellator.addVertexWithUV(0.0D, 0.0F + f, 0.0D, (float)l1 / (float)(textureWidth) + f1, ((float)k2 + f) / (float)(textureWidth) + f2);
tessellator.addVertexWithUV(0.0F + f, 0.0F + f, 0.0D, ((float)l1 + f) / (float)(textureWidth) + f1, ((float)k2 + f) / (float)(textureWidth) + f2);
tessellator.addVertexWithUV(0.0F + f, 0.0D, 0.0D, ((float)l1 + f) / (float)(textureWidth) + f1, (float)k2 / (float)(textureWidth) + f2);
tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (float)l1 / (float)(textureWidth) + f1, (float)k2 / (float)(textureWidth) + f2);
tessellator.draw();
GL11.glTranslatef(charWidth[i1], 0.0F, 0.0F);
GL11.glEndList();
}

<!-- end snippet -->

If you're unaware of what Minecraft's code is like, let me explain. The tessellator code is what's ordering the Tesselator to draw, which is, to my understanding, essentially an OpenGL helper that simplifies drawing with OpenGL. It's incredibly clever in my opinion.
updateFontImage and fontTextureName is just what I used to get the font texture images.

I am sure all of the code is within the render list start and end commands, and not before or after. Yes, different values are supposed to come up, but for testing where I need to put the commands I'm just using .5 for now to ensure all the code is the same no matter what images are used, as a control for testing.
So, I have tried:

  • Putting a GL11.glScaled 1, 1, 1 at the beginning of the list and the .5, .5, .5 at the end after the tessellator.draw.
  • Putting a GL11.glScaled 1, 1, 1 at the beginning of the list and a .5, .5, .5 at the end before the tessellator.draw.
  • Doing the same as above, but with the .5, .5, .5 at the beginning at the 1, 1, 1 at the end instead.
  • Doing all the same as above, but putting the first glScaled commands after startDrawingQuads, instead of before.
  • I've even tried "countering" the .5 .5 .5 by putting a 1.5 1.5 1.5 right after it... no dice! How!?
  • I've made sure trying to put the end command before the translate at the bottom, then after it. Still nothing.

No matter how hard I try, loading up the game, each letter rendered is smaller than the last as if I never tried to reset the scale. How do I fix this? I'm completely stumped. I know that each letter renders separately correctly as each letter is able to be assigned its own font image.

Thanks in advance for answers. I'll try what anyone tells me, or tell them if I've already tried it and forgot to put it in the above list.

For reference, here's the silly result pretty much everything I've tried has given.Silly Text

答案1

得分: 0

几何图元四边形随图像大小变大,游戏最初通过缩小它们以适应较大的字体纹片。然而,我可以强制其以默认大小进行渲染,高分辨率的字母也能很好地适应其中。

英文:

The tessellator quads get bigger with image size, and the game originally fixed this by scaling them down for larger font sheets. However, I can instead force it to render at the default size and higher-res letters fit in just fine.

huangapple
  • 本文由 发表于 2020年7月28日 23:28:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/63137702.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定