View Full Version : glVertex3fv question

Abhijith

10-19-2008, 03:54 PM

Hi...I was going through nate robins smooth tutorial

Nate robins smooth tutorial (http://www.xmission.com/~nate/smooth.html)

the glmDraw function defined by him uses glVector3fv to render each polygon.Now i want to rasterize the triangles myself using a simple rasterization algorithm but i need x,y,z coordinates for that.Can anyone tell me how i can extract the x y z coordinates of vertices from the vector datastructures.

Thank you.

If he uses glVertex3fv, that means, that the x,y,z coordinates have to be tightly packed in an array, e.g.:

float vertex1[3] =

{

0, // x-coordinate

0, // y-coordinate

0 // z-coordinate

};

This could then be passed like this:

glVertex3fv (vertex1);

So, if you got the array with the vertex-data, simply access [0],[1] and [2] to get x,y and z respectively.

Jan.

Abhijith

10-19-2008, 05:32 PM

thanks for the reply...

i did what u said and i can draw the model using only glvertex3f instead of glvertex3fv...

The x y z values for one of the vertices are

0.357810

0.267466

-0.070688

can u explain why the coordinates are not integers...are they relative to the screen...

Thanks

No, they are in world-space. All coordinates are given as floats, since a 3D environment is continuous, integers would only allow you to have discrete steps, which would be useless.

Try reading some book or beginners tutorials about OpenGL, many things will become clear to you then.

Jan.

_NK47

10-20-2008, 01:34 AM

Abhijith: ...are they relative to the screen...

you provide them in model space then they get "transformed" to eyespace with the Modelview matrix and to screen space with the ModelViewProjection matrix. this is a bit advanced if you are really new to 3d graphics. reading the OpenGL bible would help.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.