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.


Messages - JohnD

Pages: [1]
1
Yes of course you can. But that will still be coordinates in the same texture.

My bad! When I said differing textures, I meant "graphic" textures. So yep, giving my triangles different images from one big texture works.

2
Cool thanks! I now have a clear understanding of how this works! So a vertex array is basically an array of vertices (duh) drawn as a series of triangles (or whatever shape I choose). So I guess I'm limited to one type of shape for each vertexarray but does it also limit me to one texture? Can I not set texCoords for each triangle added via "append"? I'll go try these things out. In any case my problem's solved! Cheers!

3
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.

4
Cheers! Appreciate the info.

5
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]
anything