Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectDraw question

Started by Fender148 Aug 27, 2000 at 8:16 PM 2 replies 550+ views
Original Post
Fender148
Fender148
I''ll try to make this as simple as possible, its really not that difficult of a problem but I cant seem to figure it out I have a text file, I want to display on the screen in my DirectX program (ver 6.0). I want the text to scroll, displayed one character at a time. The only way to display text on the screen in DDraw that I know of is TextOut or DrawText and they take a LPCTSTR as the parameter, so TextOut("hi this is text") works, and TextOut(letter), letter being a char I read in, doesnt. What Ive tried to do is read in one character at a time and write that, but no matter what I cant get it to work because of what the functions take and because Im not too good with this stuff Hope I made my question simple enough, Id appreciate any input Thanks
baskuenen
baskuenen
It could be you forgot to ''\0'' terminate the string. You must give a char pointer to the TextOut function.

Maybe this will work:

    
char Str[2] = { 0,0 };

// read char

Str[0] = ''a''; // orso


TextOut((LPCTSTR)Str);


I think the LPCTSTR type can be explained as:
LP = long pointer (long comes from 32bit)
C = constant
T = zero terminated
STR = string

Fender148
Fender148
Thanks for the reply
I did just that, the call

Draw_Text_GDI((LPCTSTR)Str, x,y, RGB(0,255,0), lpddsprimary);

results in error:
error C2665: ''Draw_Text_GDI'' : none of the 2 overloads can convert parameter 1 from type ''const char *''
Error executing cl.exe.

heres the function prototype:
int Draw_Text_GDI(char *text, int x,int y,int color, LPDIRECTDRAWSURFACE4 lpdds)

thats simpler I guess, when I typed the function out it said LPCTSTR, you know how vis c++ does that for you so you can see what to put in

Tornado
Tornado
I''m guessing your using Lamothe''s function, right ?
Draw_Text_GDI() doesn''t recieve an LPCTSTR parameter, you should use Draw_Text_GDI() like this:
Draw_Text_GDI((char*)Str, x,y, RGB(0,255,0), lpddsprimary);
Should also work without the (char*), but just to be safe...



The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.