Archived

This topic is now archived and is closed to further replies.

Question of texture manipulation(2)

This topic is 5903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, just a couple of questions regarding textures. 1. How do I go about modifying an existing texture used for a model and having the change visible in the scene? I know how to draw directly to the backbuffer or another surface, but how do I get that into/onto a texture? 2. How do I manipulate or cycle the palette for a texture? Thanks in advance Aggie Edited by - aggie on October 19, 2001 3:54:57 PM

Share this post


Link to post
Share on other sites
There is an intermediate example called ProceduralTexture that shows how to lock and draw on a texture. This is only included with the full version not the trial.

Also in PR4, textures with a palette are not currently working. Not all cards support them anyways so it''s not a good idea to rely on them for palette animation.



Author of Power Render (http:/www.powerrender.com)

Share this post


Link to post
Share on other sites
Doh ok well I''m using the trial version. Modifing a texture is the most important point for me right now, can anyone give me any hints? I notice there used to be a function called wgetblocksurface...

Aggie

Share this post


Link to post
Share on other sites
Here's an example of some locking code I have in one of my programs:

        
D3DLOCKED_RECT d3dlr;
HRESULT ddrval;

if(TextureNumber == -1) return;

if(!Locked) {
ddrval = PR_Globals.PR_Textures[TextureNumber].image->LockRect(0, & d3dlr, 0, 0);
if(ddrval != D3D_OK) return;

Locked = true;
LockedBits = (unsigned char *)d3dlr.pBits;
LockedPitch = d3dlr.Pitch;
}


Keep in mind this is from a cpp program. For c you'd need to use:
PR_Globals.PR_Textures[TextureNumber].image->lpVtbl->LockRect

Gary


Edited by - Gary on October 20, 2001 5:49:59 AM

Share this post


Link to post
Share on other sites
Thanks for your reply Gary.

That clears up how I can access the texture, but I cant draw to the texture in the same manner as I draw to a surface with PR..or can I? IE:

bits[x + pitch * y] = RGB16(0,255,255);


Aggie

Share this post


Link to post
Share on other sites
I don''t know how to do this directly in PR, but you should also know the pixelformat to ensure it''s RGB/BGR, 555 or 565 or whatever to select the appropriate macro to bang bits into a surface. Using D3D you can probably use GetLevelDesc() on the image member of PR_Textures[x] before you lock it, then (using the example from Gary) you can just loop thru LockedBits taking pitch into account either with the array semantics you wrote or just a (*LockedBits++) kind of thing.

Cheers,
Random

Share this post


Link to post
Share on other sites