Integrate 3D texture fixes from Ben Goldstein @ Nihilistic.
This commit is contained in:
parent
ac3f2d1794
commit
63897b3ecc
@ -1242,6 +1242,7 @@ void DirectDrawSurface::readLinearImage(Image * img)
|
||||
|
||||
const uint w = img->width();
|
||||
const uint h = img->height();
|
||||
const uint d = img->depth();
|
||||
|
||||
uint rshift, rsize;
|
||||
PixelFormat::maskShiftAndSize(header.pf.rmask, &rshift, &rsize);
|
||||
@ -1260,20 +1261,23 @@ void DirectDrawSurface::readLinearImage(Image * img)
|
||||
#pragma NV_MESSAGE("TODO: Support floating point linear images and other FOURCC codes.")
|
||||
|
||||
// Read linear RGB images.
|
||||
for (uint y = 0; y < h; y++)
|
||||
for (uint z = 0; z < d; z++)
|
||||
{
|
||||
for (uint x = 0; x < w; x++)
|
||||
for (uint y = 0; y < h; y++)
|
||||
{
|
||||
uint c = 0;
|
||||
stream->serialize(&c, byteCount);
|
||||
for (uint x = 0; x < w; x++)
|
||||
{
|
||||
uint c = 0;
|
||||
stream->serialize(&c, byteCount);
|
||||
|
||||
Color32 pixel(0, 0, 0, 0xFF);
|
||||
pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
|
||||
pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8);
|
||||
pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8);
|
||||
pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
|
||||
Color32 pixel(0, 0, 0, 0xFF);
|
||||
pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8);
|
||||
pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8);
|
||||
pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8);
|
||||
pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8);
|
||||
|
||||
img->pixel(x, y) = pixel;
|
||||
img->pixel(x, y, z) = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1443,7 +1443,7 @@ FloatImage* FloatImage::clone() const
|
||||
{
|
||||
FloatImage* copy = new FloatImage();
|
||||
|
||||
copy->allocate(m_componentCount, m_width, m_height);
|
||||
copy->allocate(m_componentCount, m_width, m_height, m_depth);
|
||||
memcpy(copy->m_mem, m_mem, m_floatCount * sizeof(float));
|
||||
|
||||
return copy;
|
||||
|
@ -48,8 +48,8 @@ namespace nv
|
||||
const Color32 & pixel(uint idx) const;
|
||||
Color32 & pixel(uint idx);
|
||||
|
||||
const Color32 & pixel(uint x, uint y) const;
|
||||
Color32 & pixel(uint x, uint y);
|
||||
const Color32 & pixel(uint x, uint y, uint z = 0) const;
|
||||
Color32 & pixel(uint x, uint y, uint z = 0);
|
||||
|
||||
Format format() const;
|
||||
void setFormat(Format f);
|
||||
@ -68,16 +68,16 @@ namespace nv
|
||||
};
|
||||
|
||||
|
||||
inline const Color32 & Image::pixel(uint x, uint y) const
|
||||
inline const Color32 & Image::pixel(uint x, uint y, uint z) const
|
||||
{
|
||||
nvDebugCheck(x < m_width && y < m_height);
|
||||
return pixel(y * m_width + x);
|
||||
nvDebugCheck(x < m_width && y < m_height && z < m_depth);
|
||||
return pixel((z * m_height + y) * m_width + x);
|
||||
}
|
||||
|
||||
inline Color32 & Image::pixel(uint x, uint y)
|
||||
inline Color32 & Image::pixel(uint x, uint y, uint z)
|
||||
{
|
||||
nvDebugCheck(x < m_width && y < m_height);
|
||||
return pixel(y * m_width + x);
|
||||
nvDebugCheck(x < m_width && y < m_height && z < m_depth);
|
||||
return pixel((z * m_height + y) * m_width + x);
|
||||
}
|
||||
|
||||
} // nv namespace
|
||||
|
Loading…
Reference in New Issue
Block a user