Commit 0c92abed authored by reassembler's avatar reassembler
Browse files

Fixes for Mac OSX

parent 4c4cde9a
# Default CMake Setup. Used for Mac OS x builds
# For INTeL 32bit Mac OS X 10.5+
set(CMAKE_CXX_FLAGS " -O2 -force_cpusubtype_ALL -mmacosx-version-min=10.5 -arch i386 -m32 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -I/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include/ ")
# # For PowerPC 32bit Mac OS X 10.5+
# set(CMAKE_CXX_FLAGS " -O2 -faltivec -force_cpusubtype_ALL -mmacosx-version-min=10.5 -arch ppc -m32 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -I/Developer/SDKs/MacOSX10.5.sdk/usr/X11R6/include/ ")
# Use OpenGL for rendering
set(OPENGL 1)
# This is for MacPorts
set(lib_base /opt/local)
set(sdl_root ${lib_base})
include_directories("${sdl_root}/include/SDL/" "${lib_base}/include/" "/System/Library/Frameworks/" )
find_library(COCOA_LIBRARY Cocoa)
find_library(GLUT_LIBRARY GLUT )
find_library(OpenGL_LIBRARY OpenGL )
link_libraries(cannonball
SDL
SDLmain
${COCOA_LIBRARY}
${GLUT_LIBRARY}
${OpenGL_LIBRARY}
)
# Linking
link_directories(
"${sdl_root}/lib"
)
# Location for Cannonball to create save files
# Used to auto-generate setup.hpp with various file paths
set(xml_directory ./)
set(sdl_flags "SDL_DOUBLEBUF | SDL_SWSURFACE")
......@@ -16,6 +16,10 @@
#include "stdint.hpp"
#include "romloader.hpp"
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
#endif
RomLoader::RomLoader()
{
......@@ -38,6 +42,21 @@ void RomLoader::unload(void)
int RomLoader::load(const char* filename, const int offset, const int length, const int expected_crc, const uint8_t interleave)
{
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char bundlepath[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)bundlepath, PATH_MAX))
{
// error!
}
CFRelease(resourcesURL);
chdir(bundlepath);
#endif
std::string path = "roms/";
path += std::string(filename);
......
......@@ -108,9 +108,26 @@ bool RenderGL::init(int src_width, int src_height,
Rshift = surface->format->Rshift;
Gshift = surface->format->Gshift;
Bshift = surface->format->Bshift;
Rmask = surface->format->Rmask;
Gmask = surface->format->Gmask;
Bmask = surface->format->Bmask;
// This hack is necessary to fix an Apple OpenGL with SDL issue
#ifdef __APPLE__
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
Rmask = 0x000000FF;
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
Rshift += 8;
Gshift -= 8;
Bshift += 8;
#else
Rmask = 0xFF000000;
Gmask = 0x00FF0000;
Bmask = 0x0000FF00;
#endif
#else
Rmask = surface->format->Rmask;
Gmask = surface->format->Gmask;
Bmask = surface->format->Bmask;
#endif
// --------------------------------------------------------------------------------------------
// Initalize Open GL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment