Problem Implementing Into DirectX9 Hook

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

SidRaven
Just popping in
Just popping in
Posts: 5
Joined: Sun Jun 25, 2006 07:54

Problem Implementing Into DirectX9 Hook

Postby SidRaven » Sun Jun 25, 2006 08:35

Hey guys, i've been using something called a "ProxyDLL" DirectX9 hook to get access to a directx 9 game which i want to try add GUI to.

I've added all the includes etc, and it compiles but when i load the game the screen is totally blank but i still hear menu sounds.

The hook i'm using is located here:

http://www.mikoweb.eu/index.php?node=28

This is my includes:

Code: Select all

#include "CEGUI.h"
#include "d3d9renderer.h"


This is my begin scene:

Code: Select all

HRESULT myIDirect3DDevice9::BeginScene(void)
{
   CEGUI::DirectX9Renderer* m_CEGUI = new CEGUI::DirectX9Renderer(m_pIDirect3DDevice9, 0);
   new CEGUI::System(m_CEGUI);

   System::getSingleton().setGUISheet(myRoot);

    return(m_pIDirect3DDevice9->BeginScene());
}


And this is my end scene:

Code: Select all

HRESULT myIDirect3DDevice9::EndScene(void)
{
   CEGUI::System::getSingleton().renderGUI();
    return(m_pIDirect3DDevice9->EndScene());
}


I'm probably going about it the wrong way, but from what i understand.

CEGUI::DirectX9Renderer* m_CEGUI = new CEGUI::DirectX9Renderer(m_pIDirect3DDevice9, 0);


Is creating a whole new DirectX render surface? But all i want to do is get the current one of the game i'm hooked into...

Any help you can give me is very much appreciated.

Thanks.

MacMan45
Just popping in
Just popping in
Posts: 19
Joined: Mon Apr 24, 2006 10:33

Postby MacMan45 » Mon Jun 26, 2006 08:37

Woah, you are creating a new CEGUI::DirectX9Renderer at the start of every scene? Oh & a new CEGUI System as well...

You do realise that BeginScene is called before every single frame right?
:P

You will want to be creating it somewhere at startup.
Seeing your proxying d3d9, maybe CreateDevice would be a good place to do this?

Your EndScene hook looks fine though :)


On a side note, i'm also hooking a game, but i'm going the route of redirecting the virtual table pointers, its proving to be quite a challenge!!

SidRaven
Just popping in
Just popping in
Posts: 5
Joined: Sun Jun 25, 2006 07:54

Postby SidRaven » Tue Jun 27, 2006 19:27

After putting the thing for creating a new renderer etc in an Init event, it still does the same thing. :x Any ideas?

MacMan45
Just popping in
Just popping in
Posts: 19
Joined: Mon Apr 24, 2006 10:33

Postby MacMan45 » Sat Jul 01, 2006 12:17

Could you post up the new code?
I'll have a look & see if i can spot anything :)

Oh & another side note, i finally cracked the virtual table, just replacing the functions i want, saves on a lot of typing :D

MacMan45
Just popping in
Just popping in
Posts: 19
Joined: Mon Apr 24, 2006 10:33

Postby MacMan45 » Sat Jul 01, 2006 14:09

Ok, well now i'm in the same boat as you.

I can draw to the screen with my own code, but as soon as i initialise CEGUI dx9 renderer, the screen goes black.

I can hear the game music in the background.

I even put a timer delay on CEGUI.
Before it was initialised, i could see the hooked game fine.
When the timer expired & CE was setup, the screen went black & my CE defined window showed up happily.

I even bound a key to the renderGUI() but stopping that would only hide my own window, still leaving the background as black.

I have tried playing with the alpha, setting it from 0.5 to 0.1.
I even tried 0 alpha, still nothing but black (& my own CE window).

I just tried setting the root window to hidden ( hide() ) & that still leaves me with a black screen (except, as to be expected, my window is gone :lol: )

I hope this is a stupid me error, has anyone seen a blackscreen covering up their world before? :P

MacMan45
Just popping in
Just popping in
Posts: 19
Joined: Mon Apr 24, 2006 10:33

Postby MacMan45 » Sat Jul 01, 2006 16:00

Ok, after a bit of forum searching, i think i have an idea on where to start looking.

I think it has something to with the dx9 renderer changing the render states & not restoring them. (performance reasons apparently)

I'm guessing it is changing something my hooked game cares about :P

Its 2am here, so i'll try some stuff out tomorrow sometime.

MacMan45
Just popping in
Just popping in
Posts: 19
Joined: Mon Apr 24, 2006 10:33

Postby MacMan45 » Sun Jul 02, 2006 01:20

I have solved my problem, hopefully yours too...


Call this after you renderGUI()

Code: Select all

device->SetVertexShader(0);
device->SetPixelShader(0);
device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
device->SetRenderState(D3DRS_ZENABLE, false);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device>SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device>SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
device>SetRenderState(D3DRS_ZENABLE, true);


Now, you may not need all of those, i found that in another proxy dll from code guru.
(http://www.codeguru.com/cpp/g-m/directx ... hp/c11453/)

I'm working on cutting down that list for my game, but i thought i would give you the lot, incase your hooked game relies on one mine doesn't.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 3 guests