本文整理汇总了C++中IVideoDriver::setRenderTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ IVideoDriver::setRenderTarget方法的具体用法?C++ IVideoDriver::setRenderTarget怎么用?C++ IVideoDriver::setRenderTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoDriver
的用法示例。
在下文中一共展示了IVideoDriver::setRenderTarget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnEvent
bool Hud::OnEvent(const SEvent& event)
{
if (!_showMinimap)
return false;
ISceneManager* scene;
IVideoDriver* video;
switch (Game::ToGameEvent(event)) {
case EGE_ADDITIONAL_RENDER_STARTING:
scene = _game->getDevice()->getSceneManager();
video = _game->getDevice()->getVideoDriver();
_previousCamera = scene->getActiveCamera();
scene->setActiveCamera(_minimapCamera);
video->setRenderTarget(_minimapTexture);
show(false);
break;
case EGE_ADDITIONAL_RENDER_FINISHED:
scene = _game->getDevice()->getSceneManager();
video = _game->getDevice()->getVideoDriver();
scene->setActiveCamera(_previousCamera);
video->setRenderTarget(NULL);
show(true);
break;
}
return false;
}
示例2: pass
void pass(spNativeTexture srcTexture, const Rect& srcRect, spNativeTexture destTexture, const Rect& destRect, const Color& color)
{
IVideoDriver* driver = IVideoDriver::instance;
const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(driver->getVertexDeclaration(vertexPCT2::FORMAT));
driver->setRenderTarget(destTexture);
driver->clear(0);
driver->setViewport(destRect);
driver->setTexture(0, srcTexture);
vertexPCT2 v[4];
RectF dst = srcRect.cast<RectF>() / Vector2((float)srcTexture->getWidth(), (float)srcTexture->getHeight());
fillQuadT(v,
dst,
RectF(-1, -1, 2, 2),
AffineTransform::getIdentity(), color.rgba());
driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
driver->setTexture(0, 0);
}
示例3: update
void PostProcess::update(Actor* actor)
{
_screen = getScreenRect(*actor);
OX_ASSERT(actor->_getStage());
_rt = getRTManager().get(_rt, _screen.getWidth(), _screen.getHeight(), _format);
_transform = actor->computeGlobalTransform().inverted();
IVideoDriver* driver = IVideoDriver::instance;
driver->setRenderTarget(_rt);
Rect vp = _screen;
vp.pos = Point(0, 0);
driver->setViewport(vp);
driver->clear(0);
RenderState rs;
STDMaterial* mat = STDMaterial::instance;
STDRenderer* renderer = mat->getRenderer();
rs.material = mat;
RectF clip = vp.cast<RectF>();
rs.clip = &clip;
renderer->initCoordinateSystem(vp.getWidth(), vp.getHeight(), true);
rs.transform = actor->getParent()->computeGlobalTransform();
if (!(_options._flags & PostProcessOptions::flag_fullscreen))
{
AffineTransform offset;
offset.identity();
offset.translate(-_screen.pos);
rs.transform = rs.transform * offset;
}
mat->Material::render(actor, rs);
mat->finish();
}
示例4:
// デバイス割り当て後処理
void
IrrlichtSimpleDevice::onAttach()
{
if (useRender) {
if (device) {
IVideoDriver *driver = device->getVideoDriver();
// 描画開始
if (driver) {
target = driver->createRenderTargetTexture(driver->getScreenSize());
if (target) {
driver->setRenderTarget(target);
} else {
error_log("failed to create rendertarget");
}
}
}
}
}
示例5: updatePortProcessItems
void updatePortProcessItems()
{
if (!postProcessItems.empty())
{
Material::setCurrent(0);
IVideoDriver* driver = IVideoDriver::instance;
driver->setState(IVideoDriver::STATE_BLEND, 0);
spNativeTexture prevRT = driver->getRenderTarget();
for (size_t i = 0; i < postProcessItems.size(); ++i)
{
spTweenPostProcess p = postProcessItems[i];
p->renderPP();
p->getActor()->releaseRef();
}
postProcessItems.clear();
driver->setRenderTarget(prevRT);
}
_rtm.update();
}
示例6: main
//.........这里部分代码省略.........
sq2->SetMaterialType((E_MATERIAL_TYPE) edge);
tmp2 = defines;
tmp2 += neigh3fs;
neighcb *ncb = new neighcb();
edge = gpu->addHighLevelShaderMaterial(tmp1.c_str(),0,EVST_VS_1_1,tmp2.c_str(),0,EPST_PS_1_1,ncb);
sq3->SetMaterialType((E_MATERIAL_TYPE) edge);
// Record start time
int lastfps = -1, minfps = 10000;
unsigned long long total_frames = 0, fxtimer = 0, tmplong, onframes = 0;
struct timeval starttime, tick1, tick2;
float glsltime = 0;
gettimeofday(&starttime, NULL);
wchar_t cap[20];
glEnable(GL_STENCIL_TEST);
unsigned char firstrun = 1; // To avoid the glsl compiler in the timing
// Main loop
while (dev->run()) {
gettimeofday(&tick1, NULL);
drv->beginScene();
switch (state) {
case MLAA_OFF:
if (showpic) def->Render(false);
else smgr->drawAll();
break;
case MLAA_ON:
if (showpic) def->Render(rt1);
else {
drv->setRenderTarget(rt1);
smgr->drawAll();
}
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 1, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
sq->Render(rt2);
glStencilFunc(GL_EQUAL, 1, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
sq2->Render(rt3);
drv->setRenderTarget(rt1, false, false);
// Overlay the smoothed edges on the initial image
sq3->Render(false);
// Blit the final image to the framebuffer
glStencilFunc(GL_ALWAYS, 1, ~0);
norm->Render();
break;
}
drv->endScene();
if (state == MLAA_ON) {
gettimeofday(&tick2, NULL);
if (!firstrun) {
tmplong = (tick2.tv_sec - tick1.tv_sec) * 10000;
tmplong += (tick2.tv_usec - tick1.tv_usec) / 100;
fxtimer += tmplong;
示例7: main
//.........这里部分代码省略.........
CvCapture *capture;
IplImage *frame;
char AviFileName[]="Accel World.mp4";
capture = cvCaptureFromAVI(AviFileName);
if (driver->queryFeature(irr::video::EVDF_RENDER_TO_TARGET))
{
m_pRenderTexture = driver->addRenderTargetTexture(irr::core::dimension2d<irr::u32>((irr::u32)(720), (irr::u32)(480)));
m_cRenderMaterial.setTexture(0, m_pRenderTexture);
}
// m_pRenderTexture = driver->getTexture("wall.bmp");
// m_cRenderMaterial.setTexture(0, m_pRenderTexture);
while(device->run())
{
const u32 now = device->getTimer()->getTime();
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
then = now;
if(receiver.IsKeyDown(irr::KEY_KEY_W))
camshift.Z -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_S))
camshift.Z += MOVEMENT_SPEED * frameDeltaTime;
if(receiver.IsKeyDown(irr::KEY_KEY_A))
camshift.X -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_D))
camshift.X += MOVEMENT_SPEED * frameDeltaTime;
if(receiver.IsKeyDown(irr::KEY_KEY_X))
camshift.Y -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_SPACE))
camshift.Y += MOVEMENT_SPEED * frameDeltaTime;
cam->setPosition(camPos + camshift);
driver->beginScene(true, true, SColor(255,0,0,0));
driver->setRenderTarget(m_pRenderTexture, true, true, irr::video::SColor(0,0,0,0));
if(cvGrabFrame(capture))
{
frame=cvRetrieveFrame(capture);
void* pBits = m_pRenderTexture->lock();
u32 Pitch = m_pRenderTexture->getPitch();
int wmin= Pitch;
// for(int h=0; h< 100; h++)
// memcpy((char*)pBits+((h)*wmin),(char*)frame->imageDataOrigin + h * wmin, wmin);
char* tmp = new char[frame->imageSize + 720 * 480];
for (int i = 0; i < 480; ++i)
{
for (int j = 0; j < 720; ++j)
{
tmp[(i * 720 + j) * 4] = frame->imageDataOrigin[(i * 720 + j) * 3];
tmp[(i * 720 + j) * 4 + 1] = frame->imageDataOrigin[(i * 720 + j) * 3 + 1];
tmp[(i * 720 + j) * 4 + 2] = frame->imageDataOrigin[(i * 720 + j) * 3 + 2];
tmp[(i * 720 + j) * 4 + 3] = 255;
}
}
memcpy(pBits,tmp, frame->imageSize + 720 * 480);
delete []tmp;
m_pRenderTexture->unlock();
}
driver->setRenderTarget(0, false, false, irr::video::SColor(0,100,100,100));
//driver->setTransform(video::ETS_VIEW, core::matrix4());
driver->setTransform(video::ETS_WORLD, core::matrix4());
//driver->setTransform(video::ETS_PROJECTION, core::matrix4());
driver->setMaterial(m_cRenderMaterial);
driver->drawIndexedTriangleList(m_cPlaneVertices, 4, m_iPlaneIndices, 2);
smgr->drawAll();
driver->endScene();
}
//controller.removeListener(listener);
device->drop();
return 0;
}