Lock() Texture bug due to video card limitation to 256*256 ?
Lock() Texture bug due to video card limitation to 256*256 ?
Hello,
Lock a texture in memory can be a nice feature but we found a limitation, many video card limit the lock() function to 256*256 texture size, do you know a turnaround to this problem as we need to lock a 512*512 (320*240) texture size!
Thanks
Lock a texture in memory can be a nice feature but we found a limitation, many video card limit the lock() function to 256*256 texture size, do you know a turnaround to this problem as we need to lock a 512*512 (320*240) texture size!
Thanks
prm.DriverType = E_DRIVER_TYPE(4); (DirectX)
ITexture* g_tex = 0; // DL3D: Webcam frame
// Then
// Remove camera frame texture
_irDriver->removeTexture( g_tex );
// Then
// Create webcam frame texture if it doesn't already exists
if( g_tex == 0 )
g_tex = _irDriver->addTexture( dimension2d<s32>( 320, 240 ), "T1", ECF_R5G6B5 ); // ECF_A8R8G8B8 ECF_R5G6B5 ECF_R8G8B8
ITexture* tex = g_tex;
// Source data
u8 *psrc = (u8*)pSrc->pData;
// Lock and get texture data
u8 *pdest = (u8*)tex->lock();
// Update texture data
for( u32 y=0; y<240; y++ )
{
for( u32 x=0; x<320; x++ )
{
int i = y * 320 + x;
// BGR -> RGB conversion
pdest[ i * 4 + 0 ] = psrc[ i * 3 + 0 ]; // B
pdest[ i * 4 + 1 ] = psrc[ i * 3 + 1 ]; // G
pdest[ i * 4 + 2 ] = psrc[ i * 3 + 2 ]; // R
pdest[ i * 4 + 3 ] = 1.0; // A
}
}
// Release texture data
tex->unlock();
Thats it and we init
ITexture* g_tex = 0; // DL3D: Webcam frame
// Then
// Remove camera frame texture
_irDriver->removeTexture( g_tex );
// Then
// Create webcam frame texture if it doesn't already exists
if( g_tex == 0 )
g_tex = _irDriver->addTexture( dimension2d<s32>( 320, 240 ), "T1", ECF_R5G6B5 ); // ECF_A8R8G8B8 ECF_R5G6B5 ECF_R8G8B8
ITexture* tex = g_tex;
// Source data
u8 *psrc = (u8*)pSrc->pData;
// Lock and get texture data
u8 *pdest = (u8*)tex->lock();
// Update texture data
for( u32 y=0; y<240; y++ )
{
for( u32 x=0; x<320; x++ )
{
int i = y * 320 + x;
// BGR -> RGB conversion
pdest[ i * 4 + 0 ] = psrc[ i * 3 + 0 ]; // B
pdest[ i * 4 + 1 ] = psrc[ i * 3 + 1 ]; // G
pdest[ i * 4 + 2 ] = psrc[ i * 3 + 2 ]; // R
pdest[ i * 4 + 3 ] = 1.0; // A
}
}
// Release texture data
tex->unlock();
Thats it and we init
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Try to create a power-of-two texture (i.e. create the 512x512 texture) and lock it. And note that you have to make the proper byte conversions for the chosen format. R5G6B5 is a two byte format, while your code does 4 byte steps per pixel. There are several color format conversion methods available in CColorConverter.cpp from which you can choose (they are not exposed to the user under win32 systems, though).
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Besides that this statement does not help at all in this context, the two things you mentioned (dropping the image held and locking RTT) are not related at all. You can lock the RTT without a permanently stored image and you could lock the RTT into the stored image. However, it's simply not implemented (and you have to take care to make it efficient).
For performance reasons, a function to request just one pixel from the image would be great. Sometimes you only need to read a pixel or two from an RTT and you end up having to download the whole thing.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net