Using MyGUI in a directx hook but its not rendering anything

valleyman86

13-04-2010 11:48:06

I am trying to use MyGUI for a directx 9 hook that I created. I basically inject my code into another application. I would like to use this to create a chat screen kind of situation but unfortunately I can't get it to work quite yet. I am able to compile and get MyGUI and everything setup properly so that it builds and I can create a button widget (testing) that will load. The problem is that I can't get anything to render or show up. I am using the setupResources method straight from the demos.

The interesting thing is that I can use pIDirect3DDevice9 and do all sorts of directx drawing on my own with no issues. I assume I could pass this to MyGUI and let it draw as well. The only thing I can think of is that I am missing some other rendering code. I am calling mPlatform->getRenderManagerPtr()->drawOneFrame(); on every frame.

One thing to keep in mind is that the game already creates all the DX init code as well as draw its own stuff. I then hook into endscene() or even present() and do my own drawing which is where MyGUI is coming in.

Thanks!

My basic initialization code is

static MyGUI::Gui* mGUI;
static MyGUI::DirectXPlatform* mPlatform;

mPlatform = new MyGUI::DirectXPlatform();
mPlatform->initialise(pIDirect3DDevice9);

setupResources();

mGUI = new MyGUI::Gui();
mGUI->initialise();

MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>("Button", 100, 100, 300, 26, MyGUI::Align::Default, "Main");
button->setCaption("exit");


This is my log... If its useful.
----------------------------------------------------------------------------------------------------------------------------------
loging report for : 04/13/2010 04:33:47
----------------------------------------------------------------------------------------------------------------------------------

04:33:47 | Platform | Info | * Initialise: DirectXRenderManager | ..\..\..\..\..\MyGUI3.0\Platforms\DirectX\DirectXPlatform\src\MyGUI_DirectXRenderManager.cpp | 25
04:33:47 | Platform | Info | DirectXRenderManager successfully initialized | ..\..\..\..\..\MyGUI3.0\Platforms\DirectX\DirectXPlatform\src\MyGUI_DirectXRenderManager.cpp | 41
04:33:47 | Platform | Info | * Initialise: DirectXDataManager | ..\..\..\..\..\MyGUI3.0\Platforms\DirectX\DirectXPlatform\src\MyGUI_DirectXDataManager.cpp | 68
04:33:47 | Platform | Info | DirectXDataManager successfully initialized | ..\..\..\..\..\MyGUI3.0\Platforms\DirectX\DirectXPlatform\src\MyGUI_DirectXDataManager.cpp | 70
04:33:47 | Core | Info | * Initialise: Gui | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_Gui.cpp | 82
04:33:47 | Core | Info | * MyGUI version 3.0.1 | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_Gui.cpp | 86
04:33:47 | Core | Info | * Initialise: ResourceManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 43
04:33:47 | Core | Info | ResourceManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 51
04:33:47 | Core | Info | * Initialise: LayerManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LayerManager.cpp | 44
04:33:47 | Core | Info | LayerManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LayerManager.cpp | 52
04:33:47 | Core | Info | * Initialise: WidgetManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_WidgetManager.cpp | 66
04:33:47 | Core | Info | WidgetManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_WidgetManager.cpp | 105
04:33:47 | Core | Info | * Initialise: InputManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_InputManager.cpp | 41
04:33:47 | Core | Info | InputManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_InputManager.cpp | 58
04:33:47 | Core | Info | * Initialise: SubWidgetManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_SubWidgetManager.cpp | 44
04:33:47 | Core | Info | SubWidgetManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_SubWidgetManager.cpp | 64
04:33:47 | Core | Info | * Initialise: SkinManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_SkinManager.cpp | 46
04:33:47 | Core | Info | SkinManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_SkinManager.cpp | 54
04:33:47 | Core | Info | * Initialise: FontManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_FontManager.cpp | 43
04:33:47 | Core | Info | FontManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_FontManager.cpp | 52
04:33:47 | Core | Info | * Initialise: ControllerManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ControllerManager.cpp | 41
04:33:47 | Core | Info | ControllerManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ControllerManager.cpp | 51
04:33:47 | Core | Info | * Initialise: PointerManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_PointerManager.cpp | 51
04:33:47 | Core | Info | PointerManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_PointerManager.cpp | 69
04:33:47 | Core | Info | * Initialise: ClipboardManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ClipboardManager.cpp | 82
04:33:47 | Core | Info | ClipboardManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ClipboardManager.cpp | 96
04:33:47 | Core | Info | * Initialise: LayoutManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LayoutManager.cpp | 42
04:33:47 | Core | Info | LayoutManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LayoutManager.cpp | 48
04:33:47 | Core | Info | * Initialise: DynLibManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_DynLibManager.cpp | 34
04:33:47 | Core | Info | DynLibManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_DynLibManager.cpp | 36
04:33:47 | Core | Info | * Initialise: PluginManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_PluginManager.cpp | 36
04:33:47 | Core | Info | PluginManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_PluginManager.cpp | 40
04:33:47 | Core | Info | * Initialise: LanguageManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LanguageManager.cpp | 40
04:33:47 | Core | Info | LanguageManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_LanguageManager.cpp | 44
04:33:47 | Core | Info | * Initialise: FactoryManager | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_FactoryManager.cpp | 34
04:33:47 | Core | Info | FactoryManager successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_FactoryManager.cpp | 37
04:33:47 | Core | Info | Load ini file 'core_theme.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_language.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_font.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | ResourceTrueTypeFont 'font_DejaVuSans.17' using texture size 512 x 256 | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceTrueTypeFont.cpp | 203
04:33:47 | Core | Info | ResourceTrueTypeFont 'font_DejaVuSans.17' using real height 17 pixels | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceTrueTypeFont.cpp | 204
04:33:47 | Core | Info | ResourceTrueTypeFont 'font_DejaVuSans.14' using texture size 256 x 256 | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceTrueTypeFont.cpp | 203
04:33:47 | Core | Info | ResourceTrueTypeFont 'font_DejaVuSans.14' using real height 14 pixels | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceTrueTypeFont.cpp | 204
04:33:47 | Core | Info | Load ini file 'core_resource.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_skin.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_pointer.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_layer.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Load ini file 'core_settings.xml' | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_ResourceManager.cpp | 152
04:33:47 | Core | Info | Gui successfully initialized | ..\..\..\MyGUI3.0\MyGUIEngine\src\MyGUI_Gui.cpp | 129

my.name

13-04-2010 18:05:46

look at BaseManager for DirectX Platform.

1. mPlatform->getRenderManagerPtr()->setViewSize(width, height);
2. mPlatform->getDataManagerPtr()->addResourceLocation(_name, _recursive);
3. mPlatform->getRenderManagerPtr()->drawOneFrame();

valleyman86

13-04-2010 21:11:10

I have called all of those methods. Do they all need to be called every frame? I call the addResourceLocation to load the resources and that seems to be working. I then tried the setViewSize method but I believe I only called it once in the initialization code. Not seeing any button my screen.

My initialization code:

mPlatform = new MyGUI::DirectXPlatform();
mPlatform->initialise(pIDirect3DDevice9);

RECT rect = { 0, 0, 0, 0 };
GetClientRect(xenHwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;

//resizeRender(width, height);

if (mPlatform)
mPlatform->getRenderManagerPtr()->setViewSize(width, height);

setupResources();

mGUI = new MyGUI::Gui();
mGUI->initialise();

MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>("Button", 100, 100, 300, 26, MyGUI::Align::Default, "Main");
button->setCaption("exit");

Altren

13-04-2010 22:00:35

You should call mPlatform->getRenderManagerPtr()->drawOneFrame(); every frame.

valleyman86

13-04-2010 22:07:32

I am doing that. I also tried setting the view every frame. I am not quite sure how your DirectX render works I guess. The important thing in how my code must work is that the game will draw first and I cant get around that. I then draw my stuff just by calling the draw stuff methods in directx. I assumed once I passed MyGUI my device it would draw to it just the way I do. The only thing I can guess is that MyGUI draws to a wierd viewport or something and not the one I am drawing too.