Thread: Return Interface: problem

  1. #1
    Unregistered
    Guest

    Return Interface: problem

    Im using this function to return the used interface for d3d (after initing it.):

    Code:
    void RTIntObj::ReturnD3D (IDirect3D8** Returned)
    {
       if (!g->GeneralDX.d3d8==NULL)
            ReturnedObject = &g->GeneralDX.d3d8;
    
    }
    But it doesnt work, as it crashes my app. What should i change in my function? thanks!

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Try -

    *ReturnedObject = &g->GeneralDX.d3d8;

  3. #3
    Unregistered
    Guest
    It didnt work, it shows me errors:

    Code:
    error C2440: '=' : cannot convert from 'struct IDirect3D8 ** ' to 'struct IDirect3D8 *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    error C2440: '=' : cannot convert from 'struct IDirect3DDevice8 ** ' to 'struct IDirect3DDevice8 *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    What does g->GeneralDX.d3d8 return?

  5. #5
    Unregistered
    Guest
    What do you mean? the 'd3d8' is a valid IDirect3D8 pointer.

  6. #6
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    In that case -

    *ReturnedObject = g->GeneralDX.d3d8;

    You'll always have to de-reference the pointer to pointer otherwise your attempted return of an address will go out of scope.

  7. #7
    Unregistered
    Guest
    Ohh! It works! I didnt imagine it was so easy. Thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  4. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  5. C++ FTP class won't work
    By lord mazdak in forum C++ Programming
    Replies: 8
    Last Post: 12-18-2005, 07:57 AM