Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

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

  1. #1
    Intern Contributor
    Join Date
    Aug 2003
    Location
    singapore
    Posts
    87

    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. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    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. #3
    Guest

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

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

  4. #4
    Intern Contributor
    Join Date
    Aug 2003
    Location
    singapore
    Posts
    87

    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
  •