Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: QtCreator 4.7.3 with SFML 1.6 [Windows 7]  (Read 2010 times)

0 Members and 1 Guest are viewing this topic.

Jany

  • Newbie
  • *
  • Posts: 9
    • View Profile
QtCreator 4.7.3 with SFML 1.6 [Windows 7]
« on: December 06, 2011, 02:41:29 pm »
Good afternoon,

i am trying to use the SFML Libraries, i downloaded the MingW Libraries, within the QtCreator but its driving me crazy because its always telling me some different errors, now i am at this error:

But now it works to start, but no window appears on my desktop it only says this:
Quote
Start F:\Programming\Basic\spiele\pixelmännchenspiel\Pixelmännchenspiel-build-desktop\debug\Pixelmann.exe...
F:\Programming\Basic\spiele\pixelmännchenspiel\Pixelmännchenspiel-build-desktop\debug\Pixelmann.exe beendet, Rückgabewert -1073741819

Rückgabewert = Return Code

This is my *.pro file:
Code: [Select]
TARGET = Pixelmann

HEADERS += pixelmann_gui.hpp \
    pixelmann_qsfmlwidget.hpp
SOURCES += pixelmann_gui.cpp \
    pixelmann_main.cpp \
    pixelmann_qsfmlwidget.cpp

win32 {
  INCLUDEPATH += F:/Programming/Basic/SFML-1.6/include
  LIBS += "F:/Programming/Basic/SFML-1.6/lib/libsfml-graphics-s-d.a" \
          "F:/Programming/Basic/SFML-1.6/lib/libsfml-window-s-d.a" \
          "F:/Programming/Basic/SFML-1.6/lib/libsfml-system-s-d.a"
}


For this i have to say, i dont really know which of the libraries to use. i tried using libsfml-*.a, libsfml-*-d.a, libsfml-*-s.a and the libsfml-*-s-d.a


And this is the Declaration and Definition of the Widget. It is made with the Tutorial found in the SFML 1.6 Tutorial Section "Using SFML with Qt Interface"
Declaration:
Code: [Select]
#ifndef PIXELMANN_QSFMLWIDGET_HPP
#define PIXELMANN_QSFMLWIDGET_HPP

#include <SFML/Graphics.hpp>
#include <QPaintEngine>
#include <QPaintEvent>
#include <QShowEvent>
#include <QTimer>
#include <QWidget>

class QSFMLWidget : public QWidget, public sf::RenderWindow {
    Q_OBJECT
private:
    bool initiert;
    QTimer *idleTimer;
    sf::Image myImage;
    sf::Sprite mySprite;

    void OnInit();
    void OnUpdate();
    QPaintEngine* paintEngine() const;
    void showEvent(QShowEvent *);
    void paintEvent(QPaintEvent *);

public:
    QSFMLWidget(QWidget *parent = 0, unsigned int frameTime = 0);
    ~QSFMLWidget();
};

#endif // PIXELMANN_QSFMLWIDGET_HPP


Definition:
Code: [Select]

#include "pixelmann_qsfmlwidget.hpp"
#ifdef Q_WS_X11
    #include <qx11info_x11.h>
    #include <X11/Xlib.h>
#endif

QSFMLWidget::QSFMLWidget(QWidget *parent, unsigned int frameTime) :
    QWidget(parent),
    initiert(false) {
    // Setup some states to allow direct rendering into the Widget.
    setAttribute(Qt::WA_PaintOnScreen);
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);

    // Set Strong Focus to enable keyboard events to be received
    setFocusPolicy(Qt::StrongFocus);

    // Setup the Timer
    idleTimer->setInterval(frameTime);

    return;
}

QSFMLWidget::~QSFMLWidget(){
    return;
}

void QSFMLWidget::showEvent(QShowEvent *) {
    if ( !initiert ) {
        // Under X11, we need to flush the commands sent to the server to ensure
        // that SFML will get an updated view of the windows
        #ifdef Q_WS_X11
            XFlush(QX11Info::display());
        #endif
        ;
        // Create the SFML Window with the widget handle
        Create(winId());

        //Initalize
        OnInit();

        //Setup the Timer to trigger a refresh at specified framerate
        connect(idleTimer, SIGNAL(timeout()), this, SLOT(repaint()));
        idleTimer->start();

        initiert = true;
    } // if ( !initiert )

    return;
}

QPaintEngine* QSFMLWidget::paintEngine() const {
    return 0;
}

void QSFMLWidget::paintEvent(QPaintEvent *) {
    // Update the window
    OnUpdate();

    // Display on Screen
    Display();

    return;
}

void QSFMLWidget::OnInit() {
    // Load the Image
    myImage.LoadFromFile("images/screen/screensaver.png");

    // Setup the Sprite
    mySprite.SetImage(myImage);
    mySprite.SetCenter(mySprite.GetSize() / 2.0f);

    return;
}

void QSFMLWidget::OnUpdate() {
    // Clear Screen
    Clear(sf::Color(0,128,0));

    // Rotate the Sprite
    mySprite.Rotate(GetFrameTime() * 100.f);

    // Draw it
    Draw(mySprite);
}


King regards
Jany

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
QtCreator 4.7.3 with SFML 1.6 [Windows 7]
« Reply #1 on: December 06, 2011, 02:55:50 pm »
Quote
For this i have to say, i dont really know which of the libraries to use. i tried using libsfml-*.a, libsfml-*-d.a, libsfml-*-s.a and the libsfml-*-s-d.a

It is explained in the tutorial ;)

Quote
F:\Programming\Basic\spiele\pixelmännchenspiel\Pixelmännchenspiel-build-desktop\debug\Pixelmann.exe beendet, Rückgabewert -1073741819

Why don't you run the debugger?
Laurent Gomila - SFML developer

Jany

  • Newbie
  • *
  • Posts: 9
    • View Profile
QtCreator 4.7.3 with SFML 1.6 [Windows 7]
« Reply #2 on: December 06, 2011, 03:07:09 pm »
Yes i m sorry, i could have dont it before posting ;)

I did it and it was such an silly Error
i did QSFMLWidget *gameWorld; in the Class Declaration
but i forgot to write gameWorld = new QSFMLWidget(this); into the Constructor...
im silly, sorry ^^

Regards
Jany