[SOLVED] Ogre 1.9 RC2/"stable" + Android + libRocket
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
[SOLVED] Ogre 1.9 RC2/"stable" + Android + libRocket
I tried to use the new Ogre 1.9 RC2/"stable" using libRocket on Android. I used my project running just fine on 1.9 RC1 and did not change anything but the Ogre version.
(original thread: http://www.ogre3d.org/forums/viewtopic. ... 76#p493576)
Now i get those strange font errors:
Again: nothing changed but the Ogre RC version! Did anyone else tried to use libRocket on Ogre 1.9 RC2 @ Android?
Looks like the IOS error mentioned sometimes before: http://www.ogre3d.org/forums/viewtopic. ... os#p480978
(original thread: http://www.ogre3d.org/forums/viewtopic. ... 76#p493576)
Now i get those strange font errors:
Again: nothing changed but the Ogre RC version! Did anyone else tried to use libRocket on Ogre 1.9 RC2 @ Android?
Looks like the IOS error mentioned sometimes before: http://www.ogre3d.org/forums/viewtopic. ... os#p480978
Last edited by technique on Sun Dec 08, 2013 7:58 pm, edited 2 times in total.
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Gnoblar
- Posts: 4
- Joined: Fri Jun 14, 2013 12:43 am
Re: Ogre 1.9 RC2 + Android + libRocket
Same problem here but with the latest Ogre 1.10 source.
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2 + Android + libRocket
Thank you for you reply!
Today i found a workaround for the problem. In the libRocket-Wrapper, RocketApplication.cpp there is the ConfigureRenderSystem()-method which set up the render-system for gui-system.
I ve recognized the texture filtering is not longer working correctly using the wrapper. I added the line
to the method RenderCompiledGeometry() in the RenderInterfaceOgre3D.cpp
and i also repaced the "render_system->_disableTextureUnit(0);" with a 1x1 texture using "render_system->_setTexture( 0, true, mBlankTexture);" to display colored librockets elements correctly.
Create a texture using this line:
where "blank.png" is a white RGBA32-Texture.
This way, solid colored elements are rendered correctly and the font problem is gone. I think the rendersystem texture-filter configuration is in the wrong state while rendering. might be due to some ogre3d internal changes.
Would be great if you can check if the solution is working @ 1.10!
Today i found a workaround for the problem. In the libRocket-Wrapper, RocketApplication.cpp there is the ConfigureRenderSystem()-method which set up the render-system for gui-system.
I ve recognized the texture filtering is not longer working correctly using the wrapper. I added the line
Code: Select all
render_system->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);
Code: Select all
void RenderInterfaceOgre3D::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation)
{
render_system = Ogre::Root::getSingleton().getRenderSystem();
Ogre::Matrix4 transform;
transform.makeTrans(translation.x, translation.y, 0);
render_system->_setWorldMatrix(transform);
Ogre::Matrix4 projection_matrix;
BuildProjectionMatrix(projection_matrix);
mVertexProgramParams->setNamedConstant("worldViewProj", projection_matrix * transform);
render_system->bindGpuProgramParameters(Ogre::GPT_VERTEX_PROGRAM, mVertexProgramParams, Ogre::GPV_ALL);
RocketOgre3DCompiledGeometry* ogre3d_geometry = (RocketOgre3DCompiledGeometry*) geometry;
if (ogre3d_geometry->texture != NULL)
{
render_system->_setTexture(0, true, ogre3d_geometry->texture->texture);
[color=#008000] // ADD THIS LINE:
render_system->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);[/color]
// Ogre can change the blending modes when textures are disabled - so in case the last render had no texture,
// we need to re-specify them.
render_system->_setTextureBlendMode(0, colour_blend_mode);
render_system->_setTextureBlendMode(0, alpha_blend_mode);
}
else
{
// ADD THIS LINE:
[color=#008000] render_system->_setTextureUnitFiltering(0, Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_POINT);[/color]
// render_system->_disableTextureUnit(0);
render_system->_setTexture( 0, true, mBlankTexture);
}
render_system->_render(ogre3d_geometry->render_operation);
}
Create a texture using this line:
Code: Select all
mBlankTexture = texture_manager->load("blank.png",
"Rocket",
Ogre::TEX_TYPE_2D,
0);
This way, solid colored elements are rendered correctly and the font problem is gone. I think the rendersystem texture-filter configuration is in the wrong state while rendering. might be due to some ogre3d internal changes.
Would be great if you can check if the solution is working @ 1.10!
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Gnoblar
- Posts: 4
- Joined: Fri Jun 14, 2013 12:43 am
Re: Ogre 1.9 RC2 + Android + libRocket
Great job !
I can verify it works for 1.10, however the bug reappears if the android surface regains focus. Is this the case for 1.9 also?
I can verify it works for 1.10, however the bug reappears if the android surface regains focus. Is this the case for 1.9 also?
-
- OGRE Expert User
- Posts: 1119
- Joined: Sat Jan 01, 2011 7:57 pm
- x 216
Re: Ogre 1.9 RC2 + Android + libRocket
Sounds like that should be reported as a bug on the JIRA tracker.and i also repaced the "render_system->_disableTextureUnit(0);" with a 1x1 texture using "render_system->_setTexture( 0, true, mBlankTexture);" to display colored librockets elements correctly.
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2 + Android + libRocket
Sadly - yes! The fonts disappear completly but all texts set up programmatically are displayed correctly. I m not sure if this is Ogre related or just a ogre-libRocket-interface implementation fault. I'll try to get rid of this - if i m successful i ll post my solution here.mega28 wrote:Great job !
I can verify it works for 1.10, however the bug reappears if the android surface regains focus. Is this the case for 1.9 also?
Okay!Sounds like that should be reported as a bug on the JIRA tracker.
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2 + Android + libRocket
Same problem for Ogre 1.9 "stable"...
Didnt found a workaround yet - if the focus is lost - all fonts are gone except for those created after the focus is gained again.
Didnt found a workaround yet - if the focus is lost - all fonts are gone except for those created after the focus is gained again.
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
- masterfalcon
- OGRE Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
- Contact:
Re: Ogre 1.9 RC2/"stable" + Android + libRocket
You did report this, correct? Is it OGRE-336 in JIRA?
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2/"stable" + Android + libRocket
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2/"stable" + Android + libRocket
I added two full OpenGL ES traces of the first frame while starting the app (working) and lose focus and gain focus again (not working) + diff on JIRA (https://ogre3d.atlassian.net/browse/OGRE-336?filter=-2).
Lot of calls - but may be helpful for somebody who knows how ogres opengl es rendersystem works.
As it might be a texture problem i just filtered for the glTex*-calls and for the working trace they are 824 and for the bad trace there are only 822 on frame one. Sound far-fetched but maybe there are some missing texture calls - so any states are missing?
The same for the c-Call on the working frame 303 and on the not working one only 300. Since its the same App and there are no monte-carlo-algorithm inside the rendersystem the opengl-texture calls should be the same?
*update* Added context_state.txt - containg the whole GL_STATE for the first context (working) and the second one (not working) - the second one begins on line 5236! The second context have much less information after the first frame.
Lot of calls - but may be helpful for somebody who knows how ogres opengl es rendersystem works.
As it might be a texture problem i just filtered for the glTex*-calls and for the working trace they are 824 and for the bad trace there are only 822 on frame one. Sound far-fetched but maybe there are some missing texture calls - so any states are missing?
The same for the c-Call on the working frame 303 and on the not working one only 300. Since its the same App and there are no monte-carlo-algorithm inside the rendersystem the opengl-texture calls should be the same?
*update* Added context_state.txt - containg the whole GL_STATE for the first context (working) and the second one (not working) - the second one begins on line 5236! The second context have much less information after the first frame.
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2/"stable" + Android + libRocket
I found that i need to reinitilize the font textures generated by the libRocket RenderInterfaceOgre3D. All Ogre automatically added resources are reloaded before the focus is gained again. The manual created textures of the RenderInterfaceOgre3D::GenerateTexture() method are just not recreated. I tried to use the old OgreTexturePtr and loadRawData() and / or reload() to recreate the texture content but the texture is just black so the fonts are just black too.
I read about a similiar problem here http://www.ogre3d.org/forums/viewtopic. ... re#p491591.
I have no idea how to reinitialize the textureptr without changing the texture handle that libRocket uses internal.
I read about a similiar problem here http://www.ogre3d.org/forums/viewtopic. ... re#p491591.
I have no idea how to reinitialize the textureptr without changing the texture handle that libRocket uses internal.
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender
-
- Halfling
- Posts: 91
- Joined: Fri Oct 22, 2010 10:46 pm
- x 8
Re: Ogre 1.9 RC2/"stable" + Android + libRocket
Okay i solved the problem and found a workaround! The problem is described in my last post - the manual font textures are not regenerated after switching the context (app->homescreen->app). You need to save the raw data used to create the texture the first time and recreate it manually after switching back to the app.
Here comes the step by step guide:
1. Backup the raw data used to create the font texture.
- Create a struct to backup the texture information in RenderInterfaceOgre3D.h
To use the RocketOgre3DTexture struct move it from RenderInterfaceOgre3D.cpp to the header above the FontTextureBack declaration.
- Add a container to store the texture informations - i use just a std::vector for that purpose. Put it as a member in RenderInterfaceOgre3D.h
2. Backup the complete texture informations on creation. Replace the old GenerateTexture() method in RenderInterfaceOgre3D with the following code:
3. Create a new method in the RenderInterfaceOgre3D - class.
Since the RenderCompiledGeometry() method just binds the TexturePtr from the RocketOgre3DTexture struct - replacing the pointer with the new generated one did the trick!
4. Add a method-call in the handleCmd() to call the method above.
- add void reloadFontTextures(); to the RocketApplication and call the reload method
- add to handleCmd() (main.cpp) in the case APP_CMD_INIT_WINDOW - just right after static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_createInternalResources(app->window, config) our new reload method gRocketApplication->reloadFontTextures().
Voilà!
Here comes the step by step guide:
1. Backup the raw data used to create the font texture.
- Create a struct to backup the texture information in RenderInterfaceOgre3D.h
Code: Select all
struct FontTextureBackup
{
Rocket::Core::byte* mSource;
Rocket::Core::Vector2i mSourceDimensions;
Rocket::Core::String mName;
RocketOgre3DTexture* mRocketTexture;
};
- Add a container to store the texture informations - i use just a std::vector for that purpose. Put it as a member in RenderInterfaceOgre3D.h
Code: Select all
std::vector<FontTextureBackup*> mBackupFontTextures;
Code: Select all
bool RenderInterfaceOgre3D::GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions)
{
static int texture_id = 1;
Ogre::DataStreamPtr stream = Ogre::DataStreamPtr(new Ogre::MemoryDataStream((void*) source, source_dimensions.x * source_dimensions.y * sizeof(unsigned int)));
Rocket::Core::String name = Rocket::Core::String(16, "%d", texture_id++);
Ogre::TexturePtr ogre_texture = Ogre::TextureManager::getSingleton().loadRawData(name.CString(),
"Rocket",
stream,
(unsigned short)(source_dimensions.x),
(unsigned short)(source_dimensions.y),
Ogre::PF_A8B8G8R8,
Ogre::TEX_TYPE_2D,
0);
if (ogre_texture.isNull())
{
return false;
}
FontTextureBackup* backup = new FontTextureBackup();
backup->mSource = (Rocket::Core::byte*) malloc(source_dimensions.x * source_dimensions.y * sizeof(unsigned int));
memcpy(backup->mSource, source, source_dimensions.x * source_dimensions.y * sizeof(unsigned int));
backup->mName = name;
backup->mSourceDimensions = source_dimensions;
backup->mRocketTexture = new RocketOgre3DTexture(ogre_texture);
mBackupFontTextures.push_back(backup);
texture_handle = reinterpret_cast<Rocket::Core::TextureHandle>(backup->mRocketTexture);
return true;
}
Code: Select all
void RenderInterfaceOgre3D::reloadFontTexture()
{
for(int i = 0; i < mBackupFontTextures.size(); i++)
{
FontTextureBackup* t = mBackupFontTextures.at(i);
Ogre::TextureManager::getSingleton().remove(t->mRocketTexture->texture->getName());
Ogre::DataStreamPtr stream = Ogre::DataStreamPtr(new Ogre::MemoryDataStream((void*) mBackupFontTextures.at(i)->mSource,
mBackupFontTextures.at(i)->mSourceDimensions.x * mBackupFontTextures.at(i)->mSourceDimensions.y * sizeof(unsigned int)));
Ogre::TexturePtr ogre_texture = Ogre::TextureManager::getSingleton().loadRawData(mBackupFontTextures.at(i)->mName.CString(),
"Rocket",
stream,
(unsigned short)(mBackupFontTextures.at(i)->mSourceDimensions.x),
(unsigned short)(mBackupFontTextures.at(i)->mSourceDimensions.y),
Ogre::PF_A8B8G8R8,
Ogre::TEX_TYPE_2D,
0);
t->mRocketTexture->texture = ogre_texture;
}
}
4. Add a method-call in the handleCmd() to call the method above.
- add void reloadFontTextures(); to the RocketApplication and call the reload method
Code: Select all
void RocketApplication::reloadFontTextures()
{
ogre_renderer->reloadFontTexture();
}
Voilà!
Kingdoms Defender offers Tower Defense action with breathtaking 3-D graphics for your mobile Android device.
Give it a try:
Free-Version:
http://play.google.com/store/apps/detai ... ender_free
Full-Version:
http://play.google.com/store/apps/detai ... msdefender