Bonjour, je reposte j'ai encore besoin d'aide ^^
Donc avant d'arriver à ce crash j'ai télécharger la SFML, les sources j'ai configuré le makefiles avec CMake (MinGW en config) puis avec mingw 4.9.2 je l'ai compiler puis installer avec les commande mingw32-make et mingw32-make install, tous c'est bien passer j'ai bien eu mon dossier SFML qui c'est crée.
J'ai donc liée ce dossier en modifiant mon .pro mais lors de la compilation j'ai eu qu'un crash,(j'ai copier les DLL compilée dans le projet) j'ai du faire une erreur lors d'une étape mais je vois pas ou, j'ai refait la manip sur plusieurs pc et j'arrive au même point.
.pro#-------------------------------------------------
#
# Project created by QtCreator 2015-11-24T13:23:33
#
#-------------------------------------------------
QT += core
QT -= gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MARCHE
TEMPLATE = app
SOURCES += \
graphics-qt.cpp \
qsfmlcanvas.cpp
HEADERS += \
qsfmlcanvas.h
FORMS += mainwindow.ui
LIBS += -LC:\Qt\SFML\lib
CONFIG(release, debug|release):LIBS += -lsfml-audio -lsfml-main -lsfml-window -lsfml-graphics -lsfml-system
CONFIG(debug, debug|release):LIBS += -lsfml-audio-d -lsfml-main-d -lsfml-window-d -lsfml-graphics-d -lsfml-system-d
INCLUDEPATH += C:\Qt\SFML\include
DEPENDPATH += C:\Qt\SFML\include
/!\ J'ai trouver ce code sur un tutoriel qui donné ce code comme code fonctionnel pour tester Qt&SFML /!\
qsfmlcanvas.cpp////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "qsfmlcanvas.h"
// Platform-specific headers
#ifdef Q_WS_X11
#include <Qt/qx11info_x11.h>
#include <X11/Xlib.h>
#endif
////////////////////////////////////////////////////////////
/// Construct the QSFMLCanvas
////////////////////////////////////////////////////////////
QSFMLCanvas::QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime) :
QWidget (Parent),
myInitialized (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 widget geometry
move(Position);
resize(Size);
// Setup the timer
myTimer.setInterval(FrameTime);
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
QSFMLCanvas::~QSFMLCanvas()
{
// Nothing to do...
}
////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing initializations
////////////////////////////////////////////////////////////
void QSFMLCanvas::onInit()
{
// Nothing to do by default...
}
////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing its update and drawing stuff
////////////////////////////////////////////////////////////
void QSFMLCanvas::onUpdate()
{
// Nothing to do by default...
}
////////////////////////////////////////////////////////////
/// Return the paint engine used by the widget to draw itself
////////////////////////////////////////////////////////////
QPaintEngine* QSFMLCanvas::paintEngine() const
{
return 0;
}
////////////////////////////////////////////////////////////
/// Called when the widget is shown ;
/// we use it to initialize our SFML window
////////////////////////////////////////////////////////////
void QSFMLCanvas::showEvent(QShowEvent*)
{
if (!myInitialized)
{
// 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
// The qualification is needed because QWidget::create also exists
//RenderWindow::create(winId());
RenderWindow::create(reinterpret_cast<sf::WindowHandle>(winId()));
// Let the derived class do its specific stuff
onInit();
// Setup the timer to trigger a refresh at specified framerate
connect(&myTimer, SIGNAL(timeout()), this, SLOT(repaint()));
myTimer.start();
myInitialized = true;
}
}
////////////////////////////////////////////////////////////
/// Called when the widget needs to be painted ;
/// we use it to display a new frame
////////////////////////////////////////////////////////////
void QSFMLCanvas::paintEvent(QPaintEvent*)
{
// Let the derived class do its specific stuff
onUpdate();
// Display on screen
display();
}
qsfmlcanvas.h#ifndef QSFMLCANVAS_HPP
#define QSFMLCANVAS_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <QWidget.h>
#include <QTimer.h>
////////////////////////////////////////////////////////////
/// QSFMLCanvas allows to run SFML in a Qt control
////////////////////////////////////////////////////////////
class QSFMLCanvas : public QWidget, public sf::RenderWindow
{
public :
////////////////////////////////////////////////////////////
/// Construct the QSFMLCanvas
///
/// \param Parent : Parent of the widget
/// \param Position : Position of the widget
/// \param Size : Size of the widget
/// \param FrameTime : Frame duration, in milliseconds (0 by default)
///
////////////////////////////////////////////////////////////
QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);
////////////////////////////////////////////////////////////
/// Destructor
///
////////////////////////////////////////////////////////////
virtual ~QSFMLCanvas();
private :
////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing initializations
///
////////////////////////////////////////////////////////////
virtual void onInit();
////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing its update and drawing stuff
///
////////////////////////////////////////////////////////////
virtual void onUpdate();
////////////////////////////////////////////////////////////
/// Return the paint engine used by the widget to draw itself
///
////////////////////////////////////////////////////////////
virtual QPaintEngine* paintEngine() const;
////////////////////////////////////////////////////////////
/// Called when the widget is shown ;
/// we use it to initialize our SFML window
///
////////////////////////////////////////////////////////////
virtual void showEvent(QShowEvent*);
////////////////////////////////////////////////////////////
/// Called when the widget needs to be painted ;
/// we use it to display a new frame
///
////////////////////////////////////////////////////////////
virtual void paintEvent(QPaintEvent*);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
QTimer myTimer; ///< Timer used to update the view
bool myInitialized; ///< Tell whether the SFML window has been initialized or not
};
#endif // QSFMLCANVAS_HPP
graphics-qt.cpp////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "qsfmlcanvas.h"
#include <QApplication.h>
#include <QFrame.h>
////////////////////////////////////////////////////////////
/// Custom SFML canvas
////////////////////////////////////////////////////////////
class MyCanvas : public QSFMLCanvas
{
public :
////////////////////////////////////////////////////////////
/// Construct the canvas
///
////////////////////////////////////////////////////////////
MyCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size) :
QSFMLCanvas(Parent, Position, Size)
{
}
private :
////////////////////////////////////////////////////////////
/// /see QSFMLCanvas::onInit
///
////////////////////////////////////////////////////////////
void onInit()
{
// Load the image
myTexture.loadFromFile(QApplication::applicationDirPath().toStdString() + "/sfml.png");
// Setup the sprite
mySprite.setTexture(myTexture);
mySprite.setOrigin(sf::Vector2f(myTexture.getSize()) / 2.f);
clock.restart();
}
////////////////////////////////////////////////////////////
/// /see QSFMLCanvas::onUpdate
///
////////////////////////////////////////////////////////////
void onUpdate()
{
// Clear screen
clear(sf::Color(0, 128, 0));
// Rotate the sprite
mySprite.rotate(clock.getElapsedTime().asSeconds() * 100.f);
// Draw it
draw(mySprite);
clock.restart();
}
////////////////////////////////////////////////////////////
/// Member data
////////////////////////////////////////////////////////////
sf::Texture myTexture; ///< Some image to show
sf::Sprite mySprite; ///< A sprite to display the image
sf::Clock clock; ///< to get the time of each frame
};
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
QApplication App(argc, argv);
// Create the main frame
QFrame* MainFrame = new QFrame;
MainFrame->setWindowTitle("Qt SFML");
MainFrame->resize(400, 400);
MainFrame->show();
// Create a SFML view inside the main frame
MyCanvas* SFMLView = new MyCanvas(MainFrame, QPoint(20, 20), QSize(360, 360));
SFMLView->show();
return App.exec();
}
Merci pour votre aide