Sign in to follow this  

Need suggestion on how to handle input with OpenGL window

This topic is 4036 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
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

This topic is 4036 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this