Re: replacing "old texture" with new ones !!!

New Message Reply Date view Thread view Subject view Author view

From: Angus Dorbie (dorbie++at++sgi.com)
Date: 03/05/2001 11:13:36


Jasmina Orman wrote:
>
> Hi,
>
> The last few days I've been working on the same problem
> as I described last week:
>
> HOW TO REPLACE THE OLD TEXTURE WITH NEW ONES
>
> I also tried to work with subload-mechanisam but without any success !
>
> This is what I done and what I get :
>
> 1)
> I thought somehow I should simplify my problem and try to solve it step by step.
> ~
> So I created a new image "changed_image" which is actually the same image
> as the one of my recently used texture "tex", but I swapped
> red and blue components. Now I wanted Peroformer to use this new image
> instead of its old one. To implement this I tried 2 possibilities:
>
> //=== 1
> //---------------------------------------------------------------
> // WITH THIS PERFORMER REALLY USED MY NEW TEXTURE "changed_image"
>
> tex->setImage(changed_image, comp, ns, nt, nr)
>
> // I was even able to set correct format with the following line
> // and the image was correctly displayed
>
> tex->setFormat(PFTEX_IMAGE_FORMAT, GL_BGR_EXT);
>
> //==== 2 alternative
> // with this Performer also used the changed image
> // BUT setting here the Image_format has NO EFFECT ???!!!!
> // so my new image stayed bluish
> //
> tex->setFormat(PFTEX_SUBLOAD_FORMAT, PF_ON);
> tex->subload(PFTEX_SOURCE_IMAGE,change_image,0, 0, ns, 0,0,ns,nt);
>
> It was also interesting that the 2. alternative only works if I call it
> before calling any glBindComands (called in my compression step) ???!!!
> (I assume that performer is somehow influenced by the state of OpenGL
> engine but I have no idea how !)

YIKES!!

Performer doesn't track texture state in the gl, it has lazy traking
above OpenGL for performance reasons. When you bind you have switched
texture handles and Performer doesn't know about this.

Just apply any pfTexture before the subload and that will put texture
state back on track. You may want to apply the texture you are
subloading to. Now if you've totally lost track of things because you're
in the some draw callback for your binds (which you obviously are) then
when you're done with your OpenGL code apply any pfTexture immediately
afterwards.

Better yet use performer for all your texture state management instead
of the OpenGL bind calls.

>
> 2) Now after being somehow successfully with my "changed_image" I thought
> it must be possible to do the same with compressed image "img"
>
> so i called:
>
> tex->setImage(img, comp, ns, nt, nr);
>
> // set to correct format
>
> tex->setFormat(PFTEX_IMAGE_FORMAT, GL_BGR_EXT);
> tex->setFormat(PFTEX_INTERNAL_FORMAT,GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
> tex->setFormat(PFTEX_EXTERNAL_FORMAT, GL_UNSIGNED_BYTE);
>
> With this I get completely wrong image - not even an image !

These formats probably don't get passed through, i.e. they're
unsupported.

>
> It seems like setting the formats has no effect !
> (using subload is the same problem. I read that when using PFTEX_SUBLOAD_FORMAT
> it is not possible to reformat the texture ?! Also in method glTexSubImage2D() in OpenGL
> there is no place to define internal Format !)
>
> Is there any possibility to do this ?
> How can I tell Performer that the new image is compressed ???

OK, if you really want to do this sort of thing and Performer doesn't
support these tokens then try applying the texture in the draw process
then using raw OpenGL code, this will make Performer bind the OpenGL
handle, any OpenGL calls subsequently made will affect that handle and
the OpenGL cached texture information. This way Performer will still
manage the texture object in the scene graph and geostate but what is
actually bound by the associated handle will be the information you have
specified directly to OpenGL.

I suspect most of your problems are related to the exotic tokens you are
using.

Cheers,Angus.

-- 
For Performer+OpenGL tutorials http://www.dorbie.com/

"Whenever there is a conflict between human rights and property rights, human rights must prevail." --Abraham Lincoln


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Mar 05 2001 - 11:14:06 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.