# glVertex??() Parameter Boundaries

This topic is 4453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

You know better, glVertex2f(), glVertex3f() and glVertex4f() functions have upper and lower boundaries of -1.0f and +1.0f. glVertex2d(x, y); glVertex2i(x, y); glVertex2s(x, y); And, can you tell me, what boundaries x and y parameters have for the functions above? And one more thing... What does the 4th parameter of glVertex4?() stand for?

##### Share on other sites
There are no boundaries for glVertex. You can pass any value you like. Well, any value within the limits of the data type, but that's not a limit in glVertex.

The fourth parameter is the homogenous coordinate. It's related to the perspective, and you really don't have to worry about it as you rarely work with it explicitely. But search for "homogenous coordinates" or something on google if you want to know more.

##### Share on other sites
Suppose that, we have a window with 200 pixel height and 200 width. And we want to place a vertex to coordinates (50, 75), supposing that (0, 0) is the coordinates of the left-bottom corner.

Using glVertex3f()...
glVertex3f((float) 1.0 - (2.0 * 50.0/200.0), (float) 1.0 - (2.0 * 75.0/200.0), 0.0f);
will sure work.

But I want to learn how to do this using glVertex3i().

##### Share on other sites
glVertex*i uses exactly the same coordinate range as glVertex*f, only that i is limited to integers.

By the way, if you want to set a vertexe at a given coordinate on the screen, then don't manually calculate it, use the projection matrix to do the job instead.
glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0, window_width, 0, window_height, -1, 1);glMatrixMode(GL_MODELVIEW);glLoadIdentity();

There, now you place a veretx at (50, 75) by using glVertex3f(50, 75) or glVertex3i(50, 75) instead.

• 10
• 19
• 14
• 19
• 15
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!