- Make a rectangle mesh with a texture.
- Point a camera at the rectangle mesh so it takes up the entire screen/window.
- Render. As images from the robot come in, convert them to IImages and copy their data to the texture.

Ignore the FPS - that's just because I had just brought the window back up after minimizing it. This is what I should be seeing (stretched to the 800 x 600 window of course):

It looks like the texture isn't the expected size (maybe getting bumped up to 1024 x 512) and the rows aren't lining up because of this. Do most integrated graphics systems not support textures that aren't powers of two? I'll have to check with IVideoDriver::queryFeature(EVDF_TEXTURE_NPOT), but I was wondering if anyone had an idea about what the problem might be in the meantime.
Here's the code (Screen is just the object that sets up the camera and creates the rectangle with a texture. I'm sure this isn't the problem).
Code: Select all
#include <irrlicht.h>
#include <ctime>
#include "Screen.h"
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
using namespace irr;
using namespace video;
using namespace scene;
const SColor kBgColor(255, 0xe4, 0xe7, 0xec);
int main(void)
{
SIrrlichtCreationParameters cp;
cp.Bits = 32;
cp.DriverType = EDT_DIRECT3D9;
cp.Vsync = true;
IrrlichtDevice* device = createDeviceEx(cp);
device->setResizable(true);
IVideoDriver* vd = device->getVideoDriver();
ISceneManager* sm = device->getSceneManager();
ICameraSceneNode* cam = sm->addCameraSceneNode();
vd->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
ITexture* texture = vd->addTexture(dimension2d<u32>(640, 480), "Video Image");
IImage* awesomeImg = vd->createImageFromFile("Awesome.png");
IImage* doNotWantImg = vd->createImageFromFile("DoNotWant.png");
bool awesomeTurn = true;
Screen scrn(cam, sm, texture);
u8 sinceLastFPS = 0;
clock_t lastTime = clock();
while(device->run())
{
if(device->isWindowActive())
{
if(clock() >= lastTime + CLOCKS_PER_SEC / 30)
{
if(awesomeTurn)
{
u32 imgBytes = awesomeImg->getImageDataSizeInBytes();
void* txtPtr = texture->lock();
void* imgPtr = awesomeImg->lock();
memcpy(txtPtr, imgPtr, imgBytes);
awesomeImg->unlock();
texture->unlock();
}
else
{
u32 imgBytes = doNotWantImg->getImageDataSizeInBytes();
void* txtPtr = texture->lock();
void* imgPtr = doNotWantImg->lock();
memcpy(txtPtr, imgPtr, imgBytes);
doNotWantImg->unlock();
texture->unlock();
}
awesomeTurn = !awesomeTurn;
lastTime = clock();
}
if(++sinceLastFPS == 20)
{
sinceLastFPS = 0;
stringw title(L"Rendering at ");
title += vd->getFPS();
title += L" FPS";
device->setWindowCaption(title.c_str());
}
vd->beginScene(true, true, kBgColor);
sm->drawAll();
vd->endScene();
}
else
device->yield();
}
awesomeImg->drop();
doNotWantImg->drop();
return 0;
}