void MenuTexture::SetString( ) { // LOGI("Menu Texture set string: <%s> %dx%d stride %d bpp %d", menu_str, width, height, stride, bpp ); // LOGI("Menu Texture set string: <%s> len %d", menu_str, len ); CharMap * chars = CharMap::Instance(); int len = strlen( menu_str ); memset( texData, 0xff, stride * height ); int xoff = 0; for ( int k=0; k<len && xoff+WIDTH*bpp<=stride; ++k) { unsigned char * shape = chars->Shape( menu_str[k] ); for (unsigned char m = 0x80; m > 0; m>>=1) { unsigned char * off = texData + xoff; for ( int j=0; j<HEIGHT; ++j ) { if ( (m & shape[ j ]) == m ) { memset( off, 0, bpp ); off[bpp-1] = 0xff; } off += stride; } xoff += bpp; } xoff += 2 * bpp; } // InitTexture(); // do not initailize here: makes a black rectangle }
void StationTexture::AddStation( int k, const char * str ) { if ( k >= nStation ) return; int col = k % COLS; int row = k / COLS; int len = (length < strlen( str ))? length : strlen(str); float h = 1.0f / rows; float lw = len * (1.0f / (length * COLS)); float cw = col * (1.0f / COLS); int k20 = k*20; int k4 = k*4; int k6 = k*6; vertex[ k20 + 3 ] = cw; // (0) ---------- (1) k vertex[ k20 + 4 ] = (row+1) * h; // | | vertex[ k20 + 5 + 3 ] = cw + lw; // (2) ---------- (3) k+1 vertex[ k20 + 5 + 4 ] = (row+1) * h; vertex[ k20 +10 + 3 ] = cw; vertex[ k20 +10 + 4 ] = (row+0) * h; vertex[ k20 +15 + 3 ] = cw + lw; vertex[ k20 +15 + 4 ] = (row+0) * h; // geom coords are not initialized index[k6 + 0] = k4 + 0; index[k6 + 1] = k4 + 2; index[k6 + 2] = k4 + 1; index[k6 + 3] = k4 + 1; index[k6 + 4] = k4 + 2; index[k6 + 5] = k4 + 3; CharMap * chars = CharMap::Instance(); int xoff = name_stride * col; int yoff = table_stride * row * HEIGHT; for ( int k1=0; k1<len; ++k1) { unsigned char * shape = chars->Shape( str[k1] ); for (unsigned char m = 0x80; m > 0; m>>=1) { unsigned char * off = texData + yoff + xoff; for ( int j=0; j<HEIGHT; ++j ) { if ( (m & shape[ j ]) == m ) { memset( off, 0, bpp ); off[0] = 0xff; off[bpp-1] = 0xff; } off += table_stride; } xoff += bpp; } xoff += 2 * bpp; // two empty pixel after each char } }
void MenuTexture::UpdateString( int j ) { CharMap * chars = CharMap::Instance(); int xoff = j * 10 * bpp; unsigned char * shape = chars->Shape( menu_str[j] ); for (unsigned char m = 0x80; m > 0; m>>=1) { unsigned char * off = texData + xoff; for ( int j=0; j<HEIGHT; ++j ) { if ( (m & shape[ j ]) == m ) { memset( off, 0, bpp ); off[bpp-1] = 0xff; } off += stride; } xoff += bpp; } }