Ogre 3d: RenderTexture RenderWindowdan kattaroq

Ikki dona o'roq dasturim bor:

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) Main application, where a plane shows what is happening in the (1) "sub application", loading the texture from shared memory.

(1) ishlov beradigan to'qimalar (2) tekisligida ishlatiladigan to'qimalarga nisbatan bir xil o'lchamga ega. Masalan: 512x512

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!

Ammo agar ko'rsatish oynasi to'qimalardan kichik bo'lsa, faqat to'qimalarning bir qismi yangilanadi .

This is what is happening to me: renderwindow smaller than rendertexture

Ba'zi bir misollar 1x1 oynani va katta renderli to'qimalarni aks ettiradi, shuning uchun derazaga qaraganda kattaroq ko'rsatish mumkin.

Bu oyna qanday yaratilgan:

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

Tasviriy tuzilish shunday yaratiladi:

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);

Tasviriy tuzilishni qanday qilib yangilayman?

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 va RenderTexture'ning o'qilishini tushuntirish, bu men kutayotgan narsa emas. Xo'sh, bu bugri bug yoki openglmi? Yoki noto'g'ri qilyapmanmi?

  • OS: Linux
  • Ogre: Versiya 1.7.3 (Cthugha)
  • GL_VERSION = 4.0.0 NVIDIA 256.53
2
@Crazyjul Ha, shunday
qo'shib qo'ydi muallif Alessandro Pezzato, manba
@crazyjul yangi kamerasi bilan yangi kamerada sinxronizatsiyaBaseSettingsWith (camera_) bilan kopyalanib harakat qildi; ammo natijasi bir xil
qo'shib qo'ydi muallif Alessandro Pezzato, manba
Camera_ o'zgaruvchisi Windows render maqsad bilan almashtirilsinmi?
qo'shib qo'ydi muallif crazyjul, manba

3 javoblar

Ko'p yordam (yoki, ehtimol kech), amin emasman, bir muncha vaqt oldin, OpenGL-dan foydalanadigan derazadan kattaroq to'qimalarga ishlov bera olmasligini o'qidim. DX buni qila oladi, lekin OGL emas.

BTW Kechirasiz, bu javob va izoh bermang, lekin hali izoh yozolmayapman;]

1
qo'shib qo'ydi

Biroq, agar tuzilma oynasi to'qimadan kichik bo'lsa, faqat to'qimalarning bir qismi yangilanadi.

Exactly this is to be expected and indeed the correct behaviour. Pixels of regular on-screen windows are only processed if they pass the so called pixel ownership test. What this means is, that only those pixels that will be visible to the user will be rendered at all. So if for example you drag a window in front of your OpenGL window, those pixels will not be rendered to either; on modern systems so called compositing window management is used, where obstruction by window will not fail the pixel ownership test.

Uzun hikoyani qisqa qilish uchun: Agar siz keyingi ishlov berish uchun narsalar taqdim qilmoqchi bo'lsangiz, buni kvadratchadan hammasini o'z nazorati ostiga qo'yishingiz kerak: A Pufuffer yoki Frame Buffer Object .

0
qo'shib qo'ydi
@AlessandroPezzato: Qaysi OS va kompozitorni ishlatasiz? Yaxshiyamki, siz derazalarni renderlash uchun tarkibni ko'rsatish uchun oyna sifatida foydalanmasligingiz kerak. FBO yoki PBufferdan foydalaning, buning ma'nosi ular uchun.
qo'shib qo'ydi muallif datenwolf, manba
Sizning javobingizdan so'ng ba'zi testlarni qildim ... Kompozit yoqilgan yoki o'chirib qo'yilgan bo'lsa ham, uni ko'rsatish oynasi ko'rinmasa ham (boshqa oynada taqiqlangan, ikonka yoki boshqa virtual ish stolida) cheklangan bo'lsa ham, uni yangilash davom etmoqda. renderTarget _-> update (); bilan yangilashni majbur qilsam, bu sodir bo'ladi. Ya'ni, bu muammo emas, deb o'ylayman. To'g'ri?
qo'shib qo'ydi muallif Alessandro Pezzato, manba
Uning kompozitori bilan kde 4.6. Mening Ogre ilovasi oynaga va to'qimalarga ishlov beradi ( ogre3d.org/tikiwiki/Intermediate+Tutorial+ 7 ).
qo'shib qo'ydi muallif Alessandro Pezzato, manba

If the target change in size, your camera needs to be updated : http://www.ogre3d.org/docs/api/html/classOgre_1_1Viewport.html#a23c2b69bbc3d76fd52a4729a71caed08

_updateDimensions() ga qo'ng'iroqni tuzatish kerak

0
qo'shib qo'ydi
Hujjatlar ta'kidlaganidek _updateDimensions() " Faqat Ogre tomonidan ichki foydalanish. ". Buni vp-> setBackgroundColour (ColourValue: Black); va renderTarget _-> update (); dan oldin chaqirishga harakat qildim, lekin hech narsa o'zgarmaydi.
qo'shib qo'ydi muallif Alessandro Pezzato, manba
Nishon uning hajmini o'zgartirmaydi. Ikki xil maqsad bor: RenderWindow va RenderTexture, va ikkalasi ham o'z hajmini o'zgartirmaydilar. RenderWindow RenderTexturedan yoki undan yuqori bo'lsa, nima sodir bo'lishini men ko'rsataman.
qo'shib qo'ydi muallif Alessandro Pezzato, manba