Hello,
I’ve got initialisation code like this:-
GLuint id;
const int width=128;
const int height=128;GLubyte* buffer = new GLubyte[widthheight4];
glGenTextures(1, &id);
Now, I want to grab a rectangle of colourful pixels from the frame buffer, but without mipmapping.
The code below works (but of course produces mipmaps):-
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
glBindTexture(GL_TEXTURE_2D, id);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
But astouningly, neither of these standard functions work (they produce a 100% white texture, not the colourful pixels I expect (and indeed get using the glu function)):-
glBindTexture(GL_TEXTURE_2D, id);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
That’s it. Neither of the standard GL functions create a texture. I’ve done this kind of thing before, but suddenly I can’t get it to work.
Is there something obvious I’m missing?
I’ve checked glGetError - which doesn’t report anything is wrong.
I’ve just installed the latest (7thAugust) NVidia drivers on a geforce3 - I hope it’s not a bug…