1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-19 00:13:33 +00:00

games/xray_re-tools: unbreak the build against new nVidia Texture Tools

In 2020 Ignacio had modified the API with NVTT upstream commit adce1a00
which must have been cleanup, but was more than that.  Particularly, it
shuffled things around DirectDrawSurface class, and thus had broken the
port's build.  While here, remove all bundled 3rd-party code to prevent
accidental use thereof.
This commit is contained in:
Alexey Dokuchaev 2022-10-15 18:08:20 +00:00
parent 470f0bf1c3
commit c5f751f8a9
5 changed files with 58 additions and 37 deletions

View File

@ -6,12 +6,11 @@ MAINTAINER= danfe@FreeBSD.org
COMMENT= X-Ray engine game asset converter (unofficial)
WWW= https://github.com/abramcumner/xray_re-tools
BUILD_DEPENDS= ${NONEXISTENT}:graphics/nvidia-texture-tools:patch
LIB_DEPENDS= liblzo2.so:archivers/lzo2 \
libvorbisfile.so:audio/libvorbis \
libnvtt.so:graphics/nvidia-texture-tools
BROKEN= does not link: ld: error: undefined symbol: nv::mem::malloc
USE_GITHUB= yes
GH_ACCOUNT= abramcumner
GH_TAGNAME= 52721d2
@ -19,11 +18,13 @@ GH_TAGNAME= 52721d2
MAKEFILE= ${FILESDIR}/Makefile
BUILD_WRKSRC= ${WRKSRC}/sources
WITHOUT_FBSD10_FIX= yes
_NVTT_WRKSRC= ${MAKE} -C ${PORTSDIR}/graphics/nvidia-texture-tools -V WRKSRC
PLIST_FILES= bin/xr_converter
post-extract:
@${MV} ${WRKSRC}/sources/3rd\ party ${WRKSRC}/sources/3rd-party
@cd ${WRKSRC}/sources/3rd-party && ${RM} -r libogg libvorbis nvtt
@${MV} ${WRKSRC}/sources/utils/converter/opcode/Ice/IceTrilist.h \
${WRKSRC}/sources/utils/converter/opcode/Ice/IceTriList.h
@${LN} -s StdAfx.h ${WRKSRC}/sources/utils/converter/opcode/Stdafx.h
@ -53,6 +54,11 @@ post-patch:
@${REINPLACE_CMD} -e 's,MINGW32__),& || defined(__FreeBSD__),' \
${WRKSRC}/sources/xray_re/xr_types.h
post-configure:
@${LN} -sf ${_NVTT_WRKSRC:sh}/src ${WRKSRC}/sources/3rd-party/nvtt
@${REINPLACE_CMD} -e '/#include "nvconfig\.h"/d' \
${WRKSRC}/sources/3rd-party/nvtt/nvcore/nvcore.h
do-install:
${INSTALL_PROGRAM} ${BUILD_WRKSRC}/converter \
${STAGEDIR}${PREFIX}/bin/xr_converter

View File

@ -1,5 +1,6 @@
CXXFLAGS+= -Wall -Wextra
CPPFLAGS+= -Ixray_re -Iutils/converter/opcode -I3rd-party/nvtt -I$(LOCALBASE)/include
CPPFLAGS+= -Ixray_re -Iutils/converter/opcode -I3rd-party/nvtt \
-I3rd-party/nvtt/../extern/poshlib -I$(LOCALBASE)/include
LDFLAGS+= -L$(LOCALBASE)/lib
xray_re_OBJS= xray_re/xr_ai_cross_table.o \

View File

@ -1,20 +0,0 @@
--- sources/3rd-party/nvtt/nvcore/Memory.h.orig 2018-09-02 12:42:44 UTC
+++ sources/3rd-party/nvtt/nvcore/Memory.h
@@ -28,7 +28,7 @@ namespace nv
// Override new/delete
-inline void * operator new (size_t size) throw()
+inline void * operator new (size_t size) _THROW_BAD_ALLOC
{
return nv::mem::malloc(size);
}
@@ -38,7 +38,7 @@ inline void operator delete (void *p) throw()
nv::mem::free(p);
}
-inline void * operator new [] (size_t size) throw()
+inline void * operator new [] (size_t size) _THROW_BAD_ALLOC
{
return nv::mem::malloc(size);
}

View File

@ -1,14 +0,0 @@
--- sources/3rd-party/nvtt/nvcore/poshlib/posh.h.orig 2018-09-02 12:42:44 UTC
+++ sources/3rd-party/nvtt/nvcore/poshlib/posh.h
@@ -293,6 +293,11 @@ Metrowerks:
# define POSH_OS_STRING "Linux"
#endif
+#if defined __FreeBSD__
+# define POSH_OS_LINUX 1
+# define POSH_OS_STRING "FreeBSD"
+#endif
+
#if defined __CYGWIN32__
# define POSH_OS_CYGWIN32 1
# define POSH_OS_STRING "Cygwin"

View File

@ -0,0 +1,48 @@
--- sources/xray_re/xr_image_dds.cxx.orig 2018-09-02 12:42:44 UTC
+++ sources/xray_re/xr_image_dds.cxx
@@ -7,6 +7,7 @@
#include <nvmath/Color.h>
#include <nvtt/nvtt.h>
#pragma warning(pop)
+#undef sqrt
#include "xr_image.h"
#include "xr_file_system.h"
@@ -14,13 +15,14 @@ bool xr_image::load_dds(const std::string& path)
bool xr_image::load_dds(const std::string& path)
{
- nv::DirectDrawSurface dds(path.c_str());
+ nv::DirectDrawSurface dds;
+ dds.load(path.c_str());
if (!dds.isValid() || !dds.isTexture2D())
return false;
nv::Image image;
- dds.mipmap(&image, 0, 0);
- m_width = image.width();
- m_height = image.height();
+ imageFromDDS(&image, dds, 0, 0);
+ m_width = image.width;
+ m_height = image.height;
m_data = new rgba32[m_width*m_height];
for (unsigned i = m_height*m_width; i > 0;) {
const nv::Color32& pix = image.pixel(--i);
@@ -50,6 +52,7 @@ struct dds_writer: public nvtt::OutputHandler {
dds_writer(xr_writer& _w);
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel);
+ virtual void endImage();
virtual bool writeData(const void* data, int size);
xr_writer& w;
};
@@ -60,6 +63,10 @@ void dds_writer::beginImage(int size, int width, int h
{
}
+void dds_writer::endImage()
+{
+}
+
bool dds_writer::writeData(const void* data, int size)
{
w.w_raw(data, size_t(size & INT_MAX));