1

これが私が線を描く方法であり、マウスを使って線を描く

static struct
{
  GLfloat p[MAX_POINTS][2];
  GLuint point_cnt;
} contours [ MAX_CONTOURS ] ;


GLuint point_cnt_mouse;
point_cnt_mouse = contours[contour_cnt].point_cnt;
glColor3f( 0.0, 0.0, 0.0 );
glBegin(GL_LINES);
glLineWidth(5.0);
int i;
int j;
for(i = 0; i <= contour_cnt; i++)
{
  GLuint point_cnt;
  point_cnt = contours[i].point_cnt;
  if (contours[i].point_cnt == 0)
  {
    glVertex2fv ( P );
    glVertex2fv ( P );
  }//if   
  else
  {
    for(j = 2; j <= point_cnt; j++)
    {
      glVertex2fv (contours[i].p[j-2]);
      glVertex2fv (contours[i].p[j-1]);               
    }//for                
  }//else
}//for
if(point_cnt_mouse > 0)
{
  glVertex2fv(contours[contour_cnt].p[point_cnt_mouse-1]);
  glVertex2fv(P);
}//if  
glEnd();

次に glTexImage2D() を使用して GL_TEXTURE_2D を作成すると、私のディスプレイは

void display()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  glPushMatrix ();     
    glTranslatef(-4.0, 5.0, -6.0);
    //this is box and load texture on it
    drawPlane();
  glPopMatrix();
  glutSwapBuffers();
  glFlush();
  }

void myinit()
{
  glClearColor(1.0, 1.0, 1.0, 1.0);
  glEnable(GL_DEPTH_TEST);
  //load png image 
  drawLogo();
  glDisable(GL_DEPTH_TEST);
}

ロゴが線で表示されないのはなぜですか? 私のコードの何が問題なのか誰にもわかりますか?

4

2 に答える 2

2

線を描く前に、必ずテクスチャリング ( glDisable(GL_TEXTURE_2D)) を無効にしてください。glEnable(GL_TEXTURE_2D)テクスチャを描画する前に再度有効にします ( )。

デフォルトのテクスチャ環境を使用している場合は、テクスチャで描画する前にGL_MODULATE、現在の色を白 ( ) に設定してください。ライン ルーチンglColor3ub(255,255,255)の後にテクスチャを描画すると、すべてのテクセル RGB 値がゼロで乗算され、どこでも黒くなります。glColor3f( 0.0, 0.0, 0.0 )GL_MODULATE

于 2013-02-25T14:07:06.203 に答える
0

あなたのdisplay()関数がdrawLogo().

void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glPushMatrix ();     
    glTranslatef(-4.0, 5.0, -6.0);
    //this is box and load texture on it
    drawPlane();
    glPopMatrix();
    glutSwapBuffers();
    glFlush();
}
于 2013-02-25T14:05:10.173 に答える