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

Pages: [1] 2
1
General / Re: Choosing a File
« on: September 27, 2013, 04:16:43 pm »
Ok great thanks for your ideas, that helps =)
I am currently looking on boost::filesystem !

Thanks !  ;)

2
General / Choosing a File
« on: September 25, 2013, 09:00:09 pm »
Hello,

Currently developing a game in SFML where levels are saved as XML file, I would like to add to my GUI a button that displays a window to let the user choose the file level.xml he wants to chose.
Is it possible to do so ? Like letting the user browse a repertory to select the level he wants to load.

Please let me know if you have any idea on how to implement this properly ;)

Thanks !

3
Window / Re: SFML : trying to open a WxFrame
« on: July 11, 2013, 08:23:47 pm »
well yes, I am completely new to wxWidget, but I tought I could be able to consider it as a "blackbox" and working on SFML more than wxWidget. My applicationin "pure SFML" works well, I just wanted to add this in a larger wxFrame to be able to use wxMathplot ;).
Omw to wxWidget tutorials so.. I'll try to figure out what I'm missing,

Thanks

4
Window / Re: SFML : trying to open a WxFrame
« on: July 11, 2013, 07:44:11 pm »
hm, I don't understand... Can you clarify please :) ?
I've just followed the tutorial from SFML1.6 ....

Quote
Just implement the event table and the functions that you declare but don't define.

I don't understand what I did wrong.. please help, I've just done the same thing error and getting same mistake

5
Window / Re: SFML : trying to open a WxFrame
« on: July 11, 2013, 04:10:36 pm »
hm.. I tried to adapt (just a little the tutorial from SFML1.6) : here is the code I used :
#include "wx/wx.h"
#include <SFML/Graphics.hpp>

class wxSFMLCanvas : public wxControl, public sf::RenderWindow
{
public :

        wxSFMLCanvas(wxWindow* Parent = NULL, wxWindowID Id = -1, const wxPoint& Position = wxDefaultPosition,
                                 const wxSize& Size = wxDefaultSize, long Style = 0);

        virtual ~wxSFMLCanvas();

private :

        DECLARE_EVENT_TABLE()

        virtual void OnUpdate();

        void OnIdle(wxIdleEvent&);

        void OnPaint(wxPaintEvent&);

        void OnEraseBackground(wxEraseEvent&);
};

void wxSFMLCanvas::OnIdle(wxIdleEvent&)
{
        Refresh();
}

void wxSFMLCanvas::OnPaint(wxPaintEvent&)
{
        wxPaintDC Dc(this);

        OnUpdate();

        display();
}

#ifdef __WXGTK__
        #include <gdk/gdkx.h>
        #include <gtk/gtk.h>
        #include <wx/gtk/win_gtk.h>
#endif

wxSFMLCanvas::wxSFMLCanvas(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
wxControl(Parent, Id, Position, Size, Style)
{
        #ifdef __WXGTK__

                gtk_widget_realize(m_wxwindow);
                gtk_widget_set_double_buffered(m_wxwindow, false);
                GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
                XFlush(GDK_WINDOW_XDISPLAY(Win));
                sf::RenderWindow::create(GDK_WINDOW_XWINDOW(Win));
        #else
                sf::RenderWindow::create(GetHandle());

        #endif
}

class MyCanvas : public wxSFMLCanvas
{
public :

        MyCanvas(wxWindow*  Parent,
                         wxWindowID Id,
                         wxPoint&   Position,
                         wxSize&    Size,
                         long       Style = 0) :
        wxSFMLCanvas(Parent, Id, Position, Size, Style)
        {
                mySprite.setColor(sf::Color::Cyan);
                //mySprite.SetImage(myImage);
        }

private :

        virtual void OnUpdate()
        {
                clear(sf::Color(0, 128, 128));
                draw(mySprite);
        }

        //sf::Image  myImage;
        sf::Sprite mySprite;
};

class MyFrame : public wxFrame
{
public :

        MyFrame() :
        wxFrame(NULL, wxID_ANY, "SFML wxWidgets", wxDefaultPosition, wxSize(800, 600))
        {
                new MyCanvas(this, wxID_ANY, wxPoint(50, 50), wxSize(700, 500));
        }
};

class MyApplication : public wxApp
{
private :

        virtual bool OnInit()
        {
                MyFrame* MainFrame = new MyFrame;
                MainFrame->Show();

                return true;
        }
};

IMPLEMENT_APP(MyApplication);

& i get this error :
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual struct wxEventTable const * __thiscall wxSFMLCanvas::GetEventTable(void)const " (?GetEventTable@wxSFMLCanvas@@MBEPBUwxEventTable@@XZ)
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual class wxEventHashTable & __thiscall wxSFMLCanvas::GetEventHashTable(void)const " (?GetEventHashTable@wxSFMLCanvas@@MBEAAVwxEventHashTable@@XZ)
1>minimal.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall wxSFMLCanvas::OnUpdate(void)" (?OnUpdate@wxSFMLCanvas@@MAEXXZ)
1>minimal.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall wxSFMLCanvas::~wxSFMLCanvas(void)" (??1wxSFMLCanvas@@UAE@XZ) referenced in function "public: virtual void * __thiscall wxSFMLCanvas::`scalar deleting destructor'(unsigned int)" (??_GwxSFMLCanvas@@UAEPAXI@Z)
1>vc_mswud\minimal.exe : fatal error LNK1120: 4 unresolved externals

NB : I implemented the code on the minimal sample from wxWidget ( so that I didnt have to add wxWidget dependancies) and I have added the lib/include SFML dependancies :
(linker/General, Linker/Input and c/c++/General)
I'm sure I' doing a mistake so;ewhere ( i do believe that its a problem of linking libraries ) but as I'm completely new to wxWidget, I just tried what I thought was the easier : comes from their sample to add SFML2.0 inside. I hope you can help me here,

Thanks,

gabriel

6
Window / Re: SFML : trying to open a WxFrame
« on: July 10, 2013, 09:15:37 pm »
Ok, thanks, i'll keep you in touch with my work ;)

7
Window / Re: SFML : trying to open a WxFrame
« on: July 10, 2013, 07:28:52 pm »
hm,

yes sure, but I do not think I am able to re-create an existing library (even small) in (not even) one month or two, that's why I wanted to use the library I linked, it's just "easy-to-use" but using a wxWidget.

I was thinking of another solution tho :
do you think it is possible to include my SFML work (SFML GUI) into a wxWidget (I've seen there was a tutorial on SFML1.6) and to create new SFML window from here ?
As a result, I will be able (instead of having one SFML window opening a WxFrame) to have one WxFrame with 2 tabs, one including my GUI SFML (which should allow the user to open SMFL window) and the other tab with the curves using wxMathplot ?
Do you think this is possible to implement ?

8
Window / Re: SFML : trying to open a WxFrame
« on: July 10, 2013, 06:20:18 pm »
Well, i have drawn the curve using a class Curve I've created (a vector of sf::Vertex) with this method
void Curve::drawIn(sf::RenderWindow& window)
{
        sf::VertexArray copyCurveInArray(sf::PrimitiveType::LinesStrip,mPoints.size()); // draw the curve as a line in SFML
        for (int i = 0; i < mPoints.size(); i++)
        {
                copyCurveInArray[i].position.x = mPoints.at(i).position.x;
                copyCurveInArray[i].position.y = -mPoints.at(i).position.y + 200;
                copyCurveInArray[i].color = sf::Color::Black;
        }
        window.draw(copyCurveInArray);
}

but I wanted to use http://wxmathplot.sourceforge.net/screenshot.shtml library (that allows you to "move" in the window, zoomin, zoomout "super easily" (it wasn't easy to have the samples of this library working, but now that I managed to have the samples working, that would be awesome if I was able to draw the curves in this window)
If you have an idea using only SFML but having zoomin/zoomout/wheel motion/ display/hide grid ..., I would like to ,)

9
Window / SFML : trying to open a WxFrame
« on: July 10, 2013, 06:00:10 pm »
Hello community,

For some reasons ( I need to display curves that I have generated ), I need to merge WxWidget and SFML.
I don't want to put SFML in a wxFrame, I just want to be able to create a new window ( a wxFrame ) from SFML.

To be precise, I got my all GUI made with SFML (super easy to use this library, this is awesome :D), and I got a button on this GUI called "create Curve". When the user clicks on this button, I would like to open a WxFrame (using wxMathPlot) to display some curves generated.
Any one has an idea how to do this ? I've been able to draw a wxFrame + my SFML GUI but the wxFrame is "dead".
I do not know if it is possible tho, but I feel that it is ;) .
Any ideas are welcome ;)

10
Window / Minimizing window - bug or me ?
« on: June 24, 2013, 10:17:17 pm »
Hello!

I think I have found a bug due to Windows7 use (not sure if it's me or a bug, but i'm pretty sure this is a bug or something just different from windows 'minimize' function).
Here is my code :
    while (windowMain.isOpen())
        {
                sf::Event event;
                while (windowMain.pollEvent(event))
                {
                        switch (event.type)
                        {
                                case sf::Event::Closed: // closing using the cross button of the window
                                        windowMain.close(); // close the main window and gets out of this loop
                                        break;
                                       
                                case sf::Event::GainedFocus :
                                        if (minimized) // just to draw the window only when needed
                                        {
                                                windowMain.clear(COLOR_BACKGROUND_WINDOW);
                                                mGUInterface.drawIn(windowMain,mFont);
                                                windowMain.display();
                                        }
                                        minimized = false;
                                        break;
                                       
                                case sf::Event::LostFocus :
                                        if (windowMain.getSize().y == 0)
                                        {
                                                minimized = true;
                                        }
            }
        }
    }

The bug is : clicking on the minimize button then on the window to have it displayed works well, but using the little button in Windows7 called 'Show Desktop' that minimizes all the windows, doesn't.
I have no idea if this is a bug or just maybe something done different with the 'minimize button' of windows7 desktop, but I wanted to share this with you if you haven't seen this already ;)
I hope it can help/improve something (i don't know if I'm mistaking saying this is a bug, but it apparently looks like one).

EDIT : Also, clicking on the program task bar to minimize the program will minimize it, but restauring it will not display the window again. Is this because the size of the window is 0,0 when clicking on the minimize button & not 0,0 when reducing from the menu taskbar ?

Edit-EDIT : yes it's correct ! The size is not 0,0 when minimizing from Windows taskbar.
However, do you know how to get this event ?

Thanks if you have the solution for this ;)

11
Window / Re: sf::Event::LostFocus
« on: June 24, 2013, 03:19:39 pm »
Hello,

I managed to get exactly the same issue (wasn't so easy actually, I do believe there's a problem of mine somewhere - Well here is the minimal code :
#include <iostream>
#include <string>

using namespace std;

void createWindowAux(sf::RenderWindow& window)
{
        if (!window.isOpen())
        window.create(sf::VideoMode(400,400),
                "2nd window", sf::Style::Titlebar | sf::Style::Close);
}

 int main ()
{
        sf ::RenderWindow windowMain;
        windowMain.create(sf::VideoMode(700,800), "Simple Test");
        sf::RenderWindow windowAux;
        bool mIsComponentActive = false;

    while (windowMain.isOpen())
    {
        sf::Event event;
        while (windowMain.pollEvent(event))
        {
            switch (event.type)
                        {
                case sf::Event::Closed: // closing using the cross button of the window
                                        windowMain.close(); // close the main window and gets out of this loop
                                break;

                                case sf::Event::MouseButtonPressed:
                                        mIsComponentActive = false;
                                        sf::Vector2i localPosition = sf::Mouse::getPosition(windowMain);
                                        if (localPosition.y < 30)
                                        {
                                                mIsComponentActive = true;
                                                createWindowAux(windowAux);
                                        }
                                        windowAux.display();
                                break;
                        }
                }
                while (windowAux.pollEvent(event))
        {
                        if (mIsComponentActive)
                        {
                                switch (event.type)
                                {
                                        case sf::Event::Closed: // closing using the cross button of the window
                                                windowAux.close(); // close the main window and gets out of this loop
                                        break;

                                        case sf::Event::LostFocus:
                                                cout << "LOSTFOCUS" << endl;
                                                windowAux.clear(COLOR_BACKGROUND_WINDOW);
                                        break;

                                        case sf::Event::GainedFocus :
                                                windowAux.clear(COLOR_BACKGROUND_WINDOW);
                                                // put objects here
                                                windowAux.display();
                                                cout << "GAINFOCUS" << endl;
                                        break;
                                }
                        }
                }
        }

    return 0;
}

The sequence of events I am doing to get the 'bug' is the following one :
  • first click on the top of the first window which displayed ("simple test" window)
    You should have windowAux opened now
  • Then click on windowMain : you don't get 'LOSTFOCUS' in cout.
    Moreover, if you try to open windowAux from the taskbar of window, you will only be able to minimize it (closing it will not work)

Now, do exactly the same things, but instead of clicking on windowMain to get back to this window, just click on another program opened : this time you get the even 'LOSTFOCUS'.

I hope it's clear enough. Again, the bug is not that easy to explain too, please ask me questions if you do not understand something I'm saying.

Thanks

Edit : I do see the bug... It comes from my boolean. Mmhh, I'll try to manage this ;-)

12
Window / Re: sf::Event::LostFocus
« on: June 21, 2013, 10:40:56 pm »
The example I give you should present the problem I am talking about. I have no idea where it comes from tho :/

13
Window / Re: sf::Event::LostFocus
« on: June 21, 2013, 09:45:56 pm »
I'll try to give you a really simplify version of the issue I am encountering. This is just to show you where is my problem :

// windowMain and windowAux are two sf::renderwindow created
while (windowMain.isOpen())
{
    sf::Event event;
    while (windowMain.pollEvent(event))
    {
        switch (event.type)
        {
            case sf::Event::Closed: // closing using the cross button of the window
                windowMain.close(); // close the main window and gets out of this loop
                break;
            case sf::Event::MouseButtonPressed: // clicking
                createWindowAux(windowAux); // pops windowAux
                windowAux.display();
                break;
            default:
                break;
        }
    }
    while (windowAux.pollEvent(event)) // loop on editing/reading attributes
    {
        switch (event.type)
        {
            case sf::Event::Closed:
                windowAux.clear(COLOR_BACKGROUND_WINDOW);
                windowAux.close();
                break;

            case sf::Event::LostFocus:
                cout << "LOSTFOCUS" << endl;
                break;

            case sf::Event::GainedFocus :
                windowAux.clear(COLOR_BACKGROUND_WINDOW);
                // add objects here
                windowAux.display();
                cout << "GAINFOCUS" << endl;
                break;
            case sf::Event::Resized :
                cout << "RESIZED" << endl;
                break;
            default:
                break;
        }
    }
}
 

I just re-explain the problem I got (not so easy to explain sorry). By clicking on the mainWindow while the windowAux is opened, i do not get the event LOSTFOCUS in window2 (maybe I need to make 2 distincts event but I do not think so - events should be all equal at same time I suppose).
However, clicking on an other window - (not from SFML) as MicrosoftVisualStudios (for instance) - will give me the lostfocus event.

Also, this is the code for the creation of the window :
void createWindowForAttributes(sf::RenderWindow& window)
{
        if (!window.isOpen()) // if not already opened, creation of the window
        {
                window.create(sf::VideoMode(WIDTH_WINDOW_ATTRIBUTE,
                        HEIGHT_WINDOW_ATTRIBUTE),
                        "Editing", sf::Style::Titlebar | sf::Style::Close);
        }
        window.setTitle("Editing");
        window.setSize(sf::Vector2u(WIDTH_WINDOW_ATTRIBUTE,
                HEIGHT_WINDOW_ATTRIBUTE));
        window.clear(COLOR_BACKGROUND_WINDOW);
}
 

Thanks,
Tell me if you need anything else for the explanation,

Gabriel

14
Window / [SOLVED] sf::Event::LostFocus
« on: June 21, 2013, 09:01:42 pm »
Hello community =)

I have a question about the event : sf::Event::LostFocus and sf::Event::GainFocus.
I have 2 sf::RenderWindow opened. Let's call them window1 and window2.
Window1 is permanently opened, and window2 can open itself from interactions with window1 ( if you click on a button from window1, you will see window2 appear, "partially on" window1).
That works well and I get focus on window2 when opening it.

However, if, from here, I click on window1, I do not get an event lost focus from window2. Clicking on an other application exactly the SAME way will give me the event 'lostfocus'.
I do not know if this is a problem in my program or a problem from SFML library. Please help me, I have no idea how to correct this bug,

Thanks in advance,

Gabriel

15
Graphics / Re: Draw "not standard" char
« on: June 14, 2013, 07:33:56 pm »
Ah perfect, I managed to use sf::String correctly !

Thanks for the responses.

Pages: [1] 2
anything