1

I try to create an WPF Application with an integrated OpenGL visualization.

I found the sample project SharpGL it helped me to integrate the opengl code into my wpf program.

now I just want to draw a rectangle which has the following attributes:

40 x coordinates = columns
48 y coordinates = rows

Each (x,y) coordinate has a value which I have defined in an List<float>. The List<float> is dynamically, so it will change all the time. The goal is too show the values in real time in the drawed rectangle.

Like:
          y-coord
x coord   0  2  0  3  7  0  1  ..40
          4  5  3  0  6  0  5  ..40
          .  .
          .  .
          48 48

Unfortunately I fail already when I try to draw the rectangle.

 private void openGLControl_OpenGLDraw(object sender, OpenGLEventArgs args)
    {
        //  Get the OpenGL object.
        OpenGL gl = openGLControl.OpenGL;

        //  Clear the color and depth buffer.
        gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT);

        //  Load the identity matrix.
        //gl.LoadIdentity();
        gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Filled);
        gl.Color(0,0,0);
        //  Draw a coloured pyramid.
        gl.Begin(OpenGL.GL_QUADS);
        gl.Vertex(-1.0f, 1.0f);
        gl.Color(200,1,1);
        gl.Vertex(-1.0f, 0.0f);
        gl.Color(200, 1, 1);
        gl.Vertex(1.0f, 0.0f);
        gl.Color(200, 1, 1);
        gl.Vertex(1.0f, 1.0f);
        gl.Color(200, 1, 1);
        gl.End();

        //  Nudge the rotation.
        //rotation += 3.0f;
    }

My code shows just a black window.

How could I realize that?

1 Answer 1

2

Most likely you forgot to call gl.Flush() or gl.Finish() at the end of your openGLControl_OpenGLDraw() method. Until you call any of these methods (or gl.SwapBuffers() in case of double buffering) every drawing method you call will only be buffered but not executed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.