• Advertisement

Archived

This topic is now archived and is closed to further replies.

My code structure

This topic is 5758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering how I sould go about making an ''application'' class like the kind in the DX common framework that encupsulates the device interface. The encapsulation part would be straightforward enough but how do I make it so that the CMesh objects in there somewhere could access the device that belongs to the class that owns the mesh? In other words how would I make this work...
  

class App
{
  public:
    bool init();
    bool run();

  private:
    IDirect3Device8 myDevice;
    Mesh myMesh;
}

class Mesh
{
  public:
    bool Draw{};
    
  private:
    sVertex Verts[10];
}

bool Mesh::Draw()
{
  // How do I get access to the device here to do my drawing?


  return false; // :(

}

  
thanks ~Vendayan

Share this post


Link to post
Share on other sites
Advertisement
Would it be sufficient just to give every mesh object another pointer to the device? But that gets tricky when making it also have a link to its AI for example (although I doubt it would be needed) things like that lead to access violations very easily dont they?

~Vendayan

Share this post


Link to post
Share on other sites
You could set up your mesh object''s draw function
to accept a device object as a parameter. Then
pass the device in from the app as you draw all
of the meshes.

Spack

Share this post


Link to post
Share on other sites
Isn''t there a more intuitive way of doing it though? I know passing one variable isn''t much of a speed hit but I like to do a little extra work in the beginning to minimize the amount of typing I''ll have to do later once I''m debugging.

Sounds like whinning I know. Perhaps that is the best way, but If there are any other ideas on how this should be done let me know though.

~Vendayan

Share this post


Link to post
Share on other sites
Add a one line function to your App class that returns the Device interface.
Or you could use the friend class thing.

John B

Share this post


Link to post
Share on other sites

  • Advertisement