简体   繁体   English

有人可以解释一下这个OpenGL代码吗?

[英]Can someone explain this OpenGL code please?

I'm trying to reverse a game to see how it works using GLDebugger.. The window size if 765 x 553. 我正在尝试使用GLDebugger来反转游戏以查看它是如何工作的。窗口大小如果是765 x 553。

Texture2D 184 looks like: Texture2D 184看起来像: 在此输入图像描述

and Texture2D 203 looks like: 和Texture2D 203看起来像:

在此输入图像描述

The result of the code is (ignore the dollar sign and exclamation mark): 代码的结果是(忽略美元符号和感叹号): 在此输入图像描述

The code behind it all is: 它背后的代码是:

glEnable(GL_SCISSOR_TEST)
glScissor(516, 335, 249, 168)
glEnable(GL_SCISSOR_TEST)
glScissor(550, 341, 154, 154)
glDisable(GL_TEXTURE_RECTANGLE)
glEnable(GL_TEXTURE_2D)

glBindTexture(GL_TEXTURE_2D, 184)
glActiveTextureARB(GL_TEXTURE1)
glEnable(GL_TEXTURE_RECTANGLE)
glBindTexture(GL_TEXTURE_RECTANGLE, 203)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, 7681)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, 8448)
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, 34168)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, 768)

glBegin(GL_QUADS)
glColor3f(1, 1, 1)
glMultiTexCoord2fARB(GL_TEXTURE0, 0, 1)
glMultiTexCoord2fARB(GL_TEXTURE1, -194.55215, 353.57529)
glVertex2f(355.44785, -141.57529)
glMultiTexCoord2fARB(GL_TEXTURE0, 0, 0)
glMultiTexCoord2fARB(GL_TEXTURE1, -212.4122, -194.13358)
glVertex2f(337.5878, 406.13358)
glMultiTexCoord2fARB(GL_TEXTURE0, 1, 0)
glMultiTexCoord2fARB(GL_TEXTURE1, 335.29663, -211.99362)
glVertex2f(885.29663, 423.99362)
glMultiTexCoord2fARB(GL_TEXTURE0, 1, 1)
glMultiTexCoord2fARB(GL_TEXTURE1, 353.15674, 335.71524)
glVertex2f(903.15674, -123.71524)
glEnd()

I want to know what the above code does because I want to know how such a large map turns into something so tiny :S 我想知道上面的代码是做什么的,因为我想知道这么大的地图如何变成如此微小的东西:S

Can someone perhaps break it down or use these images or different images or anything at all to explain it? 有人可能会分解或使用这些图像或不同的图像或任何东西来解释它吗?

The big thing to recognize is that, quite simply, all this code does is to 'scissor' out the region you're standing in, apply a circular filter on it, and then draw it on the screen. 需要注意的是,很简单,所有这些代码都是“剪切”你所在的区域,在其上应用圆形滤镜,然后在屏幕上绘制。

glEnable is needed in order to use the glScissor command. 需要glEnable才能使用glScissor命令。 Why they enable it and use it twice in a row is beyond me. 为什么他们启用它并连续两次使用它超出了我的范围。 From what I understand, it only needs to be enabled and used once for this code. 根据我的理解,它只需要为此代码启用和使用一次。

We then see the main texture bound to GL_TEXTURE_2D and the smaller one bound to GL_TEXTURE_RECTANGLE. 然后我们看到绑定到GL_TEXTURE_2D的主纹理和绑定到GL_TEXTURE_RECTANGLE的较小纹理。 A number of environment flags are set so that the GL_TEXTURE_RECTANGLE being used as a filter produces the right result, by combining certain things and using source and operand on others. 设置了许多环境标志,以便GL_TEXTURE_RECTANGLE用作过滤器,通过组合某些事物并在其他事物上使用源和操作数来产生正确的结果。

Once we get into glBegin, we begin actually drawing to the screen. 一旦我们进入glBegin,我们就开始实际绘制到屏幕上。 glEnd signifies the end of drawing to the screen. glEnd表示绘制到屏幕的结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM