Trouble with OpenGL 3 texturing

07b9e9e8483468e4a0e1bac1843e6e74
0
Snoob 105 Sep 03, 2013 at 19:08 opengl

Actually I port my render sources from OpenGL 2.x to OpenGL 3.x/4.x. Basics working fine and I could render a untextured quad. Now I try to perform simple texturing but I fail, nothing is textured I only got a black quad rendered. While I couldn’t get GLSL Devil or gDEBugger working I set up APITRACE for OpenGL and GLSL state debugging. Here is my actual state trace of the first two render calls:

wglDescribePixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 1, nBytes = 0, ppfd = NULL) = 126
0 wglChoosePixelFormat(hdc = 0xffffffff9b010aaa, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, iPixelType = 0, cColorBits = 32, cRedBits = 0, cRedShift = 0, cGreenBits = 0, cGreenShift = 0, cBlueBits = 0, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 0, cAccumBits = 0, cAccumRedBits = 0, cAccumGreenBits = 0, cAccumBlueBits = 0, cAccumAlphaBits = 0, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 0, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 8
3 wglDescribePixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 8, nBytes = 40, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SWAP_EXCHANGE | PFD_SUPPORT_COMPOSITION, iPixelType = 0, cColorBits = 32, cRedBits = 8, cRedShift = 16, cGreenBits = 8, cGreenShift = 8, cBlueBits = 8, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 24, cAccumBits = 64, cAccumRedBits = 16, cAccumGreenBits = 16, cAccumBlueBits = 16, cAccumAlphaBits = 16, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 4, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 126
2 wglSetPixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 8, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, iPixelType = 0, cColorBits = 32, cRedBits = 0, cRedShift = 0, cGreenBits = 0, cGreenShift = 0, cBlueBits = 0, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 0, cAccumBits = 0, cAccumRedBits = 0, cAccumGreenBits = 0, cAccumBlueBits = 0, cAccumAlphaBits = 0, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 0, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = TRUE
5 wglGetPixelFormat(hdc = 0xffffffff9b010aaa) = 8
6 wglDescribePixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 8, nBytes = 40, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SWAP_EXCHANGE | PFD_SUPPORT_COMPOSITION, iPixelType = 0, cColorBits = 32, cRedBits = 8, cRedShift = 16, cGreenBits = 8, cGreenShift = 8, cBlueBits = 8, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 24, cAccumBits = 64, cAccumRedBits = 16, cAccumGreenBits = 16, cAccumBlueBits = 16, cAccumAlphaBits = 16, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 4, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 126
7 wglGetPixelFormat(hdc = 0xffffffff9b010aaa) = 8
8 wglDescribePixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 1, nBytes = 0, ppfd = NULL) = 126
4 wglCreateContext(hdc = 0xffffffff9b010aaa) = 0x10000
10 wglGetPixelFormat(hdc = 0xffffffff9b010aaa) = 8
11 wglGetPixelFormat(hdc = 0xffffffff9b010aaa) = 8
12 wglDescribePixelFormat(hdc = 0xffffffff9b010aaa, iPixelFormat = 1, nBytes = 0, ppfd = NULL) = 126
9 wglMakeCurrent(hdc = 0xffffffff9b010aaa, hglrc = 0x10000) = TRUE
13 glViewport(x = 0, y = 0, width = 1, height = 1)
14 glScissor(x = 0, y = 0, width = 1, height = 1)
16 wglGetPixelFormat(hdc = 0xffffffff9b010aaa) = 8
15 wglMakeCurrent(hdc = 0xffffffff9b010aaa, hglrc = 0x10000) = TRUE
621 glGetIntegerv(pname = GL_MAJOR_VERSION, params = &3)
622 glGetIntegerv(pname = GL_MINOR_VERSION, params = &3)
630 wglGetExtensionsStringARB(hdc = 0xffffffff9b010aaa) = "WGL_ARB_buffer_region WGL_ARB_create_context WGL_ARB_create_context_profile WGL_ARB_create_context_robustness WGL_ARB_extensions_string WGL_ARB_make_current_read WGL_ARB_multisample WGL_ARB_pbuffer WGL_ARB_pixel_format WGL_ARB_pixel_format_float WGL_ARB_render_texture WGL_ATI_pixel_format_float WGL_EXT_create_context_es_profile WGL_EXT_create_context_es2_profile WGL_EXT_extensions_string WGL_EXT_framebuffer_sRGB WGL_EXT_pixel_format_packed_float WGL_EXT_swap_control WGL_EXT_swap_control_tear WGL_NVX_DX_interop WGL_NV_DX_interop WGL_NV_DX_interop2 WGL_NV_delay_before_swap WGL_NV_float_buffer WGL_NV_multisample_coverage WGL_NV_render_depth_texture WGL_NV_render_texture_rectangle "
635 wglMakeCurrent(hdc = NULL, hglrc = NULL) = TRUE
636 wglMakeCurrent(hdc = NULL, hglrc = NULL) = FALSE
637 wglDeleteContext(hglrc = 0x10000) = TRUE
638 wglChoosePixelFormat(hdc = 0x79011050, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, iPixelType = 0, cColorBits = 32, cRedBits = 0, cRedShift = 0, cGreenBits = 0, cGreenShift = 0, cBlueBits = 0, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 0, cAccumBits = 0, cAccumRedBits = 0, cAccumGreenBits = 0, cAccumBlueBits = 0, cAccumAlphaBits = 0, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 0, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 8
640 wglDescribePixelFormat(hdc = 0x79011050, iPixelFormat = 8, nBytes = 40, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SWAP_EXCHANGE | PFD_SUPPORT_COMPOSITION, iPixelType = 0, cColorBits = 32, cRedBits = 8, cRedShift = 16, cGreenBits = 8, cGreenShift = 8, cBlueBits = 8, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 24, cAccumBits = 64, cAccumRedBits = 16, cAccumGreenBits = 16, cAccumBlueBits = 16, cAccumAlphaBits = 16, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 4, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 126
639 wglSetPixelFormat(hdc = 0x79011050, iPixelFormat = 8, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, iPixelType = 0, cColorBits = 32, cRedBits = 0, cRedShift = 0, cGreenBits = 0, cGreenShift = 0, cBlueBits = 0, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 0, cAccumBits = 0, cAccumRedBits = 0, cAccumGreenBits = 0, cAccumBlueBits = 0, cAccumAlphaBits = 0, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 0, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = TRUE
642 wglGetPixelFormat(hdc = 0x79011050) = 8
643 wglDescribePixelFormat(hdc = 0x79011050, iPixelFormat = 8, nBytes = 40, ppfd = &{nSize = 40, nVersion = 1, dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SWAP_EXCHANGE | PFD_SUPPORT_COMPOSITION, iPixelType = 0, cColorBits = 32, cRedBits = 8, cRedShift = 16, cGreenBits = 8, cGreenShift = 8, cBlueBits = 8, cBlueShift = 0, cAlphaBits = 8, cAlphaShift = 24, cAccumBits = 64, cAccumRedBits = 16, cAccumGreenBits = 16, cAccumBlueBits = 16, cAccumAlphaBits = 16, cDepthBits = 24, cStencilBits = 0, cAuxBuffers = 4, iLayerType = 0, bReserved = 0, dwLayerMask = 0, dwVisibleMask = 0, dwDamageMask = 0}) = 126
644 wglGetPixelFormat(hdc = 0x79011050) = 8
645 wglDescribePixelFormat(hdc = 0x79011050, iPixelFormat = 1, nBytes = 0, ppfd = NULL) = 126
641 wglCreateContext(hdc = 0x79011050) = 0x20000
647 wglGetPixelFormat(hdc = 0x79011050) = 8
648 wglGetPixelFormat(hdc = 0x79011050) = 8
649 wglDescribePixelFormat(hdc = 0x79011050, iPixelFormat = 1, nBytes = 0, ppfd = NULL) = 126
646 wglMakeCurrent(hdc = 0x79011050, hglrc = 0x20000) = TRUE
650 glViewport(x = 0, y = 0, width = 500, height = 600)
651 glScissor(x = 0, y = 0, width = 500, height = 600)
653 wglGetPixelFormat(hdc = 0x79011050) = 8
652 wglMakeCurrent(hdc = 0x79011050, hglrc = 0x20000) = TRUE
654 glViewport(x = 0, y = 0, width = 500, height = 600)
655 glScissor(x = 0, y = 0, width = 500, height = 600)
656 glGenBuffers(n = 1, buffer = &1)
658 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 1)
659 glBufferData(target = GL_ARRAY_BUFFER, size = 72, data = NULL, usage = GL_STATIC_DRAW)
660 glGetBufferParameteriv(target = GL_ARRAY_BUFFER, pname = GL_BUFFER_SIZE, params = &0)
661 glBufferSubData(target = GL_ARRAY_BUFFER, offset = 0, size = 72, data = blob(72))
662 glGenBuffers(n = 1, buffer = &2)
664 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 2)
665 glBufferData(target = GL_ARRAY_BUFFER, size = 48, data = NULL, usage = GL_STATIC_DRAW)
666 glGetBufferParameteriv(target = GL_ARRAY_BUFFER, pname = GL_BUFFER_SIZE, params = &0)
667 glBufferSubData(target = GL_ARRAY_BUFFER, offset = 0, size = 48, data = blob(48))
668 glDisable(cap = GL_CULL_FACE)
669 glDisable(cap = GL_DEPTH_TEST)
670 glCreateShader(type = GL_VERTEX_SHADER) = 1
671 glShaderSource(shader = 1, count = 1, string = &"uniform mat4 MVPMatrix;
attribute vec3 vertex;
attribute vec4 color;
attribute vec2 texCoord0;
// Those values will be passed into the fragment shader.
varying vec4 vColor;  
varying vec2 vTexCoord0;
void main( void )
{  
    // calculate vertex based on combined model view projection matrix
    gl_Position = MVPMatrix * vec4(vertex, 1.0);
  
    vColor = color;
    vTexCoord0 = texCoord0;
}
", length = NULL)
673 glCompileShader(shader = 1)
675 glGetShaderiv(shader = 1, pname = GL_COMPILE_STATUS, params = &1)
676 glCreateShader(type = GL_FRAGMENT_SHADER) = 2
677 glShaderSource(shader = 2, count = 1, string = &"#ifdef GLES2
//Set the default precision to medium. We don't need as high of a  precision in the fragment shader.
precision mediump float;
#endif
uniform sampler2D texture1;
uniform sampler2D texture2;
varying vec4 vColor;      
varying vec2 vTexCoord0;
void main( void )
{
    vec4 texel0, texel1, resultColor;
    texel0 = texture2D(texture1, vTexCoord0);
    texel1 = texture2D(texture2, vTexCoord0);
  
    resultColor = mix(texel0, texel1, texel1.a);
    gl_FragColor = resultColor;
}
", length = NULL)
679 glCompileShader(shader = 2)
681 glGetShaderiv(shader = 2, pname = GL_COMPILE_STATUS, params = &1)
682 glGenTextures(n = 1, textures = &1)
683 glBindTexture(target = GL_TEXTURE_2D, texture = 1)
684 glBindTexture(target = GL_TEXTURE_2D, texture = 1)
685 glGenerateMipmap(target = GL_TEXTURE_2D)
686 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGB, width = 256, height = 256, border = 0, format = GL_BGR, type = GL_UNSIGNED_BYTE, pixels = blob(196608))
687 glGenSamplers(count = 1, samplers = &1)
689 glGenTextures(n = 1, textures = &2)
690 glBindTexture(target = GL_TEXTURE_2D, texture = 2)
691 glBindTexture(target = GL_TEXTURE_2D, texture = 2)
692 glGenerateMipmap(target = GL_TEXTURE_2D)
693 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGBA, width = 256, height = 256, border = 0, format = GL_BGRA, type = GL_UNSIGNED_BYTE, pixels = blob(262144))
694 glGenSamplers(count = 1, samplers = &2)
696 glClearColor(red = 0, green = 0, blue = 0, alpha = 1)
697 glClear(mask = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
698 glEnable(cap = GL_SCISSOR_TEST)
699 glCreateProgram() = 3
700 glAttachShader(program = 3, shader = 2)
702 glAttachShader(program = 3, shader = 1)
704 glBindAttribLocation(program = 3, index = 2, name = "texCoord0")
705 glBindAttribLocation(program = 3, index = 0, name = "vertex")
706 glLinkProgram(program = 3)
708 glGetProgramiv(program = 3, pname = GL_LINK_STATUS, params = &1)
710 glGetAttribLocation(program = 3, name = "vertex") = 0
712 glGetAttribLocation(program = 3, name = "normal") = -1
714 glGetAttribLocation(program = 3, name = "color") = -1
716 glGetAttribLocation(program = 3, name = "texCoord0") = 2
718 glGetAttribLocation(program = 3, name = "texCoord1") = -1
720 glGetAttribLocation(program = 3, name = "texCoord2") = -1
722 glGetAttribLocation(program = 3, name = "texCoord3") = -1
724 glGetAttribLocation(program = 3, name = "texCoord4") = -1
726 glGetAttribLocation(program = 3, name = "texCoord5") = -1
728 glGetAttribLocation(program = 3, name = "texCoord6") = -1
730 glGetAttribLocation(program = 3, name = "texCoord7") = -1
732 glGetAttribLocation(program = 3, name = "tangent") = -1
734 glGetAttribLocation(program = 3, name = "binormal") = -1
736 glUseProgram(program = 3)
738 glGetUniformLocation(program = 3, name = "MVPMatrix") = 0
740 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {2.897056, 0, 0, 0, 0, 2.414213, 0, 0, 0, 0, -1.0002, -1, 0, 0, 4.80098, 5})
742 glGetUniformLocation(program = 3, name = "texture1") = 1
744 glSamplerParameteri(sampler = 1, pname = GL_TEXTURE_WRAP_S, param = GL_CLAMP_TO_EDGE)
746 glSamplerParameteri(sampler = 1, pname = GL_TEXTURE_WRAP_T, param = GL_CLAMP_TO_EDGE)
748 glSamplerParameteri(sampler = 1, pname = GL_TEXTURE_WRAP_R, param = GL_CLAMP_TO_EDGE)
750 glSamplerParameteri(sampler = 1, pname = GL_TEXTURE_MAG_FILTER, param = GL_LINEAR)
752 glSamplerParameteri(sampler = 1, pname = GL_TEXTURE_MIN_FILTER, param = GL_LINEAR_MIPMAP_LINEAR)
754 glActiveTexture(texture = GL_TEXTURE0)
755 glBindTexture(target = GL_TEXTURE_2D, texture = 1)
756 glEnable(cap = GL_TEXTURE_2D)
757 glBindSampler(unit = 0, sampler = 1)
759 glUniform1i(location = 1, v0 = 0)
761 glGetUniformLocation(program = 3, name = "texture2") = 2
763 glSamplerParameteri(sampler = 2, pname = GL_TEXTURE_WRAP_S, param = GL_CLAMP_TO_EDGE)
765 glSamplerParameteri(sampler = 2, pname = GL_TEXTURE_WRAP_T, param = GL_CLAMP_TO_EDGE)
767 glSamplerParameteri(sampler = 2, pname = GL_TEXTURE_WRAP_R, param = GL_CLAMP_TO_EDGE)
769 glSamplerParameteri(sampler = 2, pname = GL_TEXTURE_MAG_FILTER, param = GL_LINEAR)
771 glSamplerParameteri(sampler = 2, pname = GL_TEXTURE_MIN_FILTER, param = GL_LINEAR_MIPMAP_LINEAR)
773 glActiveTexture(texture = GL_TEXTURE1)
774 glBindTexture(target = GL_TEXTURE_2D, texture = 2)
775 glEnable(cap = GL_TEXTURE_2D)
776 glBindSampler(unit = 1, sampler = 2)
778 glUniform1i(location = 2, v0 = 1)
780 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 1)
781 glEnableVertexAttribArray(index = 0)
783 glVertexAttribPointer(index = 0, size = 3, type = GL_FLOAT, normalized = GL_FALSE, stride = 12, pointer = NULL)
785 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 2)
786 glEnableVertexAttribArray(index = 2)
788 glVertexAttribPointer(index = 2, size = 2, type = GL_FLOAT, normalized = GL_FALSE, stride = 8, pointer = NULL)
790 glDrawArrays(mode = GL_TRIANGLES, first = 0, count = 6)
791 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 0)
792 glDisable(cap = GL_SCISSOR_TEST)
794 wglGetPixelFormat(hdc = 0x79011050) = 8
793 wglSwapBuffers(hdc = 0x79011050) = TRUE

795 glClearColor(red = 0, green = 0, blue = 0, alpha = 1)
796 glClear(mask = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
797 glUseProgram(program = 0)
799 glEnable(cap = GL_SCISSOR_TEST)
800 glUseProgram(program = 3)
802 glGetUniformLocation(program = 3, name = "MVPMatrix") = 0
804 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {2.897056, 0, 0, 0, 0, 2.414213, 0, 0, 0, 0, -1.0002, -1, 0, 0, 4.80098, 5})
806 glGetUniformLocation(program = 3, name = "texture1") = 1
808 glActiveTexture(texture = GL_TEXTURE0)
809 glBindTexture(target = GL_TEXTURE_2D, texture = 1)
810 glEnable(cap = GL_TEXTURE_2D)
811 glBindSampler(unit = 0, sampler = 1)
813 glUniform1i(location = 1, v0 = 0)
815 glGetUniformLocation(program = 3, name = "texture2") = 2
817 glActiveTexture(texture = GL_TEXTURE1)
818 glBindTexture(target = GL_TEXTURE_2D, texture = 2)
819 glEnable(cap = GL_TEXTURE_2D)
820 glBindSampler(unit = 1, sampler = 2)
822 glUniform1i(location = 2, v0 = 1)
824 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 1)
825 glEnableVertexAttribArray(index = 0)
827 glVertexAttribPointer(index = 0, size = 3, type = GL_FLOAT, normalized = GL_FALSE, stride = 12, pointer = NULL)
829 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 2)
830 glEnableVertexAttribArray(index = 2)
832 glVertexAttribPointer(index = 2, size = 2, type = GL_FLOAT, normalized = GL_FALSE, stride = 8, pointer = NULL)
834 glDrawArrays(mode = GL_TRIANGLES, first = 0, count = 6)
835 glBindBuffer(target = GL_ARRAY_BUFFER, buffer = 0)
836 glDisable(cap = GL_SCISSOR_TEST)
838 wglGetPixelFormat(hdc = 0x79011050) = 8
837 wglSwapBuffers(hdc = 0x79011050) = TRUE

I’ve checked this trace multiple times, but I can’t find any failure. Texture and Sampler binding (line 742-778) looks ok,
also the vbo and tbo buffer binding. I’m running out of ideas. Thanks for any help.

2 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Sep 03, 2013 at 19:36

Are you checking glGetError(), or better yet using the KHR_debug extension, to see if GL reports any errors?

07b9e9e8483468e4a0e1bac1843e6e74
0
Snoob 105 Sep 03, 2013 at 21:39

Yes I use glGetError and hope I’ve checked most of the calls. Hm KHR debug sounds good, maybe I will give it a try. Meanwile I got the latest none AMD gDEBugger running. It looks like I’ve got problems with my texture objects, only a default texture is active …