I am making a game and I have a console using AllocConsole().
I want to be able to write commands in the console and I dont really know how to get input without pausing the game loop. Do I need to separate in two threads or is there another way?
1 Answer
You don't need to pause game loop. Just process the commands in the game loop as you do with keyboard, mouse, network, whatever. One thing you're probably afraid about is that I/O may block until sufficient data are available. If this is the case, you can turn on non-blocking I/O on standard input or you can use stuff like select() to check if there are any data.
2 Comments
user3684561
thank you, I think I can do it using select()
kfsone
Bear in mind that, under Windows,
select() is implemented over WaitForMultipleObjects so you have a default limit of 64 file handles you can select on.