0 Members and 1 Guest are viewing this topic.
// Dans la classe, on déclare les variables et la fonction plus tard on mettra toutes les variables dans une structure bool bDisplayStatus; int iDisplay; void Irridium::SwitchDisplay (bool Status, int Display);// Dans clbkSetClassCap on initialise les variables, plus tard, grâce aux structures, ça se fera en une ligne bDisplayStatus = 0; iDisplay = 0; [b]// Dans Mouse event, on teste quel bouton est tripoté et ou il est tripoté[/b] case AID_BOUTONTOPDISPLAY: if (my>22) SwitchDisplay(TRUE,1); else SwitchDisplay(FALSE,1); return true; case AID_BOUTONBOTTOMDISPLAY: if (my>22) SwitchDisplay(TRUE,2); else SwitchDisplay(FALSE,2); return true; // Dans Fonctions, on affiche les surfacesvoid Irridium::SwitchDisplay (bool Status,int Display){ bDisplayStatus = Status; iDisplay = Display; if (Display ==1) { oapiTriggerPanelRedrawArea (0, AID_TOPDISPLAY); oapiTriggerPanelRedrawArea (0, AID_BOUTONTOPDISPLAY); } else if (Display ==2) { oapiTriggerPanelRedrawArea (0, AID_BOTTOMDISPLAY); oapiTriggerPanelRedrawArea (0, AID_BOUTONBOTTOMDISPLAY); } if (bDisplayStatus == 0) PlayVesselWave3(MyID,ON); else PlayVesselWave3(MyID,OFF);}// Dans Redraw event, on fabrique les surfaces à afficher case AID_BOUTONTOPDISPLAY: if (bDisplayStatus == 1 && iDisplay ==1) { oapiBlt (surf, srf[1], 0, 0, 301, 241, 30, 44); // bouton 1 ON sur la bitmap } else if (iDisplay == 1) { oapiBlt (surf, srf[1], 0, 0, 331, 241, 30, 44); // bouton 1 OFF sur la bitmap } return true; case AID_TOPDISPLAY: if (bDisplayStatus == 1 && iDisplay ==1) { oapiBlt (surf, srf[1], 0, 0, 1, 1, 100, 100); // Display 1 allume sur la bitmap } else if (iDisplay == 1) { oapiBlt (surf, srf[1], 0, 0, 101, 101, 100, 100); // Display 1 eteint sur la bitmap } return true; case AID_BOUTONBOTTOMDISPLAY: if (bDisplayStatus == 1 && iDisplay ==2) { oapiBlt (surf, srf[1], 0, 0, 301, 241, 30, 44); // bouton 2 ON sur la bitmap } else if (iDisplay == 2) { oapiBlt (surf, srf[1], 0, 0, 331, 241, 30, 44); // bouton 2 OFF sur la bitmap } return true; case AID_BOTTOMDISPLAY: if (bDisplayStatus == 1 && iDisplay ==2) { oapiBlt (surf, srf[1], 0, 0, 1, 1, 100, 100); // Display 2 allume sur la bitmap } else if (iDisplay == 2) { oapiBlt (surf, srf[1], 0, 0, 101, 101, 100, 100); // Display 2 eteint sur la bitmap } return true;
picto a écrit:ZE QUESTION de débutant Y'avait il moyen de faire plus simple, plus efficace, plus mieux quoi ?Genre, du code beau à pleurer parce qu'il est simple et efficace ...
Suite à ton PM je comprend pas pour les sons "qui joue trop vite"
no matter a écrit:Il me semble avoir lu dans le header orbitersoundSDK qu'orbitersound joue en 22050 par défaut (je ne sais plus trop si c'est générique ou uniquement avec les PlayVesselWave3 ).Bref, avec un son en 11025, si il est joué en 22050, il sera forcément accéléré.
Non, c'est le buffer principal qui est jouée a 22050 mais chaque wav est joué a sa vitesse nativesi on ne touche pas au parametre "frequency" (frequency=NULL)
no matter a écrit:J'utilise par ailleurs plein d'autre fréquences (16000Hz, 8000Hz) mais il n'y a que ce wav là qui pose problème.J'essaierai de voir si c'est valable avec d'autre sons 11025hz 8bit mono.
// --------------------// Dans la classe// --------------------const int nsurf = 4; SURFHANDLE srf[nsurf];// --------------------// Dans Panel.cpp// --------------------// --------------------------------------------------------------// Constructeur// --------------------------------------------------------------Irridium::Irridium (OBJHANDLE hObj, int fmodel): VESSEL2 (hObj, fmodel){ int i; for (i = 0; i < nsurf; i++) srf[i] = 0; DefineAnimations ();}// --------------------------------------------------------------// Destructeur// --------------------------------------------------------------Irridium::~Irridium (){ ReleaseSurfaces();}// --------------------------------------------------------------// Release bitmaps used for panel animations// --------------------------------------------------------------void Irridium::ReleaseSurfaces (){ for (int i = 0; i < nsurf; i++) if (srf[i]) { oapiDestroySurface (srf[i]); srf[i] = 0; }}// --------------------------------------------------------------// Load panel animation bitmaps and initialise panel state// --------------------------------------------------------------void Irridium::InitPanel (int panel){ srf[0] = oapiCreateSurface (LOADBMP (IDB_SLIDER1)); srf[1] = oapiCreateSurface (LOADBMP (IDB_BITMAP1)); srf[2] = oapiCreateSurface (LOADBMP (IDB_BITMAP2)); srf[3] = oapiCreateSurface (LOADBMP (IDB_HORIZON)); oapiSetSurfaceColourKey (srf[3], 0);}// --------------------------------// Load 2-D instrument panel mode // --------------------------------bool Irridium::clbkLoadPanel (int id){ ReleaseSurfaces(); HBITMAP hBmp = LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (IDB_PANEL1-id)); Etc... etc ...
bool Irridium::clbkLoadPanel (int id){ ReleaseSurfaces(); HBITMAP hBmp = LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (IDB_PANEL1-id)); Etc... etc ... [glow=yellow,2,300]//C'est justement la que ca m'interessais[/glow] :rant:[glow=yellow,2,300] t'a mis tout a la fin ici [/glow]"InitPanel();" ?
bool Irridium::clbkLoadPanel (int id){ ReleaseSurfaces(); HBITMAP hBmp = LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (IDB_PANEL1-id)); MFDSPEC mfds_left = {{232, 59, 521, 349}, 6, 6, 30, 45}; MFDSPEC mfds_right = {{760, 59, 1049, 349}, 6, 6, 30, 45}; switch (id) { case 0: // main panel oapiRegisterPanelBackground (hBmp,PANEL_ATTACH_BOTTOM|PANEL_MOVEOUT_BOTTOM,0xffffff); oapiSetPanelNeighbours (-1,-1,-1,1); SetCameraDefaultDirection (_V(0,0,1)); break; case 1: // Bottom Panel oapiRegisterPanelBackground (hBmp, PANEL_ATTACH_TOP|PANEL_MOVEOUT_TOP, 0xffffff); oapiSetPanelNeighbours (-1,-1,0,-1); break; } InitPanel (id); return hBmp != NULL;}
picto a écrit:Ah ben ... comme là ça ne cause plus surfs ... je me disais Oui, j'ai le initpanel et return hBmp != NULL; aussi
picto a écrit:Par exemple la fonction ReleaseSurfaces();Je comprend qu'elle serve en destructeur, pour effacer les handles de surfaces.Mais alors pourquoi est elle utilisée au début de initpanel ?
InitPanel (int panel){ switch (panel) { case 0: srf[0] = oapiCreateSurface (LOADBMP (IDB_SLIDER1)); srf[1] = oapiCreateSurface (LOADBMP (IDB_SWITCH1)); srf[2] = oapiCreateSurface (LOADBMP (IDB_BUTTON1)); break; case 1: srf[0] = oapiCreateSurface (LOADBMP (IDB_SWITCH2)); srf[1] = oapiCreateSurface (LOADBMP (IDB_SWITCH3)); srf[2] = oapiCreateSurface (LOADBMP (IDB_SWITCH4)); srf[3] = oapiCreateSurface (LOADBMP (IDB_INDICATOR1)); srf[4] = oapiCreateSurface (LOADBMP (IDB_INDICATOR2)); break; }}
case AID_BOUTONTOPDISPLAY: if (bDisplayStatus == 1 && iDisplay ==1) { oapiBlt (surf, srf[1], 0, 0, 301, 241, 30, 44); // bouton allume sur le bitmap } else if (iDisplay == 1) { oapiBlt (surf, srf[1], 0, 0, 331, 241, 30, 44); // bouton eteint sur le bitmap }
if (bDisplayStatus == 1 && iDisplay ==1) // faux vu que iDisplay!=1 else if (iDisplay == 1) // faux aussi pour la meme raison... donc.. fait rien pas de oapiBlt... surface remplie avec du bordel.
void Irridium::SwitchDisplay (bool Status,int Display){ bDisplayStatus = Status; iDisplay = Display; ca sert probablement a rien ca if (Display ==1) { oapiTriggerPanelRedrawArea (0, AID_TOPDISPLAY); oapiTriggerPanelRedrawArea (0, AID_BOUTONTOPDISPLAY); } else if (Display ==2) { oapiTriggerPanelRedrawArea (0, AID_BOTTOMDISPLAY); // id du bottom n'est pas zéro oapiTriggerPanelRedrawArea (0, AID_BOUTONBOTTOMDISPLAY); }}
void Irridium::SwitchDisplay (bool Status){ bDisplayStatus = Status; oapiTriggerPanelRedrawArea (0, AID_TOPDISPLAY); oapiTriggerPanelRedrawArea (0, AID_BOUTONTOPDISPLAY); oapiTriggerPanelRedrawArea (1, AID_BOTTOMDISPLAY); oapiTriggerPanelRedrawArea (1, AID_BOUTONBOTTOMDISPLAY);}
case AID_BOUTONTOPDISPLAY: if (bDisplayStatus == 1) { oapiBlt (surf, srf[1], 0, 0, 301, 241, 30, 44); // bouton allume sur le bitmap } else { oapiBlt (surf, srf[1], 0, 0, 331, 241, 30, 44); // bouton eteint sur le bitmap }