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.
I'm using wxGLCanvas to "plot" something. When I resize the window, the size of canvas changes normally(with sizers), but the "graph" inside the canvas won't fit this change. So what should I do to repaint glcanvas "normally"?
//here is the code
//opSubplot is inherited from wxPlane, and "canvas" is a member of type wxGLCanvas*
void opSubplot::OnSize(wxSizeEvent & event)
{
if (context->IsOK()) {
context->SetCurrent(*canvas);
glViewport(0, 0, canvas->GetSize().GetWidth(), canvas->GetSize().GetHeight());
//glFlush(); //makes no difference?
}
}
Last edited by catalin on Thu Jan 03, 2019 9:12 am, edited 1 time in total.
Reason:code tags
The OpenGL API does not contain any command to automagically resize anything. It's your task, which is normally achieved by setting proper parameters to the projection matrix you use. Scaling or translating or moving the camera may also work (the model and view matrices).
BTW, glFlush() just tells the GPU to issue any pending commands. glFinish() will make the CPU to wait until all gl-commands have been proccessed. None of them will re-draw anything.
Is short: Redraw your scene after the call to glViewport.