Jump to content
  • Advertisement
Sign in to follow this  
Slothrop

Need suggestion on how to handle input with OpenGL window

This topic is 4253 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 have a basic C++ program that creates an OpenGL window and displays some basic points and lines. How would I go about storing user string input? I tried using getline(cin, input); thinking that may work, but the input variable never actually changes. I am using WinAPI and can handle single keystrokes, but would like to be able to store string input. Any hints, tips, tricks that you can recommended or point me towards? Thanks in advance. Here is my WinMain (I would like to get the input somewhere in the while loop):
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
	            LPSTR lpCmdLine, int nCmdHow)
{
	MSG		msg;
	int		done = 0;

	char* name = "OpenGL";
	int len = strlen(name)+1;
	wchar_t *wName = new wchar_t[len];
	memset(wName,0,len);
	::MultiByteToWideChar(  CP_ACP, NULL,name, -1, wName,len );
	
	if ( !createGLWindow( wName, windowWidth, windowHeight, 16 ))
	{
		killWindow();
		return 0;
	}
	initGL(windowWidth, windowHeight);
	
	while ( !done )
	{
		if ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
				done = TRUE;
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		drawScene();
		if ( checkKeys() )
		    done = TRUE;
	}
	killWindow();
	return (int)(msg.wParam);
}
[Edited by - Slothrop on November 27, 2006 8:50:02 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you're interested in platform-specific solutions, you might post what platform/environment/SDK you're using.

For cross-platform solutions, there's GLUT, SDL, and a few other libraries that I can't think of at the moment.

Personally I'd recomment SDL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!