Fill an area with a texture

Hello.

I’m new to SDL. Please forgive me if I’m asking the obvious or so.
I’ve been reading tutorials on SDL and made some characters, moved them, animated them … everything went smoothly.
I’m trying to make per pixel collision. But first I wanna draw some ground for the characters to stand on. I have something like this on my mind:

[Image: http://www.image-upload.net/images/lhhh7dnydmjzyixt3ssj.png ]

I want to be able to create hills (think I need to draw arc?), but I have no idea how to fill the ground (the white area on the image) with a texture? I want to be able to tile my texture image on the ground. But the ground is not a rectangle. It can be any shape. How can I do this?

Thanks for your time

I edited my first post, uploaded the image somewhere else.

I’m not using openGL I guess. I’ve loaded sprites and clipped them and used SDL_BlitSurface() and SDL_Flip();
I have no idea how to fill inside of ANY shape with a texture. Also I want to move the character on those hills, so I g otta know the pixels of those arcs, right?

If you want to stick with 2D, you could use the SDL_gfx library to draw
your “ground”. SDL_gfx has a function which draws polygons filled with a
texture:
http://www.ferzkopp.net/Software/SDL_gfx-2.0/Docs/html/_s_d_l__gfx_primitives_8c.html#a65137af308ea878f28abc95419e8aef5

The library includes a test program that shows how to use it:
http://sdlgfx.svn.sourceforge.net/viewvc/sdlgfx/Test/TestGfxTexture.c?revision=22&view=markup

Cheers,
–AndreasOn 9/1/10 9:39 PM, Force wrote:

Hello.

I’m new to SDL. Please forgive me if I’m asking the obvious or so.
I’ve been reading tutorials on SDL and made some characters, moved
them, animated them … everything went smoothly.
I’m trying to make per pixel collision. But first I wanna draw some
ground for the characters to stand on. I have something like this on
my mind:

I want to be able to create hills (think I need to draw arc?), but I
have no idea how to fill the ground (the white area on the image) with
a texture? I want to be able to tile my texture image on the ground.
But the ground is not a rectangle. It can be any shape. How can I do this?

Thanks for your time


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks a lot and thanks for the example. Without it I still would be confused.

I think this is what I need :slight_smile: