// Problem: Calling Screenshot(2, 2) generates 4 pics, 3 of which contain my image but 1 which doesn't // (and combined they still don't contain all of it) Not sure what's off... // Following isntructions here: // http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node30.html void TestGLCanvas::Screenshot(int width_mult, int height_mult) { int win_width, win_height; GetClientSize(&win_width, &win_height); glMatrixMode(GL_PROJECTION); for(int y = 0; y < height_mult; ++y) { for(int x = 0; x < width_mult; ++x) { wxLogDebug(wxString() << width_mult << _T(" ") << height_mult << _T(" ") << x << _T(" ") << y); float sceneWidth = win_width * width_mult; float sceneHeight = win_height * height_mult; float xTileWidth = sceneWidth / width_mult; float yTileWidth = sceneHeight / height_mult; float xOffset = (-2 * x * xTileWidth / sceneWidth) + (1 - 1 / width_mult); float yOffset = (-2 * y * yTileWidth / sceneHeight) + (1 - 1 / height_mult); Render(width_mult, height_mult, xOffset, yOffset); Screenshot(wxString(_T("shot")) << y << x << _T(".jpg")); } } }