Custom rendering in endscene hook menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom rendering in endscene hook

    I try to render som graphics of my own in my endscene hook.
    I can render transformed elements like fonts and primitives with vertexformats D3DFVF_XYZRHW without any problems, but when rendering primitives in world coordinates with D3DFVF_XYZ, the resulting gfx is flickering like it would be drawn just once every 10th frame or something (wow renders fine though). The resulting graphics are showing up where it should, so projection and everything seems fine. This is what i do;

    EndsceneHook()
    {
    CreateStateBlock and save current state
    Disable Zbuffer, lights, stencil,alphablending, clipplane
    SetFVF
    DrawPrimitives

    Stateblock reset
    }

    It doesnt matter if I try and get the back buffer and set it as rendertarget, the result is the same...


    Im a noob at directx (too) so if anyone knows what make my gfx flicker or any other pointers It would be greatly appretiated...
    Last edited by ggg898; 09-11-2009 at 04:03 AM. Reason: forgot disable clipplane

    Custom rendering in endscene hook
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's what I'm doing:
    Code:
      // Initialize resources such as textures (managed and unmanaged), vertex 
      // buffers, and other D3D resources
      HRESULT D3D9Mgr::Initialize()
      {
        // Create new GUI manager
        m_pD3D9Helper.reset(new D3D9Helper());
        m_pD3D9Helper->OnInitialize(m_pParent, m_pD3D9Helper);
    
        // Create state block
        m_pDevice->CreateStateBlock(D3DSBT_ALL, &m_pStateBlock);
    
        // Call registered callbacks
        m_CallsOnInitialize(m_pParent, m_pD3D9Helper);
    
        // Return success
        return S_OK;
      }
    
      // Release all unmanaged resources
      HRESULT D3D9Mgr::PreReset()
      {
        // Release state block
        m_pStateBlock->Release();
        // Prevent double-free
        m_pStateBlock = NULL;
    
        // D3D9 Helper
        m_pD3D9Helper->OnLostDevice(m_pParent, m_pD3D9Helper);
    
        // Call registered callbacks
        m_CallsOnLostDevice(m_pParent, m_pD3D9Helper);
    
        // Return success
        return S_OK;
      }
    
      // Re-initialize all unmanaged resources
      HRESULT D3D9Mgr::PostReset()
      {
        // Create state block
        m_pDevice->CreateStateBlock(D3DSBT_ALL, &m_pStateBlock);
    
        // D3D9 Helper
        m_pD3D9Helper->OnResetDevice(m_pParent, m_pD3D9Helper);
    
        // Call registered callbacks
        m_CallsOnResetDevice(m_pParent, m_pD3D9Helper);
    
        // Return success
        return S_OK;
      }
    
      // DrawIndexedPrimitive proxy
      HRESULT D3D9Mgr::DrawIndexedPrimitive(D3DPRIMITIVETYPE Type, INT BaseVertexIndex, 
          UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
      {
        // Data for DrawIndexedPrimitive
        DipData Data;
        Data.Type = Type;
        Data.BaseVertexIndex = BaseVertexIndex;
        Data.MinVertexIndex = MinVertexIndex;
        Data.NumVertices = NumVertices;
        Data.startIndex = startIndex;
        Data.primCount = primCount;
    
        // Call registered callbacks
        bool Blocked = m_CallsOnDrawIndexedPrimitive(m_pParent, m_pD3D9Helper, 
          &Data);
    
        if (Blocked)
          return 1;
    
        // Return success
        return S_OK;
      }
    
      // Do rendering
      HRESULT D3D9Mgr::Render()
      {
        // Capture state block
        m_pStateBlock->Capture();
    
        // Call registered callbacks
        m_CallsOnFrame(m_pParent, m_pD3D9Helper);
    
        // Apply captured state block
        m_pStateBlock->Apply();
    
        // Return success
        return S_OK; 
      }
    Last edited by Cypher; 09-11-2009 at 09:37 AM.

  3. #3
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your time Cypher.
    Do you perfom your rendering in an EndScene() hook, ie the call to your D3DMgr::Render()?

    Btw, you sometimes state you are lazy, but I think ive never seen such well commented code

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EndScene calls Render, and Render in turn calls all the registered callbacks.

    The system is event-based, I'm using Boost's Signals2 library.

    D3D9Mgr is just there to abstract the user away from the raw hooks and so I can migrate to newer D3D versions easier.

Similar Threads

  1. [C# DLL] aHook, use ASM through EndScene hook
    By JuJuBoSc in forum WoW Memory Editing
    Replies: 81
    Last Post: 04-22-2024, 02:55 PM
  2. How to Make EndScene Hook work?
    By misz in forum WoW Memory Editing
    Replies: 3
    Last Post: 02-23-2010, 08:36 PM
  3. Is EndScene hooking detectable?
    By xLeo123 in forum WoW Memory Editing
    Replies: 9
    Last Post: 01-13-2010, 03:49 PM
  4. [Test Theory] EndScene hook without Native Code (Kinda)
    By Apoc in forum WoW Memory Editing
    Replies: 7
    Last Post: 09-04-2009, 12:46 PM
  5. EndScene Hook not changing anything
    By lanman92 in forum WoW Memory Editing
    Replies: 32
    Last Post: 06-01-2009, 11:46 PM
All times are GMT -5. The time now is 05:57 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search