Ogre 3d:RenderTexture大于RenderWindow [英] Ogre 3d: RenderTexture bigger than RenderWindow

查看:217
本文介绍了Ogre 3d:RenderTexture大于RenderWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个ogre应用程序:

I have two ogre applications:

1)子应用程序,渲染到窗口和纹理。纹理被导出到共享内存(shm在linux)

1) Sub application, that render to a window and to a texture (using same camera). The texture is "exported" to shared memory (shm in linux)

2)主应用,其中飞机显示在(1)sub application,从共享内存中加载纹理。

2) Main application, where a plane shows what is happening in the (1) "sub application", loading the texture from shared memory.

(1)渲染的纹理与(2)中的平面使用的纹理具有相同的大小。例如,如果RenderWindow大于或等于RenderTexture,则例如:512x512

The texture where (1) renders has same size than texture used by plane in (2). E.g.: 512x512

全部正常
在(1)中看到的内容反映在(2)平面与正常的fps。共享内存是强大的!

All works fine if the RenderWindow is bigger or equal than RenderTexture. What you see in (1) is reflected in (2) plane with decent fps. Shared memory is powerful!

但是如果渲染窗口小于纹理,只更新纹理的一部分

But if render window is smaller than texture, only a part of texture is updated.

这是我发生的事情:

This is what is happening to me:

一些例子显示了1x1窗口和大渲染纹理,所以我想有一个渲染纹理比窗口大。

Some examples show 1x1 window and big render texture, so i guess it's possible to have a render texture bigger than the window.

这是窗口创建的方式:

window_ = root_->createRenderWindow("blablah"), 256, 256, false);

这是渲染纹理的创建方式:

This is how the render texture is created:

TextureManager* tm = TextureManager::getSingletonPtr();
TexturePtr rttTexture = tm->createManual(
/**/"MainRTT"
/**/, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
/**/, TEX_TYPE_2D
/**/, 512
/**/, 512
/**/, 0
/**/, PF_R8G8B8A8
/**/, TU_RENDERTARGET);
RenderTexture* renderTarget = rttTexture->getBuffer()->getRenderTarget();
renderTarget->addViewport(camera_);
renderTarget->setAutoUpdated(false);
Viewport* vp = renderTarget->getViewport(0);
vp->setClearEveryFrame(true);
vp->setOverlaysEnabled(true);
vp->setBackgroundColour(ColourValue::Black);

这是我更新渲染纹理的方式:

This is how i update the render texture:

class ShmTexUpdater: public Ogre::FrameListener {
public:
    ShmTexUpdater(const int& width, const int& height, void* data,
            const TexturePtr& tex) :
        /**/width_(width)
        /**/, height_(height)
        /**/, data_(data)
        /**/, tex_(tex)
        /**/, buf_(tex->getBuffer())
        /**/, renderTarget_(tex->getBuffer()->getRenderTarget()){

    }
    virtual ~ShmTexUpdater() {

    }
private:
    virtual bool frameStarted(const FrameEvent& evt) {
        FrameWork::instance()->window()->update();
        buf_->lock(Ogre::HardwareBuffer::HBL_NORMAL);
        renderTarget_->update();
        tex_->getBuffer()->blitToMemory(
        /**/PixelBox(width_, height_, 1, ShmTexture4k::FORMAT, data_));
        buf_->unlock();
        return true;
    }
    int const width_;
    int const height_;
    void* const data_;
    TexturePtr const tex_;
    HardwarePixelBufferSharedPtr buf_;
    RenderTexture* renderTarget_;
};

读取RenderWindow和RenderTexture的描述,这不是我期望发生的。所以...是这个ogre bug,还是opengl?

Reading description of RenderWindow and RenderTexture, this is not what I'm expecting to happen. So... is this ogre bug, or opengl? Or am I doing it wrong?


  • 操作系统:Linux

  • Ogre:版本1.7.3 Cthugha)

  • GL_VERSION = 4.0.0 NVIDIA 256.53

推荐答案

我不知道这是否有很多帮助(可能太晚了),但前一段时间我已经阅读了OpenGL不能渲染到比它使用的窗口更大的纹理。 DX是能够这样做,但不是OGL。

I'm not sure if it's much of help (and probably too late) but some time ago I've read that OpenGL can't render to texture that is bigger than window it's using. DX is capable of doing this, but not OGL.

BTW对不起,它是回答,不是评论,但我还不能写评论;]

BTW Sorry it's answer and not comment, but I can't write comments yet ;]

这篇关于Ogre 3d:RenderTexture大于RenderWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆