'Texturing' a 'Model'

edited May 2012 in Help request
Hello, here I am again wondering about an odd thing I've been using in the past.

The first thing I'd like to do is take the render and store it in a texture. Looking at the functions available, I think this is doable.

The second thing I'd like to do is to create a set of triangles (henceforth called a 'Model') in the 2D space. I want to set up my own shape, with UV's, and then dabbling the texture over it.

In OpenGL, this is quite easy, but as oRX probably never even heard of the term model, it gets tricky.

Another reason why I'd like this (triangles/models), is for procedurally generated stuff, where it also comes in useful.

Comments

  • edited May 2012
    So there are two parts there. The first one about rendering to a texture, you shouldn't have to use a lot of code if at all.
    A hint on how to do that with an additional viewport/camera can be seen on the compositing tutorial in the wiki.

    Now for rendering your own guy, well that's where custom rendering comes in. You can listen to the orxEVENT_TYPE_RENDER events and more specifically to the orxRENDER_EVENT_OBJECT_START one to override the rendering of an object.

    How does it work? Well you setup an object with a dummy graphic that uses the procedurally generated texture (it needs to have a graphic to be considered by the rendered and the graphic's size will be used for camera culling tests) and when you get that event for this guy, you simply draw the triangles you want in plain OpenGL (don't forget to save and restore the client/server states!).

    The texture will already be bind to OpenGL by orx so you only have to care about your vertices.
    When you've done rendering/restoring OpenGL states, return orxSTATUS_FAILURE from the event handler to let orx know that you don't want it to render the object (as you've already done it yourself). That's about it. :)

    Of course, if what you need doesn't require new vertices but just s fragment shader, this is supported out of the box without any need for custom rendering but you probably already know that. :)
  • edited May 2012
    Perfect, I won't be trying it for just a bit, but I hope to show something cool using this technique in a while :)

    Thanks for all your answers; and spamming up my inbox. But that's mostly my own fault :P
Sign In or Register to comment.