m_elias's picture

Suggestions for a OpenTK rookie (line stipple)

I've just started playing around with OpenTK, I have no previous OpenGL or DirectX type programming experience. I have been reading through OpenGL Superbible, Fourth Edition by Wright/Lipchak/Haemel and I would appreciate some pointers on how to convert the examples etc to OpenTK. At this point, specifically line stipple. I'm probably missing something obvious.

I am enabling it in my init routine.
GL.Enable(EnableCap.LineStipple);

Then in my rendering routine I am drawing a grid.

                GL.Begin(BeginMode.Lines);
                {
                    for (double i = -100.0; i < 101.0; i++)
                    {
                        GL.LineStipple(2, Convert.ToInt16("1111000011110000",2));
                        GL.Vertex3(i, -0.01, -100.0);
                        GL.Vertex3(i, -0.01, 100.0);
                        GL.LineStipple(1, Convert.ToInt16("1111111111111111", 2));
                        GL.Vertex3(-100, -0.01, i);
                        GL.Vertex3(100, -0.01, i);
                    }
 
                }
                GL.End();

It just shows up with solid lines, as if it's completely ignoring the stipple commands.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
flopoloco's picture

Here it is the code...

GL.Enable(EnableCap.LineStipple);
 
			for (double i = -100d; i <= 100d; i++)
			{
				GL.LineStipple(1, Convert.ToInt16("1111000011110000",2));
				GL.Begin(BeginMode.Lines);
				GL.Vertex3(i, -0.01, -100.0);
				GL.Vertex3(i, -0.01, 100.0);
				GL.End();
 
				GL.LineStipple(1, Convert.ToInt16("1010101001010101",2));				
				GL.Begin(BeginMode.LineStrip);
				GL.Vertex3(-100, -0.01, i);
				GL.Vertex3(100, -0.01, i);
				GL.End();
			}
 
			GL.End();

For more information
http://www.java-tips.org/other-api-tips/jogl/how-to-draw-lines-in-differ...

m_elias's picture

Ok, so commands such as GL.LineStipple have to be before/outside the GL.Begin/End blocks.

Thanks.