OpenGL Fonts and Displaying Input...
I hope this isnt a dumb question but I need to display onto the screen what a user types in with OpenGL Fonts. Does anyone have a quick fix for this?
Nope, no quick fixes for that. It''s actually tons of work to make an input and font engine, and if it seems intimidating to you, you should try something easier.
Good luck either way
Good luck either way
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
-Brian
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement