- OTM_IDirect3DDevice9::UpdateTexture passes not the correct textures to the original function
- OTM_IDirect3DTexture9: functions which handle with the original data are now redirected to the cross reference (if the texture was switched)
- GUI: memory expand function: more then 10 games can be started and mor then 100 texture packs be added.
This commit is contained in:
code@koerner-de.net
2011-10-08 18:09:26 +00:00
parent a4a7a957b9
commit ef57e3f86f
5 changed files with 106 additions and 57 deletions
+10 -2
View File
@@ -291,7 +291,16 @@ HRESULT OTM_IDirect3DDevice9::UpdateSurface(IDirect3DSurface9* pSourceSurface,CO
HRESULT OTM_IDirect3DDevice9::UpdateTexture(IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture)
{
return(m_pIDirect3DDevice9->UpdateTexture(pSourceTexture,pDestinationTexture));
IDirect3DDevice9 *dev = NULL;
if (pSourceTexture != NULL && ((OTM_IDirect3DTexture9*)(pSourceTexture))->GetDevice(&dev) == D3D_OK)
{
if(dev == this) pSourceTexture = ((OTM_IDirect3DTexture9*)(pSourceTexture))->m_D3Dtex;
}
if (pDestinationTexture != NULL && ((OTM_IDirect3DTexture9*)(pDestinationTexture))->GetDevice(&dev) == D3D_OK)
{
if(dev == this) pDestinationTexture = ((OTM_IDirect3DTexture9*)(pDestinationTexture))->m_D3Dtex;
}
return(m_pIDirect3DDevice9->UpdateTexture(pSourceTexture,pDestinationTexture));
}
HRESULT OTM_IDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface)
@@ -542,7 +551,6 @@ HRESULT OTM_IDirect3DDevice9::GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppT
HRESULT OTM_IDirect3DDevice9::SetTexture(DWORD Stage, IDirect3DBaseTexture9* pTexture)
{
IDirect3DDevice9 *dev = NULL;
if (pTexture != NULL && ((OTM_IDirect3DTexture9*)(pTexture))->GetDevice(&dev) == D3D_OK)
{
+8 -24
View File
@@ -79,16 +79,19 @@ HRESULT APIENTRY OTM_IDirect3DTexture9::GetDevice(IDirect3DDevice9** ppDevice)
HRESULT APIENTRY OTM_IDirect3DTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
return (m_D3Dtex->SetPrivateData(refguid, pData, SizeOfData, Flags));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
return (m_D3Dtex->GetPrivateData(refguid, pData, pSizeOfData));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::FreePrivateData(REFGUID refguid)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->FreePrivateData(refguid));
return (m_D3Dtex->FreePrivateData(refguid));
}
@@ -144,49 +147,30 @@ void APIENTRY OTM_IDirect3DTexture9::GenerateMipSubLevels()
HRESULT APIENTRY OTM_IDirect3DTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetLevelDesc(Level, pDesc));
return (m_D3Dtex->GetLevelDesc(Level, pDesc));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel));
return (m_D3Dtex->GetSurfaceLevel(Level, ppSurfaceLevel));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags));
return (m_D3Dtex->LockRect(Level, pLockedRect, pRect, Flags));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::UnlockRect(UINT Level)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->UnlockRect(Level));
return (m_D3Dtex->UnlockRect(Level));
}
HRESULT APIENTRY OTM_IDirect3DTexture9::AddDirtyRect(CONST RECT* pDirtyRect)
{
if (CrossRef_D3Dtex!=NULL) return (CrossRef_D3Dtex->m_D3Dtex->AddDirtyRect(pDirtyRect));
return (m_D3Dtex->AddDirtyRect(pDirtyRect));
}
/*
//////////////////////////////
// Useful Functions
//////////////////////////////
DWORD QuickChecksum(DWORD *pData, int size)
{
if(!pData) { return (0x0); }
DWORD sum;
DWORD tmp;
sum = *pData;
for(int i = 1; i < (size/4); i++)
{
tmp = pData[i];
tmp = (DWORD)(sum >> 29) + tmp;
tmp = (DWORD)(sum >> 17) + tmp;
sum = (DWORD)(sum << 3) ^ tmp;
}
return sum;
}
*/
+20 -15
View File
@@ -122,22 +122,14 @@ OTM_Frame::OTM_Frame(const wxString& title, const wxPoint& pos, const wxSize& si
NumberOfGames = 0;
MaxNumberOfGames = 10;
Clients = new OTM_Client*[MaxNumberOfGames];
Clients = NULL;
if (GetMemory( Clients, MaxNumberOfGames))
{
wxMessageBox( Language.Error_Memory, "ERROR", wxOK|wxICON_ERROR);
}
Show( true );
/*
wxString dx_dll;
wchar_t buffer[MAX_PATH];
if (NULL!=_wgetcwd( buffer, MAX_PATH))
{
dx_dll = buffer;
dx_dll << "\\";
}
dx_dll << OTM_d3d9_dll;
//dx_dll = "kernel32.dll";
*/
H_DX9_DLL = LoadLibraryW(OTM_d3d9_dll);
if (H_DX9_DLL!=NULL)
{
@@ -216,7 +208,15 @@ int OTM_Frame::KillServer(void)
void OTM_Frame::OnAddGame( wxCommandEvent &event)
{
if (NumberOfGames>=MaxNumberOfGames) return;
if (NumberOfGames>=MaxNumberOfGames)
{
if (GetMoreMemory( Clients, MaxNumberOfGames, MaxNumberOfGames+10))
{
wxMessageBox( Language.Error_Memory, "ERROR", wxOK|wxICON_ERROR);
return;
}
MaxNumberOfGames += 10;
}
wxString name = ((OTM_Event&)event).GetName();
PipeStruct pipe;
@@ -229,7 +229,12 @@ void OTM_Frame::OnAddGame( wxCommandEvent &event)
client->Run();
OTM_GamePage *page = new OTM_GamePage( Notebook, name, client->Pipe, Language);
if (page->LastError.Len()>0)
{
wxMessageBox(page->LastError, "ERROR", wxOK|wxICON_ERROR);
delete page;
return;
}
Notebook->AddPage( page, name, true);
Clients[NumberOfGames] = client;
+32 -16
View File
@@ -21,6 +21,12 @@ along with OpenTexMod. If not, see <http://www.gnu.org/licenses/>.
OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct &pipe, OTM_Language &lang) : wxPanel(parent), Language(lang), Game(name), GameOld(name), Sender(pipe, lang)
{
CheckBoxHSizers = NULL;
CheckButtonUp = NULL;
CheckButtonDown = NULL;
CheckButtonDelete = NULL;
CheckBoxes = NULL;
MainSizer = new wxBoxSizer(wxVERTICAL);
SizerKeys[0] = new wxBoxSizer(wxHORIZONTAL);
@@ -78,13 +84,12 @@ OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct
if (Game.LoadFromFile())
{
NumberOfEntry = 0;
MaxNumberOfEntry = 100;
CheckBoxes = new wxCheckBox*[MaxNumberOfEntry];
CheckBoxHSizers = new wxBoxSizer*[MaxNumberOfEntry];
CheckButtonUp = new wxButton*[MaxNumberOfEntry];
CheckButtonDown = new wxButton*[MaxNumberOfEntry];
CheckButtonDelete = new wxButton*[MaxNumberOfEntry];
MaxNumberOfEntry = 1024;
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return ;}
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
SavePath->SetValue(Language.TextCtrlSavePath);
}
@@ -119,15 +124,17 @@ OTM_GamePage::OTM_GamePage( wxNotebook *parent, const wxString &name, PipeStruct
Game.GetFiles( Files);
NumberOfEntry = Files.GetCount();
MaxNumberOfEntry = NumberOfEntry+100;
bool *checked = new bool[NumberOfEntry];
MaxNumberOfEntry = ((NumberOfEntry/1024)+1)*1024;
bool *checked = NULL;
if (GetMemory( checked, NumberOfEntry)) {LastError = Language.Error_Memory; return;}
Game.GetChecked( checked, NumberOfEntry);
CheckBoxes = new wxCheckBox*[MaxNumberOfEntry];
CheckBoxHSizers = new wxBoxSizer*[MaxNumberOfEntry];
CheckButtonUp = new wxButton*[MaxNumberOfEntry];
CheckButtonDown = new wxButton*[MaxNumberOfEntry];
CheckButtonDelete = new wxButton*[MaxNumberOfEntry];
if (GetMemory( CheckBoxes, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckBoxHSizers, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return ;}
if (GetMemory( CheckButtonUp, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckButtonDown, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
if (GetMemory( CheckButtonDelete, MaxNumberOfEntry)) {LastError = Language.Error_Memory; return;}
for (int i=0; i<NumberOfEntry; i++)
{
@@ -190,7 +197,15 @@ int OTM_GamePage::SetSavePath( const wxString &path)
int OTM_GamePage::AddTexture( const wxString &file_name)
{
if (NumberOfEntry>=MaxNumberOfEntry) {LastError = Language.Error_Memory; return -1;}
if (NumberOfEntry>=MaxNumberOfEntry)
{
if (GetMoreMemory( CheckBoxes, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
if (GetMoreMemory( CheckBoxHSizers, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
if (GetMoreMemory( CheckButtonUp, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
if (GetMoreMemory( CheckButtonDown, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
if (GetMoreMemory( CheckButtonDelete, MaxNumberOfEntry, MaxNumberOfEntry+1024)) {LastError = Language.Error_Memory; return -1;}
MaxNumberOfEntry+=1024;
}
OTM_File file( Language, file_name);
if (!file.FileSupported()) {LastError << Language.Error_FileNotSupported << "\n" << file_name; return -1;}
@@ -267,7 +282,8 @@ int OTM_GamePage::GetSettings(void)
Game.SetFiles( Files);
bool *checked = new bool[NumberOfEntry];
bool *checked = NULL;
if (GetMemory( checked, NumberOfEntry)) {LastError = Language.Error_Memory; return -1;}
for (int i=0; i<NumberOfEntry; i++) checked[i] = CheckBoxes[i]->GetValue();
Game.SetChecked( checked, NumberOfEntry);
delete [] checked;
+36
View File
@@ -105,4 +105,40 @@ enum
#include "OTM_GamePage.h"
#include "OTM_GUI.h"
template <class T>
int GetMemory(T* &array, int num)
{
if (array!=(T*)0) delete [] array;
try {array = new T[num];}
catch (...) {array = (T*) 0; return -1;}
return 0;
}
template <class T>
int GetMemory(T* &array, int num, T init)
{
if (array!=(T*)0) delete [] array;
try {array = new T[num];}
catch (...) {array = (T*) 0; return -1;}
for (int i=0; i<num; i++) array[i]=init;
return 0;
}
template <class T>
int GetMoreMemory(T* &old_array, int old_num, int new_num)
{
if (new_num<=old_num) return 0;
T* new_array;
try {new_array = new T[new_num];}
catch (...) {return -1;}
if (old_array!=(T*)0)
{
for (int i=0; i<old_num; i++) new_array[i]=old_array[i];
delete [] old_array;
}
old_array = new_array;
return 0;
}
#endif