다음과 같은 기능을 가지고 있습니다. 그 목적은 3D 개체를 표시하는 GLUT 창과 플롯을 표시하는 Gnuplot 창을 표시하는 것입니다.GLUT와 gnuplot 창이 동시에 나타나지 않음
나는 Gnuplot-Iostream Interface을 사용합니다. 플롯 팅 코드는 사용자가 키보드를 입력 할 때 업데이트되므로 함수 안에 있습니다. displayGraph 기능 내부의 gnuplot 인스턴스를 선언한다 작동 무엇
#include "gnuplot-iostream.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
void displayGraph();
void displayGnuplot();
Gnuplot gp;
int main(int argc, char** argv) {
displayGnuplot();
glutInit(&argc,argv);
glutInitWindowSize(1024, 1024);
glutInitWindowPosition(1080,10);
glutCreateWindow("Continuum Data");
glutDisplayFunc(displayGraph);
glutMainLoop();
}
void displayGraph(){
/*
Code to display in Glut window that will be updated
*/
}
void displayGnuplot(){
bool displayGnuplot = true;
gp << "set xrange [-2:2]\nset yrange [-2:2]\n";
gp << "plot '-' with vectors title 'pts_A', '-' with vectors title 'pts_B'\n";
}
: 나는 GLUT 창을 닫은 후
다음 코드 만의 gnuplot 창을 표시합니다. 불행히도 내 사건에 대해서는 displayGraph 함수가 호출 될 때마다 새로운 Gnuplot 윈도우가 생성 될 때마다 작동하지 않을뿐입니다. 반면 Gnuplot 윈도우는 업데이트됩니다. 내가 GNUPLOT에 다른 C++ 인터페이스를 사용하여 솔루션을 발견했습니다
#include "gnuplot-iostream.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
void displayGraph();
void displayGnuplot();
Gnuplot gp;
int main(int argc, char** argv) {
displayGnuplot();
glutInit(&argc,argv);
glutInitWindowSize(1024, 1024);
glutInitWindowPosition(1080,10);
glutCreateWindow("Continuum Data");
glutDisplayFunc(displayGraph);
glutMainLoop();
}
void displayGraph(){
/*
Code to display in Glut window that will be updated
*/
}
void displayGnuplot(){
if(!gnuplotExists){
Gnuplot gp;
gnuplotExists = true;
}
gp << "set xrange [-2:2]\nset yrange [-2:2]\n";
gp << "plot '-' with vectors title 'pts_A', '-' with vectors title 'pts_B'\n";
}
왜'gnuplot'이 OpenGL을 사용할 수 있다고 생각하십니까? – Ripi2
내 코드가 다소 혼란 스러웠다. GLUT와 Gnuplot의 사용을 분리하기 위해 코드를 업데이트했다. 내가 원하는 것은 Gnuplot과 GLUT 윈도우가 동시에 나타나기 위해서입니다. 그들은 서로 상호 작용하지 않습니다. –