Results 1 to 5 of 5

Thread: Scaling sprites without smoothing or anti-aliasing

  1. #1

    Default Scaling sprites without smoothing or anti-aliasing

    First of all I would like to thank ClanLib developers for creating this great piece of software. I am working on a retro-MMORPG and in 3 days I managed to create a client & server enabling the user to log in, interact with other players and walk on a map using animated sprites. Awesome framework.

    Anyway, due to the retro-nature of my graphics I wanted to use low-res sprites and render them x2 the size. When I use the scale attribute in my resources file, the sprite is bigger but the edges are blurred. Is there a way of scaling the sprite without using anti-aliasing?

    Any help will be much appreciated.

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

    Default

    If using CL_Sprite:

    Code:
    void CL_Sprite::set_linear_filter  ( bool  linear_filter = true  )   
    
    Set to true if a linear filter should be used for scaling up and down, false if a nearest-point filter should be used.
    You cannot specify that flag in the resources, but it should be easy for you to patch clanlib to let you do that.

  3. #3

    Default

    Wow, how did I miss that? Thanks.

    Related question, after scaling, if I try to get the height of the sprite object, will it return the original height or the actual height? Also, any way to set 'global' scale?

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

    Default

    Quote Originally Posted by Maciej Baron View Post
    Wow, how did I miss that? Thanks.

    Related question, after scaling, if I try to get the height of the sprite object, will it return the original height or the actual height? Also, any way to set 'global' scale?
    It should return the original height. (I have not checked)

    For the scaled width, it's simply: scaled_width = original_width * scale_x

    Setting the global scale, you need to modify the modelview matrix.

    If the "standard" screen is 800x600 use:

    Code:
    CL_Mat4f matrix = CL_Mat4f::scale( (float) gc.get_width() / 800.0f, (float) gc.get_height() / 600.0f, 1.0f);
    gc.set_modelview(matrix);
    That will scale the graphics to whatever the display window size is (even fullscreen)

  5. #5

    Default

    Thank you ever so much, that was really helpful.

Similar Threads

  1. Menu auto-scaling
    By BigBMan in forum Proton SDK
    Replies: 13
    Last Post: 02-07-2011, 02:10 AM
  2. Possible Bug? Scaling and clipped frames.
    By catch22 in forum Official ClanLib SDK Forums
    Replies: 14
    Last Post: 06-11-2009, 12:25 PM
  3. font anti alias issue
    By alpharesearch in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 05-20-2009, 08:41 AM
  4. Scaling when some tile of parallaxed background selected.
    By Rrrichi in forum Novashell Game Creation System
    Replies: 4
    Last Post: 06-13-2007, 03:11 AM
  5. sprites
    By seyah3 in forum Dink Smallwood HD
    Replies: 0
    Last Post: 02-03-2006, 03:05 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
  •