I am pounding my head into the wall with this.
I’m hoping someone can explain the behavior that I’ve been seeing. Solutions would be helpful as well, but even if someone could fully explain to me what I’m seeing, I’d very much appreciate it.
I’m trying to make a screenshot system in an application using wxWidgets. I can get a screenshot fine using glReadPixels, blah blah.
However, I’m tasked to create high-resolution screenshots. My instinct for for this is to call glViewport with the view volume I want, redraw the scene, then save the back buffer using glReadPixels.
However, when I try this with a viewport larger than my current window, the areas drawn beyond my window are saved as pure blackness.
My guess is that the back buffer is not changing size with the viewport. Would I be correct in supposing this?
Here is my code:
GLint view; glGetIntegerv(GL_VIEWPORT, view); glViewport(0, 0, view*3, view*3); this->mp_mainCanvas->DrawScene(); //Draws the scene on the back buffer only void* pixels = malloc(pow(3.0, 3) * view * view); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadBuffer(GL_BACK); glReadPixels(0, 0, view*3, view*3, GL_RGB, GL_UNSIGNED_BYTE, pixels); wxImage image(view*3, view*3); image.SetData((unsigned char*) pixels); image = image.Mirror(false); image.SaveFile(filename, wxBITMAP_TYPE_BMP); glViewport(0, 0, view, view);