From 6c1a1f7cd20a2674f33b5318e6e07a3a28d016f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Sun, 26 Apr 2020 13:25:03 +0300 Subject: Initial GLFW support --- src/rw/RwHelper.cpp | 2 ++ src/rw/TexRead.cpp | 2 +- src/rw/TxdStore.cpp | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 707f1b44..ed618dd8 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -1,4 +1,6 @@ +#if defined RW_D3D9 || defined RWLIBS #define WITHD3D +#endif #include "common.h" #include "Timecycle.h" diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index 9f0cae3c..60945665 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -2,7 +2,7 @@ #pragma warning( disable : 4005) #pragma warning( pop ) #include "common.h" -#include "win.h" +#include "crossplatform.h" #include "Timer.h" #ifdef GTA_PC diff --git a/src/rw/TxdStore.cpp b/src/rw/TxdStore.cpp index 51d018f6..bb7386d5 100644 --- a/src/rw/TxdStore.cpp +++ b/src/rw/TxdStore.cpp @@ -127,6 +127,38 @@ CTxdStore::RemoveRefWithoutDelete(int slot) 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 CTxdStore::LoadTxd(int slot, RwStream *stream) { @@ -134,6 +166,9 @@ CTxdStore::LoadTxd(int slot, RwStream *stream) if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ def->texDict = RwTexDictionaryGtaStreamRead(stream); +#ifdef RW_GL3 + convertTxd(def->texDict); +#endif return def->texDict != nil; } printf("Failed to load TXD\n"); -- cgit v1.2.3