0
我嘗試使用集成的OpenGL可視化創建WPF應用程序。我發現the sample project SharpGL它幫助我將opengl代碼集成到我的wpf程序中。在WPF應用程序中渲染OpenGL
現在我只想繪製,其具有以下屬性的矩形:
40 x coordinates = columns
48 y coordinates = rows
每個(X,Y)座標具有我在List<float>
已定義的值。 List<float>
是動態的,所以它會一直改變。 目標也是在繪製的矩形中實時顯示值。
Like:
y-coord
x coord 0 2 0 3 7 0 1 ..40
4 5 3 0 6 0 5 ..40
. .
. .
48 48
不幸的是,當我嘗試繪製矩形時,我已經失敗。
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;
}
我的代碼只顯示一個黑色的窗口。
我怎麼能意識到這一點?