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

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

问题描述

这是一个非常模糊的问题,所以请随时澄清这个项目什么。

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

我工作的一个非常大的应用程序,并在最近一个非常令人困惑的bug也随之而来,关于纹理。一些我们正在加载被加载的纹理 - 我在code已经加强,并且它运行 - 但所有的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

我很困惑,而且不知道还有什么可以是错误的。有没有办法,可以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是一个状态机。检查您是否正在改变纹理坐标状态在错误的时间。你可能会设置在您的code稍后纹理坐标,那么当你回到重绘这些元素的状态是可以接受你的纹理映射到code。

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调用不及时执行的计时问题,和你的线程code是正确的,请尝试载入纹理后面添加一个调用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天全站免登陆