Jogl GL_线在多维数据集中不可见

Jogl GL_线在多维数据集中不可见,jogl,Jogl,我想做的是画一个平行六面体(使用GL_四边形)及其边(使用GL_线)。 平行六面体应该是一个挤压场,相机将在里面。 问题是当我使用GL_线时,当相机位于平行六面体内时,绘制的线不可见 两个屏幕截图,让您更好地了解: 内侧-线条不可见: 外线可见: 这是我的init方法中的内容: GL2 gl = drawable.getGL().getGL2(); // get the OpenGL graphics context glu = new GLU();

我想做的是画一个平行六面体(使用GL_四边形)及其边(使用GL_线)。 平行六面体应该是一个挤压场,相机将在里面。 问题是当我使用GL_线时,当相机位于平行六面体内时,绘制的线不可见

两个屏幕截图,让您更好地了解:

内侧-线条不可见:

外线可见:

这是我的init方法中的内容:

GL2 gl = drawable.getGL().getGL2();      // get the OpenGL graphics context
      glu = new GLU();                         // get GL Utilities
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // set background (clear) color
      gl.glClearDepth(1.0f);      // set clear depth value to farthest
      gl.glEnable(GL_DEPTH_TEST); // enables depth testing
      gl.glEnable(GL_BLEND);
      gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      gl.glDepthFunc(GL_LEQUAL);  // the type of depth test to do
      gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // best perspective correction
      gl.glShadeModel(GL_SMOOTH); // blends colors nicely, and smoothes out lighting
      gl.glEnable(GL_LINE_SMOOTH);
GL2 gl = drawable.getGL().getGL2();  // get the OpenGL 2 graphics context
  gl.glClearColor(0.55f, 0.55f, 0.55f, 1.0f);
  gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
  gl.glLoadIdentity();  // reset the model-view matrix


  gl.glTranslated(-3.2, -2.82, -10); // translate into the screen

  gl.glBegin(GL_QUADS); // Start Drawing The Quad
  gl.glColor4ub(r,g,b, alpha);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(6.400, 5.640, 0);
  gl.glVertex3d(6.400, 0, 0);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(0, 0, 9.750);

  gl.glVertex3d(6.400, 0, 0);
  gl.glVertex3d(6.400, 5.640, 0);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);

  gl.glVertex3d(0, 0, 9.750);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 0, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);
  gl.glVertex3d(6.400, 0, 0);

  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 0);

  gl.glEnd(); // Done Drawing The Quad

  gl.glLineWidth(2);
  gl.glBegin(GL_LINES);
  gl.glColor4ub((byte)0,(byte)0,(byte)0, (byte)255);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);

  gl.glEnd();
这是我的显示方法:

GL2 gl = drawable.getGL().getGL2();      // get the OpenGL graphics context
      glu = new GLU();                         // get GL Utilities
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // set background (clear) color
      gl.glClearDepth(1.0f);      // set clear depth value to farthest
      gl.glEnable(GL_DEPTH_TEST); // enables depth testing
      gl.glEnable(GL_BLEND);
      gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      gl.glDepthFunc(GL_LEQUAL);  // the type of depth test to do
      gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // best perspective correction
      gl.glShadeModel(GL_SMOOTH); // blends colors nicely, and smoothes out lighting
      gl.glEnable(GL_LINE_SMOOTH);
GL2 gl = drawable.getGL().getGL2();  // get the OpenGL 2 graphics context
  gl.glClearColor(0.55f, 0.55f, 0.55f, 1.0f);
  gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
  gl.glLoadIdentity();  // reset the model-view matrix


  gl.glTranslated(-3.2, -2.82, -10); // translate into the screen

  gl.glBegin(GL_QUADS); // Start Drawing The Quad
  gl.glColor4ub(r,g,b, alpha);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(6.400, 5.640, 0);
  gl.glVertex3d(6.400, 0, 0);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(0, 0, 9.750);

  gl.glVertex3d(6.400, 0, 0);
  gl.glVertex3d(6.400, 5.640, 0);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);

  gl.glVertex3d(0, 0, 9.750);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 0, 9.750);
  gl.glVertex3d(6.400, 0, 9.750);
  gl.glVertex3d(6.400, 0, 0);

  gl.glVertex3d(0, 5.640, 0);
  gl.glVertex3d(0, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 9.750);
  gl.glVertex3d(6.400, 5.640, 0);

  gl.glEnd(); // Done Drawing The Quad

  gl.glLineWidth(2);
  gl.glBegin(GL_LINES);
  gl.glColor4ub((byte)0,(byte)0,(byte)0, (byte)255);

  gl.glVertex3d(0, 0, 0);
  gl.glVertex3d(0, 5.640, 0);

  gl.glEnd();

谢谢您的帮助。

线条是使用与四边形相同的z缓冲区绘制的。所以,当你们在室外时,线比四边形的边更靠近相机,它们是被画出来的。当你们在里面的时候,四边形的表面更接近,线并没有画出来。但是,由于数值误差,线条可能会不时出现或消失。应始终绘制深度测试和测线