help in drawing object's face (new)

I wish to draw this polygon with 6 coodinates (front face) which are (-x,y,1),(-x,-y,1),(0,-y,1),(0,y-d,1),(-w,y-d,1),
(-w-d,y,1). The arc is between the last 2 coodinates with an angle of 90deg. And d<w.

I have problems with the arc part, below is what i did:

glBegin(GL_POLYGON);
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f(-x, y, 1.0f);
glVertex3f(-x,-y, 1.0f);
glVertex3f(0,-y, 1.0f);
glVertex3f(0,y-d,1.0f);

float arcx = dcos(i);
float arcy = d
sin(i);
for (i=0;i<= pi/2; i++){
glVertex3f(arcx,arcy,1.0f);
}
glVertex3f(-w-d, y, 1.0f);
glEnd();

think this is nt very correct. Can someone help?

[This message has been edited by coda (edited 01-10-2004).]

float arcx = dcos(i);
float arcy = d
sin(i);
for (i=0;i<= pi/2; i++){
glVertex3f(arcx,arcy,1.0f);
}

Did you really expect that arcx would change at all during the loop ??? Learn C before OpenGL…

Do this :

float x=1.0f;
float y=1.0f;
float d=0.5f;
int SUBDIVS=10;

glBegin(GL_POLYGON);
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f(-x+d, d, 1.0f);
glVertex3f(-x+d,-y-d, 1.0f);
glVertex3f(d,-y-d, 1.0f);
glVertex3f(d,0,1.0f);

  float arcx;
  float arcy;
  for (i=0;i<= SUBDIVS; i++) {
  	arcx = d*cos(i*M_PI_2/SUBDIVS);
  	arcy = d*sin(i*M_PI_2/SUBDIVS);
  	glVertex3f(arcx,arcy,1.0f);
  }

glEnd();

thanx for your help. The arc is drawn but my original intention is to draw the arc in the inverted way i.e mirror image along the line y=x such that the rect look “chipped” off… i tried changing the angle but turned out funny. Also, d is radius of arc but I still cannot figure out why you use those coodinates in the vertices (before the for loop)

[This message has been edited by coda (edited 01-10-2004).]

>>>>The arc is drawn but my original intention is to draw the arc in the inverted way i.e mirror image along the line y=x such that the rect look “chipped” off… i tried changing the angle but turned out funny.<<<<

Not very clear. Mirror along y=x would change nothing for the circular part. If you meant something else, you can try it out by offsetting the angle by M_PI and moving the origin.

>>>>Also, d is radius of arc but I still cannot figure out why you use those coodinates in the vertices (before the for loop)<<<<

Come on, it is not so hard. Plot the coords by hand, on a paper, and you will understand

okie i think i figured it out, your origin is at the rounded corner, distance d from the edge? hmm now my problem is how to get the arc to look inverted- much like a arc in the 3rd quadrant of a circle.

float x=1.0f;
float y=1.3f;
float d=0.5f;
int SUBDIVS=10;

// glBegin(GL_POLYGON);
glBegin(GL_TRIANGLE_FAN);
// glBegin(GL_LINE_LOOP); // use this to debug your drawing
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f(-x,-y, 1.0f);
glVertex3f(-x, 0, 1.0f);
float arcx;
float arcy;
for (i=0;i<= SUBDIVS; i++) {
arcx = dcos(iM_PI_2/SUBDIVS+M_PI);
arcy = dsin(iM_PI_2/SUBDIVS+M_PI);
glVertex3f(arcx,arcy,1.0f);
}
glVertex3f(0,-y, 1.0f);

glEnd();

I have nothing to do, so…
I believe that you got ‘funny results’ because the polygon is no more convex. As it is ultimately tesselated into triangles by the GL renderer, it is better to use ‘TRIANGLE_FAN’ (read the docs), as behavior is specified. Start at the lower left corner to avoid concavity problems.

And read the docs ! The red book is avalable online, check the opengl main page.

I finally can draw the arc in the inverted way by changing the angle and using for (i=10;i>=0;i–)…etc . thanx for your help!