Jump to content
  • Advertisement
Sign in to follow this  
Bostown

Drawing graph with Polygon

This topic is 2559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I've been reading this forum for a while now, but made an account for my problem.
I couldn't find a similar problem...


I've been making a graph in C# - OpenGL. Graph #1 is the one it's supposed to look like.
But only the first part looks good, after that I get some weird parts where they go back to base.


We're using the TAO Framework


Gl.glColor4ub(255,255,0,48);
Gl.glBegin(Gl.GL_POLYGON);


lastPoint = new PointD(Start.X, Start.Y + height);
for (int i = 0; i < arr.Length; i++)
{
double thisValue = arr;
double valueHeight = height / currentHighestValue * thisValue;

thisPoint = new PointD(Start.X + i * xGain, Start.Y + height - valueHeight);

Gl.glVertex2d(lastPoint.X, lastPoint.Y);
Gl.glVertex2d(thisPoint.X, thisPoint.Y);
lastPoint = thisPoint;
}



I hope any of you knows how to fix this.

Regards,

Share this post


Link to post
Share on other sites
Advertisement
Don't use polygons. You are drawing "invalid polygons".

I'd use GL_QUADS instead.

[font="Courier New"]Gl.glVertex2d(lastPoint.X, 0);
Gl.glVertex2d(thisPoint.X, 0);
Gl.glVertex2d(thisPoint.X, thisPoint.Y);
Gl.glVertex2d(lastPoint.X, lastPoint.Y);
[/font]

Share this post


Link to post
Share on other sites

Don't use polygons. You are drawing "invalid polygons".

I'd use GL_QUADS instead.

[font="Courier New"]Gl.glVertex2d(lastPoint.X, 0);
Gl.glVertex2d(thisPoint.X, 0);
Gl.glVertex2d(thisPoint.X, thisPoint.Y);
Gl.glVertex2d(lastPoint.X, lastPoint.Y);
[/font]





Ok Thanx, It works now


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!