[SOLVED] Mogre in a form - resolution 200x100

lickstab

04-02-2009 12:19:29

hello, i've created a subclassed panel control which renders mogre inside of it.
the rendering, using the engine and all that works fine, but i have one problem.
the resolution of the window is only 200x100, so it's obviously very stretched and blurry..
i can't figure out how to set the resolution.

first i did what the mogre form samples does:
root.RenderSystem.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
as part of creating the mogre window.. but it would still create it at 200x100 (as the ogre.log reports.)

then i tried telling CreateRenderWindow my resolution directly (which the sample doesn't do):
window = root.CreateRenderWindow("MogreBox Window", 640, 480, false, misc.ReadOnlyInstance);
no difference.

another problem i have is that i'm doing this:
root.RenderSystem.SetConfigOption("VSync", "Yes");
but ogre.log still reports that vsync is disabled and gives me a warning about it.

here's what the log file says about these things:

12:51:37: D3D9 : RenderSystem Option: VSync = Yes
// ..cpu identifier/features part here
12:51:37: D3D9RenderSystem::createRenderWindow "MogreBox Window", 640x480 windowed miscParams: externalWindowHandle=527810
12:51:37: D3D9 : Created D3D9 Rendering Window 'MogreBox Window' : 200x100, 32bpp
12:51:37: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.

where is it getting 200x100 from? it's not the size of the panel itself, it's much larger than that.
i'm using the mogre 1.4.8 sdk.

Quall

04-02-2009 23:08:56

edit: I just opened the forms sample and stretched the pain. I think I see what you mean. Try setting the aspect of the camera, or do it automatically:

camera.AutoAspectRatio = true;

here is the message you can ignore.
Have you tried calling the resize method?

Root.RenderWindow.Resize( 800, 600 ); (after everything has loaded)

I am a little confused though. Are you saying that a 200x100 image is being stretched to the size of the pane? Or are you saying that an 800x600 (or other) is being squashed to 200x100?

I have not messed with ogre forms in .net yet, but if your pane is 800x600 and the ogre window is not stretching to the pane, then its parent handle probably isn't completely correct. Did you pass it the handle "527810" or where is it getting that?

lickstab

05-02-2009 04:40:16

i'm saying the renderwindow is actually given a very tiny resolution of 200x100 and then getting stretched to the size of the panel.
i tried using resize but it has no effect.

i'm giving it the handle exactly the same way as samples\MogreForm\MogreForm.cs does it, the only difference being i use a panel while it uses a form.

--

AHA. i figured i'd mess around with it a bit more before posting a reply, and sure enough i found the answer.
eureka!

regardless of what resolution you pass to the CreateWindow function, it seems it will use the size of the control at the time of window creation.
the Panel class must be created with a default size of 200x100, and as i wasn't explicitly specifying its size (just relying on DockStyle.Fill to resize it in the container), it would use this resolution.

my fix was to simply make the constructor explicitly set the size of the control to my desired resolution:
(adapted from MogreForm.cs in Samples)


// create a Mogre panel with resolution 800x600
public MogreBox()
{
this.Width = 800;
this.Height = 600;
this.Disposed += new EventHandler(MogreBox_Disposed);
this.Paint += new PaintEventHandler(MogreBox_Paint);
mogreWin = new OgreWindow(new Point(0, 0), this.Handle);
mogreWin.InitMogre();
}


EDIT:
i'd like to add for clarification, the reason i ran into this problem while the forms sample didn't is because they added the control it renders with in the forms designer, while i add it programatically in my code, thus not specifically setting its width&height. also, thanks for taking the time to look into it!