Replies: 23 comments
-
I've reproduced the issue. In this case, there's nothing in the binding that could explain the result. I think, this is how SFML is working, and I suppose the same result would be obtained in C/C++. Could be related with line spacing? I tried to get some understanding, only to discover a real bug: |
Beta Was this translation helpful? Give feedback.
-
I've, nevertheless, patched ASFML (2a4af34) so the correct version of the function can be called, if your version of CSFML does not have that issue. Maybe you are able to call the function. |
Beta Was this translation helpful? Give feedback.
-
Ok, i will try more ideas to fix my problem with the bounds and scaling later. It is frustrating to waste so much hours on this single problem. I also tried to call Sf.Graphics.Text.getLineSpacing, i get the error message
After a short check I found out that the last Update, with an source change, of the CSFML on Debian is from 4. November 2018, so before the patch was added. |
Beta Was this translation helpful? Give feedback.
-
I solved my problem using mapPixelToCoords/mapCoordsToPixel and now I feel a little bit stupid. At some point in the next few days I'll see if I can compile the CSFML myself and then test if the function can be called. |
Beta Was this translation helpful? Give feedback.
-
That makes sense now. I had seen these functions used, but didn't remember them at first. In any case, this has been useful to discover the issue with |
Beta Was this translation helpful? Give feedback.
-
So, today I compiled the SFML and CSFML myself (statically and dynamically) and then uninstalled the versions from the package manager. After I copied the dynamic variants into the lib folder of the ASFML, my program compiled without errors. With the static ones I got a lot of error messages when compiling and without the files the error messages: So I assume I have to use the dynamic ones? It now also compiles when using Sf.Graphics.Text.getLineSpacing. Now I only have the problem that my program does not find the SFML files. Can you help me with that too? This solution didn't work. I also noticed that "-lcsfml-audio" appears twice in the gpr files of the ASFML under Linker. |
Beta Was this translation helpful? Give feedback.
-
Try adding "-L/path/to/libs" to the Linker_Options in asfml.gpr. |
Beta Was this translation helpful? Give feedback.
-
Is this for the static library? If so it seems to work and after adding "-lsfml-X" it starts to compile but then crashes with the errors: Will definitely test again tomorrow, maybe I made a mistake when compiling the C/SFML, or choose the wrong versions. The terminal was a lot easier. |
Beta Was this translation helpful? Give feedback.
-
-L and -l are for any kind of library but they give preference to the dynamic version when both are found. The errors seem to come from CSFML not finding the definitions of SFML (C++). I think when one is static, the other must be statically linked too. Another source of problems is order of library arguments on the linker command line.Try inverting order of the dependent and defining libraries when giving errors. I hope this can help you somehow. |
Beta Was this translation helpful? Give feedback.
-
Inverting the order helped, i am down to two errors:
But I think these two messages are not related to the ASFML. Maybe an incorrect setting when compiling the C/SFML which I haven't found yet. Should I leave the error message open so I can post the solution to both errors here later if I find them? And thanks again for your help. |
Beta Was this translation helpful? Give feedback.
-
Now it seems you need to add -lm for including the C math library in the linking process. I found this reference, which is very didactic about the linker behaviour. https://stackoverflow.com/a/55086637/1092849
That seems a good intention. The final process to link against a self compiled version of CSFML couId be documented in the wiki. |
Beta Was this translation helpful? Give feedback.
-
Adding -lm doesn't do anything if I add it before -lsfml-X and if I add it after I'm back to the pile of error messages. Also compiled a SFML version with the SFML_USE_SYSTEM_DEPS option enabled, no change either. I'll try it again tomorrow or the day after and go through the various solutions that were in your link or that I can find elsewhere. If I compile more versions of the C/SFML now, I'll get even crazier than I already am. |
Beta Was this translation helpful? Give feedback.
-
Well, I made more attempts to get this running today. Adding -lm doesn't seem to work at all, no matter where I add it. I also tried to build the C/SFML with different compiler versions, didn't work either. I also created a new project and only included the ASFML, which compiled without errors. Then I integrated one package after the other. Compilation errors then occurred with the following packages, interestingly different errors and not always the same ones: It was enough to integrate them with "with", access to the functions, records, etc. was not necessary. The remaining packages compiled without errors. I also uploaded my asfml.gpr and the compiled libraries. It compiles with the dynamic versions, but not with the static ones. I have no idea what I'm missing. |
Beta Was this translation helpful? Give feedback.
-
I tried with the project file and libraries you attached. When using the static version, it's a matter of providing all the libraries on which SFML is directly or indirectly depending. You have to install the development version of the libraries. I had to do:
In this way I was able to link the following executables in the tests directory: But the other failed with the following errors, apparently a problem with the stdc++ library version, which I was unable to solve:
I attach my GPR file: The dynamic version raises errors similar to yours:
|
Beta Was this translation helpful? Give feedback.
-
I know that with the developer versions, they are all installed. After changing the asfml.gpr to:
my game compiles without errors, using the static librarys. So it seems that I have done everything right now? I also tested the programs in tests.
Probably because these files are not present in the ASFML? In any case, they are not in the example folder. The rest compiles and work fine. Adding "-lGLU", "-lpthread", like you did, don’t change anything. With the dynamic librarys opengl works too, the rest has the same problems. In the next few days I will record a tutorial video on how I configured/compiled all of them. Maybe I'll write a tutorial for that too. In any case, thanks for your help and patience. |
Beta Was this translation helpful? Give feedback.
-
Great!
This is because it requires an audio file as argument. In the last commit, I've added a usage message.
It requires pressing Space to start the game. In the last commit, I've added an initial message.
This example is a direct translation of https://www.sfml-dev.org/documentation/2.5.1/ which doesn't provide the files. I tested with some local files, but since they weren't "nice" I didn't add them to git 😄
I'm looking forward to seeing that. I'll add a link to the wiki then. |
Beta Was this translation helpful? Give feedback.
-
So, I recorded a tutorial video, but before I publish it, take a look at it. Especially if it is reasonably understandable and if I haven't forgotten anything. With such videos I always have the feeling of being too slow and too fast at the same time. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I took your advice into account and created a new version. Will unlock it for everyone this afternoon. I will probably also create a German version later. |
Beta Was this translation helpful? Give feedback.
-
Nice. I've added it to the Wiki, so other people can find it. By the way, I've also moved this to the Discussions section, since it contains valuable information and it would be a bit hidden when the issue is closed. On the other hand, there is no setting in the video configuration for configuring the spoken language? I've seen that subtitles are still in German. I'm no expert of Youtube, so maybe you cannot set the language, and it is automatically determined by location or browser preferences. Maybe you can remove the subtitles altogether. |
Beta Was this translation helpful? Give feedback.
-
I set the language to English, no idea why the subtitles are in German. I just deleted them, maybe YouTube is creating them correctly now. |
Beta Was this translation helpful? Give feedback.
-
Now I also created a German version of the tutorial. And with the English version, YouTube doesn't seem to want to create English subtitles. |
Beta Was this translation helpful? Give feedback.
-
No idea about why YouTube doesn't create the English subtitles, it's something odd. Added link to German version to the wiki too. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm back with a new problem/error.
I've just reworked my menu system so that it scales with the resolution/window size. But it no longer works properly with small resolutions (e.g. 640x480). Since I don't know whether the problem is with me or with the ASFML, I'll explain my strange solution for a menu system.
The graphics task:
First it is checked if the area of the view is smaller than the current resolution and if so the area is set to the current resolution. The initial value of the area is (5.00, 5.00) and the later values depend on the text calculations that come later. Then I set the view to the calculated area and the center to half of the axes accordingly. Then the various properties for the text are set, followed by the text position. When positioning the text, all lines that should be selectable are then written into an array using Sf.Graphics.Text.getGlobalBounds. The text positioning function then returns the height and width, which is then used to calculate the new area of the view on the next run.
The logic task:
It reads the written value from the array and checks whether the current mouse position is in it. If so, you can select the option and the text will be colored green.
The whole thing works without errors at high resolutions (eg 1600x1000). Scaling up is also not a problem. When scaling down, however, it only works correctly up to a certain resolution, the resolution up to which it works depends on the text width and number of lines. Below this resolution, the text will still display/scale correctly, but the position for selection will start to shift to the right, down, or right down, depending on how you scale. Picture 1 shows how it is correct at high resolutions, pictures 2 and 3 then the shift at low resolutions.
I've been looking for the error for some time now and I noticed that the local bounds and global bounds never match the set position, unless the string to be set is empty. So if I set a text to position (0.00, 0.00), then the text position is (0.00, 0.00), but value of top and left are always slightly larger than 0.00, regardless of whether I get the values with getLocalBounds or getGlobalBounds. This discrepancy looks like a mistake to me. Which is why I'm now wondering if the text positioning and bounds queries are wrong or if my system is just crap.
Hope you understand halfway what I mean, even if the explanation is probably unnecessarily long.
Pictures
Beta Was this translation helpful? Give feedback.
All reactions