RTT by RenderTarget

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
pasu
Gnoblar
Posts: 6
Joined: Fri Aug 12, 2011 7:33 am

RTT by RenderTarget

Post by pasu »

Hello,I need a function that create a texture and render some objects on the texture,then i want to get the texture buffer.The code is as follow:

Code: Select all

// Create RTT texture
Ogre::TexturePtr texture = TextureManager::getSingleton().createManual("Rtt", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 1024, 768, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET, 0, false, 16);   

// some ro render then ...

// get bits from the texture
size_t tDepth = texture->getDepth();
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
byte* pData = (byte*)(pixelBuffer->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
pixelBuffer->unlock();
the problems is:
my graphics card is GeoForce210 and it runs well on the Win7 with RenderSystem_GL,but I switch the rendersystem as RenderSystem_GLES2,it could not work on my computer,I am not sure about two points:

1.create the RTT in GLES2
i changed the format as R8G8B8,the texture is created well,could I think that the issue is about my graphics card that not support RGBA format?
i run it on another computer with graphics card geoforce gt 640,it also can not work.
2.how to get bits in GLES2
i debug the code and it says not support by OpenGL ES in the function GLES2TextureBuffer::download(const PixelBox &data),is there some ways else i can realise my purpose?

i hope someone can give me some suggestions,thanks very much.
pasu
Gnoblar
Posts: 6
Joined: Fri Aug 12, 2011 7:33 am

Re: RTT by RenderTarget

Post by pasu »

i write code that realise the RTT through opengles2 without ogre,and it is successful,i debug the code and find the different,i am not sure that it is a bug to ogre.

the difference is in the GLES2Texture::createInternalResourcesImpl(void),
at first,i set the value of mFormat as Ogre::R8G8B8A ,but during the function getNativeFormat,it becomes as Ogre::A8R8G8B8,but it affects the variables format and internalformat(format is GL_BGRA and internalformat is GL_RGBA) and they are used in the glTexImage2D(),in RenderSystem_GL,it will be ok,but in RenderSystem_GLES2,it will make the status of glCheckFramebufferStatus() not right(in GLES2FrameBufferObject::initialise) .

i change the source code that maks the format and internalformat equals each other and finially it is ok,i am not sure whether it is right.
Post Reply