Jump to content

new Primitive type in Canvas has dispose problem


MasterK
 Share

Recommended Posts

I develop a new Primitive type MY_PRIM base on RenderablePrim2D. And it almost same as Sprite2D

It works right.

But in this case:

create two screenCanvas, add MY_PRIM to each one.

delete one screenCanvas,  there will be webgl errors. And other screenCanvas's MY_PRIM object is not display. 

WebGL: INVALID_OPERATION: uniform1i: location not for current program
babylon.engine.js:1010 WebGL: INVALID_OPERATION: drawElementsInstancedANGLE: no valid shader program in use

 

And if use Sprite2D instead of MY_PRIM, there will be no error and display ok.

@Nockawa What should i take care of  to develop a new Primitive type???

Link to comment
Share on other sites

http://babylonjs-playground.com/#E5BQM#9

 

I create in playground, but dont reproduce the error... And in another computer, there will be same error by chance...

 

And I try to directly modify babylon.sprite2d.js in my local environment. And the error appears!!!! And I try to get back the original js file, The error didn't disappear!!!!! So confused... Because before i change the file, there's no error with babylon.sprite2d.js

I think it's a bit hard for you to understand... Just look at the PG and check my primtive class ... I dont think the code has problem. 

The sprite's texture must be the root of the problem. as it used by effect.

 

 

Link to comment
Share on other sites

I track the code. And find when worldSpaceCanvas's sprite2d dispose, the sprite2d effect and effectInstance was release,

So another ScreenCanvas's sprite2d's same effect is diabled.

Is that OK? I'm not sure, just ask.

================================================

@Nockawai see you fixed... I'll update.

Link to comment
Share on other sites

3 hours ago, MasterK said:

I track the code. And find when worldSpaceCanvas's sprite2d dispose, the sprite2d effect and effectInstance was release,

So another ScreenCanvas's sprite2d's same effect is diabled.

Is that OK? I'm not sure, just ask.

================================================

@Nockawai see you fixed... I'll update.

Yep, I've fixed it, I didn't knew how Effect instance were managed internally, after talking with DK the best thing to do was not releasing the Effect, it's useless.

Link to comment
Share on other sites

11 hours ago, Nockawa said:

Yep, I've fixed it, I didn't knew how Effect instance were managed internally, after talking with DK the best thing to do was not releasing the Effect, it's useless.

Dispose problem is solved.

Still sprite2d not display problem... 

Sometime Sprite2DRenderCache.render is not called...And no display...

Link to comment
Share on other sites

when render sprite2d:

in Group2D.prototype._groupRender :

this._renderableData._renderGroupInstancesInfo.forEach(function (k, v) {
                    // Prepare the context object, update the WebGL Instanced Array buffer if needed
                    var renderCount = _this._prepareContext(engine, context_1, v);

in Group2D.prototype._prepareContext

renderCount += array.usedElementCount;  (when usedElementCount = 0 not display (very much time happens), when usedElementCount = 1 , it display)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...