Black screen when sampling OpenGL texture on AMD graphics cards

Started by
11 comments, last by lawnjelly 7 years, 5 months ago

vstrakh: I see you're calling glTextureParameteri(), while passing GL_TEXTURE_2D as first argument. That's totally wrong.

Is it wrong? I do bind texture before calling glTextureParameteri. I use the function QOpenGLTexture::setMinMagFilters, which automatically binds the texure ID to GL_TEXTURE_2D


lawnjelly: I do the test using gl_FragColor = vec4(texture2D (matcapTexture, vec2(0.5, 0.5)).rgb, 1.0); it stil show the black screen. And I also put breakpoints in CodeXL when there's some OpenGL bugs, and it doesn't break anywhere. Could you suggest me some other tests?
JohnnyCode: I set up texture binding use three functions glActiveTexture(GL_TEXTURE0) ==> glBindTexture(GL_TEXTURE_2D) ==> glUniformi(3,0), where 3 is the location of texture sampler in shader program. you can see more details in the attached iamge.

C0lumbo: thank for your advice. I didn't know that pow need the base parameter to be postive. But when I changed the code as you said, it sill show black screen. Idon't think it's the problem because I tried to use the fixed texture coordinates for sampling the texutre earlier.
Advertisement
Is it wrong? I do bind texture before calling glTextureParameteri. I use the function QOpenGLTexture::setMinMagFilters

Mmm... sorry, probably I was misled by something. Why I even thought it wasn't texture id?..

How do you bind your texture before draw call?
How do you setup the sampler's uniform variable?

I think johnnycode likely has the right area.
To summarise : the texture is created ok and white and is just coming up as black when rendered with a simple shader, and hard coding the colour in the shader instead of accessing the texture works...

This does seem to suggest it is likely something simple with the shader setup (is the sampler location hard coded for example? afaik there should be a glGetUniformLocation as this may change?). Maybe just some example 'hello world' rendering a texture example code on the test machine. If it works, then go through the example code and your code, and make sure you are doing all the necessary stages, perhaps turning off everything else in your code apart from the minimum necessary.

It does sound like one of those difficult problems to debug, but is a good learning tool for this process of deduction and a binary search to try and narrow down the possibilities. It is kind of fun! :D And you will kick yourself when you find the answer... lol

This topic is closed to new replies.

Advertisement