mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Remove hwnd and related ddraw stuff
This commit is contained in:
parent
0d8a21dd47
commit
ac144a0522
56
blupi.cpp
56
blupi.cpp
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
// Variables globales
|
// Variables globales
|
||||||
|
|
||||||
HWND g_hWnd; // handle à la fenêtre
|
|
||||||
SDL_Window *g_window;
|
SDL_Window *g_window;
|
||||||
SDL_Renderer *g_renderer;
|
SDL_Renderer *g_renderer;
|
||||||
CEvent* g_pEvent = NULL;
|
CEvent* g_pEvent = NULL;
|
||||||
@ -416,10 +415,10 @@ bool InitFail(char *msg, bool bDirectX)
|
|||||||
else strcpy(buffer, "Error (");
|
else strcpy(buffer, "Error (");
|
||||||
strcat(buffer, msg);
|
strcat(buffer, msg);
|
||||||
strcat(buffer, ")");
|
strcat(buffer, ")");
|
||||||
MessageBox(g_hWnd, buffer, TITLE, MB_OK);
|
|
||||||
|
SDL_ShowSimpleMessageBox (SDL_MessageBoxFlags::SDL_MESSAGEBOX_ERROR, "Error", buffer, g_window);
|
||||||
|
|
||||||
FinishObjects();
|
FinishObjects();
|
||||||
DestroyWindow(g_hWnd);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +426,6 @@ bool InitFail(char *msg, bool bDirectX)
|
|||||||
|
|
||||||
static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
|
||||||
POINT totalDim, iconDim;
|
POINT totalDim, iconDim;
|
||||||
RECT rcRect;
|
RECT rcRect;
|
||||||
bool bOK;
|
bool bOK;
|
||||||
@ -444,21 +442,6 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|||||||
// Create a window.
|
// Create a window.
|
||||||
if ( g_bFullScreen )
|
if ( g_bFullScreen )
|
||||||
{
|
{
|
||||||
g_hWnd = CreateWindowEx
|
|
||||||
(
|
|
||||||
WS_EX_TOPMOST,
|
|
||||||
NAME,
|
|
||||||
TITLE,
|
|
||||||
WS_POPUP,
|
|
||||||
0, 0,
|
|
||||||
GetSystemMetrics(SM_CXSCREEN),
|
|
||||||
GetSystemMetrics(SM_CYSCREEN),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
hInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
g_window = SDL_CreateWindow (
|
g_window = SDL_CreateWindow (
|
||||||
NAME,
|
NAME,
|
||||||
0, 0,
|
0, 0,
|
||||||
@ -469,31 +452,6 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sx, sy;
|
|
||||||
RECT WindowRect;
|
|
||||||
|
|
||||||
sx = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
sy = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
|
|
||||||
SetRect(&WindowRect, (sx-LXIMAGE)/2, (sy-LYIMAGE)/2,
|
|
||||||
(sx+LXIMAGE)/2, (sy+LYIMAGE)/2);
|
|
||||||
AdjustWindowRect(&WindowRect, WS_POPUPWINDOW|WS_CAPTION, true);
|
|
||||||
WindowRect.top += GetSystemMetrics(SM_CYCAPTION);
|
|
||||||
|
|
||||||
g_hWnd = CreateWindow
|
|
||||||
(
|
|
||||||
NAME,
|
|
||||||
TITLE,
|
|
||||||
WS_POPUPWINDOW|WS_CAPTION|WS_VISIBLE,
|
|
||||||
(sx-LXIMAGE)/2, (sy-LYIMAGE)/2,
|
|
||||||
WindowRect.right - WindowRect.left,
|
|
||||||
WindowRect.bottom - WindowRect.top,
|
|
||||||
HWND_DESKTOP,
|
|
||||||
NULL,
|
|
||||||
hInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
g_window = SDL_CreateWindow (NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, LXIMAGE, LYIMAGE, 0);
|
g_window = SDL_CreateWindow (NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, LXIMAGE, LYIMAGE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,10 +469,6 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(g_hWnd, nCmdShow);
|
|
||||||
UpdateWindow(g_hWnd);
|
|
||||||
SetFocus(g_hWnd);
|
|
||||||
|
|
||||||
if ( !bOK ) // config.def pas correct ?
|
if ( !bOK ) // config.def pas correct ?
|
||||||
{
|
{
|
||||||
return InitFail("Game not correctly installed", false);
|
return InitFail("Game not correctly installed", false);
|
||||||
@ -526,7 +480,7 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|||||||
|
|
||||||
totalDim.x = LXIMAGE;
|
totalDim.x = LXIMAGE;
|
||||||
totalDim.y = LYIMAGE;
|
totalDim.y = LYIMAGE;
|
||||||
if ( !g_pPixmap->Create(g_hWnd, totalDim, g_bFullScreen, g_mouseType) )
|
if ( !g_pPixmap->Create(totalDim, g_bFullScreen, g_mouseType) )
|
||||||
return InitFail("Create pixmap", true);
|
return InitFail("Create pixmap", true);
|
||||||
|
|
||||||
OutputDebug("Image: init\n");
|
OutputDebug("Image: init\n");
|
||||||
@ -677,14 +631,14 @@ static bool DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|||||||
g_pDecor = new CDecor;
|
g_pDecor = new CDecor;
|
||||||
if ( g_pDecor == NULL ) return InitFail("New decor", false);
|
if ( g_pDecor == NULL ) return InitFail("New decor", false);
|
||||||
|
|
||||||
g_pDecor->Create(g_hWnd, g_pSound, g_pPixmap);
|
g_pDecor->Create(g_pSound, g_pPixmap);
|
||||||
g_pDecor->MapInitColors();
|
g_pDecor->MapInitColors();
|
||||||
|
|
||||||
// Crée le gestionnaire d'événements.
|
// Crée le gestionnaire d'événements.
|
||||||
g_pEvent = new CEvent;
|
g_pEvent = new CEvent;
|
||||||
if ( g_pEvent == NULL ) return InitFail("New event", false);
|
if ( g_pEvent == NULL ) return InitFail("New event", false);
|
||||||
|
|
||||||
g_pEvent->Create(g_hWnd, g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
g_pEvent->Create(g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
||||||
g_pEvent->SetFullScreen(g_bFullScreen);
|
g_pEvent->SetFullScreen(g_bFullScreen);
|
||||||
g_pEvent->SetMouseType(g_mouseType);
|
g_pEvent->SetMouseType(g_mouseType);
|
||||||
#if _INTRO
|
#if _INTRO
|
||||||
|
@ -41,7 +41,7 @@ CButton::~CButton()
|
|||||||
|
|
||||||
// Crée un nouveau bouton.
|
// Crée un nouveau bouton.
|
||||||
|
|
||||||
bool CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool CButton::Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int type, bool bMinimizeRedraw,
|
POINT pos, int type, bool bMinimizeRedraw,
|
||||||
int *pMenu, int nbMenu,
|
int *pMenu, int nbMenu,
|
||||||
int *pToolTips, int nbToolTips,
|
int *pToolTips, int nbToolTips,
|
||||||
@ -60,7 +60,6 @@ bool CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|||||||
iconDim.x = ttypes[type*2+0];
|
iconDim.x = ttypes[type*2+0];
|
||||||
iconDim.y = ttypes[type*2+1];
|
iconDim.y = ttypes[type*2+1];
|
||||||
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
m_pPixmap = pPixmap;
|
||||||
m_pSound = pSound;
|
m_pSound = pSound;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
3
button.h
3
button.h
@ -10,7 +10,7 @@ public:
|
|||||||
CButton();
|
CButton();
|
||||||
~CButton();
|
~CButton();
|
||||||
|
|
||||||
bool Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int type, bool bMinimizeRedraw,
|
POINT pos, int type, bool bMinimizeRedraw,
|
||||||
int *pMenu, int nbMenu,
|
int *pMenu, int nbMenu,
|
||||||
int *pTooltips, int nbToolTips,
|
int *pTooltips, int nbToolTips,
|
||||||
@ -42,7 +42,6 @@ protected:
|
|||||||
bool MouseUp(POINT pos);
|
bool MouseUp(POINT pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
CPixmap* m_pPixmap;
|
||||||
CDecor* m_pDecor;
|
CDecor* m_pDecor;
|
||||||
CSound* m_pSound;
|
CSound* m_pSound;
|
||||||
|
@ -99,7 +99,6 @@ POINT GetVector(int direct)
|
|||||||
|
|
||||||
CDecor::CDecor()
|
CDecor::CDecor()
|
||||||
{
|
{
|
||||||
m_hWnd = NULL;
|
|
||||||
m_pSound = NULL;
|
m_pSound = NULL;
|
||||||
m_pUndoDecor = NULL;
|
m_pUndoDecor = NULL;
|
||||||
|
|
||||||
@ -149,9 +148,8 @@ CDecor::~CDecor()
|
|||||||
|
|
||||||
// Initialisation générale.
|
// Initialisation générale.
|
||||||
|
|
||||||
void CDecor::Create(HWND hWnd, CSound *pSound, CPixmap *pPixmap)
|
void CDecor::Create(CSound *pSound, CPixmap *pPixmap)
|
||||||
{
|
{
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pSound = pSound;
|
m_pSound = pSound;
|
||||||
m_pPixmap = pPixmap;
|
m_pPixmap = pPixmap;
|
||||||
m_bOutline = false;
|
m_bOutline = false;
|
||||||
|
3
decor.h
3
decor.h
@ -363,7 +363,7 @@ public:
|
|||||||
POINT ConvPosToCel(POINT pos, bool bMap=false);
|
POINT ConvPosToCel(POINT pos, bool bMap=false);
|
||||||
POINT ConvPosToCel2(POINT pos);
|
POINT ConvPosToCel2(POINT pos);
|
||||||
|
|
||||||
void Create(HWND hWnd, CSound *pSound, CPixmap *pPixmap);
|
void Create(CSound *pSound, CPixmap *pPixmap);
|
||||||
void Init(int channel, int icon);
|
void Init(int channel, int icon);
|
||||||
void InitAfterBuild();
|
void InitAfterBuild();
|
||||||
void ResetHili();
|
void ResetHili();
|
||||||
@ -439,7 +439,6 @@ protected:
|
|||||||
int GetSeeIcon(char *pBits, int index);
|
int GetSeeIcon(char *pBits, int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND m_hWnd;
|
|
||||||
CSound* m_pSound;
|
CSound* m_pSound;
|
||||||
CPixmap* m_pPixmap;
|
CPixmap* m_pPixmap;
|
||||||
Cellule* m_pUndoDecor;
|
Cellule* m_pUndoDecor;
|
||||||
|
15
event.cpp
15
event.cpp
@ -1538,12 +1538,11 @@ void CEvent::SetMouseType(int mouseType)
|
|||||||
|
|
||||||
// Crée le gestionnaire d'événements.
|
// Crée le gestionnaire d'événements.
|
||||||
|
|
||||||
void CEvent::Create(HWND hWnd, CPixmap *pPixmap, CDecor *pDecor,
|
void CEvent::Create(CPixmap *pPixmap, CDecor *pDecor,
|
||||||
CSound *pSound, CMovie *pMovie)
|
CSound *pSound, CMovie *pMovie)
|
||||||
{
|
{
|
||||||
POINT pos;
|
POINT pos;
|
||||||
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
m_pPixmap = pPixmap;
|
||||||
m_pDecor = pDecor;
|
m_pDecor = pDecor;
|
||||||
m_pSound = pSound;
|
m_pSound = pSound;
|
||||||
@ -1553,10 +1552,10 @@ void CEvent::Create(HWND hWnd, CPixmap *pPixmap, CDecor *pDecor,
|
|||||||
|
|
||||||
pos.x = 10;
|
pos.x = 10;
|
||||||
pos.y = 158;
|
pos.y = 158;
|
||||||
m_jauges[0].Create(m_hWnd, m_pPixmap, m_pSound, pos, 1, true);
|
m_jauges[0].Create(m_pPixmap, m_pSound, pos, 1, true);
|
||||||
|
|
||||||
pos.y += DIMJAUGEY+2;
|
pos.y += DIMJAUGEY+2;
|
||||||
m_jauges[1].Create(m_hWnd, m_pPixmap, m_pSound, pos, 3, true);
|
m_jauges[1].Create(m_pPixmap, m_pSound, pos, 3, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1720,7 +1719,7 @@ bool CEvent::CreateButtons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buttons[i].Create(m_hWnd, m_pPixmap, m_pSound, pos,
|
m_buttons[i].Create(m_pPixmap, m_pSound, pos,
|
||||||
table[m_index].buttons[i].type,
|
table[m_index].buttons[i].type,
|
||||||
bMinimizeRedraw,
|
bMinimizeRedraw,
|
||||||
table[m_index].buttons[i].iconMenu+1,
|
table[m_index].buttons[i].iconMenu+1,
|
||||||
@ -3506,7 +3505,7 @@ bool CEvent::PlayUp(POINT pos, Uint16 mod)
|
|||||||
{
|
{
|
||||||
m_menuCel = m_pDecor->ConvPosToCel(pos);
|
m_menuCel = m_pDecor->ConvPosToCel(pos);
|
||||||
m_menuPos = pos;
|
m_menuPos = pos;
|
||||||
m_menu.Create(m_hWnd, m_pPixmap, m_pSound,
|
m_menu.Create(m_pPixmap, m_pSound,
|
||||||
pos, m_menuNb, m_menuButtons, m_menuErrors,
|
pos, m_menuNb, m_menuButtons, m_menuErrors,
|
||||||
m_menuPerso);
|
m_menuPerso);
|
||||||
m_bMenu = true;
|
m_bMenu = true;
|
||||||
@ -4031,7 +4030,7 @@ bool CEvent::StartMovie(char *pFilename)
|
|||||||
strcpy(filename+strlen(filename)-4, ".blp"); // remplace .avi par .blp
|
strcpy(filename+strlen(filename)-4, ".blp"); // remplace .avi par .blp
|
||||||
m_pSound->Cache(SOUND_MOVIE, filename);
|
m_pSound->Cache(SOUND_MOVIE, filename);
|
||||||
|
|
||||||
if ( !m_pMovie->Play(m_hWnd, rect, pFilename) ) return false;
|
if ( !m_pMovie->Play(rect, pFilename) ) return false;
|
||||||
m_bRunMovie = true;
|
m_bRunMovie = true;
|
||||||
m_pSound->Play(SOUND_MOVIE, 0, 0);
|
m_pSound->Play(SOUND_MOVIE, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
@ -4041,7 +4040,7 @@ bool CEvent::StartMovie(char *pFilename)
|
|||||||
|
|
||||||
void CEvent::StopMovie()
|
void CEvent::StopMovie()
|
||||||
{
|
{
|
||||||
m_pMovie->Stop(m_hWnd);
|
m_pMovie->Stop();
|
||||||
m_pPixmap->RestorePalette();
|
m_pPixmap->RestorePalette();
|
||||||
m_pSound->Flush(SOUND_MOVIE);
|
m_pSound->Flush(SOUND_MOVIE);
|
||||||
// m_pSound->RestartMusic();
|
// m_pSound->RestartMusic();
|
||||||
|
3
event.h
3
event.h
@ -59,7 +59,7 @@ public:
|
|||||||
~CEvent();
|
~CEvent();
|
||||||
|
|
||||||
POINT GetMousePos();
|
POINT GetMousePos();
|
||||||
void Create(HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie);
|
void Create(CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie);
|
||||||
void SetFullScreen(bool bFullScreen);
|
void SetFullScreen(bool bFullScreen);
|
||||||
void SetMouseType(int mouseType);
|
void SetMouseType(int mouseType);
|
||||||
int GetWorld();
|
int GetWorld();
|
||||||
@ -156,7 +156,6 @@ protected:
|
|||||||
bool m_bAccessBuild;
|
bool m_bAccessBuild;
|
||||||
bool m_bFullScreen;
|
bool m_bFullScreen;
|
||||||
int m_mouseType;
|
int m_mouseType;
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
CPixmap* m_pPixmap;
|
||||||
CDecor* m_pDecor;
|
CDecor* m_pDecor;
|
||||||
CSound* m_pSound;
|
CSound* m_pSound;
|
||||||
|
@ -34,10 +34,9 @@ CJauge::~CJauge()
|
|||||||
|
|
||||||
// Crée un nouveau bouton.
|
// Crée un nouveau bouton.
|
||||||
|
|
||||||
bool CJauge::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool CJauge::Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int type, bool bMinimizeRedraw)
|
POINT pos, int type, bool bMinimizeRedraw)
|
||||||
{
|
{
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
m_pPixmap = pPixmap;
|
||||||
m_pSound = pSound;
|
m_pSound = pSound;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
3
jauge.h
3
jauge.h
@ -14,7 +14,7 @@ public:
|
|||||||
CJauge();
|
CJauge();
|
||||||
~CJauge();
|
~CJauge();
|
||||||
|
|
||||||
bool Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int type, bool bMinimizeRedraw);
|
POINT pos, int type, bool bMinimizeRedraw);
|
||||||
void Draw();
|
void Draw();
|
||||||
void Redraw();
|
void Redraw();
|
||||||
@ -29,7 +29,6 @@ public:
|
|||||||
void SetRedraw();
|
void SetRedraw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
CPixmap* m_pPixmap;
|
||||||
CDecor* m_pDecor;
|
CDecor* m_pDecor;
|
||||||
CSound* m_pSound;
|
CSound* m_pSound;
|
||||||
|
3
menu.cpp
3
menu.cpp
@ -92,14 +92,13 @@ CMenu::~CMenu()
|
|||||||
|
|
||||||
// Crée un nouveau bouton.
|
// Crée un nouveau bouton.
|
||||||
|
|
||||||
bool CMenu::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool CMenu::Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int nb, int *pButtons, int *pErrors,
|
POINT pos, int nb, int *pButtons, int *pErrors,
|
||||||
int perso)
|
int perso)
|
||||||
{
|
{
|
||||||
pos.x -= DIMBUTTONX/2;
|
pos.x -= DIMBUTTONX/2;
|
||||||
pos.y -= DIMBUTTONY/2;
|
pos.y -= DIMBUTTONY/2;
|
||||||
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
m_pPixmap = pPixmap;
|
||||||
m_pSound = pSound;
|
m_pSound = pSound;
|
||||||
m_nbButtons = nb;
|
m_nbButtons = nb;
|
||||||
|
3
menu.h
3
menu.h
@ -12,7 +12,7 @@ public:
|
|||||||
CMenu();
|
CMenu();
|
||||||
~CMenu();
|
~CMenu();
|
||||||
|
|
||||||
bool Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
bool Create(CPixmap *pPixmap, CSound *pSound,
|
||||||
POINT pos, int nb, int *pButtons, int *pErrors,
|
POINT pos, int nb, int *pButtons, int *pErrors,
|
||||||
int perso);
|
int perso);
|
||||||
void Update(int nb, int *pButtons, int *pErrors);
|
void Update(int nb, int *pButtons, int *pErrors);
|
||||||
@ -33,7 +33,6 @@ protected:
|
|||||||
bool MouseUp(POINT pos);
|
bool MouseUp(POINT pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
CPixmap* m_pPixmap;
|
||||||
CDecor* m_pDecor;
|
CDecor* m_pDecor;
|
||||||
CSound* m_pSound;
|
CSound* m_pSound;
|
||||||
|
35
movie.cpp
35
movie.cpp
@ -62,7 +62,7 @@ void CMovie::termAVI()
|
|||||||
// Sets the movie rectange <rcMovie> to be
|
// Sets the movie rectange <rcMovie> to be
|
||||||
// centered within the app's window.
|
// centered within the app's window.
|
||||||
|
|
||||||
void CMovie::positionMovie(HWND hWnd, RECT rect)
|
void CMovie::positionMovie(RECT rect)
|
||||||
{
|
{
|
||||||
// reposition the playback (child) window
|
// reposition the playback (child) window
|
||||||
MoveWindow(m_hwndMovie,
|
MoveWindow(m_hwndMovie,
|
||||||
@ -73,7 +73,7 @@ void CMovie::positionMovie(HWND hWnd, RECT rect)
|
|||||||
// Close the movie and anything associated with it. |
|
// Close the movie and anything associated with it. |
|
||||||
// This function clears the <m_fPlaying> and <m_fMovieOpen> flags |
|
// This function clears the <m_fPlaying> and <m_fMovieOpen> flags |
|
||||||
|
|
||||||
void CMovie::fileCloseMovie(HWND hWnd)
|
void CMovie::fileCloseMovie()
|
||||||
{
|
{
|
||||||
MCI_GENERIC_PARMS mciGeneric;
|
MCI_GENERIC_PARMS mciGeneric;
|
||||||
|
|
||||||
@ -82,10 +82,6 @@ void CMovie::fileCloseMovie(HWND hWnd)
|
|||||||
|
|
||||||
m_fPlaying = false; // can't be playing any longer
|
m_fPlaying = false; // can't be playing any longer
|
||||||
m_fMovieOpen = false; // no more movies open
|
m_fMovieOpen = false; // no more movies open
|
||||||
|
|
||||||
// cause a total repaint to occur
|
|
||||||
InvalidateRect(hWnd, NULL, true);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +91,7 @@ void CMovie::fileCloseMovie(HWND hWnd)
|
|||||||
// the movie paused when opened.
|
// the movie paused when opened.
|
||||||
// Sets <m_fMovieOpen> on success.
|
// Sets <m_fMovieOpen> on success.
|
||||||
|
|
||||||
bool CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
bool CMovie::fileOpenMovie(RECT rect, char *pFilename)
|
||||||
{
|
{
|
||||||
MCI_DGV_OPEN_PARMS mciOpen;
|
MCI_DGV_OPEN_PARMS mciOpen;
|
||||||
MCI_DGV_WINDOW_PARMS mciWindow;
|
MCI_DGV_WINDOW_PARMS mciWindow;
|
||||||
@ -113,7 +109,7 @@ bool CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we got a filename, now close any old movie and open the new one. */
|
// we got a filename, now close any old movie and open the new one. */
|
||||||
if ( m_fMovieOpen ) fileCloseMovie(hWnd);
|
if ( m_fMovieOpen ) fileCloseMovie();
|
||||||
|
|
||||||
// we have a .AVI movie to open, use MCI
|
// we have a .AVI movie to open, use MCI
|
||||||
// set up the open parameters
|
// set up the open parameters
|
||||||
@ -123,7 +119,7 @@ bool CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
|||||||
mciOpen.lpstrElementName = string;
|
mciOpen.lpstrElementName = string;
|
||||||
mciOpen.lpstrAlias = NULL;
|
mciOpen.lpstrAlias = NULL;
|
||||||
mciOpen.dwStyle = WS_CHILD;
|
mciOpen.dwStyle = WS_CHILD;
|
||||||
mciOpen.hWndParent = hWnd;
|
mciOpen.hWndParent = nullptr;
|
||||||
|
|
||||||
// try to open the file
|
// try to open the file
|
||||||
if ( mciSendCommand(0, MCI_OPEN,
|
if ( mciSendCommand(0, MCI_OPEN,
|
||||||
@ -151,12 +147,7 @@ bool CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
|||||||
m_hwndMovie = (HWND)mciStatus.dwReturn;
|
m_hwndMovie = (HWND)mciStatus.dwReturn;
|
||||||
|
|
||||||
// now get the movie centered
|
// now get the movie centered
|
||||||
positionMovie(hWnd, rect);
|
positionMovie(rect);
|
||||||
|
|
||||||
// cause an update to occur
|
|
||||||
InvalidateRect(hWnd, NULL, false);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -172,7 +163,7 @@ bool CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
|||||||
// of the <m_fPlaying> flag. |
|
// of the <m_fPlaying> flag. |
|
||||||
// This function sets the <m_fPlaying> flag appropriately when done|
|
// This function sets the <m_fPlaying> flag appropriately when done|
|
||||||
|
|
||||||
void CMovie::playMovie(HWND hWnd, int nDirection)
|
void CMovie::playMovie(int nDirection)
|
||||||
{
|
{
|
||||||
m_fPlaying = !m_fPlaying; // swap the play flag
|
m_fPlaying = !m_fPlaying; // swap the play flag
|
||||||
|
|
||||||
@ -186,7 +177,7 @@ void CMovie::playMovie(HWND hWnd, int nDirection)
|
|||||||
MCI_DGV_PLAY_PARMS mciPlay;
|
MCI_DGV_PLAY_PARMS mciPlay;
|
||||||
|
|
||||||
// init to play all
|
// init to play all
|
||||||
mciPlay.dwCallback = MAKELONG(hWnd,0);
|
mciPlay.dwCallback = MAKELONG(nullptr,0);
|
||||||
mciPlay.dwFrom = mciPlay.dwTo = 0;
|
mciPlay.dwFrom = mciPlay.dwTo = 0;
|
||||||
dwFlags = MCI_NOTIFY;
|
dwFlags = MCI_NOTIFY;
|
||||||
if ( nDirection == IDM_RPLAY )
|
if ( nDirection == IDM_RPLAY )
|
||||||
@ -280,19 +271,19 @@ bool CMovie::IsExist(char *pFilename)
|
|||||||
|
|
||||||
// Montre un film avi.
|
// Montre un film avi.
|
||||||
|
|
||||||
bool CMovie::Play(HWND hWnd, RECT rect, char *pFilename)
|
bool CMovie::Play(RECT rect, char *pFilename)
|
||||||
{
|
{
|
||||||
if ( !m_bEnable ) return false;
|
if ( !m_bEnable ) return false;
|
||||||
if ( !fileOpenMovie(hWnd, rect, pFilename) ) return false;
|
if ( !fileOpenMovie(rect, pFilename) ) return false;
|
||||||
playMovie(hWnd, IDM_PLAY);
|
playMovie(IDM_PLAY);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stoppe le film avi.
|
// Stoppe le film avi.
|
||||||
|
|
||||||
void CMovie::Stop(HWND hWnd)
|
void CMovie::Stop()
|
||||||
{
|
{
|
||||||
if ( !m_bEnable ) return;
|
if ( !m_bEnable ) return;
|
||||||
fileCloseMovie(hWnd);
|
fileCloseMovie();
|
||||||
}
|
}
|
||||||
|
12
movie.h
12
movie.h
@ -12,14 +12,14 @@ public:
|
|||||||
bool Create();
|
bool Create();
|
||||||
bool GetEnable();
|
bool GetEnable();
|
||||||
bool IsExist(char *pFilename);
|
bool IsExist(char *pFilename);
|
||||||
bool Play(HWND hWnd, RECT rect, char *pFilename);
|
bool Play(RECT rect, char *pFilename);
|
||||||
void Stop(HWND hWnd);
|
void Stop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void playMovie(HWND hWnd, int nDirection);
|
void playMovie(int nDirection);
|
||||||
bool fileOpenMovie(HWND hWnd, RECT rect, char *pFilename);
|
bool fileOpenMovie(RECT rect, char *pFilename);
|
||||||
void fileCloseMovie(HWND hWnd);
|
void fileCloseMovie();
|
||||||
void positionMovie(HWND hWnd, RECT rect);
|
void positionMovie(RECT rect);
|
||||||
void termAVI();
|
void termAVI();
|
||||||
bool initAVI();
|
bool initAVI();
|
||||||
|
|
||||||
|
261
pixmap.cpp
261
pixmap.cpp
@ -43,7 +43,7 @@ CPixmap::CPixmap()
|
|||||||
|
|
||||||
for ( i=0 ; i<MAXIMAGE ; i++ )
|
for ( i=0 ; i<MAXIMAGE ; i++ )
|
||||||
{
|
{
|
||||||
m_lpDDSurface[i] = NULL;
|
m_lpSDLTexture[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize special effects structure
|
// initialize special effects structure
|
||||||
@ -87,10 +87,10 @@ CPixmap::~CPixmap()
|
|||||||
|
|
||||||
for ( i=0 ; i<MAXIMAGE ; i++ )
|
for ( i=0 ; i<MAXIMAGE ; i++ )
|
||||||
{
|
{
|
||||||
if ( m_lpDDSurface[i] != NULL )
|
if ( m_lpSDLTexture[i] != NULL )
|
||||||
{
|
{
|
||||||
m_lpDDSurface[i]->Release();
|
SDL_DestroyTexture (m_lpSDLTexture[i]);
|
||||||
m_lpDDSurface[i]= NULL;
|
m_lpSDLTexture[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,13 +116,11 @@ void CPixmap::SetDebug(bool bDebug)
|
|||||||
// Crée l'objet DirectDraw principal.
|
// Crée l'objet DirectDraw principal.
|
||||||
// Retourne false en cas d'erreur.
|
// Retourne false en cas d'erreur.
|
||||||
|
|
||||||
bool CPixmap::Create(HWND hwnd, POINT dim,
|
bool CPixmap::Create(POINT dim,
|
||||||
bool bFullScreen, int mouseType)
|
bool bFullScreen, int mouseType)
|
||||||
{
|
{
|
||||||
DDSURFACEDESC ddsd;
|
|
||||||
HRESULT ddrval;
|
HRESULT ddrval;
|
||||||
|
|
||||||
m_hWnd = hwnd;
|
|
||||||
m_bFullScreen = bFullScreen;
|
m_bFullScreen = bFullScreen;
|
||||||
m_mouseType = mouseType;
|
m_mouseType = mouseType;
|
||||||
m_dim = dim;
|
m_dim = dim;
|
||||||
@ -140,15 +138,6 @@ bool CPixmap::Create(HWND hwnd, POINT dim,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get exclusive mode.
|
|
||||||
if ( m_bFullScreen )
|
|
||||||
{
|
|
||||||
ddrval = m_lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ddrval = m_lpDD->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
|
|
||||||
}
|
|
||||||
if ( ddrval != DD_OK )
|
if ( ddrval != DD_OK )
|
||||||
{
|
{
|
||||||
OutputDebug("Fatal error: SetCooperativeLevel\n");
|
OutputDebug("Fatal error: SetCooperativeLevel\n");
|
||||||
@ -166,54 +155,6 @@ bool CPixmap::Create(HWND hwnd, POINT dim,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the primary surface with 1 back buffer.
|
|
||||||
ZeroMemory(&ddsd, sizeof(ddsd));
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_CAPS;
|
|
||||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
|
||||||
|
|
||||||
ddrval = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL);
|
|
||||||
if ( ddrval != DD_OK )
|
|
||||||
{
|
|
||||||
TraceErrorDD(ddrval, "pixmap", 0);
|
|
||||||
OutputDebug("Fatal error: CreateSurface\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the back buffer.
|
|
||||||
ZeroMemory(&ddsd, sizeof(ddsd));
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
|
|
||||||
//? ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
|
||||||
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
|
|
||||||
ddsd.dwWidth = dim.x;
|
|
||||||
ddsd.dwHeight = dim.y;
|
|
||||||
|
|
||||||
ddrval = m_lpDD->CreateSurface(&ddsd, &m_lpDDSBack, NULL);
|
|
||||||
if ( ddrval != DD_OK )
|
|
||||||
{
|
|
||||||
TraceErrorDD(ddrval, "pixmap", 0);
|
|
||||||
OutputDebug("Fatal error: CreateBackSurface\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the mouse buffer.
|
|
||||||
ZeroMemory(&ddsd, sizeof(ddsd));
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
|
|
||||||
//? ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
|
||||||
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
|
|
||||||
ddsd.dwWidth = DIMBLUPIX;
|
|
||||||
ddsd.dwHeight = DIMBLUPIY;
|
|
||||||
|
|
||||||
ddrval = m_lpDD->CreateSurface(&ddsd, &m_lpDDSMouse, NULL);
|
|
||||||
if ( ddrval != DD_OK )
|
|
||||||
{
|
|
||||||
TraceErrorDD(ddrval, "pixmap", 0);
|
|
||||||
OutputDebug("Fatal error: CreateMouseSurface\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a DirectDrawClipper object. The object enables clipping to the
|
// Create a DirectDrawClipper object. The object enables clipping to the
|
||||||
// window boundaries in the IDirectDrawSurface::Blt function for the
|
// window boundaries in the IDirectDrawSurface::Blt function for the
|
||||||
// primary surface.
|
// primary surface.
|
||||||
@ -227,21 +168,13 @@ bool CPixmap::Create(HWND hwnd, POINT dim,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ddrval = m_lpClipper->SetHWnd(0, hwnd);
|
ddrval = m_lpClipper->SetHWnd(0, nullptr);
|
||||||
if ( ddrval != DD_OK )
|
if ( ddrval != DD_OK )
|
||||||
{
|
{
|
||||||
TraceErrorDD(ddrval, "pixmap", 0);
|
TraceErrorDD(ddrval, "pixmap", 0);
|
||||||
OutputDebug("Can't set clipper window handle\n");
|
OutputDebug("Can't set clipper window handle\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ddrval = m_lpDDSPrimary->SetClipper(m_lpClipper);
|
|
||||||
if ( ddrval != DD_OK )
|
|
||||||
{
|
|
||||||
TraceErrorDD(ddrval, "pixmap", 0);
|
|
||||||
OutputDebug("Can't attach clipper to primary surface\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -305,7 +238,6 @@ void CPixmap::Fill(RECT rect, COLORREF color)
|
|||||||
HRESULT CPixmap::RestoreAll()
|
HRESULT CPixmap::RestoreAll()
|
||||||
{
|
{
|
||||||
if ( m_bDebug ) OutputDebug("CPixmap::RestoreAll\n");
|
if ( m_bDebug ) OutputDebug("CPixmap::RestoreAll\n");
|
||||||
int i;
|
|
||||||
HRESULT ddrval;
|
HRESULT ddrval;
|
||||||
|
|
||||||
if ( m_lpDDSPrimary && m_lpDDSPrimary->IsLost() )
|
if ( m_lpDDSPrimary && m_lpDDSPrimary->IsLost() )
|
||||||
@ -326,17 +258,6 @@ HRESULT CPixmap::RestoreAll()
|
|||||||
// if( ddrval != DD_OK ) return ddrval;
|
// if( ddrval != DD_OK ) return ddrval;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i=0 ; i<MAXIMAGE ; i++ )
|
|
||||||
{
|
|
||||||
if ( m_lpDDSurface[i] && m_lpDDSurface[i]->IsLost() )
|
|
||||||
{
|
|
||||||
ddrval = m_lpDDSurface[i]->Restore();
|
|
||||||
if( ddrval == DD_OK )
|
|
||||||
{
|
|
||||||
DDReLoadBitmap(m_lpDDSurface[i], m_filename[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,18 +313,9 @@ HRESULT CPixmap::BltFast(int chDst, int channel,
|
|||||||
dstRect.y = dst.y;
|
dstRect.y = dst.y;
|
||||||
//SDL_BlitSurface (m_lpSDLSurface[channel], &srcRect, m_lpSDLBack, &dstRect);
|
//SDL_BlitSurface (m_lpSDLSurface[channel], &srcRect, m_lpSDLBack, &dstRect);
|
||||||
SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
|
SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
|
||||||
if (channel != CHMAP)
|
|
||||||
ddrval = m_lpDDSBack->BltFast(dst.x, dst.y,
|
|
||||||
m_lpDDSurface[channel],
|
|
||||||
&rcRect, dwTrans);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (channel != CHMAP)
|
|
||||||
ddrval = m_lpDDSurface[chDst]->BltFast(dst.x, dst.y,
|
|
||||||
m_lpDDSurface[channel],
|
|
||||||
&rcRect, dwTrans);
|
|
||||||
SDL_Rect srcRect, dstRect;
|
SDL_Rect srcRect, dstRect;
|
||||||
srcRect.x = rcRect.left;
|
srcRect.x = rcRect.left;
|
||||||
srcRect.y = rcRect.top;
|
srcRect.y = rcRect.top;
|
||||||
@ -437,20 +349,15 @@ HRESULT CPixmap::BltFast(int chDst, int channel,
|
|||||||
// Effectue un appel BltFast.
|
// Effectue un appel BltFast.
|
||||||
// Les modes sont 0=transparent, 1=opaque.
|
// Les modes sont 0=transparent, 1=opaque.
|
||||||
|
|
||||||
HRESULT CPixmap::BltFast(LPDIRECTDRAWSURFACE lpDD, SDL_Texture *lpSDL,
|
HRESULT CPixmap::BltFast(SDL_Texture *lpSDL,
|
||||||
int channel, POINT dst, RECT rcRect, int mode)
|
int channel, POINT dst, RECT rcRect, int mode)
|
||||||
{
|
{
|
||||||
DWORD dwTrans;
|
DWORD dwTrans;
|
||||||
HRESULT ddrval;
|
HRESULT ddrval = DD_OK;
|
||||||
|
|
||||||
if ( mode == 0 ) dwTrans = DDBLTFAST_SRCCOLORKEY;
|
if ( mode == 0 ) dwTrans = DDBLTFAST_SRCCOLORKEY;
|
||||||
else dwTrans = DDBLTFAST_NOCOLORKEY;
|
else dwTrans = DDBLTFAST_NOCOLORKEY;
|
||||||
|
|
||||||
while( true )
|
|
||||||
{
|
|
||||||
ddrval = lpDD->BltFast(dst.x, dst.y,
|
|
||||||
m_lpDDSurface[channel],
|
|
||||||
&rcRect, dwTrans);
|
|
||||||
SDL_Rect srcRect, dstRect;
|
SDL_Rect srcRect, dstRect;
|
||||||
srcRect.x = rcRect.left;
|
srcRect.x = rcRect.left;
|
||||||
srcRect.y = rcRect.top;
|
srcRect.y = rcRect.top;
|
||||||
@ -463,16 +370,6 @@ HRESULT CPixmap::BltFast(LPDIRECTDRAWSURFACE lpDD, SDL_Texture *lpSDL,
|
|||||||
SDL_SetRenderTarget (g_renderer, lpSDL);
|
SDL_SetRenderTarget (g_renderer, lpSDL);
|
||||||
SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
|
SDL_RenderCopy (g_renderer, m_lpSDLTexture[channel], &srcRect, &dstRect);
|
||||||
SDL_SetRenderTarget (g_renderer, nullptr);
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
if ( ddrval == DD_OK ) break;
|
|
||||||
|
|
||||||
if ( ddrval == DDERR_SURFACELOST )
|
|
||||||
{
|
|
||||||
ddrval = RestoreAll();
|
|
||||||
if ( ddrval != DD_OK ) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ddrval != DDERR_WASSTILLDRAWING ) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ddrval;
|
return ddrval;
|
||||||
}
|
}
|
||||||
@ -589,11 +486,6 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
|
|||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
|
|
||||||
if ( m_lpDDSurface[channel] != NULL )
|
|
||||||
{
|
|
||||||
Flush(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and set the palette.
|
// Create and set the palette.
|
||||||
if ( bUsePalette )
|
if ( bUsePalette )
|
||||||
{
|
{
|
||||||
@ -619,8 +511,6 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the offscreen surface, by loading our bitmap.
|
|
||||||
m_lpDDSurface[channel] = DDLoadBitmap(m_lpDD, pFilename, 0, 0);
|
|
||||||
std::string file = pFilename;
|
std::string file = pFilename;
|
||||||
if (_access ((file + ".bmp").c_str (), 0 /* F_OK */) != -1)
|
if (_access ((file + ".bmp").c_str (), 0 /* F_OK */) != -1)
|
||||||
file += ".bmp";
|
file += ".bmp";
|
||||||
@ -635,8 +525,18 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
|
|||||||
int access, w, h;
|
int access, w, h;
|
||||||
SDL_QueryTexture (texture, &format, &access, &w, &h);
|
SDL_QueryTexture (texture, &format, &access, &w, &h);
|
||||||
|
|
||||||
m_lpSDLTexture[channel] = SDL_CreateTexture (g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, w, h);
|
if (!m_lpSDLTexture[channel])
|
||||||
SDL_SetTextureBlendMode (m_lpSDLTexture[channel], SDL_BLENDMODE_BLEND);
|
{
|
||||||
|
m_lpSDLTexture[channel] = SDL_CreateTexture (g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, w, h);
|
||||||
|
SDL_SetTextureBlendMode (m_lpSDLTexture[channel], SDL_BLENDMODE_BLEND);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
|
||||||
|
SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 0);
|
||||||
|
SDL_RenderClear (g_renderer);
|
||||||
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
|
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
|
||||||
SDL_RenderCopy (g_renderer, texture, nullptr, nullptr);
|
SDL_RenderCopy (g_renderer, texture, nullptr, nullptr);
|
||||||
@ -654,16 +554,6 @@ bool CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
|
|||||||
if (channel != CHBLUPI)
|
if (channel != CHBLUPI)
|
||||||
SDL_FreeSurface (surface);
|
SDL_FreeSurface (surface);
|
||||||
|
|
||||||
if ( m_lpDDSurface[channel] == NULL )
|
|
||||||
{
|
|
||||||
OutputDebug("Fatal error: DDLoadBitmap\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the color key to white
|
|
||||||
if ( m_bDebug ) OutputDebug("DDSetColorKey\n");
|
|
||||||
DDSetColorKey(m_lpDDSurface[channel], RGB(255,255,255)); // blanc
|
|
||||||
|
|
||||||
strcpy(m_filename[channel], pFilename);
|
strcpy(m_filename[channel], pFilename);
|
||||||
|
|
||||||
m_totalDim[channel] = totalDim;
|
m_totalDim[channel] = totalDim;
|
||||||
@ -692,12 +582,10 @@ bool CPixmap::Cache(int channel, SDL_Surface *surface, POINT totalDim)
|
|||||||
{
|
{
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
|
|
||||||
if ( m_lpDDSurface[channel] != NULL )
|
|
||||||
{
|
|
||||||
Flush(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the offscreen surface, by loading our bitmap.
|
// Create the offscreen surface, by loading our bitmap.
|
||||||
|
if (m_lpSDLTexture[channel])
|
||||||
|
SDL_DestroyTexture (m_lpSDLTexture[channel]);
|
||||||
|
|
||||||
m_lpSDLTexture[channel] = SDL_CreateTextureFromSurface (g_renderer, surface);
|
m_lpSDLTexture[channel] = SDL_CreateTextureFromSurface (g_renderer, surface);
|
||||||
|
|
||||||
if (m_lpSDLTexture[channel] == NULL )
|
if (m_lpSDLTexture[channel] == NULL )
|
||||||
@ -715,25 +603,13 @@ bool CPixmap::Cache(int channel, SDL_Surface *surface, POINT totalDim)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Purge une image.
|
|
||||||
|
|
||||||
void CPixmap::Flush(int channel)
|
|
||||||
{
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return;
|
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return;
|
|
||||||
|
|
||||||
m_lpDDSurface[channel]->Release();
|
|
||||||
m_lpDDSurface[channel]= NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Définition de la couleur transparente.
|
// Définition de la couleur transparente.
|
||||||
|
|
||||||
void CPixmap::SetTransparent(int channel, COLORREF color)
|
void CPixmap::SetTransparent(int channel, COLORREF color)
|
||||||
{
|
{
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return;
|
if ( channel < 0 || channel >= MAXIMAGE ) return;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return;
|
if (m_lpSDLTexture[channel] == NULL ) return;
|
||||||
|
|
||||||
DDSetColorKey(m_lpDDSurface[channel], color);
|
|
||||||
m_colorSurface[2*channel+0] = color;
|
m_colorSurface[2*channel+0] = color;
|
||||||
m_colorSurface[2*channel+1] = color;
|
m_colorSurface[2*channel+1] = color;
|
||||||
}
|
}
|
||||||
@ -743,9 +619,8 @@ void CPixmap::SetTransparent(int channel, COLORREF color)
|
|||||||
void CPixmap::SetTransparent2(int channel, COLORREF color1, COLORREF color2)
|
void CPixmap::SetTransparent2(int channel, COLORREF color1, COLORREF color2)
|
||||||
{
|
{
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return;
|
if ( channel < 0 || channel >= MAXIMAGE ) return;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return;
|
if (m_lpSDLTexture[channel] == NULL ) return;
|
||||||
|
|
||||||
DDSetColorKey2(m_lpDDSurface[channel], color1, color2);
|
|
||||||
m_colorSurface[2*channel+0] = color1;
|
m_colorSurface[2*channel+0] = color1;
|
||||||
m_colorSurface[2*channel+1] = color2;
|
m_colorSurface[2*channel+1] = color2;
|
||||||
}
|
}
|
||||||
@ -772,10 +647,9 @@ bool CPixmap::IsIconPixel(int channel, int rank, POINT pos)
|
|||||||
{
|
{
|
||||||
int nbx, nby;
|
int nbx, nby;
|
||||||
COLORREF rgb;
|
COLORREF rgb;
|
||||||
HDC hDC;
|
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channel].x == 0 ||
|
if ( m_iconDim[channel].x == 0 ||
|
||||||
m_iconDim[channel].y == 0 ) return false;
|
m_iconDim[channel].y == 0 ) return false;
|
||||||
@ -785,17 +659,21 @@ bool CPixmap::IsIconPixel(int channel, int rank, POINT pos)
|
|||||||
|
|
||||||
if ( rank < 0 || rank >= nbx*nby ) return false;
|
if ( rank < 0 || rank >= nbx*nby ) return false;
|
||||||
|
|
||||||
pos.x += (rank%nbx)*m_iconDim[channel].x;
|
pos.x += (rank % nbx) * m_iconDim[channel].x;
|
||||||
pos.y += (rank/nbx)*m_iconDim[channel].y;
|
pos.y += (rank / nbx) * m_iconDim[channel].y;
|
||||||
|
|
||||||
if ( m_lpDDSurface[channel]->GetDC(&hDC) != DD_OK ) return false;
|
SDL_Rect rect;
|
||||||
rgb = GetPixel(hDC, pos.x, pos.y);
|
rect.x = pos.x;
|
||||||
m_lpDDSurface[channel]->ReleaseDC(hDC);
|
rect.y = pos.y;
|
||||||
|
rect.w = 1;
|
||||||
|
rect.h = 1;
|
||||||
|
Uint32 pixel = 0;
|
||||||
|
|
||||||
if ( rgb == m_colorSurface[2*channel+0] ||
|
SDL_SetRenderTarget (g_renderer, m_lpSDLTexture[channel]);
|
||||||
rgb == m_colorSurface[2*channel+1] ) return false;
|
SDL_RenderReadPixels (g_renderer, &rect, 0, &pixel, 4);
|
||||||
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
|
|
||||||
return true;
|
return !!pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -811,7 +689,7 @@ bool CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
|
|||||||
COLORREF oldColor1, oldColor2;
|
COLORREF oldColor1, oldColor2;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( channel != CHMAP && m_lpDDSurface[channel] == NULL ) return false;
|
if ( channel != CHMAP && m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channel].x == 0 ||
|
if ( m_iconDim[channel].x == 0 ||
|
||||||
m_iconDim[channel].y == 0 ) return false;
|
m_iconDim[channel].y == 0 ) return false;
|
||||||
@ -855,7 +733,7 @@ bool CPixmap::DrawIconDemi(int chDst, int channel, int rank, POINT pos,
|
|||||||
COLORREF oldColor1, oldColor2;
|
COLORREF oldColor1, oldColor2;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channel].x == 0 ||
|
if ( m_iconDim[channel].x == 0 ||
|
||||||
m_iconDim[channel].y == 0 ) return false;
|
m_iconDim[channel].y == 0 ) return false;
|
||||||
@ -895,7 +773,7 @@ bool CPixmap::DrawIconPart(int chDst, int channel, int rank, POINT pos,
|
|||||||
COLORREF oldColor1, oldColor2;
|
COLORREF oldColor1, oldColor2;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channel].x == 0 ||
|
if ( m_iconDim[channel].x == 0 ||
|
||||||
m_iconDim[channel].y == 0 ) return false;
|
m_iconDim[channel].y == 0 ) return false;
|
||||||
@ -933,7 +811,7 @@ bool CPixmap::DrawPart(int chDst, int channel, POINT dest, RECT rect,
|
|||||||
COLORREF oldColor1, oldColor2;
|
COLORREF oldColor1, oldColor2;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
oldColor1 = m_colorSurface[2*channel+0];
|
oldColor1 = m_colorSurface[2*channel+0];
|
||||||
oldColor2 = m_colorSurface[2*channel+1];
|
oldColor2 = m_colorSurface[2*channel+1];
|
||||||
@ -954,7 +832,7 @@ bool CPixmap::DrawImage(int chDst, int channel, RECT rect, int mode)
|
|||||||
HRESULT ddrval;
|
HRESULT ddrval;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
dst.x = rect.left;
|
dst.x = rect.left;
|
||||||
dst.y = rect.top;
|
dst.y = rect.top;
|
||||||
@ -983,7 +861,7 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask,
|
|||||||
HRESULT ddrval;
|
HRESULT ddrval;
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
if ( channel < 0 || channel >= MAXIMAGE ) return false;
|
||||||
if ( m_lpDDSurface[channel] == NULL ) return false;
|
if (m_lpSDLTexture[channel] == NULL ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channel].x == 0 ||
|
if ( m_iconDim[channel].x == 0 ||
|
||||||
m_iconDim[channel].y == 0 ) return false;
|
m_iconDim[channel].y == 0 ) return false;
|
||||||
@ -1000,7 +878,7 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask,
|
|||||||
rect.bottom = rect.top + m_iconDim[channel].y;
|
rect.bottom = rect.top + m_iconDim[channel].y;
|
||||||
posDst.x = (rankDst%nbx)*m_iconDim[channel].x;
|
posDst.x = (rankDst%nbx)*m_iconDim[channel].x;
|
||||||
posDst.y = (rankDst/nbx)*m_iconDim[channel].y;
|
posDst.y = (rankDst/nbx)*m_iconDim[channel].y;
|
||||||
ddrval = BltFast(m_lpDDSurface[channel], m_lpSDLTexture[channel], channel, posDst, rect, 1);
|
ddrval = BltFast(m_lpSDLTexture[channel], channel, posDst, rect, 1);
|
||||||
if ( ddrval != DD_OK ) return false;
|
if ( ddrval != DD_OK ) return false;
|
||||||
|
|
||||||
if ( m_iconDim[channelMask].x == 0 ||
|
if ( m_iconDim[channelMask].x == 0 ||
|
||||||
@ -1015,7 +893,7 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask,
|
|||||||
rect.top = (rankMask/nbx)*m_iconDim[channelMask].y;
|
rect.top = (rankMask/nbx)*m_iconDim[channelMask].y;
|
||||||
rect.right = rect.left + m_iconDim[channelMask].x;
|
rect.right = rect.left + m_iconDim[channelMask].x;
|
||||||
rect.bottom = rect.top + m_iconDim[channelMask].y;
|
rect.bottom = rect.top + m_iconDim[channelMask].y;
|
||||||
ddrval = BltFast(m_lpDDSurface[channel], m_lpSDLTexture[channel], channelMask, posDst, rect, 0);
|
ddrval = BltFast(m_lpSDLTexture[channel], channelMask, posDst, rect, 0);
|
||||||
if ( ddrval != DD_OK ) return false;
|
if ( ddrval != DD_OK ) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1027,61 +905,16 @@ bool CPixmap::BuildIconMask(int channelMask, int rankMask,
|
|||||||
|
|
||||||
bool CPixmap::Display()
|
bool CPixmap::Display()
|
||||||
{
|
{
|
||||||
HRESULT ddrval;
|
RECT MapRect;
|
||||||
RECT DestRect, MapRect;
|
|
||||||
|
|
||||||
m_bBackDisplayed = true;
|
m_bBackDisplayed = true;
|
||||||
|
|
||||||
// Get screen coordinates of client window for blit
|
|
||||||
GetClientRect(m_hWnd, &DestRect);
|
|
||||||
ClientToScreen(m_hWnd, (LPPOINT)&DestRect);
|
|
||||||
ClientToScreen(m_hWnd, (LPPOINT)&DestRect+1);
|
|
||||||
|
|
||||||
MapRect.left = 0;
|
MapRect.left = 0;
|
||||||
MapRect.top = 0;
|
MapRect.top = 0;
|
||||||
MapRect.right = m_dim.x;
|
MapRect.right = m_dim.x;
|
||||||
MapRect.bottom = m_dim.y;
|
MapRect.bottom = m_dim.y;
|
||||||
|
|
||||||
// do the blit from back surface
|
|
||||||
ddrval = m_lpDDSPrimary->Blt
|
|
||||||
(
|
|
||||||
&DestRect, // destination rect
|
|
||||||
m_lpDDSBack,
|
|
||||||
&MapRect, // source rect
|
|
||||||
DDBLT_WAIT,
|
|
||||||
&m_DDbltfx
|
|
||||||
);
|
|
||||||
/*SDL_Rect srcRect, dstRect;
|
|
||||||
srcRect.x = MapRect.left;
|
|
||||||
srcRect.y = MapRect.top;
|
|
||||||
srcRect.w = MapRect.right - MapRect.left;
|
|
||||||
srcRect.h = MapRect.bottom - MapRect.top;
|
|
||||||
dstRect.x = DestRect.left;
|
|
||||||
dstRect.y = DestRect.top;
|
|
||||||
dstRect.w = DestRect.right - DestRect.left;
|
|
||||||
dstRect.h = DestRect.bottom - DestRect.top;
|
|
||||||
SDL_BlitSurface (m_lpSDLPrimary, &srcRect, m_lpSDLBack, &dstRect);*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copies the bmp surface to the window surface
|
|
||||||
*/
|
|
||||||
/*SDL_BlitSurface (m_lpSDLBack,
|
|
||||||
NULL,
|
|
||||||
m_lpSDLPrimary,
|
|
||||||
NULL);*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now updating the window
|
|
||||||
*/
|
|
||||||
//SDL_UpdateWindowSurface (g_window);
|
|
||||||
|
|
||||||
SDL_RenderPresent (g_renderer);
|
SDL_RenderPresent (g_renderer);
|
||||||
|
|
||||||
if ( ddrval == DDERR_SURFACELOST )
|
|
||||||
{
|
|
||||||
ddrval = RestoreAll();
|
|
||||||
}
|
|
||||||
if ( ddrval != DD_OK ) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
pixmap.h
7
pixmap.h
@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
void SetDebug(bool bDebug);
|
void SetDebug(bool bDebug);
|
||||||
|
|
||||||
bool Create(HWND hwnd, POINT dim, bool bFullScreen, int mouseType);
|
bool Create(POINT dim, bool bFullScreen, int mouseType);
|
||||||
bool Flush();
|
bool Flush();
|
||||||
bool Restore();
|
bool Restore();
|
||||||
bool InitSysPalette();
|
bool InitSysPalette();
|
||||||
@ -31,7 +31,6 @@ public:
|
|||||||
bool Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, bool bUsePalette);
|
bool Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, bool bUsePalette);
|
||||||
bool Cache(int channel, char *pFilename, POINT totalDim, bool bUsePalette);
|
bool Cache(int channel, char *pFilename, POINT totalDim, bool bUsePalette);
|
||||||
bool Cache(int channel, SDL_Surface *surface, POINT totalDim);
|
bool Cache(int channel, SDL_Surface *surface, POINT totalDim);
|
||||||
void Flush(int channel);
|
|
||||||
void SetTransparent(int channel, COLORREF color);
|
void SetTransparent(int channel, COLORREF color);
|
||||||
void SetTransparent2(int channel, COLORREF color1, COLORREF color2);
|
void SetTransparent2(int channel, COLORREF color1, COLORREF color2);
|
||||||
void SetClipping(RECT clip);
|
void SetClipping(RECT clip);
|
||||||
@ -58,7 +57,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
HRESULT RestoreAll();
|
HRESULT RestoreAll();
|
||||||
HRESULT BltFast(int chDst, int channel, POINT dst, RECT rcRect, int mode);
|
HRESULT BltFast(int chDst, int channel, POINT dst, RECT rcRect, int mode);
|
||||||
HRESULT BltFast(LPDIRECTDRAWSURFACE lpDD, SDL_Texture *lpSDL,
|
HRESULT BltFast(SDL_Texture *lpSDL,
|
||||||
int channel, POINT dst, RECT rcRect, int mode);
|
int channel, POINT dst, RECT rcRect, int mode);
|
||||||
|
|
||||||
RECT MouseRectSprite();
|
RECT MouseRectSprite();
|
||||||
@ -70,7 +69,6 @@ protected:
|
|||||||
int m_mouseType;
|
int m_mouseType;
|
||||||
bool m_bDebug;
|
bool m_bDebug;
|
||||||
bool m_bPalette;
|
bool m_bPalette;
|
||||||
HWND m_hWnd;
|
|
||||||
POINT m_dim; // dimensions totales
|
POINT m_dim; // dimensions totales
|
||||||
RECT m_clipRect; // rectangle de clipping
|
RECT m_clipRect; // rectangle de clipping
|
||||||
|
|
||||||
@ -87,7 +85,6 @@ protected:
|
|||||||
SDL_Cursor * m_lpSDLCursors[MAXCURSORS];
|
SDL_Cursor * m_lpSDLCursors[MAXCURSORS];
|
||||||
SDL_Surface * m_lpSDLBlupi;
|
SDL_Surface * m_lpSDLBlupi;
|
||||||
LPDIRECTDRAWPALETTE m_lpDDPal; // the primary surface palette
|
LPDIRECTDRAWPALETTE m_lpDDPal; // the primary surface palette
|
||||||
LPDIRECTDRAWSURFACE m_lpDDSurface[MAXIMAGE]; // offscreen surfaces
|
|
||||||
SDL_Surface * m_lpSDLSurface[MAXIMAGE];
|
SDL_Surface * m_lpSDLSurface[MAXIMAGE];
|
||||||
SDL_Texture * m_lpSDLTexture[MAXIMAGE];
|
SDL_Texture * m_lpSDLTexture[MAXIMAGE];
|
||||||
LPDIRECTDRAWCLIPPER m_lpClipper;
|
LPDIRECTDRAWCLIPPER m_lpClipper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user