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

Pages: [1]
1
General / VM aborting when launching Android example
« on: November 29, 2014, 03:47:37 pm »
Hi,

I built SFML for Android as explained in Github Wiki tutorial. I created a new Android application project in Eclipse and then replaced the default Manifest and project.properties files with the ones included in the example provided with the source code. I also dropped all the files from the example in the project folder.

I created an AVD emulating a device running android-9 (2.3.3) with a armeabi CPU architecture and launched the application. The application crashes as soon as it starts both on the emulator and on the actual device (HTC Desire HD).

The logcat output is:
11-29 14:44:26.391: D/libEGL(485): egl.cfg not found, using default config
11-29 14:44:26.401: D/libEGL(485): loaded /system/lib/egl/libGLES_android.so
11-29 14:44:26.991: I/sfml-error(485): Failed to activate the window's context
11-29 14:44:26.991: I/sfml-error(485): Failed to activate the window's context
11-29 14:44:27.013: W/dalvikvm(485): JNI WARNING: JNI method called with exception raised
11-29 14:44:27.013: W/dalvikvm(485):              in Landroid/app/NativeActivity;.onResumeNative (I)V (GetStaticIntField)
11-29 14:44:27.021: W/dalvikvm(485): Pending exception is:
11-29 14:44:27.021: I/dalvikvm(485): Ljava/lang/NoSuchFieldError;: SYSTEM_UI_FLAG_LOW_PROFILE
11-29 14:44:27.021: I/dalvikvm(485):    at android.app.NativeActivity.onResumeNative(Native Method)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.NativeActivity.onResume(NativeActivity.java:228)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.Activity.performResume(Activity.java:3832)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-29 14:44:27.031: I/dalvikvm(485):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 14:44:27.031: I/dalvikvm(485):    at android.os.Looper.loop(Looper.java:123)
11-29 14:44:27.031: I/dalvikvm(485):    at android.app.ActivityThread.main(ActivityThread.java:3683)
11-29 14:44:27.031: I/dalvikvm(485):    at java.lang.reflect.Method.invokeNative(Native Method)
11-29 14:44:27.031: I/dalvikvm(485):    at java.lang.reflect.Method.invoke(Method.java:507)
11-29 14:44:27.031: I/dalvikvm(485):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-29 14:44:27.031: I/dalvikvm(485):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-29 14:44:27.031: I/dalvikvm(485):    at dalvik.system.NativeStart.main(Native Method)
11-29 14:44:27.081: I/dalvikvm(485): "main" prio=5 tid=1 NATIVE
11-29 14:44:27.081: I/dalvikvm(485):   | group="main" sCount=0 dsCount=0 obj=0x4001f1a8 self=0xce48
11-29 14:44:27.081: I/dalvikvm(485):   | sysTid=485 nice=0 sched=0/0 cgrp=default handle=-1345006528
11-29 14:44:27.081: I/dalvikvm(485):   | schedstat=( 709030121 900968440 86 )
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.NativeActivity.onResumeNative(Native Method)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.NativeActivity.onResume(NativeActivity.java:228)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.Activity.performResume(Activity.java:3832)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-29 14:44:27.081: I/dalvikvm(485):   at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 14:44:27.081: I/dalvikvm(485):   at android.os.Looper.loop(Looper.java:123)
11-29 14:44:27.081: I/dalvikvm(485):   at android.app.ActivityThread.main(ActivityThread.java:3683)
11-29 14:44:27.081: I/dalvikvm(485):   at java.lang.reflect.Method.invokeNative(Native Method)
11-29 14:44:27.081: I/dalvikvm(485):   at java.lang.reflect.Method.invoke(Method.java:507)
11-29 14:44:27.081: I/dalvikvm(485):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-29 14:44:27.081: I/dalvikvm(485):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-29 14:44:27.081: I/dalvikvm(485):   at dalvik.system.NativeStart.main(Native Method)
11-29 14:44:27.131: E/dalvikvm(485): VM aborting

 

What could be the cause of this?

2
Network / proper server exit cleanup
« on: February 22, 2013, 01:33:08 pm »
What I want to do is for the client to detect server disconnection and reconnect automatically when it starts listening again.
To test that, I start the client, I start the server then I stop it and try to start it again and see if the client reconnects.
The problem is that the server cannot rebind to the same port again.
What should I do ?

Client:
void SDP::RunNet()
{
    sf::TcpSocket CMDSocket;
    CMDSocket.setBlocking(false);

    sf::Time CMDSocketTimeout = sf::seconds(0.05f);

    std::cout<<"Connecting to CMD... "<<std::flush;

    mutexRunning.lock();
    bool stillRunning = Running;
    mutexRunning.unlock();
    while(stillRunning)
    {
        if(!connectedToCMD)
        {
            if(CMDSocket.connect("localhost", 55001,CMDSocketTimeout)==sf::Socket::Done)
            {
                connectedToCMD=true;
                std::cout<<"Connected to CMD."<<std::endl;
            }
            sf::sleep(CMDSocketTimeout);
        }
        else
        {
            sf::Packet packet;
            sf::Socket::Status CMDSocketStatus = CMDSocket.receive(packet);
            if(CMDSocketStatus==sf::Socket::Disconnected)
            {
                connectedToCMD=false;
                CMDSocket.disconnect();
                std::cout<<"CMD disconnected."<<std::endl<<"Trying to reconnect... "<<std::flush;
            }
        }
        mutexRunning.lock();
        stillRunning = Running;
        mutexRunning.unlock();
    }

    if(connectedToCMD)
    {
        CMDSocket.disconnect();
        std::cout<<"Disonnected from CMD."<<std::endl;
    }
 

Server:
void CMD::RunNet()
{
    sf::TcpListener listener;
    listener.setBlocking(false);
    listener.listen(55001);
    sf::SocketSelector selector;
    selector.add(listener);

    std::list<sf::TcpSocket*> clients;

    mutexRunning.lock();
    bool stillRunning = Running;
    mutexRunning.unlock();
    while (stillRunning)
    {
        if (selector.wait(sf::seconds(0.015f)))
        {
            if (selector.isReady(listener))
            {
                sf::TcpSocket* client = new sf::TcpSocket;
                if (listener.accept(*client) == sf::Socket::Done)
                {
                    std::cout<<"client accepted: "<<client->getRemoteAddress()<<std::endl;
                    std::cout<<"list size: "<<clients.size();
                    clients.push_back(client);
                    std::cout<<" then: "<<clients.size()<<std::endl;
                    selector.add(*client);
                }
                else
                {
                    delete client;
                }
            }
            else
            {
                for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
                {
                    sf::TcpSocket& client = **it;
                    if (selector.isReady(client))
                    {
                        sf::Packet packet;
                        sf::Socket::Status clientStatus = client.receive(packet);
                        if (clientStatus == sf::Socket::Done)
                        {
                            std::cout<<"Done"<<std::endl;
                        }
                        if (clientStatus == sf::Socket::Disconnected)
                        {
                            std::cout<<"Client disconnected"<<std::endl;
                            std::cout<<"list size: "<<clients.size();
                            selector.remove(client);
                            client.disconnect();
                            delete(&client);
                            clients.erase(it);
                            it--;
                            std::cout<<" then: "<<clients.size()<<std::endl;
                        }
                    }
                }
            }
        }
        mutexRunning.lock();
        stillRunning = Running;
        mutexRunning.unlock();
    }

    std::cout<<"Disconnecting from all clients."<<std::endl;
    for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
    {
        sf::TcpSocket& client = **it;
        std::cout<<"list size: "<<clients.size();
        selector.remove(client);
        client.disconnect();
        delete(&client);
        clients.erase(it);
        it--;
        std::cout<<" then: "<<clients.size()<<std::endl;
    }
    clients.clear();
    selector.remove(listener);
    listener.close();
}
 

3
Network / removing a socket from list on disconnect
« on: February 07, 2013, 08:57:42 pm »
Based on the example from the SocketSelector class reference in the SFML 2.0 documentation i completed the code to remove a TcpSocket from the std::list after it disconnects like this:

                for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
                {
                    sf::TcpSocket& client = **it;
                    if (selector.isReady(client))
                    {
                        sf::Packet packet;
                        if (client.receive(packet) == sf::Socket::Done)
                        {
                            std::cout<<"Done"<<std::endl;
                        }
                        if (client.receive(packet) == sf::Socket::Disconnected)
                        {
                            std::cout<<"Client disconnected"<<std::endl;
                            std::cout<<"list size: "<<clients.size();
                            selector.remove(client);
                            client.disconnect();
                            delete(&client);
                            clients.erase(it);
                            it--;
                            std::cout<<" then: "<<clients.size()<<std::endl;
                        }
                    }
                }
 

It is working great but i get memory leak and some other non critical errors when i profile it with Valgrind
how could i enhance it more ?

4
Graphics / wxSMFLcanvas problem
« on: August 29, 2011, 05:27:31 pm »
1- I downloaded the source from the "Integrating to a wxWidgets interface" tutorial, I use CodeBlocks with Mingw under windows and I built wxWidgets with Unicode support enabled.
when i compile it gives me the error: "cannot convert 'const TCHAR *' to 'const WCHAR*'
do you i also need to enable Unicode support somewhere else (GCC, SFML) or what's the problem exactly?

2- WxWidgets can provide a rendering context for OpenGL. What are the advantages of using SFML with it if all what you need from SFML is a redering context and handling input ?

5
General / SFML + OpenGL + wxWidgets
« on: July 14, 2011, 05:13:08 pm »
I'm trying to develop a small game in OpenGL.
can i integrate wxWidgets to SFML and use it to open dialogs inside my SFML window to allow players to change game settings ?
can someone describe briefely how to do that ?

6
Window / OpenGL cube
« on: June 20, 2011, 06:30:06 pm »
i'm trying to draw a cube using openGL and then to view it from different angles. i did it using GLUT and it works well. But, using SFML, it doesn't look right because i can see 4 faces of the cube when i should be seeing only 3, and i can see 2 faces when i should be seeing only 2 :-s

here is the code:
Code: [Select]
#include <SFML/Graphics.hpp>
int main()
{
    sf::Window App(sf::VideoMode(600, 600, 32), "SFML OpenGL", sf::Style::Close);
    GLdouble h = 0.0d;
    GLdouble v = 0.0d;
    GLdouble l = 0.0d;
    while (App.IsOpened())
    {
        App.SetActive();

        glClearColor(0, 0, 0, 0);
        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity();
        glRotated(l,0.0d,0.0d,0.2d);
        glRotated(h,0.2d,0.0d,0.0d);
        glRotated(v,0.0d,0.2d,0.0d);
        glBegin(GL_QUADS);
        //back
        glColor3f(1.0f,0.0f,0.0f); //red
        glVertex3f(-0.2f,0.2f,0.2f); //top left
        glVertex3f(0.2f,0.2f,0.2f); //top right
        glVertex3f(0.2f,-0.2f,0.2f); //bottom right
        glVertex3f(-0.2f,-0.2f,0.2f); //bottom left
        //bottom
        glColor3f(0.0f,1.0f,0.0f); //green
        glVertex3f(0.2f,-0.2f,0.2f); //back right
        glVertex3f(-0.2f,-0.2f,0.2f); //back left
        glVertex3f(-0.2f,-0.2f,-0.2f); //front left
        glVertex3f(0.2f,-0.2f,-0.2f); //front right
        //front
        glColor3f(0.0f,0.0f,1.0f); //blue
        glVertex3f(0.2f,-0.2f,-0.2f); //bottom right
        glVertex3f(-0.2f,-0.2f,-0.2f); //bottom left
        glVertex3f(-0.2f,0.2f,-0.2f); //top left
        glVertex3f(0.2f,0.2f,-0.2f); //top right
        //top
        glColor3f(1.0f,1.0f,0.0f); //yellow
        glVertex3f(0.2f,0.2f,-0.2f); //front right
        glVertex3f(-0.2f,0.2f,-0.2f); //front left
        glVertex3f(-0.2f,0.2f,0.2f); //back left
        glVertex3f(0.2f,0.2f,0.2f); //back right
        //left
        glColor3f(0.0f,1.0f,1.0f); //pink
        glVertex3f(-0.2f,-0.2f,-0.2f); //bottom front
        glVertex3f(-0.2f,-0.2f,0.2f); //bottom back
        glVertex3f(-0.2f,0.2f,0.2f); //top back
        glVertex3f(-0.2f,0.2f,-0.2f); //top front
        //right
        glColor3f(1.0f,0.0f,1.0f); //cyan
        glVertex3f(0.2f,-0.2f,-0.2f); //bottom front
        glVertex3f(0.2f,-0.2f,0.2f); //bottom back
        glVertex3f(0.2f,0.2f,0.2f); //top back
        glVertex3f(0.2f,0.2f,-0.2f); //top front
        glEnd();

        glFlush();

        App.Display();

        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Right))
                v+=10.0d;
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left))
                v-=10.0d;
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up))
                h+=10.0d;
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Down))
                h-=10.0d;
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::PageUp))
                l+=10.0d;
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::PageDown))
                l-=10.0d;
        }
    }
    return EXIT_SUCCESS;
}





am i using SFML in a wrong way ?

Pages: [1]
anything