Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working with SFML right now, and upon finishing the tutorials I still do not know how to give a shape a texture or image -- not just a solid color/outline.

The only thing I know can take an image is a sprite, but thats way to simple, as it only allows you to render rectangular images in a rectangluar way!

What are the techniques for rendering images onto shapes, and only inside the shape? It would be great if some of you could provide some resources or SFML-specific stuff!

share|improve this question
    
Griffin, I answered this when you asked on SO. The answer is the same as Josh's... –  Zack The Human Jul 9 '11 at 4:44
    
i put the answer on both sites right away, hoping i'd get an answer on 1 –  Griffin Jul 9 '11 at 6:53
add comment

1 Answer

up vote 2 down vote accepted

I don't think you can do this directly using SFML. It looks like the shape class will not support texture mapping; allegedly it is a planned feature for the next version (discussion).

Depending on the kind of visual effect you are going for -- I didn't find your description entirely clear -- you could do something like using a shape to mask a sprite, as described in this post (scroll down a ways, there's an image with the example result), or you could use OpenGL directly to render a series of texture-mapped triangles with the image mapped appropriately using texture coordinates.

Note that while sprites are rectangular in their nature, you can achieve the visual result of a non-rectangular image by including transparency (typically via the alpha channel of the image), and that may be all you need to achieve your desired visual result.

share|improve this answer
    
+1 Unfortunately for the OP this is the correct answer. It just isn't possible without writing custom classes or modifying the SFML source. –  Zack The Human Jul 10 '11 at 20:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.