dear all

any one know howt to use openGL with vc++? i encountered some problem.thanks a lot.

why glRectf(x1,y1,x2,y2) can draw a rectangle, here (x1,y1),(x2,y2),just two points,anone can exsplain to me? thanks. sorry to ask such question.no choice!

Time for some ASCII art

(x1,y1)
      |----------------------|
      |                      |
      |                      |
      |                      |
      |----------------------|
                             (x2,y2)

You see how 2 points can make a rect?

Learn more about OpenGl and C++ by visiting some links here

Edited 5 Years Ago by Nick Evan: n/a

Time for some ASCII art

(x1,y1)
      |----------------------|
      |                      |
      |                      |
      |                      |
      |----------------------|
                             (x2,y2)

You see how 2 points can make a rect?

Learn more about OpenGl and C++ by visiting some links here

dear freind, thanks a lot. i read the tutortial of openGL now,but i really don't understand well,just explain to me how does this function work? that means how to draw a rectangle. thanks again.

Edited 5 Years Ago by Nick Evan: n/a

What part don't you understand then?

i mean in openGL how to draw this rectangle use function glRectf(); how does this glRect() work..thanks

Some links:

glRect / glRectf

Nice tutorial (just find glRect in the file)

After initialising OpenGL you can draw a rectangle with glRect like:

glRect(10,20,40,50)

This would draw a 30x30 (40-10=30 and 50-20=30) rectangle with the left-top-corner on 10,20.

You could also use glVertex to draw a rectangle:

glBegin(GL_POLYGON); 
glVertex2(x1, y1);
glVertex2(x2,y1); 
glVertex2(x2, y2);	
glVertex2(x1, y2);
glEnd();

Edited 5 Years Ago by Nick Evan: n/a

Some links:

glRect / glRectf

Nice tutorial (just find glRect in the file)

After initialising OpenGL you can draw a rectangle with glRect like:

glRect(10,20,40,50)

This would draw a 30x30 (40-10=30 and 50-20=30) rectangle with the left-top-corner on 10,20.

You could also use glVertex to draw a rectangle:

glBegin(GL_POLYGON); 
glVertex2(x1, y1);
glVertex2(x2,y1); 
glVertex2(x2, y2);	
glVertex2(x1, y2);
glEnd();

thanks a lot friend. actually i would lik to draw cube and cylinder. just want to how to draw a rectangle first. after i have read openGL tutorial once, couldn't understand well. so ask you.

could you give me explain how to draw a cube and cylinder? thanks.

Edited 5 Years Ago by Nick Evan: n/a

That can't be done with glRect()
I could write you some samplecode, but someone else has already done that, so why re-invent the wheel?
Here's a link with everything you need.

Edited 5 Years Ago by Nick Evan: n/a

This article has been dead for over six months. Start a new discussion instead.