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 - battosaijenkins

Pages: [1] 2
1
General discussions / Re: Comparisons with SDL2
« on: July 28, 2021, 06:01:10 am »
Well my final observations after testing... To me sf::VertexBuffer was slower than sf::VertexArray when storing 50,000 objects with sf::TriangleFan using 8 points (octagon).  The difference was roughly 580ms to 110ms .

And within the sf::VertexBuffer options, The speed was fastest with sf::VertexBuffer::Static then Dynamic then Stream respectively.

Comparing sf::Texture to a regular colour fill at around 50,000 objects regular colour fill was slightly faster at about 10% (110ms to 100ms) But anything below 5000 objects the difference is negligible. (11ms to 12ms) And sf::Vertex was faster than sf::VertexArray.

With 50000 objects using sf::Vertex in loop, using textures was 23ms as opposed to around 17ms with color fill. With 5000 objects both resulted about 1 or 2ms each.

Lastly, avoiding divisions and optimizing algorithms did speed up the rendering by another 1-4%. And less points (for instance using an octagon instead of circle) sped things up even more.

Of course, on stackoverflow there was one QuadTree expert who claimed to hit a million particles at 60fps! But I'm happy with 50,000 objects for now, maybe one day I'll tackle dynamic QuadTrees, and re-examine SDL2 as well.

Edit: Running i9-9900k + Nvidia RTX 3090 FE windows 10 x64

2
General discussions / Re: Comparisons with SDL2
« on: July 27, 2021, 05:34:38 pm »
As I lay down each night and think of nothing but code, I've decided to re-visiting this comparison once again as I may have been biased in 1 important aspect.

On the SDL2 side I should try to point less vertices to see if that will speed up the process even more. And on SFML side I should try sf::VertexArray to see if there's any noticeable difference with sf::Vertex. And then while on that subject check performance with sf::VertexBuffer.

Not sure why I'm so ocd on this but I've gone so far tangent from my original project I might as well examine this before I make my final decision. =)

3
General discussions / Comparisons with SDL2
« on: July 27, 2021, 01:53:12 am »
If this has been discussed and already beaten to death well I apologize in advance.

But I was working on collision detection & resolution example through SFML with many objects around 900 circle objects in debug mode when things started to bog down. I know in release mode it's perfectly fine at 60 fps but out of curiosity I wanted to try SDL2 to see if it's anymore efficient.

Unfortunately SDL2 doesn't have circle primitive shapes so I had to go through a bunch of tutorials to get that up and running. There were 2 methods in SDL2 to create a circle shape one was less efficient than the other, while the other one was extremely efficient as it used 1/4 of the circle drawing then used symmetry to mirror the rest and blit textures.

While this managed to cut down the rendering by at least 10-20% in SDL2 alone, SFML was still about 3x faster with sf::CircleShape and that's not even resizing the circle points down to a lesser value!

Needless to say, it most likely means my slowing down issue lies with my collision algorithm and I'm well aware of that. I probably need to use other 'fast square root' alternatives, avoid divisions as much as possible and possibly implement dynamic quadtrees (ohhh boy).

This was quite an adventure for me and I have to say I really enjoy SFML. And after avoiding SDL2 for a very long time I also like SDL2 too but SFML to me feels natural! I'm always wondering why SFML isn't as popular as it should be. It's a terrific tool for learning everything C++ and under the hood game development!

4
Graphics / Re: Possible shearing ?
« on: April 06, 2021, 07:05:42 pm »
That's a good start. I'll check that out thx Laurent!

5
Graphics / Possible shearing ?
« on: April 04, 2021, 07:50:17 pm »
Hello, if this question has been asked to death in the past then I apologize in advance but in the SFML documentation listed here:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Transform.php

In the detailed Description it says:
A sf::Transform specifies how to translate, rotate, scale, shear, project, whatever things.

I understand it has examples of translate, rotate, scale, and project but I haven't found any examples on shear?
I've even tried to check forums but I read somewhere that it wouldn't work since textures wouldn't be applied right and/or I would need to use in addition GLSL to do the shearing transformation is this true?

6
Graphics / Re: sfml gradient shaders question
« on: May 30, 2020, 03:01:25 am »
Oh I see what you mean. You're saying I would use sf::RenderStates state and then use state.transform = transform and also use &shader in state.shader then pass state like window.draw(circle, state);? I think I understand now, thanks.

7
Graphics / Re: sfml gradient shaders question
« on: May 30, 2020, 02:22:46 am »
So I cant use sf::Transform?

8
Graphics / sfml gradient shaders question
« on: May 29, 2020, 08:10:31 pm »
Hello, I posted a question in github SFML Gradient shaders but was told to post here instead. I was wondering if it's possible to pass an sf::Transform into the draw function along with the shader?

For example normal draw I would pass a transform like:

Code: [Select]
window.draw(circle, transform);

but with shaders that 2nd parameter is already taken up like

Code: [Select]
window.draw(circle, &shader);

 and I cant add a third parameter. I read somewhere that I could use

Code: [Select]
shader.setUniform("matrix", sf::Glsl::Mat4(transform));

but I added

Code: [Select]
"uniform mat4 matrix;"

in const char RadialGradient[] but I'm getting Uniform "matrix" not found in shader. Am I doing it wrong, or overdoing it or missing something?

9
Graphics / different mouse cursors
« on: April 18, 2020, 07:48:36 am »
If this has been asked before then I apologize but I was wondering if there's more cursors besides the following:

// available types
enum     Type {
  Arrow, ArrowWait, Wait, Text,
  Hand, SizeHorizontal, SizeVertical, SizeTopLeftBottomRight,
  SizeBottomLeftTopRight, SizeAll, Cross, Help,
  NotAllowed
}

More specifically I was looking for drag and isDrag (open hand) (close hand) kind of a cursor for when mouse button is pressed and then released. I suppose I can get a png image to appear on my mouse cursor and do the handling but I was wondering if there's been more additions to the available types,  thx in advance!

10
Graphics / Re: getPixel with sf::RectangleShape
« on: April 05, 2020, 10:07:12 pm »
Sounds like you're trying to see if a point is inside a rotated rectangle. That's simpler:

if (rectangle.getLocalBounds().contains(rectangle.getInverseTransform().transformPoint(point)))
    pointIsInsideRectangle = true;

@Hapax, Dude thanks so much. This did it exactly. I was looking for something similar to JavaScript's ctx.isPointInPath() and this did it perfectly. My other method was image getPixel() but I had to rotate the png rectangle image ahead of time which was very cumbersome. Thanks again!

11
Graphics / Re: getPixel with sf::RectangleShape
« on: April 05, 2020, 07:59:15 pm »
Oooo, I'm going to have to test that out!! That looks real promising.

12
Graphics / Re: getPixel with sf::RectangleShape
« on: April 04, 2020, 08:57:11 pm »
That's what I figured. My other 'hacky' solution was to create a png file with a red rectangle already rotated. And from that I load the texture into the image and then check getPixel() for red. When I have more time I need to redo this and use your method.

13
Graphics / Re: getPixel with sf::RectangleShape
« on: April 04, 2020, 01:44:10 am »
Is there a difference from using
Code: [Select]
sf::Transform transform;
transform.rotate(angle);
window.draw(rect, transform);
as opposed to just
Code: [Select]
rect.setPosition(pos);
rect.setOrigin(rect.getSize().x/2, rect.getSize().y/2);
rect.setFillColor(sf::Color::Red);
rect.rotate(angle);
window.draw(rect);

 Also when I use getGlobalBounds() after the rotation it seems to ignore the rotation, it still checks it's normal non rotated bounds.

14
Graphics / getPixel with sf::RectangleShape
« on: April 03, 2020, 11:16:57 pm »
Hi , this may sound like a noobish question but is there a way to get a pixel color information from a rotated rectangle?

I'm asking this because so far I've been using texture images to getPixel just fine, but what if I want to rotate a simple rectangle and then check to see it's color?

My current workaround was to simply create a png file with an image of a rectangle already rotated and then checking getPixel() from there, but I thought maybe there's a better method to this? Thank you!

15
Graphics / Re: is it possible to rotate a line?
« on: January 17, 2020, 08:55:04 pm »
How to use sf::Transform to draw an entity:
https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php#custom-transforms

How to build the right transform for what you want:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Transform.php#af0b7cc3fed36d0fa22d5d331a779eee2

That did it. Thanks man. I couldn't figure out how to add another parameter for window.draw when I already had
Code: [Select]
w.draw(lines, 2, sf::Lines);
Passing transform to the draw function had only 2 arguments stated here
https://www.sfml-dev.org/tutorials/2.5/graphics-transform.php#custom-transforms
Code: [Select]
window.draw(entity, transform);
on a whim I just added transform at the end of
Code: [Select]
w.draw(lines, 2, sf::Lines, transform);
And then the .rotate() function had the center argument for rotation and that did the trick. Thx again Laurent!!

Pages: [1] 2