PDA

View Full Version : how to incorporate user input numbers into vertex position?



coda
10-07-2003, 05:07 AM
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?

nexusone
10-07-2003, 05:36 AM
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).]

10-07-2003, 05:49 AM
It appears your polygon is overlapping on itself.

|\ /| <---Your polygon
| \/ |
| /\ |
|/ \|

___ <---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();

coda
10-08-2003, 02:01 AM
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?