Results 1 to 7 of 7

Thread: filling a 2d object in openGL

  1. #1
    Senior Member
    Join Date
    May 2005
    Posts
    434
    Thanks
    0
    Thanked
    0 times in 0 posts

    filling a 2d object in openGL

    hi how do i fill in a 2d object made by bezier curves into a specific colour, tried the glLineWidth but i get jerky edges around it(see pic below) how do i get rid of these jerky lines or is their a much simplier way to to this? my teacher adviced us to fill the object with colour by just drawing loads of bezier curves that goes inside the object. the pic below will explain more



    the code fo the beziee cuves is below

    ////////the pond//////////////////////////////////////////////////

    void DrawBezier(float firstx1,float firsty1,float lastx2,float lasty2,float conx1, float cony1,float conx2,float cony2)
    {
    Ax =lastx2 -firstx1-3*conx2+3*conx1;
    Bx = 3*firstx1 -6*conx1 +3*conx2;
    Cx=-3*firstx1+3*conx1;
    Dx=firstx1;
    Ay =lasty2 -firsty1-3*cony2+3*cony1;
    By = 3*firsty1 -6*cony1 +3*cony2;
    Cy=-3*firsty1+3*cony1;
    Dy=firsty1;
    // now draw the curve
    for (t=0.0;t<=1.0 ; t=t+0.05)
    {
    x1=Ax*t*t*t +Bx*t*t + Cx*t + Dx;
    k =Ay*t*t*t +By*t*t + Cy*t + Dy;
    p=t+0.05;
    x2=Ax*p*p*p +Bx*p*p + Cx*p + Dx;
    y2=Ay*p*p*p +By*p*p + Cy*p + Dy;
    glLineWidth(7.0);
    glBegin(GL_LINES);
    glColor3f(0.0,0.0,0.5);
    glVertex2f(x1,k);
    glVertex2f(x2,y2);
    glEnd();
    }

    }

    //////////////////////////////////////////////////////////////////////////////////


    these are my co ordinates that goes on the display function

    DrawBezier(300.0,320.0,370.0,450.0,270.0,380.0,315.0,410.0);
    DrawBezier(370.0,450.0,480.0,400.0,440.0,485.0,490.0,478.0);
    DrawBezier(480.0,400.0,428.0,300.0,520.0,395.0,510.0,325.0);
    DrawBezier(428.0,300.0,300.0,320.0,380.0,300.0,330.0,310.0);



    DrawBezier(310.0,350.0,400.0,425.0,325.0,380.0,360.0,410.0);
    DrawBezier(400.0,425.0,455.0,393.0,430.0,445.0,460.0,430.0);
    DrawBezier(455.0,393.0,400.0,330.0,490.0,375.0,475.0,350.0);

  2. #2
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    o
    m
    g.

    Is that really your sig? Please tell me you've just posted a random picture and that's not your sig !

  3. #3
    Senior Member
    Join Date
    May 2005
    Posts
    434
    Thanks
    0
    Thanked
    0 times in 0 posts
    y u dont like it? its from guild wars

  4. #4
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Well for a start it's against the rules, and no, that sig to me seems utterly pointless

  5. #5
    Senior Member
    Join Date
    May 2005
    Posts
    434
    Thanks
    0
    Thanked
    0 times in 0 posts
    o whats wrong with my sig??? ok i will change it later, anywaz can u help me with my original problem plz?

  6. #6
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    I would rather have a PS 3 sig....lmao

  7. #7
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    Oh those trees...L systems right? It is a recursive algorithm you used?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Settle an argument - D3D or OpenGL
    By Steve in forum Graphics Cards
    Replies: 52
    Last Post: 14-10-2005, 09:59 PM
  2. Make a boring object sound exciting
    By Steve in forum General Discussion
    Replies: 3
    Last Post: 19-03-2005, 07:03 PM
  3. Ad-Aware Scan Results.
    By Dave_07 in forum Software
    Replies: 15
    Last Post: 04-08-2004, 06:14 AM
  4. OpenGL fix for softmodded 9800SE AIW
    By Sk!mD4Rk in forum Graphics Cards
    Replies: 3
    Last Post: 13-11-2003, 06:30 PM

Posting Permissions

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