Jump to content
  • Advertisement

Archived

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

tHaPuTeR

OpenGL Fonts and Displaying Input...

This topic is 5830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!