Hey,
I am trying to modify the sample class in order to use SDL instead of OpenGL.
The program does not work, there is a black background (default).
I think the problem comes from the onNewRGBFrame but by using CLion, I can’t put any stopping points.
Here is the different part of the code :
-
Initizalisation of the texture
void SdlNuitrackRenderHandler::initTexture(int width, int height) { if(texture == nullptr){ texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, width, height); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); } }
-
Copy Nuitrack frame to SDL_Texture
`void SdlNuitrackRenderHandler::onNewRGBFrame(RGBFrame::Ptr frame)
{
if(_viewMode != RGB_MODE)
return;std::cout << “ok”;
const tdv::nuitrack::Color3* colorPtr = frame->getData();
size_t bufferSize = static_cast<size_t>(_width) * static_cast<size_t>(_height) * 4;unsigned char *texture_data = nullptr;
int texture_pitch = 0;SDL_LockTexture(texture, nullptr, (void **) &texture_data, &texture_pitch);
memcpy(texture_data, colorPtr, bufferSize);
SDL_UnlockTexture(texture);
}` -
Render Texture
// Render prepared background texture void SdlNuitrackRenderHandler::renderTexture() { if(texture != nullptr) { SDL_RenderCopy(renderer, texture, NULL, NULL); } }
Anyone has an idea ? Maybe there is a format compatibility issue ?
Thanks you in advance.