OpenGL纹理加载问题 [英] OpenGL texture loading issue

查看:288
本文介绍了OpenGL纹理加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常模糊的问题,所以请随时澄清这个项目的任何内容。

This is a very vague problem, so please feel free to clarify anything about this project.

我正在开发一个非常大的应用程序,最近很令人困惑的bug已经出现在纹理上了。我们正在加载的一些纹理正在加载 - 我已经遍历了代码,它运行 - 但所有OpenGL渲染的纹理是一个奇怪的粉色/白色条纹纹理。

I'm working on a very large application, and recently a very perplexing bug has cropped up regarding the texturing. Some of the textures that we are loading are being loaded - I've stepped through the code, and it runs - but all OpenGL renders for those textures is a weird Pink/White striped texture.

您甚至建议甚至开始调试这种情况?

What would you suggest to even begin debugging this situation?


  • 该项目是多线程的,但互斥体确保所有OpenGL调用都不会被其他任何内容中断。

  • 正在加载一些纹理,有些纹理不会被加载。它们都以完全相同的方式加载。

  • 我确保所有纹理都存在

  • 粉红色/白色纹理是绝对加载在内存中 - 在我将任何其他纹理加载到OpenGL后,它们就会变得可见。

  • The project is multithreaded, but a mutex makes sure all OpenGL calls are not interrupted by anything else.
  • Some textures are being loaded, some are not. They're all loaded in the exact same way.
  • I've made sure that all textures exist
  • The "pink/white" textures are definitely loaded in memory - they become visible shortly after I load any other texture into OpenGL.

我很困惑,不知道还有什么可以错的是否有可以在glTexImage之后调用的OpenGL命令,这将强制纹理变得可用?

I'm perplexed, and have no idea what else can be wrong. Is there an OpenGL command that can be called after glTexImage that would force the texture to become useable?

编辑:
这不是关于命令失败,主要是时间问题。粉色/白色纹理显示了一段时间,直到加载更多的纹理。这几乎就像纹理排队一样,队列在某个时间暂停。

It's not about the commands failing, it's mainly a timing issue. The pink/white textures show up for a while, until more textures are loaded. It's almost as if the textures are queued up, and the queue just pauses at some time.

下一个编辑:我得到了glIntercept日志正常工作,这就是它输出(整个程序崩溃之前)

Next I got the glIntercept log working correctly, and this is what it outputted (before the entire program crashed)

http:// freetexthost .com / 1kdkksabdg

下一个编辑:我知道纹理加载在OpenGL内存中,但由于某些原因,它们不会在自己编程

Next I know for a fact the textures are loaded in OpenGL memory, but for some reason they're not rendering in the program themselves.

推荐答案

检查纹理坐标。如果设置错误,您只能看到一个或两个纹素映射到整个基元。记住,OpenGL是一个状态机。检查是否在错误的时间更改纹理坐标状态。您可能会稍后在代码中设置纹理坐标,然后当您重新绘制这些元素时,状态可以将您的纹理映射到代码。

Check your texture coordinates. If they are set wrong, you can see just one or two texels mapped to entire primitives. Remember, OpenGL is a state machine. Check if you're changing the texture coordinate state at the wrong time. You may be setting the texture coordinates at a later point in your code, then when you get back to redrawing these elements the state is acceptable for mapping your texture to the code.

如果它只是时间问题,其中加载OpenGL调用的纹理不会及时执行,并且您的线程代码正确,请尝试在加载纹理后添加对glFlush()的调用。 glFlush()会导致所有挂起的OpenGL命令执行。

If it is merely a timing issue where the texture loading OpenGL calls aren't executed in time, and your threading code is correct, try adding a call to glFlush() after loading the textures. glFlush() causes all pending OpenGL commands to execute.

这篇关于OpenGL纹理加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆