【问题标题】:Ogre and Allegro direct3d device 9 conflictOgre 和 Allegro direct3d 设备 9 冲突
【发布时间】:2013-02-28 23:25:33
【问题描述】:

我一直在尝试编写一个使用 Allegro 5 处理 2D 渲染和使用 Ogre 处理 3D 渲染的程序,但是我遇到了初始化问题,我已经解决了大部分问题,即 hInstance 的窗口,但现在的问题是 Ogre::D3D9RenderWindow::setDevice() 仅采用 Ogre 的类型,并且根据 Ogre API 参考由 ID3Device9 设置,而不是 al_get_d3d9_device() 返回的 LPDIRECT3DDEVICE9。我需要帮助来弄清楚如何将LPDIRECT3DDEVICE9 转换为ID3Device9

这是我目前的代码:

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{

ALLEGRO_DISPLAY *al_display = NULL;

if(!al_init())
{
    fprintf(stderr, "Cannot initialize allegro");
    return -1;
}

al_display = al_create_display(640, 480);

if(!al_display)
{
    fprintf(stderr,"Cannot initialize the display");
    return -1;
}

HWND hWnd = al_get_win_window_handle(al_display);

HINSTANCE hInst = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE);

Ogre::D3D9RenderWindow ogre_window(hInst);

ogre_window.setDevice(al_get_d3d_device(al_display)); // Function only takes an Ogre::D3D9Device

return 0;
}

【问题讨论】:

    标签: windows direct3d ogre allegro


    【解决方案1】:

    如果您使用 OpenGL,这是可能的。 example 随 Allegro 一起提供。

    不确定 D3D。

    【讨论】:

      【解决方案2】:

      在马修的回答的帮助下,经过大量的工作和繁琐的学习,我能够通过指针上的一些指针找到问题的解决方案。

      这是最终代码:

      int _tmain(int argc, _TCHAR* argv[])
      {
      ALLEGRO_DISPLAY *al_display = NULL;
      
      if(!al_init())
      {
          fprintf(stderr, "Cannot initialize allegro");
          return -1;
      }
      
      al_display = al_create_display(640, 480);
      
      if(!al_display)
      {
          fprintf(stderr,"Cannot initialize the display");
          return -1;
      }
      
      HWND hWnd = al_get_win_window_handle(al_display);
      
      HINSTANCE hInst = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE);
      
      Ogre::D3D9RenderWindow ogre_window(hInst);
      
      LPDIRECT3DDEVICE9 D3dDev = al_get_d3d_device(al_display);
      IDirect3DDevice9 *iD3dDev = D3dDev;
      Ogre::D3D9DeviceManager D3dDevManager;
      Ogre::D3D9Device *OD3dDev = D3dDevManager.getDeviceFromD3D9Device(iD3dDev);
      ogre_window.setDevice(OD3dDev);
      
      return 0;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多