#include <ddraw.h>
#include <fstream>
#include <D3d8types.h>
int main( int argc, char * argv[] ) {
if( !argv[1] || !strstr( argv[1], ".dds" ) ) {
fprintf( stderr, "Usage: noise output.dds\n" );
return 1;
}
DDSURFACEDESC2 desc;
memset( &desc, 0, sizeof(desc) );
desc.dwFlags = 0x00801007;
desc.dwSize = 124;
desc.dwDepth = 64;
desc.dwWidth = 128;
desc.dwHeight = 128;
desc.dwBackBufferCount = 64;
desc.ddsCaps.dwCaps = 0x00001002;
desc.ddsCaps.dwCaps2 = 0x00200000;
desc.dwFVF = 32;
desc.ddpfPixelFormat.dwSize = 0x20;
desc.ddpfPixelFormat.dwFlags = 0x41;
desc.ddpfPixelFormat.dwRGBBitCount = 0x20;
desc.ddpfPixelFormat.dwLuminanceBitCount = 0x20;
desc.ddpfPixelFormat.dwBumpBitCount = 0x20;
desc.ddpfPixelFormat.
dwPrivateFormatBitCount = 0x20;
desc.ddpfPixelFormat.dwRBitMask = 0x00ff0000;
desc.ddpfPixelFormat.dwGBitMask = 0x0000ff00;
desc.ddpfPixelFormat.dwBBitMask = 0x000000ff;
desc.ddpfPixelFormat.
dwRGBAlphaBitMask = 0xff000000;
unsigned int cnt =
desc.dwWidth*desc.dwHeight*desc.dwDepth*4;
unsigned char * buf = new unsigned char[ cnt ];
while( cnt-- ) {
buf[cnt] = rand()>>7;
}
std::ofstream ofst( argv[1] );
ofst << "DDS ";
ofst.write( (const char *)&desc, 124 );
ofst.write( (const char *)buf,
desc.dwWidth*desc.dwHeight*desc.dwDepth*4 );
return 0;
}
To be a really useful sample, I need to replace the flag values with constants...I need to figure out what they are, first, though!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.