Page 1 of 1

Rendering OpenGL larger than it's wxWindow

Posted: Tue Feb 23, 2021 9:48 pm
by bsenftner
I have a wxWidgets win10 desktop app where it reads and processes video, adding labels and markers for objects tracked in the video. It displays the processing inside a wxGLCanvas inside a wxFrame, setting the glViewport to the window width, height, setting gluOrtho2D to the window size, then calculates a centered aspect ratio correct placement for the video frames, glDrawPixels them into the framebuffer and then add labels and markers.

This works fine to view the analysis working, but often a person wants to save the results. Additionally, the results saved should be at the same resolution as the original source video.

Okay, to do that the code renders every frame twice, once at the original video's resolution and again at the window resolution. (The slowdown is okay.) When rendering the original resolution, I set the glViewport to the original video's width, height, set gluOrtho2D to the original video size, render as usual, then glReadPixels the rendered result back and save to disk. When the video ends, it background processes the written frames through ffmpeg and a video is produced.

This is works fine, unless the wxFrame hosting the wxGLCanvas is smaller than the original video. When the wxFrame is smaller in width or height then the original video, the rendering only occurs within the width, height of the wxFrame. No errors occur, that I can see. The glReadPixels still returns a pixelmap with the dimensions of the original video, only the rendering is limited to the area of the wxFrame.

Is there anyway to change this? How would one OpenGL render larger than the visible window? I'm looking in the wxWidgets source to see if there is a glScissor or something limiting the rendering. But I thought I'd ask here too, perhaps this jogs someone's memory. I tried searching the forums and google, but my search magic was incomplete.

Re: Rendering OpenGL larger than it's wxWindow

Posted: Tue Feb 23, 2021 10:52 pm
by doublemax
I don't know too much about OpenGL, but i'm almost certain this is not a wxWidgets issue. Googling for "opengl offscreen rendering" returns some interesting results, maybe you can research in that direction.