static void throttle_func(void *data) { if(!wxThread::IsMain() ) { OCPNStopWatch *sww = (OCPNStopWatch *)data; if(sww->Time() > 1) { sww->Start(); wxThread::Sleep(2); } } }
void Piano::DrawGL(int off) { OCPNStopWatch sw; int w = cc1->GetClientSize().x, h = GetHeight(); printf("t0: %f\n", sw.Time()); glBindTexture(GL_TEXTURE_2D, m_tex); ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); if(style->chartStatusWindowTransparent) { glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glColor4ub(255, 255, 255, 200); // perhaps we could allow the style to set this glEnable(GL_BLEND); } else glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); for(int i=0; i<30; i++) { glTexCoord2f(0, 0), glVertex2f(0, off); glTexCoord2f(m_texcoords[0], 0), glVertex2f(w, off); glTexCoord2f(m_texcoords[0], m_texcoords[1]), glVertex2f(w, off+h); glTexCoord2f(0, m_texcoords[1]), glVertex2f(0, off+h); } glEnd(); printf("t1: %f\n", sw.Time()); int iw = 9, ih = 13; if(!m_icontex) { glGenTextures( 1, &m_icontex ); glBindTexture(GL_TEXTURE_2D, m_icontex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); iw = m_pPolyIconBmp->GetWidth(); ih = m_pPolyIconBmp->GetHeight(); wxImage im = m_pPolyIconBmp->ConvertToImage(); unsigned char *data = new unsigned char[4*iw*ih], *d = data, *e = im.GetData(), *a = im.GetAlpha(); for(int i=0; i<iw*ih; i++) { memcpy(d, e, 3), d+=3, e+=3; *d = *a, d++, a++; } glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, iw, ih, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); delete [] data; } printf("t2: %f\n", sw.Time()); glBindTexture(GL_TEXTURE_2D, m_icontex); glEnable(GL_BLEND); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); printf("t3: %f\n", sw.Time()); glBegin(GL_QUADS); int nKeys = m_key_array.GetCount(); // draw the bitmaps for( int i = 0; i < nKeys; i++ ) { int key_db_index = m_key_array.Item( i ); if( -1 == key_db_index ) continue; wxRect box = KeyRect.Item( i ); float u1 = 0, u2 = 1, v = 1; int x1, y1; if(InArray(m_noshow_index_array, key_db_index)) x1 = box.x + 4, y1 = box.y + 3; else { x1 = box.x + box.width - iw - 4, y1 = box.y + 2; if(InArray(m_skew_index_array, key_db_index)) ; else if(InArray(m_tmerc_index_array, key_db_index)) ; else if(InArray(m_poly_index_array, key_db_index)) ; else continue; } y1 += off; int x2 = x1 + iw, y2 = y1 + ih; glTexCoord2f(u1, 0), glVertex2i(x1, y1); glTexCoord2f(u2, 0), glVertex2i(x2, y1); glTexCoord2f(u2, v), glVertex2i(x2, y2); glTexCoord2f(u1, v), glVertex2i(x1, y2); } glEnd(); printf("t4: %f\n", sw.Time()); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); }