| View previous topic :: View next topic |
| Author |
Message |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Tue Jul 05, 2011 2:53 am Post subject: Class design |
|
|
Hello,
I'm trying to make a wrapper class for Direct2D, this is what I've now.
-DirectX classes
In the InitDX, I make the factory and the com etc, but the bitmap and text classes need the factory, so should I use class friendly ship or is it better to use a function to get the static pointer of a factory?
Further the BitMap class will load a bitmap and then you can draw it or not etc, but how if I would like to load 10 bitmaps, I've to make 10 variables of bitmaps, but next time it could be 26 bitmaps. An array would be nice. But I guess that's not possible for this?
I did not code anything yet, since this is just my design.
Thanks for reading.
NM
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Jul 05, 2011 10:26 am Post subject: |
|
|
Your base factory could be a singleton (static pointer setup) as one method of setting up. Everyone has their own opinion about singletons, so its up to you to choose that method if you want it.
If you plan to allow other extensions to be able to render everything you will want to virtualize any major function and allow it to be overridden by a lower base. (DirectX, OpenGL, etc.)
As for the Bitmap question, just use a container of a type. If you're using a custom class like; CCustomBitmap, you could use any of the container types to hold an array of them ex.
std::list<CCustomBitmap> m_vBitmaps;
std::vector<CCustomBitmap> m_vBitmaps;
(or std::map, std::hash
There are a bunch of other containers, or you can code your own.
_________________
- Retired. |
|
| Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Tue Jul 05, 2011 5:17 pm Post subject: |
|
|
Thanks that helped, I just made the pointer static and a GetPointer function. That works now.
So my next problem is that I made a CBackground class and for the background Im just drawing a bitmap as background. Then at top of that I draw the other pictures etc. But how if I would like a map to be chaning, for example in some games when you walk right the map changes to, it goes right. How do they do this?
Another thing, the D2 examples all uses .rc files, I would like to load from a directory is this possible?
Thanks.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Thu Jul 07, 2011 3:38 am Post subject: |
|
|
Well, I'm creating further and further, but im not sure if my design is done well. Since I need lots of static pointers. Ill show the classes.
| Quote: | CMain.Wndproc -> calls the CMessage(WM.PAINT and WM.CREATE).
CMessage.WmCreate->CBackground->SetBackGroundColor(white)
CMessage.WmCreate->CBackground->SetBackGroundBitMap("BitMapname")
CMessage.WmPaint -> CBackground->DrawBackGround |
Now in CBackground I've got 2 static members, the color and one for the bitmap. I'm not sure but it seems there has to be a better way to do this.
Also if Ill code further all things will become static in other classes to, that's not my intention.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Jul 07, 2011 6:34 pm Post subject: |
|
|
Why are you using static pointers for color / bitmap?
_________________
- Retired. |
|
| Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Fri Jul 08, 2011 3:00 am Post subject: |
|
|
| Because I use another instance of a class. I'm not sure if I can save that one somewhere or something.
|
|
| Back to top |
|
 |
|