Archived

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

Phillip Schuster

Changing textures of PR durch runtime

Recommended Posts

Make sure you called PR_SetTextureFormat(TEXTURE_P_8); before loading the texture, or if you're using PR 3 and have it in a .PRO file then use editmat to set the format.

Even though the texture is stored in 8 bit PR may convert it to another format when you load it.

Chris

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi,

>Then I don't get a texture (on the screen) >which has different grayscale images, but
>it has a lot of colors (white, blue, green, >red) depending on color ??? Any Ideas ??

Are you using Direct3D ?
Direct3D should be okay.

I have the same problem on Glide.

>So, even if this functions well, I only can >create a white fog map.
>How do I create a colored fog map ?? Is >there a possibility ??

do not use gray image, fill the palette
with the colors you needed.

You can amend the palette also, if required.

The sky in my game will change colour according to the time of the day.

I just update the palette to change the colour, it is better than keeping a lot of textures in memory.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi again !!

Well, thanks a lot. I tested it, and if I just hard code any values, so :

bits[y*pitch*x] = 64; // or 32 or 128 or 255

everything works fine, but as soon as calculating this value it fails !!

I need to calculate the distance of two points:

float len = PR_VecLength(dif); //dif is the difference vector of both points.

Then using something like that fails (the maximum distance is 255, the lowest of course 0.

unsigned int len2 = (unsigned int)len;
bits[y*pitch*x] = len2;

This does not work. Setting len2 before to 64 or so:

unsigned int len2 = (unsigned int)len;
len2 = 64;
bits[y*pitch*x] = len2;

then it works again ???? I tried all kind of types, int, unsigned int, char, BYTE, and so on for type casting, nothing helps.

Thanks alot ??

Btw. How do I change the palette ??

Phillip

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
To get the palette:

PR_WorldTextures[texture_num].pal[color];

pal is a structure in color which contains r,g,b.

get the new palette and assign to the r,g,b.

btw, updating palette do not need the UpdateTexture command.


Share this post


Link to post
Share on other sites
Hi all !!


Ok, I want to edit my textures. Chris provided an example which shows how to do that.
I have created a texture which is BMP, 8-Bit and a grayscale palett.
Now, during my program execution I want to edit this texture (I want to calc a
Volumetric Fog Map) every frame and uploading it again.
When I calculate each pixel (it's between 0 and 255) and then using something like that:

unsigned char* bits = wgetblocksurface (PR_WorldTextures[m_TexNum].image, &pitch);
color = rand() % 255;
bits[y*pitch+x] = color;
wunlocksurface (PR_WorldTextures[m_TexNum].image);

Then I don't get a texture (on the screen) which has different grayscale images, but
it has a lot of colors (white, blue, green, red) depending on color ??? Any Ideas ??

So, even if this functions well, I only can create a white fog map.
How do I create a colored fog map ?? Is there a possibility ??

Thanks

Phillip

Share this post


Link to post
Share on other sites