Announcement

Collapse
No announcement yet.

The webgl program created with the Visual Studio plug-in cannot run..

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    The webgl program created with the Visual Studio plug-in cannot run..

    Made a first try... Click image for larger version  Name:	01.png Views:	1 Size:	5.3 KB ID:	5243
    Click image for larger version  Name:	02.png Views:	2 Size:	19.4 KB ID:	5244
    Click image for larger version  Name:	03.png Views:	1 Size:	8.5 KB ID:	5249
    Click image for larger version  Name:	04.png Views:	1 Size:	8.0 KB ID:	5246
    Click image for larger version  Name:	06.png Views:	1 Size:	10.2 KB ID:	5248

    Last edited by silverys; 2018-02-23 @ 04:49 AM.

    #2
    Thank you for the report. We will have to investigate why this is failing.

    Until we fix, can you work-around this issue by just declaring a var? The following Deck demonstrates:

    https://deck.net/b5d799200d0288a99e405bf460351ac9

    using Bridge;
    using Bridge.WebGL;
    using Bridge.Html5;
    using System;
    
    public class Program
    {
        public static void Main()
        {
            HTMLCanvasElement canvas = Document.CreateElement<HTMLCanvasElement>("canvas");
            canvas.Width = 800;
            canvas.Height = 600;
            Document.Body.AppendChild(canvas);
    
            var gl = canvas.GetContext(CanvasTypes.CanvasContextWebGLType.WebGL);
    
            if (gl == null || gl == Script.Undefined)
            {
                Console.WriteLine("failed");
            }
            else
            {
                Console.WriteLine("Success");
            }
        }
    }
    For our future reference, here's your failing case in Deck:

    https://deck.net/0d3aa18f636c9e26d06ef14bead50186

    using Bridge;
    using Bridge.WebGL;
    using Bridge.Html5;
    using System;
    
    public class Program
    {
        public static void Main()
        {
            HTMLCanvasElement canvas = Document.CreateElement<HTMLCanvasElement>("canvas");
            canvas.Width = 800;
            canvas.Height = 600;
            Document.Body.AppendChild(canvas);
    
            WebGLRenderingContext gl = canvas.GetContext(CanvasTypes.CanvasContextWebGLType.WebGL) as WebGLRenderingContext;
    
            if (gl == null || gl == Script.Undefined)
            {
                Console.WriteLine("failed");
            }
            else
            {
                Console.WriteLine("Success");
            }
        }
    }

    Comment


      #3
      I would recommend using Retyped instead of Bridge.WebGL.

      https://deck.net/e0aa9783ea3684dbc6610acbe3822cd4

      using Bridge;
      using static Retyped.dom;
      
      public class Program
      {
          public static void Main()
          {
              var canvas = new HTMLCanvasElement();
              canvas.width = 800;
              canvas.height = 600;
              document.body.appendChild(canvas);
      
              // string id
              var gl = canvas.getContext("webgl");
      
              // or, string literal
              // var gl = canvas.getContext(Literals.Options.contextId.webgl);
      
              if (gl == null || gl == Script.Undefined)
              {
                  System.Console.WriteLine("failed");
              }
              else
              {
                  System.Console.WriteLine("Success");
              }
          }
      }
      Hope this helps.

      Comment


        #4
        The Bridge.WebGL library will be archived and will not be supported after the Bridge 17.0 release, so we would recommend moving to Retyped.

        Comment

        Working...
        X