Results 1 to 9 of 9

Thread: Best way to render big background?

  1. #1
    Squire
    Join Date
    Aug 2011
    Posts
    21

    Default Best way to render big background?

    Whats the best way in clanlib to render the big background image in a rts-style world? The idea is to show a part of an image inside the displayed window.

    One solution is to just create a huge sprite, and when rendering that, it shows only the part visible in the window. However, I feel that this is not very efficient, and besides, it doesn't work on some graphics cards...

    Any ideas?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    How big is big?

    Do you plan to handpaint/render the entire background, or compose it using separate parts/tiles?

  3. #3
    Squire
    Join Date
    Aug 2011
    Posts
    21

    Default

    Yes, the idea is to have one big image, and no tiles.

    The test background I have is about 3000x3000 pixels, what works on some graphics cards, and gives a black image on others...

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    You are basically limited to the max texture size of the graphic cards. These days most support 4096x4096, but I guess on some crappier laptop / intel cards, the limit is 2048x2048.

    An option is to split the huge background into smaller parts, for instance 1024x1024 or 2048x2048, and create some logic that only draws those textures that would be visible on the screen.

  5. #5
    Lesser Knight
    Join Date
    Nov 2010
    Location
    Winfield, BC Canada
    Posts
    32

    Default

    If the problem is drawing a huge image you might consider this....
    Specify a grid in your resource xml as to split the image up into frames.
    Here we have a 3000x3000 image split into 1/10th pieces ((10x300)x(10x300) grid)
    Code:
    <sprite name="bg-texture">
    	<image file="big-image.png">
    		<grid
    			size="300,300"
    			array="10,10"
    			spacing="0,0" />
    	</image>
    </sprite>
    Create your sprite, do the math for the sector you need to display, set the frames, draw.
    Never tried with such a large image but it should work.

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

    Default

    What I used to do in mid 1990's is to create a small "template" image with all the items I plan to use in the entire level.

    Then using a grid on the paint package set to a constant (usually 32x32 pixels).

    Copy from the template onto a large level image

    Then I ran a program to inspect the large level image finding unique occurances of 32x32 blocks to create 2 files.
    1) The unique blocks as a small image file
    2) A large level "map" containing offsets to the unique blocks

    The "map" could also contain attributes via a "map editor" for collision detection, baddies start points etc.

    I wish I did not loose the source code for the map editor and image to block converter many years ago

    I would love to write one again, there isn't a good free one out there.

    If only I had the time.

  7. #7
    Squire
    Join Date
    Aug 2011
    Posts
    21

    Default

    Thanks a lot for the answers! I think I will try it with the grid in the xml file... I didn't know that ClanLib had this option. Sounds quite usefule.

    By the way, cool idea with the template and unique occurrences, rombust. If you ever find the code for that again, I'll be glad to try it

  8. #8
    Lesser Knight
    Join Date
    Nov 2010
    Location
    Winfield, BC Canada
    Posts
    32

    Default

    Check out these two pages, they've got everything you need to use the xml resource.

    http://www.clanlib.org/wiki/MainDocs:Sprite_Resources
    http://codegrind.net/2010/09/30/clan...art-2-visuals/

  9. #9
    Squire
    Join Date
    Aug 2011
    Posts
    21

    Default

    Great, I'll have a look at them, thank you!

Similar Threads

  1. draw sprites without background
    By Koli14 in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 01-14-2010, 09:26 AM
  2. Background animation?
    By NinjaNumberNine in forum Novashell Game Creation System
    Replies: 6
    Last Post: 11-19-2009, 03:24 AM
  3. Render Targets
    By ShadowDust in forum Novashell Game Creation System
    Replies: 0
    Last Post: 12-21-2008, 08:13 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. how to create a window with picture background
    By gison in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 06-05-2007, 01:34 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
  •