HelpWriting text with DirectX

Posts 1–10 of 10 · Page 1 of 1
Writing text with DirectX
Hi guys , in the last days I read a lot about hooking and how to create a DirectX-overlay.

With the help of many tutorials I managed to create a injectable DLL.

Now I want to Print some text before the EndScene. I also did this with rectangles and it worked.

My problem is that all tutorials I found didn't work at all , or i guess im to stupid

Ok I used this tut from MPGH

 
i used the first method , here is the Code , I put this in a header and want to call it in the cpp file
Code:
void PrintText1(double x, double y, DWORD dwColor, LPD3DXFONT pFont, char *Text, ...)
{
	char buffer[256];

	//This is for handling the "..." parameters
    va_list argList;
    va_start(argList, Text);
    vsnprintf_s(buffer, sizeof(buffer), sizeof(buffer) - strlen(buffer), Text, argList);
    va_end(argList);

	//Our Rect to where the text will be printed
    RECT Rect =
	{
		x,
		y,
		x + 500,
		y + 50
	};

    pFont->DrawText(NULL, buffer, -1, &Rect, DT_NOCLIP, dwColor);
}


But always get this Error in Visual Studio 2010:
IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCWSTR"

Ok and then my problem is how to call the function correctly

Have you any other suggestions to display text , or do you know why this isn't working?

THX in advance
Explicitly call DrawTextA instead of the DrawText macro, or change the character set of your project to "multi-byte"
Quote Originally Posted by kibbles18 View Post
Or cast it as LPCWSTR
Casting doesn't work. A wide string can't be cast back and forth between to a C-string
Quote Originally Posted by Jason View Post


Casting doesn't work. A wide string can't be cast back and forth between to a C-string
Not directly but there are ways to do it.
Quote Originally Posted by Nico View Post


Not directly but there are ways to do it.
I'm aware of that, but I just said a direct cast wouldn't work
Quote Originally Posted by Jason View Post


I'm aware of that, but I just said a direct cast wouldn't work
Let's discuss more about that.
Quote Originally Posted by Nico View Post


Let's discuss more about that.
What more is there to discuss?
LPCWSTR in msvc++ is wchar_t *.
you should declare UNICODE in your project.
Quote Originally Posted by lannyboy View Post
LPCWSTR in msvc++ is wchar_t *.
you should declare UNICODE in your project.
Thanks for being completely redundant. Toddle on.
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Talk with us