It looks like you're new here. If you want to get involved, click one of these buttons!
// Called by Rocket when it wants to render geometry that it does not wish to optimise.
void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int ROCKET_UNUSED(num_vertices), int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
{
glPushMatrix();
glTranslatef(translation.x, translation.y, 0);
glVertexPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].position);
//glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rocket::Core::Vertex), &vertices[0].colour);
if (!texture)
{
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
else
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, (GLuint) texture);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].tex_coord);
}
//glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);
/*
** CRASHES AT THIS LINE
*/
glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, indices);
glPopMatrix();
}
Comments
Look for glPushAttrib and glPushClientAttrib on the net. However those aren't dispo for OpenGL ES I believe, which means you'll have to save everything you're going to modify manually, for example calling glGetPointerv before glVertexPointer/glColorPointer.
All this isn't very fun I know, so another option would be to call the orxDisplay_* interface instead. As long as you draw quads/polygons you should be able to do it without having to issue your own OpenGL calls.
Let me know if you have more troubles with that.
I added glPush and glPop around the rest of the function:
Same problem. Also, the crash happens the very first time that glDrawElements call is it, so it probably doesn't mean GL state corruption from the last frame, right?
I will pull this out of my Orx project and set up a very basic example in a barebones OpenGL project.
http://i.imgur.com/sCWuH.png
So yes.. looks like I need to save these pointers manually. I will try it.
Forgot to mention we're using an IBO (Index Buffer Object) for rendering, so if you don't unbind it, the last arg you send to your draw element code will make OpenGL look outside the buffer and crash.
You simply need to unbind it before your drawing call. Look for GL _ELEMENT_ARRAY_BUFFER_ARB in the glfw display plugin.
you can check this post maybe it will help
http://forums.librocket.com/viewtopic.php?f=6&t=870
iarwain
when you say:
I have no idea on what kind of geometry libRocket is using, the comments in the source referts to TRIANGLES and that vertex_num is always a multiple of 3, but not 6 (2 TRIANGLES)
so basically we should use orxDisplay_TransformBitmap / orxDisplay_BlitBitmap ?
lydesik
Thanks for that thread. I did come across it elsewhere. Right now, I'm just trying to get it to work on the computers. Getting close. I will post if/when I get it right.
Here's the full function on pastebin in case it helps anyone else: http://pastebin.com/ViDAgySd
Hopefully no one minds pastebin. I like it because the forum seems to lose indentation formatting.
How's the editor coming?
Here's what's left for my 'proof of concept' milestone:
- Finishing implementing WidgetManager for libRocket.
- Complete the Object Editor and FX Editor windows
- Complete save/load function for Orx config files
At that time, I will post details and see if anyone else wants to help with the project.
I've since noticed there's a "Save" flag for ScrollObjects which ScrollEd uses, so I might change it to use that instead.
Hopefully I can get some momentum and one or two other interested people and get an editor going. I think it would be great to have a config section editor that could work seamlessly alongside ScrollEd for map creation.
Good luck!
an UI manager/editor for orx would be awesome.
I'm ready to help you to make this works on Android
librocket has a reputation for good design, but I found the library is a lot less helpful than CEGUI. CEGUI has a bad reputation around the internet for bloat and design, but most of its dependencies are optional, it has a lot of very helpful functions, and pretty much "just works" as is advertised.
For that reason, I'm continuing with CEGUI in my project. The librocket support is still there in a separate branch, but it's now out of sync with the master.
@lydesik, please check https://github.com/fmahnke/OrxCraft if you're interested in this project. I would love any help. graag has also taken an interest and has added some things in his own branches.