Archived

This topic is now archived and is closed to further replies.

tHaPuTeR

OpenGL Fonts and Displaying Input...

Recommended Posts

Nope, nothing seems intimidating until I try it for myself. Im trying to figure out exactly what I need to do to write on of the engines. Does anyone know where a example is or what I would need to do to make this. Thanks for your help

-Brian

Share this post


Link to post
Share on other sites
not that hard at all!!

mini tute here...
start with nehe Lesson 14 - Outline Fonts.

add 3 variables at the top:

char string[256]; // string containing user input
int sl=0; // length of string
int lastkey=0; // last key that was pressed

then in the WndProc() function under case WM_KEYDOWN: change to the following:

case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE; // If So, Mark It As TRUE
lastkey = wParam; // NEW note last key pressed
return 0; // Jump Back
}

then in WinMain() after SwapBuffers(hDC) there the rest of your input handeling is done:

if (lastkey > 0) // was a key pressed?
{
if(lastkey == VK_BACK || lastkey == VK_DELETE) // was it backspace or del?
{
if (sl > 0) // then if string not empty shorten it
{
sl = sl - 1;
}
string[sl] = 0; // dont forget the null ending
}
else if ( sl < 255 && lastkey > 31 && lastkey < 127) // if string not to big and charictor key pressed
{
string[ sl+1 ] = 0;
string[ sl++ ] = lastkey; // add key to string
}
lastkey = 0;
}

than all you need to do is display the string in DrawGLScene useing the:

glPrint("%s", string);

there. ive done ''tons of work'' for you i hope! lol
not that intimidating i hope.


- Jono AH

Share this post


Link to post
Share on other sites