M
ich glaube is ist das beste, wenn ich einfach mal den wichtigsten teil meines programmes kopiere. das ganze findet in der prozedur des win32- programmes statt. den timer1 verwende ich zum zeichnen der kurve, den timer2 zum verdunkeln des bildes.
case WM_TIMER:
hDC = GetDC(hWnd);
wglMakeCurrent(hDC,hRC);
glLoadIdentity();
if ((long)wParam == ID_TIMER1)
{
KillTimer(hWnd,ID_TIMER1);
div = ((float)bufLen)/(tb*1000.0);
td = GetTickCount()-startTime;
num = (long)((float)td*div);
if (num < 64)
{
glDrawGrid();
glBegin (GL_LINE_STRIP);
glColor4f (0.0f, 0.0f,1.0f,1.0f);
for (cnt = last; cnt <= num; cnt ++)
{
x = ((float)cnt/((float)(bufLen-1)))*2.0-1.0;
y = buffer[cnt];
if (x > 1.0f){x = 1.0f;}
if (x < -1.0f){x = -1.0f;}
if (y > 1.0f){y = 1.0f;}
if (y < -1.0f){y = -1.0f;}
glVertex2f (x,y);
}
last = num;
glEnd ();
}
else
{
glDrawGrid();
glBegin (GL_LINE_STRIP);
glColor4f (0.0f, 0.0f,1.0f,1.0f);
for (cnt = last; cnt < bufLen; cnt ++)
{
x = ((float)cnt/63.0)*2.0-1.0;
y = buffer[cnt];
if (x > 1.0f){x = 1.0f;}
if (x < -1.0f){x = -1.0f;}
if (y > 1.0f){y = 1.0f;}
if (y < -1.0f){y = -1.0f;}
glVertex2f (x,y);
}
last = 0;
glEnd ();
tb = timeBase*(float)divisions;
reTime = (long)(tb/((float)bufLen));
startTime = GetTickCount();
}
SetTimer(hWnd,ID_TIMER1,reTime,NULL);
}
if ((long)wParam == ID_TIMER2)
{
KillTimer(hWnd,ID_TIMER2);
glBegin(GL_QUADS);
glColor4f(0.0f,0.0f,0.0f,lightMult);
glVertex2f(-1.0f,-1.0f);
glVertex2f(1.0f,-1.0f);
glVertex2f(1.0f,1.0f);
glVertex2f(1.0f,-1.0f);
glEnd();
SetTimer(hWnd,ID_TIMER2,lightTime,NULL);
}
glFlush();
break;