Jump to content
  • Advertisement
Sign in to follow this  
aphelix

Font assignement problem!

This topic is 4229 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

Hi! My Font class has a assignment operator.. class CFont{ private: ID3DXFont* m_Font; ..... public: // = operator CFont& operator = (const CFont& _font) { IDirect3DDevice9* device = NULL; if (this == &_font) // Same object? return *this; device = GetDevice(...); ..... Release<ID3DXFont*>(m_Font); m_Font = NULL; // Interface assignment... if(_font.m_Font){ if(FAILED(D3DXCreateFontIndirect(device, &_font.m_FontDesc, &(this->m_Font)))){ m_Font = NULL; throw ... } } return *this; } and i will set a font .... CFont font(10); Window->SetFont(&font); with int Window::SetFont(CFont* _font) { if(!m_Font){ // CFont* m_Font --> member of Window m_Font = new(std::nothrow)CFont(*_font); if(!m_Font) return 1; } else *(m_Font) = *_font; return 0; } voila... when i debug the code all seems ok..But writing something with Window::Write(...) { Font->GetFont()->DrawText(.... } don't work... Why?? Not: when i don't set a font with Window::SetFont.. all work good.... thanks!!!

Share this post


Link to post
Share on other sites
Advertisement
It could be mulitple things. Are you checking the HRESULT of the DrawText function? Is that what is failing? Or are you just not seeing anything?
Also, i would advice looking over where you fill the description structure.

~Trandafira

Share this post


Link to post
Share on other sites
... when i debug ,return value of D3DXCreateFontIndirect and FontDesc in assignement operation seems ok...

Share this post


Link to post
Share on other sites
Quote:
Original post by aphelix
... when i debug ,return value of D3DXCreateFontIndirect and FontDesc in assignement operation seems ok...
So what's not working then? "Not working" could mean anything from you get nothing displayed to it causes every computer you run the code on to blow up...

Share this post


Link to post
Share on other sites
Quote:
Not: when i don't set a font with Window::SetFont.. all work good....


I'm not 100% sure on this, but the D3D font probably is a quite different class/type/resource than the WinAPI font (seems to be true: ID3DXFont vs CFont). Setting it (the ID3DXFont) the on the window is probably causing this problem and it's not needed anyway. Just draw your texts directly to the D3D scene with the ID3DXFont object and don't worry about the unrelated CFont set on the window.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!