PDA

View Full Version : How to use glEdgeFlagv ?



_student
12-20-2004, 06:50 AM
#include <gl/glew.h>
#include <gl/glut.h>

#include <cassert>

GLfloat spin = 0.0;

void change()
{
spin += 1.0;

if (spin > 360.0)
spin -= 360.0;

glutPostRedisplay();
}

void Init()
{
glewInit();
assert(GLEW_VERSION_1_2);

glClearColor(0.0, 0.0, 0.0, 1.0);
glShadeModel(GL_SMOOTH);

glPolygonMode(GL_FRONT, GL_FILL);
glPolygonMode(GL_BACK, GL_LINE);

//glFrontFace(GL_CCW);
//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);

glutIdleFunc(change);
}

GLboolean edgeFlag[] = {
GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE,
};

void display()
{
glClear(GL_COLOR_BUFFER_BIT);

glPushMatrix();
glRotatef(spin, 1.0, 1.0, 0.0);

glFrontFace(GL_CCW);

glBegin(GL_POLYGON);
glEdgeFlagv(edgeFlag);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(50.0, 50.0, -20.0);
glVertex3f(-50.0, 50.0, -20.0);
glVertex3f(-50.0, 0.0, 0.0);
glEnd();

glFrontFace(GL_CW);

glBegin(GL_POLYGON);
glEdgeFlagv(edgeFlag);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(50.0, -50.0, -20.0);
glVertex3f(-50.0, -50.0, -20.0);
glVertex3f(-50.0, 0.0, 0.0);
glEnd();
glPopMatrix();

glutSwapBuffers();
}

void reshape(int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0, 100.0, -100.0, 100.0, -200.0, 200.0);
//gluPerspective(60.0, (double)width / height, 0.1, 550.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0.0, 0.0, 400.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100, 100);
glutInitWindowSize(600, 600);
glutCreateWindow("");

Init();

glutDisplayFunc(display);
glutReshapeFunc(reshape);

glutMainLoop();
}

The result was incorrect. Could anyone help me to change the code? Thanks.

mikael_aronsson
12-21-2004, 12:58 AM
Hi !

Is it your own code or what ?, I mean, it would be nice if you would explain what you try to do and what is going wrong at least, just saying "hey, this does not work, can someone fix it for me ?" is not very creative.

Mikael

_student
12-22-2004, 02:43 AM
I drew a polygon, it combines with two small polygon, there is a line in the center of it, use glEdgeFlag can disable it, but I don't know how to use glEdgeFlagv. Could you give me an example about it?