c# - SharpGL not rendering on Button Click -


i testing sharpgl sample on winform, rendering triangle on opengldraw event. when trying render button click not working. supposed not render outside of opengldraw event ? here codes:

private void drawscene() {     opengl gl = openglcontrol.opengl;     gl.clear(opengl.gl_color_buffer_bit | opengl.gl_depth_buffer_bit);     gl.loadidentity();     gl.begin(opengl.gl_triangles);     gl.color(1.0f, 0.0f, 0.0f);     gl.vertex(0.0f, 1.0f, 0.0f);     gl.color(0.0f, 1.0f, 0.0f);     gl.vertex(-1.0f, -1.0f, 1.0f);     gl.color(0.0f, 0.0f, 1.0f);     gl.vertex(1.0f, -1.0f, 1.0f);     gl.color(1.0f, 0.0f, 0.0f);     gl.vertex(0.0f, 1.0f, 0.0f);     gl.color(0.0f, 0.0f, 1.0f);     gl.vertex(1.0f, -1.0f, 1.0f);     gl.color(0.0f, 1.0f, 0.0f);     gl.vertex(1.0f, -1.0f, -1.0f);     gl.color(1.0f, 0.0f, 0.0f);     gl.vertex(0.0f, 1.0f, 0.0f);     gl.color(0.0f, 1.0f, 0.0f);     gl.vertex(1.0f, -1.0f, -1.0f);     gl.color(0.0f, 0.0f, 1.0f);     gl.vertex(-1.0f, -1.0f, -1.0f);     gl.color(1.0f, 0.0f, 0.0f);     gl.vertex(0.0f, 1.0f, 0.0f);     gl.color(0.0f, 0.0f, 1.0f);     gl.vertex(-1.0f, -1.0f, -1.0f);     gl.color(0.0f, 1.0f, 0.0f);     gl.vertex(-1.0f, -1.0f, 1.0f);     gl.end(); }  private void openglcontrol_opengldraw(object sender, rendereventargs e) {     //this.drawscene(); //working }  private void button1_click(object sender, eventargs e) {     this.drawscene(); //not working } 

just add openglcontrol.refresh(); after drawscene(). fooling me past few days. discovered after reading source code. :d

private void button1_click(object sender, eventargs e) {     this.drawscene(); //not working     openglcontrol.refresh();  } 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -