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

Pages: 1 2 [3] 4 5 ... 27
Feature requests / Re: Update android default project
« on: February 02, 2018, 08:57:41 pm »
I got already four personal messages about the android studio project  ::). I can do a PR which updates the android example and also write a "SFML for Android" tutorial for the webpage if we can agree on switching to android studio. I just do not want to do it and then it gets rejected ;)

It would definitly make the progress on android much more smooth.


General / Re: Errors building SFML for Android
« on: October 13, 2017, 09:05:45 am »
Sadly you cannot use sfml-audio only out of the box. But have a look at sfmlActivity under src/main/. If you call this function yourself
loadLibrary("openal", lJNIEnv, ObjectActivityInfo);
you might be able to use sfml-audio as standalone. But I am not sure if this will work.

Another option could be loading openal  in your Java Activity, sadly I don't have the time to try it out and test it.


General / Re: Errors building SFML for Android
« on: October 12, 2017, 07:05:28 pm »
The example project does include audio, and if this works something in your mk file is wrong. But we cannot tell without seeing it ;)


General / Re: Errors building SFML for Android
« on: October 11, 2017, 06:34:20 pm »
You can upgrade your ndk to r12 to use libc++ with sfml master. Or use the latest ndk Version and the PR from above.

It shouldn't affect your code at all.

Ndk r9 is very old i am not sure if libc++ was somewhere complete and stable at the time. You could also try gnustl (but look at the license) which may work in r9 with a descent STL support


General / Re: Errors building SFML for Android
« on: October 10, 2017, 09:12:03 am »
Have you tried to include gl2platform before gl2ext as I said above? Maybe it is also a problem with older NDK version.


General / Re: Errors building SFML for Android
« on: October 09, 2017, 09:16:28 pm »
Are you using the newest NDK?

If so you have to add "#include <GLES2/gl2platform.h>" before the gl2ext.h in SFML/include/OpenGL.hpp. Also you cannot use libc++ with the newsest NDK.

You can also use this PR which fixes the build issues and supports libc++ (read the description of the PR, the build process is a tiny bit different)


General discussions / Re: Creating a new sf::Event object in each loop?
« on: October 01, 2017, 03:28:32 pm »
However, if you feel that you absolutely must keep from the event being declared every cycle, you can have the best of both worlds (correct scope and persistent life) by simply declaring it as static.

But static will/may be the slowest, because of cache locality ;).

As eXpl0it3r said, sf::Event is POD, so creating and instance is done by increasing the stack pointer register by some amount (size of sf::Event (+ padding/alignment)). This usally is done in one CPU-cycle or less. So placing it inside the loop is the best option, because as hapax said, keep variables as local as possible.


General / Re: Android example fails to compile
« on: September 30, 2017, 10:45:43 am »
The current version of SFML with NDK version >12 do not work together when you use libc++ as STL implementation (has the best c++11 support). If stlport is fine for your usecase go with it, if you need libc++ you have two options:

1) Downgrade to NDK version 12
2) Use this pull request . With this pull request you have to use the toolchain provided by your NDK (NDK_ROOT/build/cmake) to build SFML, the rest works the same.


Graphics / Re: Is it possible to remove "transparent" background of sprite?
« on: September 23, 2017, 11:38:06 pm »
@Frex: The first idea can be quite fast for 2D, by using the depth buffer and depth test settings to your advantage, so you wont have an extra draw call ;).


Graphics / Re: Is it possible to remove "transparent" background of sprite?
« on: September 23, 2017, 10:58:53 pm »
(FRex his solution is a lot simpler ;D)

This can be done by using the GPU (little hack) or with some polygon point checking algorithm.

1) On the GPU, this is called "picking". You simply draw the tree onto another rendertarget (e.g. renderTexture). When you click you check the color of this position, if it is transparent you missed, if it is a non transparent color you hit the tree. This is easy if you have one element you want to check.
If you have multiple object this is a bit tricky, because you cannot create a renderTexture for every object, you would run out of GPU VRAM, or the multiple getPixelColor will slow down your game (Transfer from GPU to CPU bottleneck). Howerver there is a trick, you can draw with a custom shader where you set a unique color for all your objects. So if the alpha of the sprite/texture fragment is > 0 draw this color otherwise dont fill the pixel. Then you can draw every object with a different color onto one renderTexture get the color and match it to one(clicked) object.

2) On the CPU, for this you have to model the non transparent parts of the image as a polygon. There is also the option to create it automatically (google it, but it may be compilcated). If you have the polygon you have to check if your point is inside this polygon, for an example for such an algorithm look here.

Feature requests / Update android default project
« on: September 19, 2017, 11:10:40 pm »
The android example still uses the old build system (ADT), because at the time support for the NDK in Android Studio was non existent. Maybe even Android Studio was not released back then ???

Nowadays Android studio has finally integrated good working support for the NDK, via Gradle+Cmake. So we should think about updating the example, or at least offer and android studio project. Because currently it is not simple, easy or fast for a person which does not know something about the build system to get SFML working under android.

There is already a nice template, which works out of the box without any configuration needed (with this PR).

SFML Thread:

For the future it would also be possible to build SFML inside Android Studio. So the user does only need to copy his code into the example and everything will be setup.


General / Re: Enemy movement to Player
« on: September 19, 2017, 09:58:59 pm »
Your enemy class should store the movement direction. Set it only once, when you spawn the enemy in the middle of the screen. Then use this static movement direction to move the enemy without following the player.

Hint: store the movement direction as a unit vector so you can scale the speed easily. (multiply with a scalar)

Yes, a vector is a good choice, simply push them when spawning, and remove them when you want to destroy them. This is the simplest approach and will get you far (> 1000 enemies shouldn't be a problem).

(The next part is only important if you need a lot enemies and spawn/despawn them rapidly, 99% this is not important for smaller games)
If you need more and run into performance troubles, you could add a "isAlive" flag, and reuse dead enemies when spawning new ones. This will save you realloc(s) and copying data inside the vector (erase) when your enemy count wont increase anymore.
When your enemies die in the same order as they spawn and you have a maximum enemy count, a ring buffer is also an option.


General discussions / Re: SFML in Android Studio Example
« on: September 18, 2017, 06:18:18 pm »

nice template and thanks for the work! I just submitted a pull request which adds support for finding SFML automatically inside your NDK folder (where make install will install SFML). I also added support for multiple ABIs.

Maybe the SFML team should think about adding this template to the examples in the SFML repository, because it is working out of the box now. (I will submit a SFML pull request today which fixes the build system for NDK r >12)

P.S. I'm the creator of the old ugly template  :P


General / Re: Fps Check every second
« on: September 16, 2017, 12:44:54 pm »
This forum does support Code tags, please use them  ;)

You could do something simple like
sf::Time interval = sf::seconds(1);
float fpsCounter = 0;
  fpsCounter ++;
  if(fpsclock.getElaspedTime() >= interval)
    fpsLog << fpsCounter / interval.asSeconds();
    fpsCounter = 0;
I just wrote it without testing, but it should be accurate enough (+- 1Frame) and very short to implement.

Also keep in mind that FPS is not linear and does not show peaks in frametime (if you measure a whole second into one value, as in the example). If your game does not feel smooth but still has >= 60FPS you should look at frametime variation.

P.S. fpsclock.restart() does return the elapsedTime before restarting, so your .asSeconds() does nothing ;). But you could write instead of
FPSTimer = fpsclock.getElapsedTime();
simply write:
FPSTimer = fpsclock.restart()
Which does exactly the same :)


General / Re: How to implement character control with the mouse
« on: September 15, 2017, 11:06:42 am »
If i do this, my character moving with freeze, by jerks

Have you tried printing the totalMovement vector? The axis values should be <= 1.  If this is the case there should be not freezes/jerks, do you have a constant frametime (vsync or framelimit)?

If the freezes/jerks come from your variable frametime you should read this very well written articel on how to fix this "issue"

Pages: 1 2 [3] 4 5 ... 27