| 
     
      
      
      From: Rapthor <ra...@ly...> - 2007-01-06 19:47:43
      
     
   | 
Hello,
I'm frustrated ... I am using CsGL with Visual Studio Express C# and it =
renders poorly. The performance on a 2 GHz system is not worth it. Am I =
doing something wrong? I am rendering some very simple terrain with few =
polygons. A similar example runs at more than 30 fps in JAVA with JOGL.
Here is the C# code for my glDraw()-method:
public override void glDraw()
{
    processKeys();
    calcCamera();
    nowTime =3D Environment.TickCount;
    totalTime =3D nowTime - lastTime;
    lastTime =3D nowTime;
    if (totalTime =3D=3D 0)
        fps =3D 25;
    else
        fps =3D (float) Math.Round(1.0f / ((float)totalTime/1000f), 0, =
MidpointRounding.AwayFromZero);
    GL.glLoadIdentity(); // Reset The Current Modelview Matrix=20
    GL.gluLookAt(camPosition[0], camPosition[1], camPosition[2],
    camPosition[0] + camDirection[0], camPosition[1] + camDirection[1], =
camPosition[2] + camDirection[2],
    camUpVector[0], camUpVector[1], camUpVector[2]);
    GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // =
Clear The Screen And The Depth Buffer
    GL.glEnable(GL.GL_NORMALIZE);
    GL.glBegin(GL.GL_TRIANGLES);
    // length of the array is about 9000
    for (int i =3D 0; i < indexArray.Length; i++)
    {
        GL.glNormal3f(normals[i / 3].X, normals[i / 3].Y, normals[i / =
3].Z);
        GL.glVertex3f(pointArray[indexArray[i]].X,    =
pointArray[indexArray[i]].Y,    pointArray[indexArray[i]].Z);
    }
    GL.glEnd();
    GL.glFlush();
    this.SwapBuffer(); // swap Buffers
}
I'm using static methods from GL all the time. I hope it's ok to do so.
Can anybody please help me? Have you some experience how to speed up =
applications in C#?
I am using a BackgroundWorkerThread to render continously:
 ...
bgw =3D new BackgroundWorker();
this.bgw.RunWorkerCompleted +=3D new =
System.ComponentModel.RunWorkerCompletedEventHandler(this.bgw_RunWorkerCo=
mpleted);
this.bgw.RunWorkerAsync();
 ....
private void bgw_RunWorkerCompleted(object sender, =
RunWorkerCompletedEventArgs e)
{
    while (!this.Disposing)
    {
        view.Refresh();
        //view.glDraw();
        Application.DoEvents();
    }
}
 |