# HG changeset patch # User benoitrigolleau # Date 1194532932 0 # Node ID e236ce53a2e7e4d4d4b6ab31d13b470f620d4c9a # Parent b5087d5a7814d194f14f20b52d28912978c39165 diff -r b5087d5a7814 -r e236ce53a2e7 data/model/SDLWidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/SDLWidget.cpp Thu Nov 08 14:42:12 2007 +0000 @@ -0,0 +1,40 @@ +#include +#include +#include +#include "SDLWidget.h" + +SDLWidget::SDLWidget() + :windowInitialized(false), screen(0) + { + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_NoSystemBackground); + setMinimumSize(320,240); + resize(320, 240); + } + +SDLWidget::~SDLWidget() + { + SDL_Quit(); + } + +void SDLWidget::showEvent(QShowEvent *e) + { + (void)e; + if(!windowInitialized) + { + // it's here the link between SDL and QT + char windowid[64]; +#ifdef Q_WS_WIN + sprintf(windowid, "SDL_WINDOWID=0x%lx", reinterpret_cast(winId())); +#elif defined Q_WS_X11 + sprintf(windowid, "SDL_WINDOWID=0x%lx", winId()); +#else + qFatal("uncorrect window ID"); +#endif + SDL_putenv(windowid); + + //SDL_Init(SDL_INIT_VIDEO); + //screen = SDL_SetVideoMode(width(), height(), 32, SDL_SWSURFACE); + windowInitialized = true; + } + } \ No newline at end of file diff -r b5087d5a7814 -r e236ce53a2e7 data/model/SDLWidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/SDLWidget.h Thu Nov 08 14:42:12 2007 +0000 @@ -0,0 +1,32 @@ +#ifndef _SDL_WIDGET_H +#define _SDL_WIDGET_H +#include +#include +#include + +#ifdef WIN32 +#include +#endif +#ifdef __unix__ +#include +#endif +#undef main + +class SDLWidget : public QWidget +{ + Q_OBJECT + +public: + SDLWidget(); + virtual ~SDLWidget(); + +protected: + + bool windowInitialized; + SDL_Surface *screen; + + virtual void showEvent(QShowEvent *e); +}; + + +#endif