游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2809|回复: 3

关于OGRE嵌入其他程序中出现的问题

[复制链接]

2

主题

5

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2009-8-10 11:40:00 | 显示全部楼层 |阅读模式
我接触OGRE才几天,遇到的问题如果太过于肤浅请诸位不要笑话。

我这里有个项目,类似于GoogleEarth,原先是用DirectX做的,现在要转移平台,选择了MOGRE,
当我创建一个RenderWindow的时候是需要嵌入其他窗口的,但是在初始化输入(InputHandler)的时候
出现异常情况:

PS: 如果我使用root.Initialize(true)所得到的RenderWindow的话就正常,请高人指点迷津

Microsoft Visual C++ Runtime Library
Runtime Error!
Program:...iles\OgreSDK\bin\Release\OgreEart.vhost.exe

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

代码是参照Sample中写的

/// <summary>
/// 创建渲染窗体
/// <param name="handle">用于渲染状态的窗口句柄</param>
/// </summary>
protected virtual RenderWindow CreateRenderWindow(IntPtr handle, Mogre.Root root)
{
    RenderWindow result = null;
    if (handle != IntPtr.Zero)
    {
        System.Drawing.Rectangle rect = user32.GetWindowRect(handle);
        NameValuePairList misc = new NameValuePairList();
        misc["externalWindowHandle"] = handle.ToString();
        result = root.CreateRenderWindow("Simple Mogre Form Window",
            (uint)rect.Width, (uint)rect.Height, false, misc);
    }
    else
    {
        result = root.CreateRenderWindow("Autumn main RenderWindow",
            (uint)0, (uint)0, false);
    }
    return result;
}        

protected virtual void CreateInputHandler()
{
    MOIS.ParamList pl = new MOIS.ParamList();
    IntPtr windowHnd;
    mWindow.GetCustomAttribute("WINDOW", out windowHnd);
    pl.Insert("WINDOW", windowHnd.ToString());

    mInputManager = MOIS.InputManager.CreateInputSystem(pl);

    //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
    >>>>>>>就是在执行这个代码时出现了上面所说的异常信息框<<<<<<<
    mInputKeyboard = (MOIS.Keyboard)mInputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
    mInputMouse = (MOIS.Mouse)mInputManager.CreateInputObject(MOIS.Type.OISMouse, false);
}

2

主题

16

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2009-8-10 16:17:00 | 显示全部楼层

Re:关于OGRE嵌入其他程序中出现的问题

试试在创建渲染窗口前面加上这样一句:
result = root.initialise(false);

2

主题

5

帖子

9

积分

新手上路

Rank: 1

积分
9
 楼主| 发表于 2009-8-10 16:47:00 | 显示全部楼层

Re: Re:关于OGRE嵌入其他程序中出现的问题

main90: Re:关于OGRE嵌入其他程序中出现的问题

试试在创建渲染窗口前面加上这样一句:
result = root.initialise(false);

有加的,在执行CreateRenderWindow方法之前这个就已经执行过

2

主题

16

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2009-8-11 16:23:00 | 显示全部楼层

Re:关于OGRE嵌入其他程序中出现的问题

据说,在创建OIS输入设备的时候需要一个顶级窗口HWND,所以在创建之前试试加上类似
windowHnd = (size_t)::GetAncestor((HWND)windowHnd, GA_ROOT);
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-21 18:27

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表