Note that there are some explanatory texts on larger screens.

plurals
  1. POtexture problems with librocket, ogre & ios
    primarykey
    data
    text
    <p>We are trying to use librocket <a href="http://librocket.com/" rel="nofollow">http://librocket.com/</a> together with Ogre <a href="http://www.ogre3d.org/" rel="nofollow">http://www.ogre3d.org/</a>. They're both part of gamekit <a href="http://code.google.com/p/gamekit/" rel="nofollow">http://code.google.com/p/gamekit/</a> which I use for this project.</p> <p>This all works fine together as long as I don't load an image with librocket. As soon as I do that the viewport on the iPad is not fullscreen anymore but small in the lower corner. Like this: <a href="http://uploads.undef.ch/machine/ipad.png" rel="nofollow">http://uploads.undef.ch/machine/ipad.png</a></p> <p>I can't make a connection between loading/rendering a texture and resizing of the viewport. And I can't find anything wrong with the RenderInterface. <a href="http://uploads.undef.ch/machine/RenderInterfaceOgre3D.cpp" rel="nofollow">http://uploads.undef.ch/machine/RenderInterfaceOgre3D.cpp</a></p> <p>Is there any OpenGLES command that could have an affect on the active viewport size?</p> <p>This is the relevant code that loads an image and displays it:</p> <pre><code>// Called by Rocket when a texture is required by the library. bool RenderInterfaceOgre3D::LoadTexture(Rocket::Core::TextureHandle&amp; texture_handle, Rocket::Core::Vector2i&amp; texture_dimensions, const Rocket::Core::String&amp; source) { Ogre::TextureManager* texture_manager = Ogre::TextureManager::getSingletonPtr(); Ogre::TexturePtr ogre_texture = texture_manager-&gt;getByName(Ogre::String(source.CString())); if (ogre_texture.isNull()) { ogre_texture = texture_manager-&gt;load(Ogre::String(source.CString()), DEFAULT_ROCKET_RESOURCE_GROUP, Ogre::TEX_TYPE_2D, 0); } if (ogre_texture.isNull()) return false; texture_dimensions.x = ogre_texture-&gt;getWidth(); texture_dimensions.y = ogre_texture-&gt;getHeight(); texture_handle = reinterpret_cast&lt;Rocket::Core::TextureHandle&gt;(new RocketOgre3DTexture(ogre_texture)); return true; } // Called by Rocket when it wants to render geometry that it does not wish to optimise. void RenderInterfaceOgre3D::RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f&amp; translation) { // We've chosen to not support non-compiled geometry in the Ogre3D renderer. // But if you want, you can uncomment this code, so borders will be shown. /* Rocket::Core::CompiledGeometryHandle gh = CompileGeometry(vertices, num_vertices, indices, num_indices, texture); RenderCompiledGeometry(gh, translation); ReleaseCompiledGeometry(gh); */ } // Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future. Rocket::Core::CompiledGeometryHandle RenderInterfaceOgre3D::CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture) { RocketOgre3DCompiledGeometry* geometry = new RocketOgre3DCompiledGeometry(); geometry-&gt;texture = texture == NULL ? NULL : (RocketOgre3DTexture*) texture; geometry-&gt;render_operation.vertexData = new Ogre::VertexData(); geometry-&gt;render_operation.vertexData-&gt;vertexStart = 0; geometry-&gt;render_operation.vertexData-&gt;vertexCount = num_vertices; geometry-&gt;render_operation.indexData = new Ogre::IndexData(); geometry-&gt;render_operation.indexData-&gt;indexStart = 0; geometry-&gt;render_operation.indexData-&gt;indexCount = num_indices; geometry-&gt;render_operation.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST; // Set up the vertex declaration. Ogre::VertexDeclaration* vertex_declaration = geometry-&gt;render_operation.vertexData-&gt;vertexDeclaration; size_t element_offset = 0; vertex_declaration-&gt;addElement(0, element_offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION); element_offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); vertex_declaration-&gt;addElement(0, element_offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE); element_offset += Ogre::VertexElement::getTypeSize(Ogre::VET_COLOUR); vertex_declaration-&gt;addElement(0, element_offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES); #if GK_PLATFORM == GK_PLATFORM_APPLE_IOS // Create the vertex buffer. Ogre::HardwareVertexBufferSharedPtr vertex_buffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(vertex_declaration-&gt;getVertexSize(0), num_vertices, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,true); geometry-&gt;render_operation.vertexData-&gt;vertexBufferBinding-&gt;setBinding(0, vertex_buffer); // Fill the vertex buffer. RocketOgre3DVertex* ogre_vertices = (RocketOgre3DVertex*) vertex_buffer-&gt;lock(0, vertex_buffer-&gt;getSizeInBytes(), Ogre::HardwareBuffer::HBL_DISCARD); #else Ogre::HardwareVertexBufferSharedPtr vertex_buffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(vertex_declaration-&gt;getVertexSize(0), num_vertices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); geometry-&gt;render_operation.vertexData-&gt;vertexBufferBinding-&gt;setBinding(0, vertex_buffer); // Fill the vertex buffer. RocketOgre3DVertex* ogre_vertices = (RocketOgre3DVertex*) vertex_buffer-&gt;lock(0, vertex_buffer-&gt;getSizeInBytes(), Ogre::HardwareBuffer::HBL_NORMAL); #endif for (int i = 0; i &lt; num_vertices; ++i) { ogre_vertices[i].x = vertices[i].position.x; ogre_vertices[i].y = vertices[i].position.y; ogre_vertices[i].z = 0; Ogre::ColourValue diffuse(vertices[i].colour.red / 255.0f, vertices[i].colour.green / 255.0f, vertices[i].colour.blue / 255.0f, vertices[i].colour.alpha / 255.0f); render_system-&gt;convertColourValue(diffuse, &amp;ogre_vertices[i].diffuse); ogre_vertices[i].u = vertices[i].tex_coord[0]; ogre_vertices[i].v = vertices[i].tex_coord[1]; } vertex_buffer-&gt;unlock(); #if GK_PLATFORM == GK_PLATFORM_APPLE_IOS // Create the index buffer. Ogre::HardwareIndexBufferSharedPtr index_buffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_16BIT, num_indices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); geometry-&gt;render_operation.indexData-&gt;indexBuffer = index_buffer; geometry-&gt;render_operation.useIndexes = true; #else Ogre::HardwareIndexBufferSharedPtr index_buffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(Ogre::HardwareIndexBuffer::IT_32BIT, num_indices, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); geometry-&gt;render_operation.indexData-&gt;indexBuffer = index_buffer; geometry-&gt;render_operation.useIndexes = true; #endif // Fill the index buffer. unsigned short * ogre_indices = (unsigned short*)index_buffer-&gt;lock(0, index_buffer-&gt;getSizeInBytes(), Ogre::HardwareBuffer::HBL_NORMAL); #if GK_PLATFORM == GK_PLATFORM_APPLE_IOS //unsigned short short_indices[num_indices]; for(int i=0;i&lt;num_indices;i++) ogre_indices[i] = indices[i]; //memcpy(ogre_indices, short_indices, sizeof(unsigned short) * num_indices); #else memcpy(ogre_indices, indices, sizeof(unsigned int) * num_indices); #endif index_buffer-&gt;unlock(); return reinterpret_cast&lt;Rocket::Core::CompiledGeometryHandle&gt;(geometry); } // Called by Rocket when it wants to render application-compiled geometry. void RenderInterfaceOgre3D::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f&amp; translation) { Ogre::Matrix4 transform; transform.makeTrans(translation.x, translation.y, 0); render_system-&gt;_setWorldMatrix(transform); render_system = Ogre::Root::getSingleton().getRenderSystem(); RocketOgre3DCompiledGeometry* ogre3d_geometry = (RocketOgre3DCompiledGeometry*) geometry; if (ogre3d_geometry-&gt;texture != NULL) { render_system-&gt;_setTexture(0, true, ogre3d_geometry-&gt;texture-&gt;texture); // 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-&gt;_setTextureBlendMode(0, colour_blend_mode); render_system-&gt;_setTextureBlendMode(0, alpha_blend_mode); } else render_system-&gt;_disableTextureUnit(0); render_system-&gt;_render(ogre3d_geometry-&gt;render_operation); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload