Android NDK OpenGL ES 2.0 纹理间距
有没有什么方法可以在 opengl es 2.0 中以与其宽度不同的间距来位图纹理。通常我会通过使用 PBO 或通过 glPixelStore 调整 GL_PACK_ROW_LENGTH 来解决此问题。然而,Android 平台上似乎既不存在用于绑定缓冲区的 GL_PIXEL_UNPACK_BUFFER 也不存在 GL_PACK_ROW_LENGTH 。
glTex(Sub)Image2D 不支持此功能。
有什么建议吗?
Is there any way to blit a texture in opengl es 2.0 with a pitch that differs from its width. Normally I would fix this by using a PBO or adjusting the GL_PACK_ROW_LENGTH via glPixelStore. However it seems neither GL_PIXEL_UNPACK_BUFFER for binding a buffer to or GL_PACK_ROW_LENGTH exist on the Android platform.
glTex(Sub)Image2D does not support this.
Any tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
引用@Halsafar
假设我有一个
512
x512< /code>
纹理间距为
512
*位深度
但我想要使用的数据被定位到
256
*位深度
我继续,
glSubTexImage2D
仍然,但将纹理坐标调整为0
至 (256/512
),而不是
0
到1
。换句话说,去掉我不使用的纹理部分。
Quoting @Halsafar
Lets say I have a
512
x512
texture pitched at512
*bitdepth
but the data I want to use is pitched to
256
*bitdepth
I go ahead and
glSubTexImage2D
still but adjust the texture coords to be0
to (256/512
)instead of
0
to1
.In other words strip off the part of the texture I'm not using.
这听起来可能有点矫枉过正(甚至不太符合您的期望),但也许您可以简单地利用光栅化器和帧缓冲区对象:
创建一个带有纹理作为颜色缓冲区的 FBO,然后...通过一个简单的顶点+片段着色器在其中绘制一些纹理四边形:您可以在其中使用简单的 Ortho。在顶点着色器中使用投影矩阵,并在片段着色器中使用点采样纹理采样。
it might sound a bit overkill (or even not so fitting to your expectation), but maybe you could simply take advantage of the rasterizer and Frame-buffer objects :
create a FBO with the texture as the color buffer and... draw in it some textured quad(s) thanks to a trivial vertex+fragment shader : where you would use a simple Ortho. projection matrix in the vertex shader and use a Point-sampling texture sampling in the fragment shader.
因为我在评论中回答了这个问题,所以这里有一个更直接的答案:
现在使用这些 texcoords 进行渲染,您可以将 256x256 纹理粘贴在 512x512 缓冲区中。您要使用的宽度和高度可以是等于或小于最大尺寸的任何尺寸。
Since I answered it in a comment here is a more direct answer:
Now use these texcoords to render and you can stick a 256x256 texture in a 512x512 buffer. The width and height you want to use can be any size equal to or below your max size.