# Thread: how to incorporate user input numbers into vertex position?

1. ## how to incorporate user input numbers into vertex position?

my vertex position depends on user dimension input. suppose to draw a rect, user specify 200 by 100. i tried:

float a= m_dialog.m_length;
float b= m_dialog.m_breath;

glBegin(GL_POLYGON);
glColor3ub(0,40,230);
glVertex2f(0.0f, 0.0f);
glColor3ub(0,40,230);
glVertex2f(0.0f, b);
glColor3ub(0,40,230);
glVertex2f(a, 0.0f);
glColor3ub(0,40,230);
glVertex2f(a, b);

glEnd();

but it din work, is there a way to get around this?

2. ## Re: how to incorporate user input numbers into vertex position?

What do you mean by did not work?
It did not draw as expected or not draw at all?

Also could this also be related to your screen refresh problem after a dialog box.

Originally posted by coda:
my vertex position depends on user dimension input. suppose to draw a rect, user specify 200 by 100. i tried:

float a= m_dialog.m_length;
float b= m_dialog.m_breath;

glBegin(GL_POLYGON);
glColor3ub(0,40,230);
glVertex2f(0.0f, 0.0f);
glColor3ub(0,40,230);
glVertex2f(0.0f, b);
glColor3ub(0,40,230);
glVertex2f(a, 0.0f);
glColor3ub(0,40,230);
glVertex2f(a, b);

glEnd();

but it din work, is there a way to get around this?

[This message has been edited by nexusone (edited 10-07-2003).]

3. ## Re: how to incorporate user input numbers into vertex position?

It appears your polygon is overlapping on itself.

| \/ |
| /\ |
|/ \|

___ <---What I think you think
| | your polygon should look like
| |
| |
|___|

glBegin(GL_POLYGON);
glColor3ub(0,40,230);
glVertex2f(0.0f, 0.0f);
glColor3ub(0,40,230);
glVertex2f(0.0f, b);
glColor3ub(0,40,230);
glVertex2f(a, b); <----
glColor3ub(0,40,230);
glVertex2f(a, 0.0f); <----
glEnd();

4. ## Re: how to incorporate user input numbers into vertex position?

it din work as in i get assertion error when tried to run, so that means opengl can take in (a,c,b) vertex coordinates which usually are predefined by programmer rite?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•