unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2006, 07:23 AM
zero_tolerance zero_tolerance is offline
Senior Member
 
Join Date: Dec 2006
Posts: 289
Default Printing text and resetting font object

By RoverTurbo

Font creation and function code in d3d.

Code:
#include <stdarg.h>
#include <stdio.h>



LPD3DXFONT oFont;
bool bCreateFont = true;



void TEXT(LPD3DXFONT oFont, int iX, int iY, int iA, int iR, int iG, int iB, const char *cText, ...)
{

  D3DCOLOR oColour = D3DCOLOR_ARGB(iA, iR, iG, iB);

  RECT rPostion;
  rPostion.left = iX;
  rPostion.right = rPostion.left + 1001;
  rPostion.top = iY;
  rPostion.bottom = rPostion.top + 1001;

  char cVar[101] = "";

  va_list pArgs;
  va_start(pArgs, cText);
  _vsnprintf((cVar + strlen(cVar)), (sizeof(cVar) - strlen(cVar)), cText, pArgs);
  va_end(pArgs);

  oFont->DrawText(cVar, -1, &rPosition, 0, oColour);

}


HRESULT APIENTRY IDirect3DDevice9::BeginScene()
{

  if(bCreateFont == true)
  {

    bCreateFont = false;

    HFONT hFont = CreateFont(15, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, 0, 0, PROOF_QUALITY, 0, "Arial Black");
    D3DXCreateFont(Device, hFont, &oFONT);

  }

  return Device->BeginScene();

}
Resetting a font object.

Code:
HRESULT APIENTRY IDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS *pPresentationParameters)
{

  if(oFont)
  oFont->OnLostDevice();
    
  HRESULT hRet = Device->Reset(pPresentationParameters);

  if(oFont)
  oFont->OnResetDevice();

  return hRet;

}
Credits: Msdn, Google, Directx documentation and Directx Community.
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
font, object, printing, resetting, text

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 03:52 PM.