Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - JohnD

Pages: [1]
1
Graphics / Vertex Arrays - How to draw multiple shapes with 1 call to draw?
« on: September 17, 2019, 06:55:58 am »
I've been looking at vertex arrays and I just can't wrap my head around how to draw multiple vertex arrays with just a single call to the "draw" function? Am I even saying that right? I've looked at a ton of guides and tutorials but they all seem to be just teaching me how to draw a single line, triangle or rectangle. I have seen tilemap sample codes but with little to no explanation to what's going on.

I'm sorry I don't have a sample code because I don't even know where to begin. Basically, I want to draw 2 or more triangles with differing sizes and textures. I feel like if I just have an example of drawing two triangles using vertex array using 1 instance of window.draw, I'd be ok. Any clarification to my confusion would be very much appreciated.

2
Graphics / Updating texture with images with transparent background
« on: July 25, 2019, 03:48:20 am »
Hi guys! New user here.

Is there a way to update a texture with images with transparent background?

I've tried texture.update() but it literally copies the whole image into the texture including the transparent pixels. This results in the texture having holes in it. Is that intended? If so, is there no way to a create a new image using images with transparent backgrounds in SFML?

sf::Texture texture;
if (!texture.loadFromFile("backgroundimage.png"))
     return EXIT_FAILURE;

sf::Image item;
if (!item.loadFromFile("imagewithtransparentbackground.png"))
     return EXIT_FAILURE;

texture.update(item,50,50);
sf::Sprite sprite (texture);

~Edit: I just found a way around it using RenderTexture. It seems transparency only works when drawing? I'm still curious if the above code should work. With RenderTexture I'm having to pass texture to sprite to rendertexture and back to sprite to get the result I want.

Pages: [1]