buffer to texture

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
khatarat
Posts: 18
Joined: Wed Dec 19, 2012 10:41 am

buffer to texture

Post by khatarat »

hi
i have a buffer of an image that i get it from a camera. i want to display this image as a texture on a 3d plane. how can i convert this buffer that is an array of bytes to ITexture?
khatarat
Posts: 18
Joined: Wed Dec 19, 2012 10:41 am

Re: buffer to texture

Post by khatarat »

i create an IImage pointer to my buffer.
i used following function to convert it to ITexture but it has access Violation error

video::ITexture* FacialMotionCapture::ImageTexture(video::IImage* image, core::stringc name)
{
video::ITexture* texture = m_Driver->addTexture(name.c_str(),image);
texture->grab(); //this line has access violation error
return texture;
}
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: buffer to texture

Post by polylux »

If you want to display your camera stream I'd recommend a different approach.
1, Create an empty texture using this method
2, Whenever your cam buffer has new data available, call the texture's lock function to get access to the pixel data. Use write access to push the buffer data into the texture
3, Don't forget to unlock the texture and you're good to go
4, Such things rather belong to the beginners' forum ;)

Cheers,
p.
beer->setMotivationCallback(this);
Post Reply