StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
285 stars 88 forks source link

shader crashes #68

Closed AndreAhmed closed 10 years ago

AndreAhmed commented 10 years ago

Hi All,

I'm just writing a code like that //draw line var lineShape:Shape = new Shape(); lineShape.graphics.lineStyle(m_width,m_color); lineShape.graphics.moveTo(m_lineCoords[0].x,m_lineCoords[0].y); for(var i:uint = 1; i < m_lineCoords.length ; i++) { lineShape.graphics.lineTo(m_lineCoords[i].x, m_lineCoords[i].y); }

I get a crash like that: on the line graphics.lineTo

TypeError: Error #1034: Type Coercion failed: cannot convert to starling.display.shaders.IShader. at starling.display.materials::StandardMaterial()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\materials\StandardMaterial.as:0] at starling.display.graphics::Graphic()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\graphics\Graphic.as:69] at starling.display.graphics::Stroke()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\graphics\Stroke.as:0] at starling.display::Graphics/createStroke()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\Graphics.as:518] at starling.display::Graphics/beginStroke()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\Graphics.as:534] at starling.display::Graphics/lineTo()[D:\perforce\prj\Libs\Flash\PrimaryFeather-Starling-Framework-1a50854\starling\src\starling\display\Graphics.as:400] at at.rabcat.wintoday.XSLOT.control.WinlineControl::StarlingSlotWinLine/CreateDisplay()[D:\ff\CashPotAway\Source\cashpot\framework\src\at\rabcat\wintoday\XSLOT\control\WinlineControl\StarlingSlotWinLine.as:182]

IonSwitz commented 10 years ago

Hello, Andre.

I will check on this ASAP

AndreAhmed commented 10 years ago

Thanks.

FYI, I just copied the src files of the starling_extension, and I added it to starling 1.5.

Amazing work, You saved me a lot of time!

IonSwitz commented 10 years ago

Thank you.

Anyway, I have tested the code above (which isn't using Materials at all, so I wonder what else you have going there :) )

The following runs without any problems:

                   var m_lineCoords:Vector.<Point> = new Vector.<Point>();
        m_lineCoords.push(new Point (100, 100));
        m_lineCoords.push(new Point (200, 100));
        m_lineCoords.push(new Point (200, 300));
        m_lineCoords.push(new Point (100, 300));
        m_lineCoords.push(new Point (100, 200));
            var lineShape:Shape = new Shape();
        lineShape.graphics.lineStyle(5,0xFFFFFF);
        lineShape.graphics.moveTo(m_lineCoords[0].x,m_lineCoords[0].y);

        for(var i:uint = 1; i < m_lineCoords.length ; i++)
        {
            lineShape.graphics.lineTo(m_lineCoords[i].x, m_lineCoords[i].y);
        }

        addChild(lineShape);

Do you have any materials connected to this shape anywhere?

Or could you check your project if you have any other Interfaces named "IShader"? or "IMaterial"? in a different namespace, or so? It looks like a type clash to me.

AndreAhmed commented 10 years ago

No, but I'm using away3d with starling, both are integrated and I'm using other 3D Models which have other materials.

This is really weird :/

IonSwitz commented 10 years ago

Away3D has an IShader interface and an IMaterial interface, so I would assume there is some interference in ways that are not fully clear to me, depending on how the integration of the two is set up.

If you set up the same Starling Graphics code in a Starling-only environment, do you get the same error? Leaving Away3D out of the equation?

Maybe try building one of the Starling Graphics sample projects?

AndreAhmed commented 10 years ago

Thanks for the away3d hint. I will do your suggestions and will give you the feedback asap.

AndreAhmed commented 10 years ago

I tested away3d + starling + your new extension in flashdevelop, and they worked fine without any conflicts.

In flashbuilder 4.7, the conflicts appear. Very weird problem.

AndreAhmed commented 10 years ago

I also testing starling+your extension in flashbuilder 4.7 it crashed with the same output. starling+your extension in flash develop works fine.

IonSwitz commented 10 years ago

I wish I could help here, but it seems that there is problems with source paths or something? I have no way to reproduce this problem, AndreAhmed, and I don't know what to do to help.

AndreAhmed commented 10 years ago

it seems that flash builder has a problem with going down from interfaces to child parents. I changed the code to public function StandardMaterial( vertexShader:AbstractShader = null , fragmentShader:AbstractShader = null )

Instead of providing the IShader Interface. and it worked.

IonSwitz commented 10 years ago

What if you write out the full namespace name:

public function StandardMaterial( vertexShader: starling.display.shaders.IShader = null, fragmentShader : starling.display.shaders.IShader = null);

Does that work?

AndreAhmed commented 10 years ago

Unfortunately, same conversion problem. This is really weird.

IonSwitz commented 10 years ago

I'm sorry that I can't help you with this. It seems to be a development environment problem, rather than a Starling Graphics Extension problem