Skip to main content
42 votes
Accepted

What advantage do OpenGL, SFML and SDL have over software rendering?

It's not just about speed of execution, but also about simplicity. Although the software rendering used in this example would be a lot slower than using hardware acceleration (i.e. a GPU), drawing a ...
Richard Greenlees's user avatar
25 votes

What advantage do OpenGL, SFML and SDL have over software rendering?

My question is: why even bother using something like open gl, sfml, sdl when all you have to do is simply allocate some buffer, pass a bitmap and draw it to the screen? Short: Because its fast (...
tkausl's user avatar
  • 1,860
11 votes

What advantage do OpenGL, SFML and SDL have over software rendering?

What he does is called software rendering, what OpenGL does is called GPU rendering What's the difference between them? Speed and memory. Rasterization (filling out triangles on screen) takes some ...
Bálint's user avatar
  • 14.9k
8 votes

What advantage do OpenGL, SFML and SDL have over software rendering?

While the answers from others are more correct than any answer I could give, I want to point out the fundamental misunderstanding about how software development works that I think underlies your ...
egherrmann's user avatar
7 votes
Accepted

Screen tearing in fragment shader on R9 380 GPUs

I came back to this today and after some more investigation and trial and error I discovered that the culprit was targetTexture. With some more investigation I learned that reading and writing to the ...
jmcmorris's user avatar
  • 151
7 votes
Accepted

How to make a character jump in SFML?

I do not know how familiar you are with movement physics, but for this instance, you ideally want to work with Velocity and Acceleration. Basically, Acceleration impacts Velocity which impacts ...
qwarten's user avatar
  • 108
6 votes
Accepted

Perlin Noise unwanted artifacts

I don't entirely understand why, but I shouldn't have been doing 1-normX/Y. Instead, I looked at the question posted here and our approaches were similar enough that I could make It work. Changing ...
Paraxon's user avatar
  • 136
5 votes
Accepted

How do I program attacks and combos in a fighting game?

This advice is more general, rather than being specific to fighting games, but typically player behaviour in games with any reasonable level of complexity will be coded as a finite state machine, ...
Bryan Robertson's user avatar
4 votes

Correct way of managing player states?

You should not have if-statements nor case-statements; at least not nearly so many. The immediate problem is that you're hard-coding a bunch of logic where a data-driven approach would work better. ...
Sean Middleditch's user avatar
4 votes
Accepted

Moving a sprite along a circle given by an implicit equation

We can solve this by completing the square: $$\begin{align} x^2 + y^2 + ax + by + 1 &= 0\\ \left(x^2 + ax \right) + \left(y^2 + by \right) + 1 &= 0\\ \left(x^2 + ax + \frac {a^2} 4\right) + \...
DMGregory's user avatar
  • 135k
4 votes
Accepted

How to create a button in SFML?

The first thing to note, is that you have a ; after an if statement, before the code for the true condition. This means that the ...
Vaillancourt's user avatar
  • 16.3k
4 votes
Accepted

When detecting a keyboard key is released. What happened if the key is released at the end of the game loop?

The System events will be placed in SFML's event queue and be processed during the next loop. Imagine if the events were lost? What a bad game dev library that would make! Roughly, the way a program ...
Vaillancourt's user avatar
  • 16.3k
4 votes
Accepted

Are there any practical applications for clearing the screen with a specific color?

Clearing the color buffer can be optional. For example, if you know that you're going to overwrite every pixel each frame, then you might decide to not clear at all. On the other hand, some drivers ...
Maximus Minimus's user avatar
3 votes

What advantage do OpenGL, SFML and SDL have over software rendering?

The above answers are excellent, but none really goes over the most important reason as to why OpenGL and such are preferred. The main reason is to make use of dedicated hardware designed especially ...
Aiman Al-Eryani's user avatar
3 votes

How to render images/textures in shape/polygon form?

SFML has been updated since this question was originally answered and you can now add textures to shapes easily. The shape class has the setTexture() and ...
Summer's user avatar
  • 829
3 votes

What advantage do OpenGL, SFML and SDL have over software rendering?

Engines do much more that just draw a picture to the screen. They handle lighting, shadows, input , collision detection. Even just the rendering part is way more complex than just pushing a buffer ...
Uri Popov's user avatar
  • 3,027
3 votes
Accepted

SFML - How to implement a simple 2D lighting system

Without shadows The most direct approach is to have a PNG image with the texture of a light. If you don't want to use an external file, you can even create it yourself inside the program: Create a ...
Miguel's user avatar
  • 158
3 votes

Passing a value to a stuct

you are copying in your ranged-for loop. You should use for (auto& path : Path) This will pass by reference and allow you to make changes to the variable ...
Summer's user avatar
  • 829
3 votes

Confused, maybe the mistake ik is the foreach loop

You have at least one obvious error at hand. foreach (RectangleShape obstacles in JumpAtObjectList) { MainPlayer.Jump(deltaTime, obstacles); break; } ...
Zibelas's user avatar
  • 4,346
3 votes
Accepted

Is it useless to check whether a window is requested to be closed in full-screen mode?

Check sfml-window-events: The sf::Event::Closed event is triggered when the user wants to close the window, through any of the possible methods the window manager provides ("close" button, ...
Mangata's user avatar
  • 2,581
3 votes
Accepted

I did changed the text of a graphical text and set its new center origin. Should I reposition it in dead center again?

You are right; in this short example, the call is not needed. However, consider this: what if you kept adding code between those two calls? what if you reused the same text object for different ...
Vaillancourt's user avatar
  • 16.3k
3 votes

Should the coordinates, and rotation angles of all the sprites be stored in variables?

Storing values in variables is not the same thing as using magic numbers. The magic number anti-pattern is a direct usage of a number in the code. For instance, compare the following code snippet: <...
Pikalek's user avatar
  • 12.4k
3 votes
Accepted

Is there a logical reason for SFML's Vector2 being templated?

Unity, for example, has both Vector2 and Vector2Int types (and so on for other dimensionalities), since C# didn't/doesn't have ...
DMGregory's user avatar
  • 135k
2 votes

Drawing a level in SFML (C++)

Unfortunately, I don't have enough reputation to add a comment to your original post. Here is my go at a partial answer! Here is where you populate the top row with 30 white boxes. ...
Daniel's user avatar
  • 21
2 votes
Accepted

Simple 2D Platformer Collision Detection?

You are totally on target. One approach would be to return an integer which is the index of which one you hit, and a "special value" if nothing was hit. So: ...
david van brink's user avatar
2 votes

How i can make better jump to my game? - C++ SFML

Here's one of my go-to jump functions. It's similar to a Mario jump - fast at first, slowing down until reaching the top. Please excuse the syntax. I haven't used C++ in ages, and never SFML. ...
AndrewEkeren's user avatar
2 votes
Accepted

SFML with Box2D

Eventually I found the answer myself. The problem was with this line: world.Step(1 / 60, 8, 3); where 60 was considered an integer so the division rounded out to ...
Greg Treleaven's user avatar
2 votes

SFML collisions

Usually if you have a tiled level, you can calculate from World coordinates of your character the index of your tile by dividing your coordinates by tile size. Example: your character is at position ...
Peter Parker's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible