Horde3D
http://horde3d.org/forums/

Window resizing
http://horde3d.org/forums/viewtopic.php?f=2&t=1911
Page 1 of 1

Author:  72deluxe [ 01.11.2013, 11:58 ]
Post subject:  Window resizing

Hello

I have put Horde3D inside a wxWidgets canvas and context. When the canvas is resized, I tell Horde3D to resize using:
Code:
h3dSetNodeParamI(FCam, H3DCamera::ViewportXI, 0);
h3dSetNodeParamI(FCam, H3DCamera::ViewportYI, 0);
h3dSetNodeParamI(FCam, H3DCamera::ViewportWidthI, width);
h3dSetNodeParamI(FCam, H3DCamera::ViewportHeightI, height);
h3dSetupCameraView(FCam, 45.0f, static_cast<float>(width)/height, 0.1f, 1000.0f);
h3dResizePipelineBuffers(FPipelineRes, width, height);

where FCam is the camera resource and FPipelineRes is the pipeline resource. This works on resize when the window is set up but when I resize the window later on, I the Horde3D drawing region does not resize. If I step into h3dResizePipelineBuffers, I can see that is calls pipeResObj->resize( width, height );, which in turn calls createRenderTargets().

The canvas and parent window is reporting the correct size but I have a bounding box that the content is drawn inside. If I do not call glClear at the beginning of the paint routine, I get all manner of buffer rubbish drawn outside the bounding box region.

My code is pretty much identical to http://www.horde3d.org/docs/html/_tutorial.html., merged with the Qt5 code on the wiki.

Does anyone have any tips?

Author:  72deluxe [ 01.11.2013, 16:56 ]
Post subject:  Re: Window resizing

As an example, I have attached a screenshot. The red section at the top is a panel, with the rest of the window being a wxGLCanvas / wxGLContext. The rendering is done in debug mode (h3dSetOption( H3DOptions::DebugViewMode, 1);), and as you can see there is a large bounding box region. If I scale the window larger, the knight will be drawn further right until it disappears into the black void.

Attachments:
File comment: A screenshot
screenshotscaled.png
screenshotscaled.png [ 65.78 KiB | Viewed 19317 times ]

Author:  Volker [ 01.11.2013, 22:52 ]
Post subject:  Re: Window resizing

Never used wxWidgets before, do they manipulate the viewport settings anywhere?
Do you have more than one camera/pipeline within the scene, so that it could be that you're settings the new size on the wrong nodes/resources?
Are there any warnings or errors within the log. As an additional debug step you may want add some debug code to read out the viewport params (glGetIntegerv(GL_VIEWPORT, viewport);) set within Horde3D's render code and check if they may have been overriden somewhere.

Author:  72deluxe [ 04.11.2013, 01:39 ]
Post subject:  Re: Window resizing

Volker wrote:
Never used wxWidgets before, do they manipulate the viewport settings anywhere?


Yes! Thanks for the help. It turns out that wxWidgets is calling some Mac specific code (a function named void wxGLCanvas::SetViewport()). This is called from within wxGLContext::SetCurrent() which assigns a wxGLCanvas to the context. Resizing the window is not enough to get this SetViewport called, so when the window is resized, I simply needed to call wxGLContext::SetCurrent with the same canvas again, and all works.

Many thanks for the help
Rich

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/