And after I've made the changes to the texture I re-render using
g3d->DrawPixmap and call BeginDraw, FinishDraw and Print
again?

Thanks again.

On 1/15/07, res <[EMAIL PROTECTED]> wrote:

On 14.01.2007 20:35, Amir Taaki wrote:
> 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);

What happens here is that you create a texture with non-PO2 dimensions.
CS will resize these to PO2 dimensions; to 512x512 in the case of 640x480.

Don't worry, there are ways to deal with that. There's just a bit tricky
:)

First, you can ask for a non-PO2 texture - the CS_TEXTURE_NPOTS flag is
for that. But: emphasis on "ask". You may not get it! Make sure to read
the docs on the flag.

If you get it, you may get a RECT texture. This needs some extra dealing
with since it uses unnormalized texture coordinates(*). Or you may get a
2D texture, which would use normalized texture coordinates. You can use
GetTextureTarget() to find out.

Now, I said "you may not get it". If you have got it, you can test by
checking the texture flags for CS_TEXTURE_NPOTS - if it isn't there, you
didn't get it.

If you didn't get it, PO2 resizing will kick in. To deal with that case,
passing in the CS_TEXTURE_SCALE_UP comes handy. It instructs the
renderer to always use the next bigger texture dimensions. That way, you
can at least render to e.g. the upper left corner of your target texture.

(*) CS actually tries to compensate and de-normalize texture coordinates
for you. Problem is, it breaks down when things like shader programs
that take their input as e.g. vertex attributes ... that "texture
coordinate fixup" is brittle and I'd rather have it gone. I just didn't
get around removing it...

The whole texture dimensions thing *is* messy; but there's no good way
to deal with it universally, transparently and HW-accelerated, so the
burden goes to the app who has to deal with various cases. All in all,
it's not difficult - for you it basically boils down to choosing the
right texture coordinates, but you need to be aware of those little
details.

>     tex->Register (txtmgr);
>     printf ("Register in txtmgr\n");
>     iTextureHandle *texh = tex->GetTextureHandle ();
>     if (!texh)
>       printf ("iTextureHandle is not here!!!\n");
>     texh->SetTextureClass("nocompress");

The texture class should be set before registering with the texture
manager to have an effect.

>   }
>
>   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);
>   }

The view rectangle, perspective center, FOV... would of course have to
be adjusted to the actual desired dimensions.

-f.r.



-------------------------------------------------------------------------
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
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]
?subject=unsubscribe




-------------------------------------------------------------------------
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
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to