• Advertisement

Slothrop

Member
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Slothrop

  • Rank
    Newbie
  1. Quote:Original post by CmpDev You could create a win32 console project and replace *** Source Snippet Removed *** with a standard main function, spawn a thread to grab user input via the console and pass messages between that thread and the game thread via a thread safe queue. Is this what you were thinking or have I got it totally wrong? Thanks for the reply. I will look into the thread safe queue. That sounds like exactly what I am looking for. I don't really care how it is done, just that it is, well, done! I appreciate it.
  2. I have a basic C++ program that creates an OpenGL window and displays some basic points and lines. How would I go about storing string input from the user? I can handle single key strokes, but would like the user to be able to enter a full string to delete a specfic class instance by name that is displayed on the screen. For instance, if a graph with a node named 'dog' is displayed on screen, I would like the user to be able to type 'dog', press enter, and 'dog' is stored in a string. Any hints, tips, tricks, resources, tutorials, articles that you can recommended or point me towards? Thanks in advance. Here is my WinMain: 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); }
  3. 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]
  • Advertisement