• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
anders211

How to get HFONT from ID3DXFont instance

0 posts in this topic

Hi,
Short introduction:
I have created ID3DXFont instance with the aid of function D3DXCreateFont(). In fact this instance You might also create with the aid of D3DXCreateFontIndirect. What You can do with this font instance after creating - You may invoke ID3DXFont::DrawText method to draw the text.
The problem is how to convert ID3DXFont instance to HFONT, because sometimes I would like to use function which draw text based on HFONT instance, not ID3DXFont one. In my particular case this function which I would like to use it: ScriptTextOut(), in which first parameter is HDC. In fact I might obtain HDC from ID3DXFont interface with the aid of method ID3DXFont::GetDC. However after I did it nothing is draw in this obtained ID3DXFont HDC - I cannot see any drawn text. But when I change HDC into hDC of window, I can see drawn text. However the window HDC has some default HFONT related. So the question is how to relate ID3DXFont HFONT into hDC of window??? I know that there isn't HFONT in ID3DXFont but the question is how to solve my problem?
This is my code in which the text is not seen (it is seen only when I use default hWnd font, not obtained from ID3DXFont):
HRESULT Buffer::drawText(i32 x, i32 y, RECT* rect){/*HRESULT hr = ScriptTextOut(hdc_In_ const HDC hdc,_Inout_ SCRIPT_CACHE *psc,_In_ int x,_In_ int y,_In_ UINT fuOptions,_In_opt_ const RECT *lprc,_In_ const SCRIPT_ANALYSIS *psa,_In_ const WCHAR *pwcReserved,_In_ int iReserved,_In_ const WORD *pwGlyphs,_In_ int cGlyphs,_In_ const int *piAdvance,_In_opt_ const int *piJustify,_In_ const GOFFSET *pGoffset*/HDC hDC = NULL;if(mFont != NULL)hDC = mFont->font->GetDC(); //get font DCelse{::MessageBox(NULL, "Buffer::drawText - font not initialized", "Warning", MB_ICONWARNING);return S_FALSE;}HPEN fPen = (HPEN)SelectObject(hDC, NULL); //get font HPENSelectObject(hDC, fPen); //restore font HPENHDC hDCWin = GetDC(GUI::hWnd); //get window DCHPEN winPen = (HPEN)SelectObject(hDCWin, fPen); //set new HPEN to window and get old HPEN//SCRIPT_CACHE scriptCache = NULL; //in: font infoTextOutW(hDC,rect->left, rect->top, mBuffer,getTextSize()); //let's first try this simple function instead of ScriptTextOutHRESULT hr = S_OK;//ScriptTextOut(hDC, &scriptCache, x, y, ETO_CLIPPED | ETO_OPAQUE, rect, &mItems[0].a, NULL, 0, &mGlyphs[0],//static_cast<i32>(mGlyphs.size()), &mPiAdvance[0], NULL, &mGoffset[0]); //&mPiJustify[0]//ScriptFreeCache(&scriptCache);SelectObject(hDCWin, winPen); //restore original window HPENReleaseDC(GUI::hWnd, hDCWin); //release window HDCreturn hr;}

I hope that You understand my problem. If not, in other words the question might be how to draw the text with the aid of ScriptTextOut (or TextOutW) with font from ID3DXFont interface in the way that it is seen in the screen? Edited by anders211
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0