Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 688355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:13:17+00:00 2026-05-14T02:13:17+00:00

This is kind of a COM question to do with DirectX. So, both ID3DXSprite

  • 0

This is kind of a COM question to do with DirectX.

So, both ID3DXSprite and ID3DXFont and a bunch of the other ID3DX* objects require you to call OnLostDevice() when the d3d device is lost AND OnResetDevice() when the device is reset.

What I want to do is maintain an array of all ID3DX* objects and simply call OnResetDevice() and OnLostDevice() on each whenever the device is lost or reset.

However I can’t seem to find a BASE CLASS for the ID3DX* classes… they all seem to COM-ually inherit from IUnknown.

Is there a way to do this or do I have to maintain separate arrays of ID3DXFont* pointers, ID3DXSprite* pointers, etc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:13:17+00:00Added an answer on May 14, 2026 at 2:13 am

    There isn’t a common base class, sorry.

    You could use multiple inheritance and templates to sort of achive what you want. Something like this (untested but hopefully you’ll get the idea)…

    #include <d3dx9.h>
    #include <vector>
    
    using namespace std;
    
    class DeviceLostInterface
    {
    public:
        virtual void onLost() = 0;
        virtual void onReset() = 0;
    };
    
    template <typename Base>
    class D3DXWrapper : public Base, public DeviceLostInterface
    {
    public:
        virtual void onLost() { Base::OnLostDevice(); }
        virtual void onReset() { Base::OnResetDevice(); }
    };
    
    
    int main()
    {
        // Wouldn't be set to null in real program
        D3DXWrapper<ID3DXSprite>* sprite = 0;
        D3DXWrapper<ID3DXFont>* font = 0;
    
        vector<DeviceLostInterface*> things;
        things.push_back(sprite);
        things.push_back(font);
    
        // This would be a loop...
        things[0]->onLost();
        things[1]->onLost();
    
    }
    

    This sort of meets your requirements, but to be honest I don’t really think it’s very useful. You’d either need some way to know what to cast each item back to, or keep the pointers in a type specific list anyway and then you might as well just write separate code to reset each type anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kind of related to this question: https://stackoverflow.com/questions/8708525/how-to-check-if-mako-function-exist I want to check if a function
This is kind of a follow to my other post about Unity (http://stackoverflow.com/questions/3998559/irepository-iservice-unity-in-an-asp-net-mvc-application-reference-question). Basically
What kind of UML diagram is this? (source: tripod.com )
this kind of follows on from another question of mine. Basically, once I have
I know, I know... Eric Lippert's answer to this kind of question is usually
This kind of builds up on Already asked question ... However here, say, I'm
This question is kind of related to our web application and it is bugging
This is kind of an odd question, I hope this enough information to go
I know this kind of question exist but I'm confused in this case. I'm
This is kind of a two part question. Is it possible to retrieve data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.