
Draw Quads with foreach
Posted Friday, 6 February, 2009 - 17:33 by Symkortem inHi!
I have a little problem.
I want to draw Quads with foreach, but every time i use foreach, the programm draws only one (the first) quad.
I have a List with many Point Object, which stores the X and Y coordinates.
void Application_Idle(object sender, EventArgs e) { glControl1.Invalidate(); } private void glControl1_Paint(object sender, PaintEventArgs e) { GL.ClearColor(Color.Green); GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); foreach(Point p in pointlist) { GL.Begin(BeginMode.Quads); GL.Color3(Color.White); GL.Vertex2(p.X, p.Y); GL.Vertex2(p.X+10, p.Y); GL.Vertex2(p.X+10, p.Y+10); GL.Vertex2(p.X, p.Y+10); GL.End(); } }
Whats my fault?
Best regards
Symi
Ps.: Sorry for my bad english.. :)


Comments
Re: Draw Quads with foreach
You need to make sure these quads lie within the view frustum (i.e. don't call
GL.Ortho(-1, 1, -1, 1, -1, 1)and expect a quad at (2, 2)-(3, 3) to be visible).Also, make
pointlistactually contains more than one Point (set a debugger breakpoint and check its contents).Other than these things, there's no reason why the above code wouldn't work.
Off-topic, but you can move the GL.Begin() - GL.End() pair outside the foreach, for a sizable speed increase.
PS: Your english is just fine ;)
Re: Draw Quads with foreach
I found it!
All points in the list were the same.
Thanks.