Home > other >  C # use thread calls OpenGL drawing how should do
C # use thread calls OpenGL drawing how should do

Time:09-24

I want to implement a program, a data-driven data are ready, to OpenGL rendering, but found that OpenGL doesn't draw the success, also is the OpenGL cannot accept other threads, even my thread calls OpenGL cannot achieve, hope everybody gives guidance to the HTML code is as follows:
Private void the draw () {
GL. The Begin (BeginMode. LineStrip);
GL. Vertex2 (10, r.N ext (200));
GL. Vertex2 (30, r.N ext (200));
GL. Vertex2 (40, r.N ext (200));
GL. Vertex2 (50, r.N ext (200));
GL. End ()
GL. Flush ();
GlControl1. SwapBuffers ();
GlControl1. Invalidate ();
}

Private void button1_Click (object sender, EventArgs e) {
Thread t=new Thread (draw);
t.start();
}
The results, and can't draw images, please grant instruction how to achieve what I want?
Before the program I use GDI + implements a plot pattern:
Public void dispatchTask () {
While (true) {
Int [] datas=getData ();

The UI. The BeginInvoke (datas);//asynchronous UI rendering
FIO. The BeginInvoke (datas);//asynchronous output to a file
Thread.sleep(200);
}
}
The UI now want to switch to OpenGL implementation, but there is a problem, consult everybody

CodePudding user response:

Opengl drawing can only be carried out in the main thread, you can put the data processing, information processing etc. On the other thread
  • Related