adityatan's picture

OpenTK lagging due to thousands of points

Hi there:

I just plotted a thousand points in OpenTK window. I also have created a first-person camera on that window. As I tried to maneuver, the window lagged so bad.

Do you think the lagging is possibly due to my code, or is it due to the capacity of OpenTK? (Things were fine when I only plotted hundreds of cubes.)

FYI, I'm trying to make a stress-strain-force-displacement visualization of a pile. So, if OpenTK cannot handle my coordinates, I might as well just switch to another platform.

THank you for your help.

Aditya


Comments

Comment viewing options

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

Here's the two pictures. The first one is my way, while the second picture is Fiddler's way.

Here's my code on OnRenderFrame:

        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.Translate(0, 0, -500);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.LoadMatrix(ref cameraMatrix);
            GL.Rotate(camera_rotation, 0, 1, 0); // Add the rotation
 
            //This is where I am going to plot the nodes.
            //And this is the code that I am going to use:
 
            GL.Begin(BeginMode.Points);
 
            foreach (var vertex in coordinates)
            {
                GL.Vertex3(vertex);
            }
 
            GL.End();
 
            GL.Begin(BeginMode.Lines);
 
            foreach (var c in connectingLines)
            {
                GL.Vertex3(c);
            }
 
            GL.End();
 
...

Side note: Have anyone ever wondered the purpose of the following lines? I'm not the one who wrote the following lines, by the way. You don't have to answer as this is not OpenTK problem. :)

                        a.Nodes.ElementAt(i).Coordinate[0] = Convert.ToDouble(fields[0]); // x coordinate
                        a.Nodes.ElementAt(i).Coordinate[1] = Convert.ToDouble(fields[1]); // y coordinate
                        a.Nodes.ElementAt(i).Coordinate[2] = Convert.ToDouble(fields[2]); // z coordinate

Wow many many thanks for the help.

Aditya

AttachmentSize
Pic2.jpg32.6 KB
Pic1.jpg51.36 KB
reibisch's picture

Unfortunately, there's nothing in the code you provided that might indicate why they're displaying different results. As far as OpenGL is concerned, they're functionally identical (though the Lines loop probably won't work as you intend). I'd take another look at your loading code to make sure you haven't missed something or that you aren't doing something different with your cameraMatrix Mat4.

What part of a.Nodes.ElementAt(i).Coordinate[0] = Convert.ToDouble(fields[0]); are you questioning the purpose of? It's not terribly attractive code, but I'm not sure that there's anything really weird about it.

adityatan's picture

I kinda get "a.Nodes.ElementAt(i).Coordinate[0] = Convert.ToDouble(fields[0]);" now. At first I have no idea as to what it returns. Now after my Prof. explained it in detail, I finally got it.

I also couldn't see what's wrong with the two methods that it yields two different results. Please let me know when you find something. Thank you.

Aditya