Original Post
Hello. I am trying to use a DIBSection as a render target so I can draw on it with OGL, and then I want to use that as a texture. I have successfully rendered to the DIBSection, but when I try to use it as a texture, it just appears white. In simplified form, here is what I am doing: After calling this code, I can see an all white cube with no texture. Maybe I am doing something wrong to convert the DIB into a gl-usable texture. Any help will be greatly appreciated.
wglMakeCurrent(dc, rc); // DIBSection's dc and rc
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0, 0, 1, 1); // Just use a blue texture for now..
glBindTexture(GL_TEXTURE_2D, m_index);
glTexImage2D(GL_TEXTURE_2D, 0, 4, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_data); // m_data is the buffer created by CreateDIBSection
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
wglMakeCurrent(wdc, wrc); // Window's dc and rc
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1, 0, 0, 1);
glBindTexture(GL_TEXTURE_2D, index); // index is the texture name of the DIBSection, obtained from glGenTextures()
{draw a texture mapped cube here}