简体   繁体   English

OpenGL纹理渲染的质量很低

[英]OpenGL texture renders with very low quality

Due to performance bottlenecks in Core Graphics, I'm trying to use OpenGL EL on iOS to draw a 2D scene, but OpenGL is rendering my images at an incredibly low resolution. 由于Core Graphics的性能瓶颈,我试图在iOS上使用OpenGL EL绘制2D场景,但是OpenGL以令人难以置信的低分辨率渲染图像。

Here's part of the image I'm using (in Xcode): 这是我正在使用的图像的一部分(在Xcode中):

在此处输入图片说明

And OpenGL's texture rendering (in simulator): 以及OpenGL的纹理渲染(在模拟器中):

在此处输入图片说明

I'm using Apple's Texture2D to create a texture from a PNG, and then to draw it to the screen. 我正在使用Apple的Texture2D从PNG创建纹理,然后将其绘制到屏幕上。 I'm using an Ortho projection to look straight down on the scene as was recommended in Apress' Beginning iPhone Development book. 我正在使用Ortho投影来直视场景,这在Apress的《 Beginning iPhone Development》一书中是推荐的。 The image happens to be the exact size of the screen and is drawn as such (I didn't take the full image in the screenshots above). 该图像恰好是屏幕的确切尺寸,并以此方式绘制(我没有在上面的屏幕截图中拍摄完整图像)。 I'm not using any transforms on the model, so drawing the image should cause no sub-pixel rendering. 我没有在模型上使用任何变换,因此绘制图像不应导致任何亚像素渲染。

I'm happy to post code examples, but thought I'd start without in the case that there's a simple explanation. 我很高兴发布代码示例,但是我认为如果没有简单的解释,我会从头开始。

Why would the image lose so much quality using this method? 为什么使用这种方法会导致图像质量下降太多? Am I missing a step in my environment setup? 我是否缺少环境设置步骤? I briefly read about textures performing better as sizes of powers of two -- does this matter on the iPhone? 我简要介绍了纹理的性能是2的幂次方更好-在iPhone上这有关系吗? I also read about multisampling, but I wasn't sure if that was related. 我还阅读了有关多重采样的信息,但不确定是否相关。

Edit: Updated screen shots so as to alleviate confusion. 编辑:更新了屏幕截图,以减轻混乱。

I still don't fully understand why I was having quality issues with my code, but I managed to work around the problem. 我仍然不完全理解为什么我的代码存在质量问题,但是我设法解决了该问题。 I was originally using the OpenGLES2DView class provided by the makers of the Apress book "Beginning iPhone 4 Development", and I suspect the problem lied somewhere within this code. 我最初使用的是Apress的“ Beginning iPhone 4 Development”一书的提供者提供的OpenGLES2DView类,我怀疑问题出在此代码内。 I then came across this tutorial which suggested I use GLKit instead. 然后,我遇到了本教程该教程建议我改用GLKit。 GLKit allowed me to do exactly what I wanted! GLKit允许我做我想做的事情!

A few lessons learned: 一些经验教训:

  1. Using GLKit and the sprites class in the tutorial linked above, my textures don't need to be powers of two. 使用上面链接的教程中的GLKit和sprites类,我的纹理不必是2的幂。 GLKit seems to handle this fine. GLKit似乎可以解决这个问题。

  2. Multisampling was not the solution to the problem. 多重采样不是解决问题的方法。 With GLKit, using multisampling seemingly has no effect (to my eye) when rendering 2D graphics. 使用GLKit,在渲染2D图形时,使用多重采样似乎没有作用(在我看来)。

Thanks all who tried to help. 感谢所有尝试提供帮助的人。

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

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