]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
- Fixed JPEG support on Mac OS X
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Dec 2004 09:58:41 +0000 (09:58 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Dec 2004 09:58:41 +0000 (09:58 +0000)
- Fixed Ogg Vorbis support on Mac OS X (the vorbis DLL is now also loaded manually since some OSes don't do that for us)
- Fixed loading of MD3 models on big-endian CPUs

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4872 d7cf8633-e32d-0410-b094-e92efae38249

jpeg.c
model_alias.c
snd_ogg.c

diff --git a/jpeg.c b/jpeg.c
index ba1d8913aebcbe94d8d7ab19a784a575f6f32de5..964b170c4c5a6b107d7bed05e1c0d930c58bb0d8 100644 (file)
--- a/jpeg.c
+++ b/jpeg.c
@@ -406,6 +406,8 @@ qboolean JPEG_OpenLibrary (void)
        dllname = "libjpeg.dll";
 #elif defined(__FreeBSD__)
        dllname = "libjpeg.so";
+#elif defined(MACOSX)
+       dllname = "libjpeg.62.dylib";
 #else
        dllname = "libjpeg.so.62";
 #endif
index d72ea3c95603d19d839af68c4d17d401c142678b..a2483327aea7677d98db116a2b3d352dfa16d8e8 100644 (file)
@@ -1027,17 +1027,17 @@ void Mod_IDP3_Load(model_t *mod, void *buffer)
                mesh->data_texcoord2f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2]));
                mesh->data_morphvertex3f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * mesh->num_morphframes * sizeof(float[3]));
                for (j = 0;j < mesh->num_triangles * 3;j++)
-                       mesh->data_element3i[j] = LittleLong(((int *)((qbyte *)pinmesh + pinmesh->lump_elements))[j]);
+                       mesh->data_element3i[j] = LittleLong(((int *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_elements)))[j]);
                for (j = 0;j < mesh->num_vertices;j++)
                {
-                       mesh->data_texcoord2f[j * 2 + 0] = LittleFloat(((float *)((qbyte *)pinmesh + pinmesh->lump_texcoords))[j * 2 + 0]);
-                       mesh->data_texcoord2f[j * 2 + 1] = LittleFloat(((float *)((qbyte *)pinmesh + pinmesh->lump_texcoords))[j * 2 + 1]);
+                       mesh->data_texcoord2f[j * 2 + 0] = LittleFloat(((float *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_texcoords)))[j * 2 + 0]);
+                       mesh->data_texcoord2f[j * 2 + 1] = LittleFloat(((float *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_texcoords)))[j * 2 + 1]);
                }
                for (j = 0;j < mesh->num_vertices * mesh->num_morphframes;j++)
                {
-                       mesh->data_morphvertex3f[j * 3 + 0] = LittleShort(((short *)((qbyte *)pinmesh + pinmesh->lump_framevertices))[j * 4 + 0]) * (1.0f / 64.0f);
-                       mesh->data_morphvertex3f[j * 3 + 1] = LittleShort(((short *)((qbyte *)pinmesh + pinmesh->lump_framevertices))[j * 4 + 1]) * (1.0f / 64.0f);
-                       mesh->data_morphvertex3f[j * 3 + 2] = LittleShort(((short *)((qbyte *)pinmesh + pinmesh->lump_framevertices))[j * 4 + 2]) * (1.0f / 64.0f);
+                       mesh->data_morphvertex3f[j * 3 + 0] = LittleShort(((short *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_framevertices)))[j * 4 + 0]) * (1.0f / 64.0f);
+                       mesh->data_morphvertex3f[j * 3 + 1] = LittleShort(((short *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_framevertices)))[j * 4 + 1]) * (1.0f / 64.0f);
+                       mesh->data_morphvertex3f[j * 3 + 2] = LittleShort(((short *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_framevertices)))[j * 4 + 2]) * (1.0f / 64.0f);
                }
 
                Mod_ValidateElements(mesh->data_element3i, mesh->num_triangles, mesh->num_vertices, __FILE__, __LINE__);
@@ -1045,7 +1045,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer)
                Mod_Alias_Mesh_CompileFrameZero(mesh);
 
                if (LittleLong(pinmesh->num_shaders) >= 1)
-                       Mod_BuildAliasSkinsFromSkinFiles(mesh->data_skins, skinfiles, pinmesh->name, ((md3shader_t *)((qbyte *) pinmesh + pinmesh->lump_shaders))->name);
+                       Mod_BuildAliasSkinsFromSkinFiles(mesh->data_skins, skinfiles, pinmesh->name, ((md3shader_t *)((qbyte *) pinmesh + LittleLong(pinmesh->lump_shaders)))->name);
                else
                        for (j = 0;j < mesh->num_skins;j++)
                                Mod_BuildAliasSkinFromSkinFrame(mesh->data_skins + j, NULL);
index 74a2e193f708082f2b11762c34117946db69cafb..ad74ff0c6520292d5ee5368646760d8beacadf45 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -215,7 +215,8 @@ static dllfunction_t oggvorbisfuncs[] =
        {NULL, NULL}
 };
 
-// Handle for the Vorbisfile DLL
+// Handles for the Vorbis and Vorbisfile DLLs
+static dllhandle_t vo_dll = NULL;
 static dllhandle_t vf_dll = NULL;
 
 typedef struct
@@ -293,7 +294,7 @@ Try to load the VorbisFile DLL
 */
 qboolean OGG_OpenLibrary (void)
 {
-       const char* dllname;
+       const char *dllname_vo, *dllname_vf;
 
        // Already loaded?
        if (vf_dll)
@@ -304,14 +305,23 @@ qboolean OGG_OpenLibrary (void)
                return false;
 
 #ifdef WIN32
-       dllname = "vorbisfile.dll";
+       dllname_vo = "vorbis.dll";
+       dllname_vf = "vorbisfile.dll";
+#elif defined(MACOSX)
+       dllname_vo = "libvorbis.dylib";
+       dllname_vf = "libvorbisfile.dylib";
 #else
-       dllname = "libvorbisfile.so";
+       dllname_vo = "libvorbis.so";
+       dllname_vf = "libvorbisfile.so";
 #endif
 
-       // Load the DLL
-       if (! Sys_LoadLibrary (dllname, &vf_dll, oggvorbisfuncs))
+       // Load the DLLs
+       // We need to load both by hand because some OSes seem to not load
+       // the vorbis DLL automatically when loading the VorbisFile DLL
+       if (! Sys_LoadLibrary (dllname_vo, &vo_dll, NULL) ||
+               ! Sys_LoadLibrary (dllname_vf, &vf_dll, oggvorbisfuncs))
        {
+               Sys_UnloadLibrary (&vo_dll);
                Con_Printf ("Ogg Vorbis support disabled\n");
                return false;
        }
@@ -331,6 +341,7 @@ Unload the VorbisFile DLL
 void OGG_CloseLibrary (void)
 {
        Sys_UnloadLibrary (&vf_dll);
+       Sys_UnloadLibrary (&vo_dll);
 }