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

Pages: [1]
1
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!

2
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?

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

4
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!

5
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!

6
Graphics / is it possible to rotate a line?
« on: January 16, 2020, 10:25:18 pm »
I'm having a tiny brain fart and sorry if it seems very simple to figure out, but i cant seem to rotate a line. I'm using 2 points using
Code: [Select]
sf::Vertex lines[] = {
        sf::Vertex(sf::Vector2f(pos)),
        sf::Vertex(sf::Vector2f(pos.x + ret.getRadius(), pos.y)) // <-- this one is the radius line
    };
w.draw(lines, 2, sf::Lines);
-or-
Code: [Select]
sf::Vertex lines[2];
    lines[0].position = sf::Vector2f(pos);
    lines[0].color = sf::Color::Yellow;
    lines[1].position = sf::Vector2f(pos.x + ret.getRadius(), pos.y); // <-- this one is the radius line
    lines[1].color = sf::Color::Yellow;
    w.draw(lines, 2, sf::Lines);

its for my stroke circle. I want to rotate just the radius line around the circle's center point around and around like a spinning radar and cant seem to use rotate or transform on these lines, or maybe I'm doing it wrong? I can rotate an image using trig but thought this may be possible as well

7
I've been searching for days on google and reddit and other forums but I can't seem to figure it out. And if there is already a solution for this then I apologize for duplicates...

What I want is to test my mouse point on getPixel() for rgba values but that can only be done with sf::Image which I understand.

However, after I setScale with sprite I realize that the resize doesn't apply to the original image. Is there a way to resize the sf::Image somehow so that the scale updates as well?

For example, i have a star image that's width 50 and height 48 with a transparent background as star.png. I can set a sf::Texture and then sf::Sprite sprite(starImage) then setScale(2, 2) which doubles; but when I try to getPixel() for the image from sf::Image image = starImage.copyToImage() I get the original dimensions and not the doubled.

I feel like I'm missing something or is this not possible? I suppose I can just resize the original star png file and all the other png files ahead of time manually in photoshop to fit the window but is there an easier way? Thanks in advance.

8
General / adding sf::Vector2f ?
« on: September 15, 2019, 05:47:04 am »
+Just a quick question,
 
is it possible to add multiple sf::Vector2f? For example I have a apos.x and apos.y in the form of sf::Vector2f apos.
If I have another sf::Vector2f bPos is there a way to .add() them like something equivalent in p5 js? Or do I just do apos.x + bpos.x  and then apos.y + bpos.y etc..? Thanks in advance!

9
Graphics / "destination-over" equivalent
« on: May 30, 2019, 01:44:42 am »
Hello there,
I'm coming from javascript where if you're experiencing objects flickering when getting rid of objects in an array, you can do a reverse loop to prevent objects from flickering, however the rendering of the images are in front of the initial object (such as in a trail effect) and to remedy this you use something called ctx.globalCompositeOperation = "destination-over" where the trail effects will be drawn behind the initial object instead.

Is there a similar remedy in sfml c++? I can't seem to find any documentation or anything related through google searches for drawing objects behind something. I know you can literally window.draw() after another to show it in the foreground but when Im looping through an object's trail it doesnt seem to work.

What happens is when I use a normal incrementing for loop, the ball created will show a trailing effect behind the new ball (correctly) but during removal of each ball there is a 'flickering' for existing balls. This can be solved by doing a reverse loop decrement instead but then the rendering is changed where each new ball will be behind the older created ball.

I want the no flickering AND where the new object will be in front of the ball but a reverse loop doesnt seem to solve both these issues. An incrementing for loop will solve the draw placement but flickering occurs, but decrement for loop will solve the flickering but draw placement is wrong. And there doesn't seem to be a "destination-over" or "source-over" equivalent to solve this issue.

Is there a way to solve both the flickering and the new ball to be drawn in front of the older? Thx in advance!

Pages: [1]
anything