OpenGL printing with wxWidgets

Hello, i’ve been facing this problem for a long time now…

I’m using wxWidgets and OpenGL in a project, and now I’d like to print what I’m rendering…

I’ve started with this basic code:

    void* pixels = malloc(3 * m_viewport[2] * m_viewport[3]);
    glPixelStorei(GL_PACK_ALIGNMENT, 1);
    glReadPixels(0, 0, m_viewport[2], m_viewport[3], GL_RGB, GL_UNSIGNED_BYTE, pixels);

it works kinda ok, but the problem is that it just takes my screen’s resolution, while my printer’s is much higher…

I’ve read some articles using CreateDIBSection in Windows and drawing directly to a bitmap, but I don’t think I can use that approach in wxWidgets, mainly because that is not portable.

I was thinking of rendering a much bigger image and then shrink to a small one, maybe that would make a better result, but I can’t use glReadPixels since it only get’s what’s in my view. Is there any other function which gets the whole buffer, not just the frame one? Any other thoughts?


Not sure what you mean by “the whole buffer”. If your hardware supports FBOs, you could make an FBO in a larger size, render to that, then read from it.