C 线条和纹理不会同时显示
这是我画线的方法,我用鼠标画线C 线条和纹理不会同时显示,c,opengl,C,Opengl,这是我画线的方法,我用鼠标画线 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)
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();
徽标不会显示线条,为什么?有人能告诉我代码出了什么问题吗?我觉得你的
display()
函数从未调用drawLogo()
在绘制线条之前,请确保禁用纹理(
glDisable(GL\u TEXTURE\u 2D)
)。并在绘制纹理之前重新启用(glEnable(GL_TEXTURE_2D)
)
如果使用默认的
GL_MODULATE
纹理环境,请确保在使用纹理绘制之前将当前颜色设置为白色(glColor3ub(255255255)
)。如果在线条例程中,在glColor3f(0.0,0.0,0.0)
之后绘制纹理,那么GL\u MODULATE
将把所有的texel RGB值乘以零,让你到处都是黑色。如果我使用glDisable(GL\u texture\u 2D),纹理将消失实际上我有drawPlane(),这意味着在这个平面上绘制纹理。My drawLogo()正在将png图像加载到openGL。void drawPlane(){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glBegin(GL_四边形);glTexCoord2f(0.0,0.0);glVertex3f(-1.0,-1.0,0.0);glTexCoord2f(-1.0,1.0);glvertexcoord2f(1.0,1.0,0.0);glTexCoord2f(1.0,0);glvertex(1.0,-1.0,0.0);printf(“malegebbide鼠标的坐标, %d-0--0->%d\n“,a,b);glEnd();}是线条显示时没有徽标,还是徽标显示时没有线条?
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);
}
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();
}