Featured post
c# - How can I rotate triangle (clock-wise ) with CSGL? -
i'm trying make clock-wise rotating triangle, can not. made timer control result same without timer. result, below code not show rotating triangle. how can rotate triangle csgl?
namespace windrawcoordinate { public partial class form1 : form { public form1() { initializecomponent(); } private float = 0.0f; private void form1_load(object sender, eventargs e) { timer1.start(); } protected void gosterim() { gl.glclear(gl.gl_color_buffer_bit); gl.glloadidentity(); hesapla(); ucgen(); } protected void ayarlar() { gl.glclearcolor(1, 1, 1, 1); gl.glshademodel(gl.gl_flat); } protected void hesapla() { += 0.5f; this.refresh(); } protected void ucgen() { gl.glcolor3f(0, 1, 1); gl.glrotatef(a, 0, 0, -1); gl.glbegin(gl.gl_triangles); gl.glvertex2f(-0.2f, -0.2f); gl.glvertex2f(0.2f, -0.2f); gl.glvertex2f(0.0f, 0.2f); gl.glend(); } private void timer1_tick(object sender, eventargs e) { ayarlar(); gosterim(); } }
from code posted see couple things:
you don't have matrix set-up. while can use default matrices should specify own ensure triangle expect. default matrices should work here specify identity modelview , projection.
you don't have call swap buffers. need call after you're done drawing swap front , buffers triangle displayed. csgl think there
swapbuffer()
method can use.don't use timer pump redrawing. timers work unreliably use windows message pump , hard results from. instead should use render loop--a loop runs entire time program runs , keeps refreshing screen. have make sure give operating system time handle messages though. simple render loop might be:
void renderloop() { while (true) { setupcamera(); creategeometry(); swapbuffers(); application.doevents(); // lets windows process messages } }
note there better ways message loop in c# easy set , reason about.
- Get link
- X
- Other Apps
Comments
Post a Comment