Hi,

void Simple::FinishFrame ()
{
  if (!tex)
  {
    iTextureManager *txtmgr = g3d->GetTextureManager ();
    if (!txtmgr)
      return;

    iGraphics2D* g2d = g3d->GetDriver2D ();
    tex = engine->CreateBlackTexture ("Untitled", g2d->GetWidth (), 
g2d->GetHeight (), 0,
        CS_TEXTURE_3D);
    tex->Register (txtmgr);
    printf ("Register in txtmgr\n");
    iTextureHandle *texh = tex->GetTextureHandle ();
    if (!texh)
      printf ("iTextureHandle is not here!!!\n");
    texh->SetTextureClass("nocompress");
  }

  g3d->SetRenderTarget (tex->GetTextureHandle ());

  if (!view.IsValid())
  {
    // @@@ Here to get the render target size, not screen size
    iSector *room = engine->GetSectors ()->FindByName ("room");
    view = csPtr<iView> (new csView (engine, g3d));
    view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (-0.5,0,0));
    view->GetCamera ()->SetSector (room);
    view->SetRectangle (0, 0, 256, 256);
    view->GetCamera ()->SetPerspectiveCenter (128, 128);
    view->GetCamera ()->SetFOVAngle (view->GetCamera ()->GetFOVAngle(), 256);
  }

  // move the camera
  csVector3 Position (-0.5, 0, 3 + sin (10 / (10*1000.0))*3);
  view->GetCamera ()->Move (Position - view->GetCamera ()
    ->GetTransform ().GetOrigin ());

  // Switch to the context of the procedural texture.
  iTextureHandle *oldContext = engine->GetContext ();
  engine->SetContext (tex->GetTextureHandle ());

  // Draw the engine view.
  g3d->BeginDraw (CSDRAW_3DGRAPHICS | engine->GetBeginDrawFlags ()
    | CSDRAW_CLEARSCREEN | CSDRAW_CLEARZBUFFER);
  g3d->GetDriver2D()->Clear (g3d->GetDriver2D()->FindRGB (0, 255, 0));
  view->Draw ();
  g3d->FinishDraw ();

  // switch back to the old context
  engine->SetContext (oldContext);
  // Just tell the 3D renderer that everything has been rendered.

  //g3d->FinishDraw ();
  //g3d->Print (0);
}

This gives http://img488.imageshack.us/img488/3157/archvile4wv8.png , and runs 
reaaally slow.

How can I correctly render to a texture? I assume after I've made changes to 
it, I just use g3d->DrawPixmap and call BeginDraw, FinishDraw and Print 
again?

Thanks.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to