1
보로 노이 메쉬를 계산하고 자유 유리를 초기화 한 다음 메쉬를 그리는 코드가있는 무료 glut 프로젝트가 있습니다.freeGlut 프로젝트에서 stdoutput을 가져올 수 없습니다.
pre-calculations
...
printf("Elapsed %lf seconds\n", (double)(clock() - start)/CLOCKS_PER_SEC);
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (WIDTH, HEIGHT);
// create window
glutCreateWindow ("Voronoy");
// register handlers
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutKeyboardFunc (key );
glutMainLoop();
return 0;
...
그래서 프로그램은 콘솔 모드에서 작동하고 자유 유리 창을 만듭니다. 또한이 프로그램에 연결된 stdout 파이프에서 읽는 별도의 프로그램이 있습니다. 이 매개 변수를 사용하여 프로세스를 만듭니다.
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = stdinput.ReadPipe();
si.hStdOutput = stdoutput.WritePipe();
si.hStdError = stderror.WritePipe();
stdoutput.DuplicateReadPipe();
if (!CreateProcess("j:\\Projects\\study\\fortune\\Debug\\voronoy.exe",//"C:\\GnuWin32\\bin\\ls.exe",
NULL,
NULL, NULL,
TRUE,
(CREATE_SUSPENDED | CREATE_SEPARATE_WOW_VDM | CREATE_NO_WINDOW),
NULL, NULL,
&si, &process_info))
{
throw("!!!");
}
DWORD w = ResumeThread(process_info.hThread);
CloseHandle(process_info.hProcess);
CloseHandle(process_info.hThread);
그리고 저는 MSDN에서 표준 파이프 예제를 시도했습니다.
문제는 프로그램이 파이프에서 데이터를 수신하지 않는다는 것입니다. 또한 cmd.exe에서 voronoy.exe> test.txt를 시도했으며 test.txt는 비어 있습니다. 그러나 파이프없이 실행하면 잘 작동하며 콘솔에서 결과를 볼 수 있습니다.