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:
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:
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:
#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:
#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