Horde3D

Next-Generation Graphics Engine
It is currently 27.04.2024, 07:09

All times are UTC + 1 hour




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re:
PostPosted: 25.05.2010, 02:50 
Offline

Joined: 18.09.2009, 07:44
Posts: 17
Volker wrote:
You can use the Horde3DUtils::createTGAImage and Horde3D::updateResourceData methods for that. We have done something similar here at our lab using DirectShow.

You first create a Texture Resource with the dimensions of your video source

Following code is untested:
Code:
char* img = 0;
unsigned int imgsize = 0;
unsigned char* tgaImgData = new unsigned char[videoBufferSize];
Horde3DUtils::createTGAImage(tgaImgData, width, height, depth, &img, &imgsize);
delete[] tgaImgData;
textureID = Horde3D::addResource(ResourceTypes::Texture2D, textureName, ResourceFlags::NoCompression);
Horde3D::loadResource(textureID, (char*) img, imgsize))
Horde3DUtils::freeMem(&img);   


Later you will update the texture data using updateResourceData
Code:
Horde3D::updateResourceData(textureID, ResourceData::Tex2DPixelData, imgData, size);


Since the texture data is not really a scene node I'm not sure if it would make sense to realize something like that as a SceneNode extension


Sorry to reopen an older thread, but I've been trying to get this working (DirectShow) with SourceForge r242 and am not having much luck. I seem to end up with nothing more than a black texture and the sound of my video playing in the background.

Here's what I'm doing:

1. load video
2. create tga with video dimensions, an empty bytearray and 32bit depth
3. create new material with albedo which points to the created tga
4. assign material to my mesh node
5. copy bytes from the sample grabber to my byte array:

Code:
for (int y = 0, y2 = _VideoHeight - 1; y < _VideoHeight; y++, y2--)
        {
            for (int x = 0; x < _VideoWidth; x++)
            {
                samplePosRGBA = (((y2 * _VideoWidth) + x) * 4);
                samplePosRGB24 = ((y * _VideoWidth) + x) * 3;
                _VideoFrameBytes[samplePosRGBA + 0] = _BGRData[samplePosRGB24 + 0];
                _VideoFrameBytes[samplePosRGBA + 1] = _BGRData[samplePosRGB24 + 1];
                _VideoFrameBytes[samplePosRGBA + 2] = _BGRData[samplePosRGB24 + 2];
                _VideoFrameBytes[samplePosRGBA + 3] = _AlphaTransparency;                       
            }
        }


6. write my bytes using a new method I introduced (I considered there may have been issue with the .NET wrapper) which looks like this:

Code:
DLLEXP void *h3dWriteBytes( ResHandle res, int elem, int elemIdx, int stream, const char *data, int size)
{
   Resource *resObj = Modules::resMan().resolveResHandle( res );
   VALIDATE_RES( resObj, "h3dMapResStream", 0x0 );

   unsigned char* mappedStream = (unsigned char *)resObj->mapStream( elem, elemIdx, stream, false, true );
   
   for(int i = 0; i < size; i++)
   {
      mappedStream[i] = data[i];
   }

   resObj->unmapStream();
}


I've tried putting hardcodes into the _VideoFrameBytes array but seem unable to get the black to change to any other colour, which to me indicates something important is missing or being done incorrectly.

Any ideas?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 29 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group