fixes for glfw

This commit is contained in:
aap 2020-04-26 20:16:31 +02:00
parent b7ee3792df
commit 41586c7cda
3 changed files with 37 additions and 51 deletions

View File

@ -290,9 +290,29 @@ RwTextureAddressMode RwTextureGetAddressingV(const RwTexture *texture);
// TODO // TODO
void _rwD3D8TexDictionaryEnableRasterFormatConversion(bool enable) { } void _rwD3D8TexDictionaryEnableRasterFormatConversion(bool enable) { }
static rw::Raster*
ConvertTexRaster(rw::Raster *ras)
{
using namespace rw;
Image *img = ras->toImage();
ras->destroy();
img->unindex();
ras = Raster::createFromImage(img);
img->destroy();
return ras;
}
// hack for reading native textures // hack for reading native textures
RwBool rwNativeTextureHackRead(RwStream *stream, RwTexture **tex, RwInt32 size) RwBool rwNativeTextureHackRead(RwStream *stream, RwTexture **tex, RwInt32 size)
{ *tex = Texture::streamReadNative(stream); return *tex != nil; } {
*tex = Texture::streamReadNative(stream);
#ifdef RW_GL3
if(strcmp((*tex)->name, "copnu") == 0)
tex = tex;
(*tex)->raster = ConvertTexRaster((*tex)->raster);
#endif
return *tex != nil;
}

View File

@ -127,38 +127,6 @@ CTxdStore::RemoveRefWithoutDelete(int slot)
GetSlot(slot)->refCount--; GetSlot(slot)->refCount--;
} }
#ifdef RW_GL3
rw::Raster*
convertTexRaster(rw::Raster* ras)
{
rw::Image* img = ras->toImage();
// ras->destroy();
img->unindex();
ras = rw::Raster::createFromImage(img);
img->destroy();
return ras;
}
void
convertTxd(rw::TexDictionary* txd)
{
rw::Texture* tex;
FORLIST(lnk, txd->textures) {
tex = rw::Texture::fromDict(lnk);
rw::Raster* ras = tex->raster;
if (ras && ras->platform != rw::platform) {
if (!(ras->platform == rw::PLATFORM_D3D8 && rw::platform == rw::PLATFORM_D3D9 ||
ras->platform == rw::PLATFORM_D3D9 && rw::platform == rw::PLATFORM_D3D8)) {
tex->raster = convertTexRaster(ras);
ras->destroy();
}
}
tex->setFilter(rw::Texture::LINEAR);
}
}
#endif
bool bool
CTxdStore::LoadTxd(int slot, RwStream *stream) CTxdStore::LoadTxd(int slot, RwStream *stream)
{ {
@ -166,9 +134,6 @@ CTxdStore::LoadTxd(int slot, RwStream *stream)
if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){
def->texDict = RwTexDictionaryGtaStreamRead(stream); def->texDict = RwTexDictionaryGtaStreamRead(stream);
#ifdef RW_GL3
convertTxd(def->texDict);
#endif
return def->texDict != nil; return def->texDict != nil;
} }
printf("Failed to load TXD\n"); printf("Failed to load TXD\n");

View File

@ -19,11 +19,25 @@
#include "platform.h" #include "platform.h"
#include "crossplatform.h" #include "crossplatform.h"
#include "patcher.h"
#include "main.h"
#include "FileMgr.h"
#include "Text.h"
#include "Pad.h"
#include "Timer.h"
#include "DMAudio.h"
#include "ControllerConfig.h"
#include "Frontend.h"
#include "Game.h"
#include "PCSave.h"
#include "Sprite2d.h"
#include "AnimViewer.h"
#define MAX_SUBSYSTEMS (16) #define MAX_SUBSYSTEMS (16)
using namespace rw; rw::EngineOpenParams openParams;
EngineOpenParams openParams;
static RwBool ForegroundApp = TRUE; static RwBool ForegroundApp = TRUE;
@ -49,19 +63,6 @@ static psGlobalType PsGlobal;
#define JIF(x) if (FAILED(hr=(x))) \ #define JIF(x) if (FAILED(hr=(x))) \
{debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;} {debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;}
#include "patcher.h"
#include "main.h"
#include "FileMgr.h"
#include "Text.h"
#include "Pad.h"
#include "Timer.h"
#include "DMAudio.h"
#include "ControllerConfig.h"
#include "Frontend.h"
#include "Game.h"
#include "PCSave.h"
#include "Sprite2d.h"
#include "AnimViewer.h"
// TODO: This is used on selecting video mode, so either think something or remove it completely // TODO: This is used on selecting video mode, so either think something or remove it completely
DWORD _dwMemTotalVideo = 1024 * (1024 * 1024); // 1024 MB as placeholder DWORD _dwMemTotalVideo = 1024 * (1024 * 1024); // 1024 MB as placeholder