I am atempting to make 2 c++ class's and I need data from one into another.
I have class A
class Draw
{
private:
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DSURFACE9 backbuffer;
LPD3DXSPRITE spriteobj;
public:
Draw(HWND hwnd,int width,int height,bool fullscreen)
{
d3d = NULL;
d3ddev = NULL;
backbuffer = NULL;
spriteobj = NULL;
Direct3D_Init(hwnd,width,height,fullscreen);
}
bool Direct3D_Init(HWND,int,int,bool);
void Direct3D_Shutdown();
LPDIRECT3DSURFACE9 LoadSurface(string filename);
void DrawSurface(LPDIRECT3DSURFACE9 dest, float x, float y, LPDIRECT3DSURFACE9 source);
LPDIRECT3DTEXTURE9 LoadTexture(string filename, D3DCOLOR transcolor = D3DCOLOR_XRGB(0,0,0));
};
that needs to send data to class B
class Font
{
private:
//font variables
LPD3DXFONT font;
LPDIRECT3DDEVICE9 *d3ddev;
LPD3DXSPRITE *spriteobj;
public:
Font(string name, int size)
{
MakeFont(name,size);
}
//font functions
LPD3DXFONT MakeFont(string name, int size);
void FontPrint( int x, int y, string text, D3DCOLOR color = D3DCOLOR_XRGB(255,255,255));
void getInfo(LPDIRECT3DDEVICE9 *d3ddev, LPD3DXSPRITE *spriteobj);
};
the data I need is the LPDIRECT3DDEVICE9 and LPD3DXSPRITE passed from a to b and also should I call a pointer or by reference?
I am not sure I need to change it or just need the info of it
Here are the class functions that need the data
LPD3DXFONT Font::MakeFont(string name, int size)
{
LPD3DXFONT font = NULL;
D3DXFONT_DESC desc = {
size, //height
0, //width
0, //weight
0, //miplevels
false, //italic
DEFAULT_CHARSET, //charset
OUT_TT_PRECIS, //output precision
CLIP_DEFAULT_PRECIS, //quality
DEFAULT_PITCH, //pitch and family
"" //font name
};
strcpy(desc.FaceName, name.c_str());
D3DXCreateFontIndirect(d3ddev, &desc, &font);
return font;
}
void Font::FontPrint(LPD3DXFONT font, int x, int y, string text, D3DCOLOR color)
{
//figure out the text boundary
RECT rect = { x, y, 0, 0 };
font->DrawText( NULL, text.c_str(), text.length(), &rect, DT_CALCRECT, color);
//print the text
font->DrawText(spriteobj, text.c_str(), text.length(), &rect, DT_LEFT, color);
}