Archived

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

Phillip Schuster

Plotting Pixels on Textures in RealTime

Recommended Posts

Guest Anonymous Poster
Maybe Chris can confirmed this.

After you draw on the texture, you should
call the updatetexture with a TRUE.

PR_UpdateTexture (m_TexNum, TRUE);

Share this post


Link to post
Share on other sites
Intuition tells me that it's using a hardware mode of 16bpp and I recall hearing Chris Egerter say in a previous post:

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

If that's what's happening in this case, then it's likely that "int color" is being interpreted as RGBA or variant. To correctly map between a palette index and the pixel value, you may need to reference your original palette to retrieve the RGB information in order to set the correct pixel value that would give you the color you want.

Although I would keep it the way you have, just treat "int color" as the actual pixel value instead of a palette index.

Correct me if I'm wrong

Share this post


Link to post
Share on other sites
Hi !!

I think you are right. I tried my code on a 3DFX Voodoo Card, and there it works fine. This means, that 3DFX Voodoo can store the texture in 8-bit, while my RivaTNT can't do that and stores the texture in another Mode, I think TEXTURE_NORMAL. So, you are absolutely right. But how do I plot that damn pixel. I tried some code used for DirectDraw.
I lock the DirectDrawSurface of the texture(the texture is nothing else), then I use a function which gets the pixel format, and based on this pixel format information there is a function which plots the pixel given x,y and r,g and b !!
But this does not work, the texture is completely unchanged.
I really don't know how to do that. That's really very hard stuff.
I would like to go the 16-Bit way, because I sometime want colored LightMaps, and then 8-Bit does not help me.

Thanks, Phillip

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Maybe the TNT do not allow storing in 8-bit
format.

I remember reading this on the Ultima 9 discussion, they are complaining that they cannot do 8-bit palettized format.

Share this post


Link to post
Share on other sites
Hi all !

Well, although Chris let me know today that I don't need to spend time on lightmapping, because he will provide an example in the next beta, I just got it up and running today. But, my last problem:

I need to draw the lightmaps. They are created when all objects are loaded. But, how do I plot a pixel in a Texture ??

Check this out:

//This functions plot the pixel

void CDrawableTexture::SetPixel(long x, long y, int color)
{
m_bits[y*m_pitch+x] = (unsigned char)color;
}

//This function updates the texture
void CDrawableTexture::UpdateTexture()
{
PR_UpdateTexture (m_TexNum, FALSE);
}

//Here I "Open" the texture
void CDrawableTexture::OpenTexture()
{
m_bOpen = TRUE;
m_bits = wgetblocksurface (PR_WorldTextures[m_TexNum].image, &m_pitch);
m_width = m_pitch;
m_height = PR_WorldTextures[m_TexNum].height;
//Setting the texture to black
memset(m_bits,0,sizeof(char)*m_width*m_height);
}

//Here I close the texture
void CDrawableTexture::CloseTexture(BOOL bUpdate)
{
wunlocksurface (PR_WorldTextures[m_TexNum].image);
if (bUpdate) {
UpdateTexture();
}
m_bOpen = FALSE;
m_width = 0;
m_height = 0;
}

Well, Before loading the texture, I use PR_SetTextureFormat(TEXTURE_P_8);

The bmp also has a 8 Bit Greyscale palette. So, using SetPixel(0,0,128) should give me a grey, but I get green.

When I just use all colors from 0 to 255 (randomly) I don't get just grey-scale, but different colors, from green to red to blue and so on.

Anyone knows what's wrong here ??

Phillip

Share this post


Link to post
Share on other sites