Any have this problem before?

Started by
2 comments, last by Miraj 24 years, 1 month ago
Hi Everyone, I just recently tried out Nate Miller''s GLTextFont Library to allow for drawing 2d text over a 3d world and it works great! I''m just having a minor problem though and this may not even be related to that, infact I''m almost sure it isn''t. As you probably guessed I am using OpenGL, and for input I''m using DirectInput. All is well, except this one thing... When I press a key the letter does write to the screen, which is great, but as soon as I let go of the key its gone. My function for checking input is in the message pump, right before SwapBuffers(hDC);. Am I right in assuming that it is dissapearing because of SwapBuffers? I''ve tried putting the AquireDIStatus(hwnd); after SwapBuffers but nothing comes up then, which I pretty much figured anyway. Does anyone have any suggestions or advice? I hope I''m making sense, if not I''ll post a snippet of the code if need be. Thanks! -Miraj
-Miraj
Advertisement
It sounds like you are only drawing the charecter in the keydown message loop. What you want is some buffer that stores all the charecters you want to output, and output them every frame. Hope this helps

Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
Okay...

You mean, kind of like my own cin() except something compatible with OpenGL?

This is one of those things I''ve never really done yet so I''ll need to experiment and hopefully find a tutorial out there of some kind. Anyone know of such a tuorial?

-Miraj
-Miraj
You''re going to want to do something like this.

Array buffer;

/*get input*/
if(keys[''a''])
buffer.push_back(''a'');
...for all keys you want to process. I''m assuming you draw the charecters here, which means it will only be on the screen while the key is down.

.
.
.
void redraw()
{
write buffer to screen;
and whatever else you need
}

that should do it.
Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown

This topic is closed to new replies.

Advertisement