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

Pages: [1] 2
1
General / Re: How to debug NDK-projects?
« on: March 02, 2017, 03:42:21 pm »
Adding sf::View view = window.getDefaultView(); does not fix it, sadly.

I started to remove certain sections of my code. Could it be that multiple views aren't allowed on Android builds?

Edit: Or could it be that certain files have not been shipped and it fails finding them ergo crashes... Have to check this in a bit.

Edit 2: Yes... I ship wrong files :' D I expect too much automation - of course I have to add them manually, sorry xD!

Edit 3: Might be worth another thread, but can I just drop everything in my assets folder? The SFML-example used that one, but seems not to work : O
I have an asset folder for graphics and a few other folders for different scripts.

2
General / How to debug NDK-projects?
« on: February 27, 2017, 02:30:33 pm »
Hello forum : )

My android-application "stops working" upon starting.
Is there a way to debug this? The SFML example worked perfectly fine, could play around with it and nothing stopped working, but my own project is a bit larger and depends on Lua as well.

At the moment, I'm using
ndk-build
apt debug
adb install
and then run it.

When I start the app, I cannot see anything at all (but the upper bar with the app's name - android's interface, not mine) - stops working.
Building etc. worked fine.

SFML: 2.3.2
NDK: r13b
Lua: 5.1

Since Nsight Tegra probably won't help according to this http://en.sfml-dev.org/forums/index.php?topic=21513.0, stating that I cannot debug my app running, what are my options : /? Blindly guessing?
As I use Lua, might it be that something went wrong with linking it and they fail to find the .so files during runtime but manage to ndk-build it anyway?

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := sfml-game

LOCAL_SRC_FILES := main.cpp
LOCAL_SRC_FILES += ...

LOCAL_CPPFLAGS  = -std=c++1y
LOCAL_CPPFLAGS += -lstdc++fs
LOCAL_CPP_FEATURES := rtti exceptions

LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_SHARED_LIBRARIES += lua

LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-module,sfml)
$(call import-module,lua\jni)

3
General / Re: [SOLVED] Cannot ndk-build example
« on: February 23, 2017, 02:49:13 pm »
Did so, encountered a weird bug, though.

When I do as mentioned and reach the ndk-build point, it tries to use
[...]\android-ndk-r12b\toolchains\arm-linux-androideabi-4.8
instead of
[...]android-ndk-r12b\toolchains\arm-linux-androideabi-4.9

Had to cheat: Duplicate folder, rename the clone to arm-linux-androideabi-4.8.
Works. Sadly, I could not find a single file where it would state to use 4.8.
Unless NDKABI 23 is associated with 4.8? No idea, haha.

Thanks a lot, cvkfak! Did not try out the vibration-fix though, as I do not need it now.

I really hope SFML does not give up porting to Android : )!


4
General / Re: [SOLVED] Cannot ndk-build example
« on: February 22, 2017, 11:26:43 am »
Haha, sorry, I think I ninja'd you :' )
It seems it did not completely build it... it definitely had SFML in sources "[NDK]/sources/SFML" but well.

Can you say whether  "Unfortunately, SFML has stopped." is an error I did on my end? No edits on the example-projects. Just wondering if my build-process may failed at some point?

5
General / [SOLVED] Cannot ndk-build example
« on: February 22, 2017, 01:26:07 am »
Hello forum : )

A few stats to begin with:
OS: Windows 7 - 64 bit
NDK: r12b
SFML: 2.4.2

I built for armeabi and armeabi-v7a and installed both to the NDK into the SFML-module.

First, I used the "Visual Studio 15 2017" compiler, being aware of it probably not going to work.
It failed during ndk-build.

So I used MSYS, did build and make, but ended up having the same error once trying to ndk-build.

The error:
[...]\SFML\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
jni/main.cpp:1:27: fatal error: SFML/System.hpp: No such file or directory
 #include <SFML/System.hpp>

I did not change anything about SFML's source-tree. Just added build with its 4 sub-folders for each target.
But once I copy the SFML folder with its System.hpp into the example, a new set of errors occur: DO NOT DO THIS - LET THE NDK SORT THINGS OUT VIA SFML'S INSTALLED MODULE
[...]\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
[armeabi-v7a] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-li
bc++/libs/armeabi-v7a/
[armeabi-v7a] SharedLibrary  : libsfml-example.so
jni/main.cpp:24: error: undefined reference to 'sf::getNativeActivity()'
jni/main.cpp:57: error: undefined reference to 'sf::Time::asMilliseconds() const
'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'sf::Transformabl
e::~Transformable()'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'vtable for sf::S
prite'
[...]/NDK/android-ndk-r12b/build//../toolchains/arm-linux-androideabi-4.9/prebu
ilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-li
nux-androideabi/bin/ld.exe: the vtable symbol may be undefined because the class
 is missing its key function (see go/missingkeymethod)
jni/main.cpp:79: error: undefined reference to 'sf::VideoMode::getDesktopMode()'

jni/main.cpp:79: error: undefined reference to 'sf::String::String(char const*,
std::__ndk1::locale const&)'
jni/main.cpp:79: error: undefined reference to 'sf::RenderWindow::RenderWindow(s
f::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
jni/main.cpp:81: error: undefined reference to 'sf::Texture::Texture()'
jni/main.cpp:82: error: undefined reference to 'sf::Texture::loadFromFile(std::_
_ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator
<char> > const&, sf::Rect<int> const&)'
jni/main.cpp:85: error: undefined reference to 'sf::Sprite::Sprite(sf::Texture c
onst&)'
jni/main.cpp:86: error: undefined reference to 'sf::Transformable::setPosition(f
loat, float)'
jni/main.cpp:87: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:87: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:87: error: undefined reference to 'sf::Transformable::setOrigin(flo
at, float)'
jni/main.cpp:89: error: undefined reference to 'sf::Music::Music()'
jni/main.cpp:90: error: undefined reference to 'sf::Music::openFromFile(std::__n
dk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<c
har> > const&)'
jni/main.cpp:91: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:93: error: undefined reference to 'sf::SoundStream::play()'
jni/main.cpp:95: error: undefined reference to 'sf::RenderTarget::getDefaultView
() const'
jni/main.cpp:97: error: undefined reference to 'sf::Window::isOpen() const'
jni/main.cpp:101: error: undefined reference to 'sf::Window::pollEvent(sf::Event
&)'
jni/main.cpp:106: error: undefined reference to 'sf::Window::close()'
jni/main.cpp:109: error: undefined reference to 'sf::View::setSize(float, float)
'
jni/main.cpp:110: error: undefined reference to 'sf::View::setCenter(float, floa
t)'
jni/main.cpp:111: error: undefined reference to 'sf::RenderTarget::setView(sf::V
iew const&)'
jni/main.cpp:116: error: undefined reference to 'sf::Transformable::setPosition(
float, float)'
jni/main.cpp:118: error: undefined reference to 'sf::milliseconds(int)'
jni/main.cpp:125: error: undefined reference to 'sf::RenderTarget::clear(sf::Col
or const&)'
jni/main.cpp:126: error: undefined reference to 'sf::RenderTarget::draw(sf::Draw
able const&, sf::RenderStates const&)'
jni/main.cpp:127: error: undefined reference to 'sf::Window::display()'
jni/main.cpp:89: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:81: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:128: error: undefined reference to 'sf::RenderWindow::~RenderWindow
()'
jni/main.cpp:83: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:83: error: undefined reference to 'sf::RenderWindow::~RenderWindow(
)'
jni/main.cpp:129: error: undefined reference to 'sf::Color::White'
jni/main.cpp:129: error: undefined reference to 'sf::RenderStates::Default'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
 

Tried this thread already: http://en.sfml-dev.org/forums/index.php?topic=19298
It inspired me to try MYSYS.

This is the android.mk:
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := sfml-example

LOCAL_SRC_FILES := main.cpp

LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main

include $(BUILD_SHARED_LIBRARY)

$(call import-module,sfml)
 

Thanks for taking your time to read my thread : ) Have a sweet day/evening : )

SOLUTION!
I managed to build and debug it : )
This thread helped me: http://en.sfml-dev.org/forums/index.php?topic=20587.0

I did: cmake --build . --target install --config Release
in armeabi and armeabi-v7a

Sadly: android update project --target 1 --path . --name SFML-Example
did not work for me, but:
android update project --target "android-23" --path .
next I did:
ndk-build
ant debug


Got my SFML-Example-debug.apk
This pretty much shows, it still got the --name SFML-Example from the upper android update, but the --target 1 probably is too low for my NDK - no idea.

But whenever I press the home-button or leave the app somehow, "Unfortunately, SFML has stopped." : /
Well, that might be an issue with the example (I hope).


6
Graphics / Re: Shader(?) for transforming one sprite to another
« on: February 19, 2017, 10:20:15 pm »
Thanks Hapax and Mario,

About the Hapax's first and second method:
Well, shapes can be quite different are 100% unpredictable as the effect shall cope with sprites added by the user. Canvas size is known, though.

How would your methods work if there is an uneven amount of coloured pixels?

Mario, sadly default sprites are quite huge already - the effect happens to multiple objects at once, too.

I'm not even sure, if there is a cheap method for this. Maybe working in rough chunks instead of pixel-by-pixel.

7
Graphics / Re: Shader(?) for transforming one sprite to another
« on: February 18, 2017, 11:26:45 pm »
Yes, like morphing from one sprite to another. But colours do not matter as they should start "glowing", losing colours for a bright white.

What I thought:

Turn one sprite white (add some glow effects, too).
Check the shape of the other sprite.
Turn sprite #1 white pixels to the shape of sprite #2.
Create the same bright effect for sprite #2.
Place it below sprite #1, make sprite #1 disappear.
Sprite #2 turns back to its original colours.

8
Graphics / Re: Shader(?) for transforming one sprite to another
« on: February 18, 2017, 08:22:02 pm »
Thanks, I browsed that page a bit but could not find anything that seems similar to what I would want.

I searched "transition", "transformation" - appended 2d, too.

Well, seems like I have to commission someone or learn it myself.
If you have any neat resources I would be happy to see them : )

Have a sweet weekend : )

9
Graphics / Shader(?) for transforming one sprite to another
« on: February 14, 2017, 08:56:50 pm »
Hello forum! : )

I want to achieve the following:

One sprite (e.g. an elephant) transforming to another one (e.g. flower).

It shall be similar to the way Pokémon are evolving. They turn very bright and change their bright/glowing shape to the other form. Then change from a glowing back to the real colors.
Opposed to a Pokémon evolution, I need no shifting back and forth. Just a straight transformation, needed for a quick effect.

I probably need a shader for this, am I right?
Would this be particularly difficult? Are there any common patterns for this?

I could rasterize the whole image, check where non-transparent pixels sit but mapping them to a new shape seems difficult.

Thanks for taking your time to read my thread, looking forward for your tips <3


10
Graphics / Scene-graphs and multiple sf::views
« on: January 28, 2017, 03:46:37 am »
Hello dear forum : )

I have a tile-grid-based game (and layered) with some GUI-widgets on top.
Additionally, I'm rolling an entity-compoment-system, so there is a graphics-component per entity aiming to be visualised (contains proxy to their texture).

At the moment, I store them in a vector - being the level-structure itself.
The order represents the coordinate in the grid: First element is upper-left of the grid and last element is bottom-right.

Now, sending my level-structure to the painter-class should not happen - why would a painter-class need to know how my level is structured..
Additionally, I require multiple sf::views (one for a GUI-menu and one for the level).

How would you structure your code?
My component-factory could be linked to a scene-graph. Immediately adding a reference of every graphics-component upon creation.

But then, what is about multiple sf::views?
Should there be a view-graph as well? One that can simply add sf::views to an unordered map, each having a unique string as key ("gui" or "level_scene"). Every node within the scene-graph would then refer to either sf::view.

Probably a better idea: Have one scene-graph per view. Every scene-graph composites one sf::view.
When my GUI-loader loads, I create one graph just for that. When my level-loader loads, I create one graph just for that, too.
Both are then added to the painter-class, who iterates over their owned visualisation component.

Only thing about that, it would require my painter-class to additionally iterate over a vector of scene-graphs (just feel like this is bad design - not trying to prematurely optimise).

I'm really curious if there are any neat patterns that solved this issue already? Are there already other SFML-projects that tackled this problem?

Thanks a lot, have a great day : )


11
Window / Re: Window Resizing
« on: December 19, 2016, 11:48:33 am »
Ah! I can totally understand that : )

Hm, well having it on another thread would require it to be on the same as the window, right?

12
Window / Window Resizing
« on: December 19, 2016, 11:22:03 am »
Hello dear forum : )

I just found out, that the window does not update during resize.
So I did some research and this seems to be because SFML goes into an infinite loop.
Hence there is no solution to this.

But is there really nothing to do? I heard using another thread would be a solution, but that sounds like an extreme solution.

How much change would SFML need to go through to make this behaviour work as expected (screen shows what actually should be shown when resizing)?
Is switching the event-polling to maybe an observer-pattern a solution?
Anything that could be done? Even if it ends up in editing SFML.

I really would not want to switch my libraries just because of this, as I pretty much love SFML! : )

Thanks for taking your time reading my thread, have a great week!

13
Graphics / Re: Shaders make my Sprite disappear
« on: November 19, 2016, 07:00:47 pm »
Thanks for your reply!
When I load the fragment shader only, I have a black spot where my tile would be rendered.

In your fragment shader vColor and vTexCoord will be replaced by gl_Color and gl_TexCoord[0].xy (you don't need to define them as inputs/varyings)

Now, the black spot became a white one with my sprite in front of it. Does not seem to be blurred, though.

Edit:
Here is my updated shader which creates a white spot with my sprite on top:
//declare uniforms
uniform sampler2D u_texture;
uniform float resolution;
uniform float radius;
uniform vec2 dir;

void main() {
    //this will be our RGBA sum
    vec4 sum = vec4(0.0);

    //our original texcoord for this fragment
    vec2 tc = gl_TexCoord[0].xy;

    //the amount to blur, i.e. how far off center to sample from
    //1.0 -> blur by one pixel
    //2.0 -> blur by two pixels, etc.
    float blur = radius/resolution;

    //the direction of our blur
    //(1.0, 0.0) -> x-axis blur
    //(0.0, 1.0) -> y-axis blur
    float hstep = dir.x;
    float vstep = dir.y;

    //apply blurring, using a 9-tap filter with predefined gaussian weights

    sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162;
    sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541;
    sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216;
    sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946;

    sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.2270270270;

    sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946;
    sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216;
    sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541;
    sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162;

    //discard alpha for our simple demo, multiply by vertex color and return
    gl_FragColor = gl_Color * vec4(sum.rgb, 1.0);
}


14
Graphics / Shaders make my Sprite disappear
« on: November 19, 2016, 03:33:18 pm »
Hello forum!

I'm using the normal C++ SFML and tried to use the shader being presented here: https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson5

Drawing the sprite without passing the shader renders my normal sprite. Once I add the shader, nothing is being drawn but the cleared coloured background.
Moreover, this applies to a variety of attempts to use other GLSL-shaders - nothing is drawn but the cleared background colour.

When copying a full C++-SFML-shader  example from another website, everything works.

The C++/SFML-code:
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{

        sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML Sandbox");

        sf::Event event;

        // Texture
        sf::Texture texture;
        texture.loadFromFile("assets/tile.png");

        // Sprite
        sf::Sprite sprite;
        sprite.setTexture(texture);
        sprite.setPosition(500, 500);

        // Shader
        sf::Shader shader;

        if (!shader.loadFromFile("shaders/glsl.vert", "shaders/glsl.frag"))
        {
                std::cout << "Error. \n";
        }


        shader.setUniform("u_texture", sf::Shader::CurrentTexture);
        shader.setUniform("resolution", 118.0f*77.0f); // width * height of my sprite
        shader.setUniform("radius", 1.0f);
        shader.setUniform("dir", sf::Vector2f(1.0f, 0.0f));

        while (window.isOpen())
        {

               
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }


                window.clear(sf::Color(200, 200, 200));
                window.draw(sprite, &shader);
                window.display();
        }

        return 0;
}
 

My glsl.vert (from previous lessons, as stated in the article https://github.com/mattdesl/lwjgl-basics/blob/master/test/res/shadertut/lesson4.vert):
//combined projection and view matrix
uniform mat4 u_projView;

//"in" attributes from our SpriteBatch
attribute vec2 Position;
attribute vec2 TexCoord;
attribute vec4 Color;

//"out" varyings to our fragment shader
varying vec4 vColor;
varying vec2 vTexCoord;
 
void main() {
        vColor = Color;
        vTexCoord = TexCoord;
        gl_Position = u_projView * vec4(Position, 0.0, 1.0);
}

My glsl.frag:
//"in" attributes from our vertex shader
varying vec4 vColor;
varying vec2 vTexCoord;

//declare uniforms
uniform sampler2D u_texture;
uniform float resolution;
uniform float radius;
uniform vec2 dir;

void main() {
    //this will be our RGBA sum
    vec4 sum = vec4(0.0);

    //our original texcoord for this fragment
    vec2 tc = vTexCoord;

    //the amount to blur, i.e. how far off center to sample from
    //1.0 -> blur by one pixel
    //2.0 -> blur by two pixels, etc.
    float blur = radius/resolution;

    //the direction of our blur
    //(1.0, 0.0) -> x-axis blur
    //(0.0, 1.0) -> y-axis blur
    float hstep = dir.x;
    float vstep = dir.y;

    //apply blurring, using a 9-tap filter with predefined gaussian weights

    sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162;
    sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541;
    sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216;
    sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946;

    sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.2270270270;

    sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946;
    sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216;
    sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541;
    sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162;

    //discard alpha for our simple demo, multiply by vertex color and return
    gl_FragColor = vColor * vec4(sum.rgb, 1.0);
}

I hope my code-samples did not make this post too verbose, if they did, please inform me : )

Additionally, I tried searching already:
The thread over here did not help me: http://en.sfml-dev.org/forums/index.php?topic=18191.0
Also, my image is a PNG and owns an alpha channel.

Thanks for reading! I would be very thankful if you could help me  : )

15
Graphics / Re: Allocated Size of sf::RenderWindow
« on: September 01, 2016, 02:11:49 pm »
Yeah, I know it's not comparable. But I worried about possible memory leaks and unnecessary allocations and whatnot. It just ended up that sf::RenderVideo was allocating a lot, now I wanted to find out if that is my fault.

Thanks for your effort, eXpl0it3r : )
I tried your code, debug build (SFML 2.3.1, statically linked).

Task-Manager: 52mb
Visual Studio profiler: 64.8mb

Which confuses me already, but well.
This rather odd in general. I could not imagine what Visual Studio would add.


Pages: [1] 2
anything