dwmkerr / sharpgl

Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
MIT License
759 stars 299 forks source link

Nothing being rendered at all #212

Open burdoto opened 2 years ago

burdoto commented 2 years ago

Hello, I'm already sure I'm doing something stupidly wrong, but this is extremely frustrating since I cannot locate the issue.

Basically I'm trying to draw ANYTHING using this Draw() method:

public const float lim = 1000;
private void Draw(object sender, OpenGLRoutedEventArgs args)
        {
            var gl = args.OpenGL;

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.LoadIdentity();
            gl.LineWidth(10.0f);
            gl.PointSize(2.0f);

            gl.Color(1, 1, 1);

            // y axis
            gl.Begin(BeginMode.Lines);
            gl.Vertex(-lim, 0);
            gl.Vertex(lim, 0);
            gl.End();

            // x axis
            gl.Begin(BeginMode.Lines);
            gl.Vertex(0, -lim);
            gl.Vertex(0, lim);
            gl.End();

            for (int i = 0; i < 500; i++)
            {
                gl.Begin(BeginMode.TriangleFan);
                var Segments = 50;
                var radius = 1000;
                var Position = new Vector2(i, i);
                for (var a = 0; a < Segments; a++)
                {
                    float theta = 2f * MathF.PI * a / Segments;
                    float x = radius * MathF.Sin(theta);
                    float y = radius * MathF.Cos(theta);
                    gl.Vertex(Position.X + x, Position.Y + y);
                }
                gl.End();   
            }

            gl.Flush();
        }

But I'm only ever getting a black screen (with the FPS counter working fine). I've tried comparing my code to this sample, but I really cannot find the problem.

As you can see from the code, I have already made desperate, frustrated attempts to draw large cirlces ANYWHERE, with no success whatsoever. What am I missing?