Skip to content

Instantly share code, notes, and snippets.

@Swyter
Created October 5, 2024 21:38
Show Gist options
  • Save Swyter/cb30eaf000a28277919239a2cbdf2377 to your computer and use it in GitHub Desktop.
Save Swyter/cb30eaf000a28277919239a2cbdf2377 to your computer and use it in GitHub Desktop.
From 603a46c6cdb031fbc46c309a490c6f72450667a8 Mon Sep 17 00:00:00 2001
From: swyter <[email protected]>
Date: Sat, 5 Oct 2024 23:36:18 +0200
Subject: [PATCH] Stub Linux support.
---
brfAnimation.cpp | 4 ++--
brfBody.cpp | 6 +++---
brfData.cpp | 6 +++---
brfMesh.cpp | 12 ++++++------
brfSkeleton.cpp | 2 +-
glwidgets.cpp | 4 ++--
glwidgets.h | 2 ++
ioMB.cpp | 6 +++---
ioMD3.cpp | 28 ++++++++++++++--------------
ioSMD.cpp | 8 ++++----
openBrf.pro | 2 +-
vcgmesh.cpp | 4 ++--
12 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/brfAnimation.cpp b/brfAnimation.cpp
index 23bafff..30dac27 100644
--- a/brfAnimation.cpp
+++ b/brfAnimation.cpp
@@ -594,7 +594,7 @@ static bool myReadline(FILE* f, char*res, int max){
int BrfAnimation::Break(vector<BrfAnimation> &vect, const wchar_t* fn, wchar_t *fn2) const{
int res=0;
- FILE *fin=_wfopen(fn,L"rt");
+ FILE *fin=NULL;//_wfopen(fn,L"rt");
//static char fn2[1024];
//swprintf(fn2,L"%ls [after splitting %s].txt",fn,name);
//FILE *fout=_wfopen(fn2,L"wt");
@@ -747,7 +747,7 @@ void BrfAnimation::Save(FILE *f) const{
}
void BrfAnimation::Export(const wchar_t* fn){
- FILE* f = _wfopen(fn,L"wt");
+ FILE* f = NULL;//_wfopen(fn,L"wt");
fprintf(f,"%s -- %d bones %u frames...\n",name, nbones,frame.size());
for (unsigned int j=0; j<frame.size(); j++) {
for (int i=0; i<nbones; i++) {
diff --git a/brfBody.cpp b/brfBody.cpp
index e5930f4..d50864a 100644
--- a/brfBody.cpp
+++ b/brfBody.cpp
@@ -154,7 +154,7 @@ bool _startsWith(const char*a, const char* b){
char s[512];
sprintf(s,"%s",a);
s[ strlen(b) ] =0;
- return !stricmp(s,b);
+ return !strcasecmp(s,b);
}
void BrfBodyPart::InferTypeFromString(char* str){
type = MANIFOLD;
@@ -258,7 +258,7 @@ bool BrfBody::ImportOBJ(const wchar_t *fn){
int startV = 0; // starting v
// to do: read all v and f fields, looking for "o" (objects)
- FILE* f = _wfopen(fn,L"rt");
+ FILE* f = NULL;//_wfopen(fn,L"rt");
if (!f) return false;
std::string s;
@@ -779,7 +779,7 @@ bool BrfBodyPart::ExportOBJ(FILE* f, int i, int &vc) const{
}
bool BrfBody::ExportOBJ(const wchar_t* fn) const {
- FILE* f =_wfopen(fn,L"wb");
+ FILE* f =NULL;//_wfopen(fn,L"wb");
if (!f) return false;
fprintf(f,
"# export of a body (Mount and Blade collision object)\n"
diff --git a/brfData.cpp b/brfData.cpp
index 66143fa..055f3c2 100644
--- a/brfData.cpp
+++ b/brfData.cpp
@@ -209,7 +209,7 @@ void BrfData::Merge(const BrfData& b){
bool BrfData::Load(const wchar_t *filename,int verbose, int imposeVersion){
- FILE *f = _wfopen(filename,L"rb");
+ FILE *f = NULL;//_wfopen(filename,L"rb");
if (!f) return false;
return Load(f, verbose, imposeVersion);
}
@@ -253,7 +253,7 @@ bool BrfData::Save(FILE *f) const{
bool BrfData::Save(const wchar_t*fn) const{
- FILE *f = _wfopen(fn,L"wb");
+ FILE *f = NULL;//_wfopen(fn,L"wb");
if (!f) return false;
Save(f);
@@ -351,7 +351,7 @@ bool BrfData::Load(FILE*f,int verbose,int imposeVers){
bool BrfData::LoadFast(const wchar_t*filename, bool faster){
- FILE *f = _wfopen(filename,L"rb");
+ FILE *f = NULL;//_wfopen(filename,L"rb");
if (!f) return false;
version = 0;
diff --git a/brfMesh.cpp b/brfMesh.cpp
index 8ba8070..7d802f4 100644
--- a/brfMesh.cpp
+++ b/brfMesh.cpp
@@ -543,7 +543,7 @@ void BrfMesh::FreezeFrame(const BrfSkeleton& s, const BrfAnimation& a, int frame
bool MeshMorpher::Save(const wchar_t *filename) const{
- FILE *f = _wfopen(filename,L"wt");
+ FILE *f = NULL;//fopen(filename.toUtf8(),"wt");
if (!f) return false;
for (int bi=0; bi<MAX_BONES; bi++) {
for (int i=0; i<3; i++) {
@@ -2386,11 +2386,11 @@ void BrfMesh::SetTimings(const std::vector<int> &v){
bool BrfMesh::SaveAsPly(int frameIndex, const wchar_t* path) const{
- wchar_t filename[255];
- if (frame.size()==0) swprintf(filename,L"%s%s.ply",path, name);
- else swprintf(filename,L"%ls\\%ls%02d.ply",path, name,frameIndex);
+ char filename[255];
+ if (frame.size()==0) sprintf(filename,"%s%s.ply",path, name);
+ else sprintf(filename,"%ls\\%ls%02d.ply",path, name,frameIndex);
- FILE* f = _wfopen(filename,L"wt");
+ FILE* f = fopen(filename,"wt");
if (!f) { printf("Cannot save \"%ls\"!\n",filename); return false;}
printf("Saving \"%ls\"...\n",filename);
fprintf(f,
@@ -3481,4 +3481,4 @@ bool BrfMesh::reverseVertexAni(){
SetTimings(timings);
return true;
-}
\ No newline at end of file
+}
diff --git a/brfSkeleton.cpp b/brfSkeleton.cpp
index e25e77b..9907483 100644
--- a/brfSkeleton.cpp
+++ b/brfSkeleton.cpp
@@ -385,7 +385,7 @@ void BrfSkeleton::BuildTree(){
void BrfSkeleton::Export(const wchar_t* fn){
- FILE* f = _wfopen(fn,L"wt");
+ FILE* f = NULL;//_wfopen(fn,L"wt");
fprintf(f,"%s -- %d bones:\n",name,bone.size());
for (unsigned int i=0; i<bone.size(); i++){
fprintf(f,"\n (%d) ",i);
diff --git a/glwidgets.cpp b/glwidgets.cpp
index 695a329..4dcb64c 100644
--- a/glwidgets.cpp
+++ b/glwidgets.cpp
@@ -7,7 +7,7 @@
//#include <QtOpenGL>
#include <QGLShaderProgram>
#include <QMessageBox>
-#include <GL/GLU.h>
+#include <GL/glu.h>
#include <math.h>
@@ -1014,7 +1014,7 @@ void GLWidget::setDummyNormTexture(){
bool GLWidget::fixTextureFormat(QString st){
- FILE* f = _wfopen(st.toStdWString().c_str(),L"rb");
+ FILE* f = fopen(st.toUtf8(), "rb");
if (!f) return false;
unsigned int h[22]; // header
fread(h,4 , 22,f); // 4 = sizeof uint
diff --git a/glwidgets.h b/glwidgets.h
index 3456be4..cfff5d1 100644
--- a/glwidgets.h
+++ b/glwidgets.h
@@ -11,6 +11,8 @@
#include "iniData.h"
#include "ddsData.h"
+#define _wfopen fopen
+
class BrfData;
class QGLShaderProgram;
diff --git a/ioMB.cpp b/ioMB.cpp
index f08da23..7ccca5f 100644
--- a/ioMB.cpp
+++ b/ioMB.cpp
@@ -763,7 +763,7 @@ static void ioMB_exportSkeleton(const BrfSkeleton &s){
}
bool IoMB::Export(const wchar_t*filename, const BrfMesh &m , const BrfSkeleton &s, int fi){
- f = _wfopen(filename,L"wt");
+ f = NULL;//_wfopen(filename,L"wt");
if (!f) return false;
ioMB_exportHeader();
ioMB_exportSkeleton(s);
@@ -859,10 +859,10 @@ static bool ioMB_importBone(BrfSkeleton &s ){
bool IoMB::Import(const wchar_t*filename, std::vector<BrfMesh> &m , BrfSkeleton &s, int want){
- debug=_wfopen(L"debug.txt",L"w");
+ debug=NULL;//_wfopen(L"debug.txt",L"w");
lastErr = QString("Unkonwn error??");
- f = _wfopen(filename,L"rb"); lineN=0;
+ f = NULL;//_wfopen(filename,L"rb"); lineN=0;
if (!f) {
lastErr =QString("cannot open file '%1' for reading").arg(QString::fromStdWString(filename));
return false;
diff --git a/ioMD3.cpp b/ioMD3.cpp
index 125d6a1..7e3b8ae 100644
--- a/ioMD3.cpp
+++ b/ioMD3.cpp
@@ -100,9 +100,9 @@ static void norm2int(vcg::Point3f res, Byte &zenb,Byte &azib){
bool IoMD::ExportMD2(const wchar_t *filename, const BrfMesh &m){
- FILE *f = _wfopen(filename,L"wb");
+ FILE *f = NULL;//_wfopen(filename,L"wb");
if (!f){
- swprintf(errorStr,L"Cannot write on file:\n %ls",filename);
+ //sprintf(errorStr,"Cannot write on file:\n %s",filename);
return false;
}
SaveUint(f,MAGIC_MD2);
@@ -154,21 +154,21 @@ bool IoMD::ExportMD2(const wchar_t *filename, const BrfMesh &m){
bool IoMD::Export(const wchar_t *filename, const BrfMesh &m){
if (m.frame.size()>1024){
- swprintf(errorStr,L"Too many frames %d. Max = 1024",m.frame.size());
+ //sprintf(errorStr,"Too many frames %d. Max = 1024",m.frame.size());
return false;
}
if (m.vert.size()>4096){
- swprintf(errorStr,L"Too many vertices %d. Max = 4096",m.vert.size());
+ //sprintf(errorStr,"Too many vertices %d. Max = 4096",m.vert.size());
return false;
}
if (m.face.size()>8192){
- swprintf(errorStr,L"Too many faces: %d. Max = 8192",m.face.size());
+ //sprintf(errorStr,"Too many faces: %d. Max = 8192",m.face.size());
return false;
}
- FILE *f = _wfopen(filename,L"wb");
+ FILE *f = NULL;//fopen(filename,"wb");
if (!f){
- swprintf(errorStr,L"Cannot write on file:\n %ls",filename);
+ //sprintf(errorStr,"Cannot write on file:\n %s",filename);
return false;
}
SaveUint(f,MAGIC_MD3);
@@ -260,7 +260,7 @@ bool IoMD::Import(FILE *f, BrfMesh &m){
unsigned int magic=0;
LoadUint(f,magic);
if (magic != MAGIC_MD3) {
- swprintf(errorStr,L"Invalid magic number in surface: %X",magic);
+ //sprintf(errorStr,"Invalid magic number in surface: %X",magic);
return false;
}
@@ -283,7 +283,7 @@ bool IoMD::Import(FILE *f, BrfMesh &m){
LoadUint(f,oxyz);
LoadUint(f,oend);
- swprintf(errorStr, L"Loaded: %dv %dt %df\n",nverts,ntriangles,nframes);
+ //swprintf(errorStr, L"Loaded: %dv %dt %df\n",nverts,ntriangles,nframes);
m.face.resize(ntriangles);
m.vert.resize(nverts);
@@ -341,15 +341,15 @@ bool IoMD::Import(FILE *f, BrfMesh &m){
bool IoMD::Import(const wchar_t *filename, std::vector<BrfMesh> &mv){
- FILE *f = _wfopen(filename,L"rb");
+ FILE *f = NULL;//_wfopen(filename,L"rb");
if (!f) {
- swprintf(errorStr,L"File not found");
+ //swprintf(errorStr,L"File not found");
return false;
}
unsigned int magic=0,ver=0;
LoadUint(f,magic);
if (magic != MAGIC_MD3) {
- swprintf(errorStr,L"Invalid magic number: %X",magic);
+ //swprintf(errorStr,L"Invalid magic number: %X",magic);
return false;
}
@@ -370,12 +370,12 @@ bool IoMD::Import(const wchar_t *filename, std::vector<BrfMesh> &mv){
//sprintf(errorStr,"Found: %s (%d surface %d frames, off: %0X)",name,nsurfaces,nframes,osurfaces);
if (nsurfaces>255 ) {
- swprintf(errorStr,L"File format error (%d surfaces?)",nsurfaces);
+ //swprintf(errorStr,L"File format error (%d surfaces?)",nsurfaces);
return false;
}
if (nsurfaces==0 ) {
- swprintf(errorStr,L"no \"surface\" found");
+ //swprintf(errorStr,L"no \"surface\" found");
return false;
}
fseek(f,osurfaces,SEEK_SET);
diff --git a/ioSMD.cpp b/ioSMD.cpp
index e85df43..9d491ba 100644
--- a/ioSMD.cpp
+++ b/ioSMD.cpp
@@ -315,7 +315,7 @@ static bool ioSMD_ImportPose(FILE* f, BrfSkeleton &s, T& pose, int &time){
}
int ioSMD::Export(const wchar_t*filename, const BrfMesh &m , const BrfSkeleton &s, int fi){
- FILE* f=_wfopen(filename,L"wb");
+ FILE* f=NULL;//_wfopen(filename,L"wb");
lastErr = 0;
if (!f) return(lastErr=2);
@@ -333,7 +333,7 @@ int ioSMD::Export(const wchar_t*filename, const BrfMesh &m , const BrfSkeleton &
int ioSMD::Export(const wchar_t*filename, const BrfAnimation &a, const BrfSkeleton &s){
- FILE* f=_wfopen(filename,L"wb");
+ FILE* f=NULL;//_wfopen(filename,L"wb");
lastErr = 0;
if (!f) return(lastErr=2);
@@ -359,7 +359,7 @@ int ioSMD::Export(const wchar_t*filename, const BrfAnimation &a, const BrfSkelet
int ioSMD::Import(const wchar_t*filename, BrfMesh &m , BrfSkeleton &s){
lastErr = 0;
nMaxBones = 0;
- FILE* f=_wfopen(filename,L"rt");
+ FILE* f=NULL;//_wfopen(filename,L"rt");
if (!f) return(lastErr=1);
if (!ioSMD_ImportBoneStruct(f,s)) return lastErr;
@@ -384,7 +384,7 @@ int ioSMD::Import(const wchar_t*filename, BrfMesh &m , BrfSkeleton &s){
int ioSMD::Import(const wchar_t*filename, BrfAnimation &a, BrfSkeleton &s){
lastErr = 0;
- FILE* f=_wfopen(filename,L"rt");
+ FILE* f=NULL;//_wfopen(filename,L"rt");
if (!f) return(lastErr=1);
if (!ioSMD_ImportBoneStruct(f,s)) return lastErr;
diff --git a/openBrf.pro b/openBrf.pro
index 71a2e0e..da92890 100644
--- a/openBrf.pro
+++ b/openBrf.pro
@@ -179,7 +179,7 @@ OTHER_FILES += shaders/bump_vertex.cpp
OTHER_FILES += shaders/iron_fragment.cpp
OTHER_FILES += femininizer.morpher
-LIBS += -lopengl32 -lglu32
+LIBS += -lGL -lGLU
DISTFILES += \
translations/openbrf_de.ts \
diff --git a/vcgmesh.cpp b/vcgmesh.cpp
index 49eb479..2f9f6d2 100644
--- a/vcgmesh.cpp
+++ b/vcgmesh.cpp
@@ -14,8 +14,8 @@
//#include <vcg/complex/trimesh/clean.h>
-#include "vcgexport.h"
-#include "vcgimport.h"
+#include "vcgExport.h"
+#include "vcgImport.h"
//#include <wrap/io_trimesh/import.h>
//#include <wrap/io_trimesh/export.h>
--
2.46.2
@Swyter
Copy link
Author

Swyter commented Oct 27, 2024

380527122-cdb21970-7014-463a-a232-3216f6f5b2ab

@Swyter
Copy link
Author

Swyter commented Oct 27, 2024

380522146-ca7c62c2-91f8-4e2c-9d80-0e26bc1aba2c

@Swyter
Copy link
Author

Swyter commented Oct 29, 2024

imagen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment