852 views
in GUI Development by

Hi,

my WebGL export from my project has a error i can not resolv:

WEBGL11130: INVALID_OPERATION: texSubImage2D: Daten müssen in einem typisierten Array übergeben werden

Datei: emwi_0_98.js, Zeile: 5088, Spalte: 5

The code witch makes problems:

// ---------------------------------------------------------------------------
  // The function GetGlyph() determines the glyph of the given font and ensures
  // that the glyph is available in the glyph cache surface. If successful, the
  // function returns an object containing the glyph metrics and the position
  // within the glyph cache surface where the glyph is available. If the glyph
  // is not available in the cache, the function reserves space in the cache and
  // loads there the glyph pixel data. In the case, the entire cache is occupied
  // and all glyphs are in use, the function fail and returns null. In such case
  // the preceding text operation need to be terminated before new glyphs can be
  // loaded.
  // ---------------------------------------------------------------------------
  emwi._GetGlyph = function( aFont, aCharCode )
  {
    // No valid font specified
    if ( !aFont )
    {
      if ( this._Debug )
        console.log( "EmWi error: Invalid font resource." );
      return null;
    }

    var glyph = aFont.Cache[ aCharCode ];
   
    // If the desired glyph remains in the font's private cache - use it! Move
    // the glyph to the beginning of the glyph list.
    if ( glyph )
    {
      UncacheGlyph( this, glyph );
      CacheGlyph( this, glyph );
      return glyph;
    }

    // The glyph is not available in the cache. Search the glyph information in
    // the font data.
    if (!( glyph = this._GetGlyphMetrics( aFont, aCharCode )))
      return null;
   
    // Get the glyph metrics and with these metrics calculate the size of the
    // area to alloc within the glyph cache surface.
    var cellSize  = this._GlyphSurfaceCellSize;
    var rows      = (( glyph.Height + cellSize - 1 ) / cellSize ) | 0;
    var cols      = (( glyph.Width  + cellSize - 1 ) / cellSize ) | 0;
    var pos       = null;
    var tail      = this._GlyphCacheTail;
    var discarded = null;

    // Find an empty unused area within the glyph surface. This can cause the
    // older glyphs to be discarded in order ti make space for the new glyph.
    do
    {
      // Search for an area with the desired number or cell rows and columns
      if (!( pos = discarded = FindFreeGlyphCacheArea( this, cols, rows )))
      {
        // No free area found. Search for the oldest unused glyph within the
        // cache
        while ( tail && tail.Usage )
          tail = tail.Newer;

        // Discard the found unused glyph and free its area
        if ( tail )
        {
          // Calculate the origin and the size of the area occupied by the glyph
          var glyph = tail;
          var row   = ( glyph.CacheY / cellSize ) | 0;
          var col   = ( glyph.CacheX / cellSize ) | 0;
          var rows  = (( glyph.Height + cellSize - 1 ) / cellSize ) | 0;
          var cols  = (( glyph.Width  + cellSize - 1 ) / cellSize ) | 0;

          // Track the operations
          if ( this._Debug )
            console.log( "EmWi info: DiscardGlyph( " + glyph.CharCode + ", " +
                         glyph.Width + ", " + glyph.Height + " )" );

          // The glyph being discarded and the next possible candidate to be
          // discarded
          discarded = glyph;
          tail      = tail.Newer;

          // Remove the glyph from the cache and release the area within the surface
          UncacheGlyph( this, glyph );
          ReleaseGlyphCacheArea( this, col, row, cols, rows );
        }
      }
    }
    while ( !pos && discarded );

    // No free area in the cache found. All existing glyphs are in use
    if ( !pos )
      return null;

    // The current glyph will be stored in the font's private cache now
    aFont.LastGotGlyph = null;

    var invSize = 1 / this._GlyphSurfaceSize;

    // Prepare the glyph descriptor. It contains the glyph metrics and the
    // position where the glyph pixel are stored in the surface.
    glyph.Cache   = aFont.Cache;
    glyph.CacheX  = pos[0] * cellSize;
    glyph.CacheY  = pos[1] * cellSize;
    glyph.CacheS1 = glyph.CacheX * invSize;
    glyph.CacheT1 = glyph.CacheY * invSize;
    glyph.CacheS2 = ( glyph.CacheX + glyph.Width  ) * invSize;
    glyph.CacheT2 = ( glyph.CacheY + glyph.Height ) * invSize;
    glyph.Usage   = 0;
   
    // Prepare a temp. buffer to receive the decomporessed glyph pixel
    var size  = glyph.Width * glyph.Height;
    var pixel = new Uint8Array( size );
    var gl    = this._Context;
   
    // Decompress the pixel data into the previously created buffer
    aFont.DecompressProc( aFont.Pixel, pixel, glyph.Pixel, glyph.NoOfBits );
    XOrRows( pixel, size, glyph.Width );

    // Transfer the pixel information into the glyph cache surface
    gl.bindTexture( gl.TEXTURE_2D, this._GlyphCacheTexture );
    gl.texSubImage2D( gl.TEXTURE_2D, 0, glyph.CacheX, glyph.CacheY, glyph.Width,
                      glyph.Height, gl.ALPHA, gl.UNSIGNED_BYTE, pixel );

 

I am using EmWi 8.20.

Thanks.

 

 

2 Answers

0 votes
by

Hello,

the error message is difficult to understand. The array is already declared with an explicitly specified type. Please see the row:

var pixel = new Uint8Array( size );

Since we run the code successfully on many different web-browser I suppose the cause of the problem may be associated to your particular web-browser version. Which browser are you using?

Best regards

Paul Banach

0 votes
by
Hi,

I use Chrome.

I made an update to EmWi 8.30 end the error its solved.

Thanks.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...