Results 1 to 10 of 10

Thread: Porting from 2.3 to 3.0

  1. #1
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default Porting from 2.3 to 3.0

    Hello again.
    I've decided to resume one of my old project and have to port it to 3.0 now, since I had a hdd crash with all of my dev environment, and only project's source was backuped on flash drive. So I've set up new environment with ClanLib 3.0(since 2.3 isn't supported anymore - I couldn't find dependency libraries for it so I had to go with 3.0).
    Well, there was some number of unpleasant surprises as always happens with SDK upgrades. Most confusing was resource manager overhaul - I completely don't understand how is it supposed to work now, with the absolute lack of the documentation and examples describing it. I found the way how to use it the old style, anyway. But now I've encountered a problem without any answer I could find so far:
    There was a pretty little functions in Sprite class - "set_angle_yaw" and "set_angle_pitch". I used them a lot for a number of graphic effects. And now they are gone. And I don't see anything replacing them. And now I have a lot of broken code without a way to repair it.
    Is it possible to return these function to Sprite class? Or is there some replacements I didn't find? I don't see any reason to remove such useful functions.

    I think there is one more serious problem ahead - with my custom batch renderer, but I didn't see into it yet.

  2. #2
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    I think I'll just implement these functions myself back from 2.3 source code, it's simple enough change.

    But I would greatly appreciate if someone described me how render batchers work in 3.0. There was very neat and simple system in 2.3, I implemented my own custom renderer very easy, but now I got confused with VertexArrayVector and VertexArrayBuffer needed for it to work. It seems that vertex data structure all render batchers take is hardcoded now and I couldn't figure out yet how to implement a custom renderer.

  3. #3
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    I'm not sure what you mean with the batcher syntax having changed. Looking at the source code in git master, I see the following definition:

    Code:
    class RenderBatcher
    {
    public:
      virtual void flush(GraphicContext &gc) = 0;
      virtual void matrix_changed(const Mat4f &modelview, const Mat4f &projection) = 0;
    };
    
    class Canvas
    {
      ...
      void set_batcher(RenderBatcher *batcher);
      ...
    };
    I haven't checked with 2.x, but I believe the syntax was the same back then? Either way, I don't know where you see a VertexArrayVector except in the implementation of the built-in batchers.

    If you're making a copy of the built-in batchers, maybe it is easier to just add the set_angle_yaw and set_angle_pitch functions back. They were probably removed mainly because we thought nobody used them.

    If its the buffers in RenderBatchBuffer that are confusing you, then the idea here is that the various built-in batchers can share certain GPU buffers (for memory efficiency). VertexArrayBuffer is the class for a generic memory buffer (on the GPU) for vertex data, while VertexArrayVector<T> simplifies accessing the contents of the buffer with a specific type. For example RenderBatchTriangle has a SpriteVertex struct with vertex attributes for triangles and VertexArrayVector<SpriteVertex> allows you to access the contents of a VertexArrayBuffer seen as an array of SpriteVertex elements.

    I can't remember the exact way set_angle_yaw and set_angle_pitch worked, but if they are just rotating the sprite in certain ways, then maybe the easiest way to add the feature back in is to add it to Sprite_Impl::draw. This is where the other sprite rotations and such are performed.

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    That's my fault.

    Looking at the SVN logs...

    30 May 2013 "Remove rotate_pitch and rotate_yaw because they were never set" ....
    26 October 2012 "Remove Sprite's angle_pitch and angle_yaw, the values were never used"

    Oh dear!

    The question is, should we restore them?


    Code:
    Revision: 9891
    Author: rombust
    Date: 30 May 2013 16:09:26
    Message:
    Since rotate_pitch and rotate_yaw doesn't even exist in clan::Sprite API, lets remove the uninitialised variables that are actually used
    ----
    Modified : /ClanLib/Development/ClanLib-3.0/Sources/Display/2D/sprite_impl.cpp
    Modified : /ClanLib/Development/ClanLib-3.0/Sources/Display/2D/sprite_impl.h
    Code:
    Revision: 8416
    Author: rombust
    Date: 26 October 2012 13:56:41
    Message:
    Remove Sprite's angle_pitch and angle_yaw ... Which actually did not work anyway, the values were never used!
    ----
    Modified : /ClanLib/Development/ClanLib-2.4/Sources/API/Display/2D/sprite.h
    Modified : /ClanLib/Development/ClanLib-2.4/Sources/Display/2D/sprite.cpp
    Modified : /ClanLib/Development/ClanLib-2.4/Sources/Display/2D/sprite_impl.cpp
    Modified : /ClanLib/Development/ClanLib-2.4/Sources/Display/2D/sprite_impl.h

  5. #5
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    Quote Originally Posted by Judas View Post
    They were probably removed mainly because we thought nobody used them.
    The question is, should we restore them?
    I used them! A lot!
    Please restore them.

  6. #6
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    As for RenderBatcher, the main problem is in PrimitivesArray class. Previously it's set_attributes function took only a pointer to the data array(of simple data types that I filled myself with my data in simple and easy way). Now it takes VertexArrayVector and... offset?(btw there is cl_ prefix in macros cl_offsetof used there) And I don't know where to go from there. I have my vertex data filled in three arrays(positions, colors, tex_coords) by my custom draw function and when there is time to flush it to render batcher, I don't quite understand how to form a PrimitivesArray from it. Previously my code for rendering looked like this:
    Code:
    	CL_PrimitivesArray primarray(gc);
    	primarray.set_attributes(0, positions);
    	primarray.set_attributes(1, colors);
    	primarray.set_attributes(2, tex1_coords);
    
    	gc.set_texture(0, current_texture);
    	gc.set_program_object(cl_program_single_texture);
    	gc.draw_primitives(cl_triangles, cur_position, primarray);
    	gc.reset_program_object();
    	gc.reset_texture(0);
    
    	cur_position = 0;
    	current_texture = CL_Texture();
    That was simple and worked perfectly. But how do I implement it now?

  7. #7
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by Noro View Post
    I used them! A lot!
    Please restore them.
    I have added them back into ClanLib 4.0

    I have not got time to update ClanLib 3.0 stable release, and I think it would be foolish to update it anyway. ClanLib 4.0 API is very close to ClanLib 3.0 with unmaintained and obsolete parts taken out ... that as far as I know, nobody uses.

  8. #8
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    Quote Originally Posted by rombust View Post
    I have added them back into ClanLib 4.0

    I have not got time to update ClanLib 3.0 stable release, and I think it would be foolish to update it anyway. ClanLib 4.0 API is very close to ClanLib 3.0 with unmaintained and obsolete parts taken out ... that as far as I know, nobody uses.
    Is there some list of these parts that were taken out?

    And what about changed PrimitivesArray implementation?

  9. #9
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    Please help with render batcher
    It was so simple and nicely working before, and now I can't get it to work.

  10. #10
    Lesser Knight
    Join Date
    Jul 2011
    Posts
    57

    Default

    Disregard this, I refactored previous code to use Canvas.fill_triangles() with the same result as previous implementation.
    Now I have finished with porting to 3.0 and can continue development
    Thank you anyway, and thank you for your work on ClanLib.

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 03:43 AM
  2. Porting Novashell to Pandora
    By LairdPleng in forum Novashell Game Creation System
    Replies: 5
    Last Post: 03-22-2011, 09:45 AM
  3. Porting 1.0 to 2.0
    By rombust in forum Official ClanLib SDK Forums
    Replies: 9
    Last Post: 10-01-2010, 07:21 PM
  4. Porting?
    By orgos in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 08-19-2009, 06:44 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •