Rendering OpenGL larger than it's wxWindow

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
bsenftner
Experienced Solver
Experienced Solver
Posts: 80
Joined: Thu May 26, 2016 9:19 pm

Rendering OpenGL larger than it's wxWindow

Post by bsenftner » Tue Feb 23, 2021 9:48 pm

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.

User avatar
doublemax
Moderator
Moderator
Posts: 15691
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Rendering OpenGL larger than it's wxWindow

Post by doublemax » Tue Feb 23, 2021 10:52 pm

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.
Use the source, Luke!

Post Reply