Clipping

edited February 2015 in Help request
Hi,
while implementing the custom CEGUI renderer for the orx I stumbled on the clipping.

I would need to set clipping in some circumstances. I don't want to use direct OpenGL calls, only the orx API.

So what are the options here?

Thanks

Comments

  • edited February 2015
    Can you describe the problem a little further?

    When I needed to do that in my game I simply used orxObject_Enable but it was a very simple case.
  • edited February 2015
    orxDisplay_SetBitmapClipping() should be what you need, if I understand your question.
  • edited February 2015
    Yes, my description was poor, sorry.

    I've implemented the custom renderer (and other classes) for the CEGUI. But sometimes, CEGUI need to draw only to a portion of the screen, so only this portion should be updated (so if screen is 800x600 and clipping rect is set to (400, 300, 450, 350), the stuff drawn beyond the rect shouldn't be shown).

    For now I'm drawing the GUI with orxDisplay_DrawMesh() and computing the transformations by custom transformation matrix etc (but would like to get rid of). I'm using orxDisplay_DrawMesh() because I've got only vertices from the CEGUI and therefor need to generate the mesh from them. So I don't think I could use orxObjects, I would need to use some heuristic to find out if the polygon is a rectangle etc.

    I was looking at orxDisplay_SetBitmapClipping() but as I understand it, it could be use only if I'm using texture as a render target, right? So maybe I could create the new GUI camera, render there the stuff and then show the image on the screen? But could I use orxDisplay_DrawMesh() with this? Wouldn't the orxDisplay_DrawMesh() bypass the camera altogether?

    Or should I use some other work flow?

    Thank You
  • edited February 2015
    orxDisplay_SetBitmapClipping() works on screen as well, just pass it the result of orxDisplay_GetScreenBitmap(). It'll issue a glScissor() command. And it should work just fine with orxDisplay_DrawMesh() (which does bypass the camera, but not the OpenGL scissor command).
  • edited February 2015
    Thanks for the reply,
    that works like a charm :)

    Is there any way to get the actual clipping? Because after the CEGUI rendering I want to restore the previous clipping. For now I'm setting the clipping to the display bitmap. But I would rather restore what it was. Can it be done somehow (glGet() with GL_SCISSOR_BOX)?

    Thanks
  • edited February 2015
    I'm glad it worked! :)

    Yes, you can retrieve the current scissor values this way and restore it manually later on. If it turns up to be a performance bottleneck (because of the CPU-GPU sync point it introduces), I could add the glscissor reset in the orxDisplay_SetVideo_Mode(orxNULL). :)
  • edited February 2015
    As I have said I would rather not use direct OGL calls. What I meant, is to make it as API function in orx ;) But the workaround for now is OK.

    As you said maybe it would be better to reset the scissor in the orxDisplay_SetVideo_Mode(orxNULL). So I would let it be for now and when I encounter some problems, we could discuss it later then.
  • edited February 2015
    Trigve wrote:
    As I have said I would rather not use direct OGL calls. What I meant, is to make it as API function in orx ;) But the workaround for now is OK.

    As you said maybe it would be better to reset the scissor in the orxDisplay_SetVideo_Mode(orxNULL). So I would let it be for now and when I encounter some problems, we could discuss it later then.

    Ok! Adding it is really straightforward and I can't think of a reason to not have it there so I'll probably add it. :)
Sign In or Register to comment.