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?