1
\$\begingroup\$

I have started to develop a simple 3D engine. I use OpenGL for rendering, and it is developed for Windows. It is all written in C.

How do I write an interface for the keyboard and mouse input? I would like to keep it as simple as possible - in contrast to the native Win32 input system.

\$\endgroup\$
2
\$\begingroup\$

There is more than one one way to skin the cat. If I understand correctly, you want to be able to take input from keyboard and mouse and use that to control stuff in your engine. But to write such interface from scratch, by yourself, would not only be a classic case of reinventing the wheel, but also, a very tedious task (think about it... you want to be able to support PS/2 and USB mice, as well as keyboards and you must admit, testing whether there's something present in a particular port, polling through USB hubs and ports... it's too much hassle when there's already available software to do that for you, right?)

So you will save much time using an already developed interface/framework of that kind. Such a component is a part of already mentioned FreeGLUT, but there is also SDL, which handles not only that, but also window manipulation, threading and more. Check it out. Pay attention to SDL_event struct and SDL_PollEvent function.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

There are frameworks like FreeGLUT that give a basic input/output abilities with keyboard and mouse, but if you want more there are the Visual C++ APIs for Windows.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.