1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| //ca c est ma fonction de rendu
void TestGLCanvas::Render()
{
wxPaintDC dc(this);
#ifndef __WXMOTIF__
if (!GetContext()) return;
#endif
SetCurrent();
if (!m_init)
{
InitGL();
m_init = true;
}
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
//ca c etai pour voir si les valeur changeai mais ici rien
wxString text;
text = _T("rotation 1 = ") + wxString::Format("%f",rotationCam[0]);
FramePrincipale->GetStatusBar()->SetStatusText(text,0);
text = _T("rotation 2 = ") + wxString::Format("%f",rotationCam[1]);
FramePrincipale->GetStatusBar()->SetStatusText(text,1);
//les transfo que j aimerai afficher en "temps reel"
glRotatef(rotationCam[1], 0,1,0);
glRotatef(rotationCam[0], 1,0,0);
glTranslatef(-0 , -0 , -100);
//ici normalement y a mes fonction d affichage (un peu long)
glPopMatrix();
glFlush();
SwapBuffers();
}
//et ca c es tma fonction mouvement qui enregistre le deplacement de la souris
inline void TestGLCanvas::OnMouseMove(wxMouseEvent& event)
{
//si on peut bouger la camera
//dans cette fonction, les parametres rotation change bien en "temps reel" ce qui n est pas le cas dans la fonction d affichage
if (m_bRotateCam)
{
rotationCam[0] = rotationCam[0]+(float)(m_nMouseY-event.GetY())*0.2;
rotationCam[1] = rotationCam[1]+(float)(m_nMouseX-event.GetX())*0.2;
m_nMouseX=event.GetX();
m_nMouseY=event.GetY();
}
} |
Partager