Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:46:46+00:00 2026-06-14T11:46:46+00:00

I drawn 2 shapes with Bezier curve algorithm with using GL_LINE_STRIP. My shape likes

  • 0

I drawn 2 shapes with Bezier curve algorithm with using GL_LINE_STRIP.
My shape likes moon and i want to coloring the space of between two curves.
I used GL_POLYGON but it didn’t produce the result that i want.

This is my Code:

float Points[4][3] = {
{275,356,0},
{ 395,353,0 },
{  435,325,0 },
{ 476,232,0 }
                     };
float SecendPoints[4][3] = {
{ 476,232,0},
{441,331,0},
{369,372,0},
{283,388,0}
                     };
void init()
    {
  glClearColor(0.0,0.0,0.0,0.0);
  glMatrixMode(GL_PROJECTION);
  gluOrtho2D(0.0,640,0.0,480.0);

    }
void Display(void)
    {
  int segment = 20;

   // clear the screen & depth buffer
   glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);

   glColor3f(1,1,1);


  glColor3f(1,0,1);

  // we will draw lots of little lines to make our curve

  glBegin(GL_LINE_STRIP);

for(int i=0;i!=segment;++i) {

    // use the parametric time value 0 to 1
    float t = (float)i/(segment-1);

    // nice to pre-calculate 1.0f-t because we will need it frequently
    float it = 1.0f-t;

    // calculate blending functions
    float b0 = t*t*t;
    float b1 = 3*t*t*it;
    float b2 = 3*t*it*it;
    float b3 =  it*it*it;

    // calculate the x,y and z of the curve point by summing
    // the Control vertices weighted by their respective blending
    // functions
    //
    float x = b0*Points[0][0] +
              b1*Points[1][0] +
              b2*Points[2][0] +
              b3*Points[3][0] ;

    float y = b0*Points[0][1] +
              b1*Points[1][1] +
              b2*Points[2][1] +
              b3*Points[3][1] ;

    float z = b0*Points[0][2] +
              b1*Points[1][2] +
              b2*Points[2][2] +
              b3*Points[3][2] ;

    // specify the point
    glVertex3f( x,y,z );
}


for(int i=0;i!=segment;++i) {

    // use the parametric time value 0 to 1
    float t = (float)i/(segment-1);

    // nice to pre-calculate 1.0f-t because we will need it frequently
    float it = 1.0f-t;

    // calculate blending functions
    float b0 = t*t*t;
    float b1 = 3*t*t*it;
    float b2 = 3*t*it*it;
    float b3 =  it*it*it;

    // calculate the x,y and z of the curve point by summing
    // the Control vertices weighted by their respective blending
    // functions
    //
    float x = b0*SecendPoints[0][0] +
              b1*SecendPoints[1][0] +
              b2*SecendPoints[2][0] +
              b3*SecendPoints[3][0] ;

    float y = b0*SecendPoints[0][1] +
              b1*SecendPoints[1][1] +
              b2*SecendPoints[2][1] +
              b3*SecendPoints[3][1] ;

    float z = b0*SecendPoints[0][2] +
              b1*SecendPoints[1][2] +
              b2*SecendPoints[2][2] +
              b3*SecendPoints[3][2] ;

    // specify the point
    glVertex3f( x,y,z );
}
glVertex3f( 476,232,0 );
glEnd();
glFlush();
}

Any Idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:46:48+00:00Added an answer on June 14, 2026 at 11:46 am

    GL_POLYGON only works correctly for convex polygons.

    Tessellate the area between your curves into triangles and render those.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a custom JLayeredPane. I have several Shapes which needed to be drawn
I'm writing an application that draws certain shapes. Before each shape is drawn, some
How can I render a bunch of hand drawn shapes in opengl 1.x? I
I'd like to draw shapes which are intersections of circles using RaphaëlJS . Is
I am working with canvas in android. i want to draw shapes on canvas
I'm using Silverlight to draw some shapes and text on top of an image.
I'm making a program in which many weird shapes are drawn onto a canvas.
I am trying to simply draw a triangle in a window. I've drawn shapes
I have created different shapes like circle/rect etc in my program using BufferedPaintDC on
I'm trying to draw curved lines in Java. A simple bezier curve with an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.