Sharing context fails

Software: Away3D 4.x

andreahmed, Member
Posted: 21 October 2013 01:24 PM   Total Posts: 62

Hi all,

I’m trying to share the context with starling. The view works fine, but when I write those two lines:

  m_view.stage3DProxy = stage3DProxy;
  m_view.shareContext = true;

The view disappears.

Here is my init code:

public  function addView(ev:Event=null):void
  { 
   removeEventListener
(Event.ADDED_TO_STAGEaddView);
   
   if (!
isStage3DAndContextAvailable())return; }
   
//m_camera.lens.far = 50000;
    
    
stage3DManager Stage3DManager.getInstancestage);
   
   
// Create a new Stage3D proxy to contain the separate views
   
stage3DProxy stage3DManager.getFreeStage3DProxy();
   
stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATEDinit);
   
stage3DProxy.antiAlias 3;
   
stage3DProxy.color 0x0000FF
   
   
  


public function init(event Stage3DEvent):void
  {
    
   m_view 
= new View3D();
     
    
setCamera(-4.98, -0.20, -3829);
  
     
m_view.width =  640;
     
m_view.height 480;
    
m_view.antiAlias 3;
   
m_view.backgroundColor0x333333;
   
// Debug background
   //   graphics.beginFill(0xCCCCCC, 0.2);
   //   graphics.drawRect(0, 0, viewportWidth, viewportHeight);
   //   graphics.endFill();
   
   
addChild(m_view);
   

John Brookes, Moderator
Posted: 21 October 2013 03:12 PM   Total Posts: 732   [ # 1 ]

You need to set the views stage3Dproxy

view.stage3DProxy = stage3DProxy;

//Also may need
view.shareContext = true;

Have a look at the tutorial on the site.

   

andreahmed, Member
Posted: 21 October 2013 03:16 PM   Total Posts: 62   [ # 2 ]

Sorry I forgot to add those two lines, but they are there.

The problem is when commenting those two lines that you mentioned, the view works, and I get the 3D contents rendered.

But when I leave them un-commented,  the view disappears, and the 3D contents get lost.

   

John Brookes, Moderator
Posted: 21 October 2013 03:20 PM   Total Posts: 732   [ # 3 ]

And your enterframe listener is ?

stage3DProxy.addEventListener(Event.ENTER_FRAME, handleEnterFrame);

Otherwise you will need to call context present and clear in the render loop.
Again see tutorial wink

   

andreahmed, Member
Posted: 21 October 2013 03:22 PM   Total Posts: 62   [ # 4 ]

yes, its stage3DProxy.addEventListener(Event.ENTER_FRAME, handleEnterFrame);

I followed the tutorial and I have a sample prototype is working.

but when I deploy it in my large application, the above problems occur :(

   

andreahmed, Member
Posted: 21 October 2013 03:28 PM   Total Posts: 62   [ # 5 ]

I feel that there is a problem with that line:
stage3DManager = Stage3DManager.getInstance(m_content.stage);

In my prototype, everything works. but when I deploy it to a large game as I said, the view totally disappears.  Would someone tell me what is the use of that function really ? how to add the stage parameter here ?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X