View previous topic :: View next topic |
Author |
Message |
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon May 30, 2005 2:32 pm Post subject: mac patch from anders... |
|
|
can be found over at digitalmars.D.gnu in the topic of 'mac d stuff'
Anders wrote: |
clayasaurus wrote:
> It wouldn't be too hard for derelict to work on mac osx, would it? You'd just need to add a version(OSX) and then change one file, derelict loader.d, to make use of the macs dynamic loader library which, as far as I can tell, uses the same dlopen, dlclose, and dlsym methods as linux.
Seems like the new and improved dsource forums won't let me log in...
Here's the patch. (real name for "OSX" is darwin, but Unix is better)
Paths to be loading on Darwin are:
/System/Library/Frameworks/OpenGL.framework/OpenGL
/Library/Frameworks/SDL.framework/SDL
And here is the "dl" library, for Mac OS X versions before Panther:
http://www.opendarwin.org/projects/dlcompat/
--anders
Index: DerelictUtil/derelict/util/loader.d
===================================================================
--- DerelictUtil/derelict/util/loader.d (revision 113)
+++ DerelictUtil/derelict/util/loader.d (working copy)
@@ -6,6 +6,9 @@
import std.string;
}
+version(DigitalMars)
+ version(linux)
+ version = Unix;
private alias void* SharedLibHandle;
@@ -81,7 +84,7 @@
}
}
-else version(linux)
+else version(Unix)
{
extern(C)
{
|
|
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Mon May 30, 2005 7:03 pm Post subject: |
|
|
Excellent! I've been hoping for something like this. I'll see what I can do with it. |
|
Back to top |
|
|
afb
Joined: 26 Jan 2005 Posts: 137 Location: Sweden
|
Posted: Wed Jun 01, 2005 3:40 am Post subject: |
|
|
Here are some more fixes, for Mac and GDC:
OpenGL this time (using AGL - or "Apple OpenGL")
Code: |
Index: Makefile.linux
===================================================================
--- Makefile.linux (revision 113)
+++ Makefile.linux (working copy)
@@ -3,6 +3,7 @@
LIB.DIR = ../lib
BIN.DIR = ../bin
+DMD = dmd
DFLAGS = -w -release
LIBFLAGS = -q
DINC = -I$(SRC.DIR) -I../DerelictUtil
@@ -13,6 +14,7 @@
$(OGL.SRC.DIR)/glfuncs.d \
$(OGL.SRC.DIR)/gltypes.d \
$(OGL.SRC.DIR)/glx.d \
+ $(OGL.SRC.DIR)/agl.d \
$(OGL.SRC.DIR)/internal.d \
$(OGL.SRC.DIR)/wgl.d
@@ -22,12 +24,13 @@
$(OGL.OBJ.DIR)/glfuncs.o \
$(OGL.OBJ.DIR)/gltypes.o \
$(OGL.OBJ.DIR)/glx.o \
+ $(OGL.OBJ.DIR)/agl.o \
$(OGL.OBJ.DIR)/internal.o \
$(OGL.OBJ.DIR)/wgl.o
OGL.LIB = $(LIB.DIR)/libderelictGL.a
-DEFAULT: all
+DEFAULT: $(OGL.LIB) example
clean_obj:
rm $(OGL.OBJ.DIR)/*.o
@@ -39,7 +42,11 @@
cleanall: clean clean_lib
-all:
+$(OGL.LIB):
mkdir -p $(OGL.OBJ.DIR)
- dmd $(OGL.SRC) -c $(DFLAGS) $(DINC) -od$(OGL.OBJ.DIR)
+ $(DMD) $(OGL.SRC) -c $(DFLAGS) $(DINC) -od$(OGL.OBJ.DIR)
ar $(LIBFLAGS) $(OGL.LIB) $(OGL.OBJ)
\ No newline at end of file
+ ranlib $(OGL.LIB)
+
+example: $(LIB.DIR)/libderelictUtil.a $(LIB.DIR)/libderelictGL.a example.d
+ $(DMD) -of$@ $(DFLAGS) $(DINC) $^
Index: derelict/opengl/gl.d
===================================================================
--- derelict/opengl/gl.d (revision 113)
+++ derelict/opengl/gl.d (working copy)
@@ -29,6 +29,7 @@
private import derelict.opengl.internal;
+package void loadPlatformGL(); // platform specific
public void DerelictGL_Load(char[] libName)
{
@@ -43,6 +44,8 @@
DerelictGL_Load("opengl32.dll");
version(linux)
DerelictGL_Load("libGL.so");
+ version(darwin)
+ DerelictGL_Load("/System/Library/Frameworks/OpenGL.framework/OpenGL");
}
public void DerelictGL_Unload()
Index: derelict/opengl/agl.d
===================================================================
--- /dev/null Wed Jun 1 11:37:02 2005
+++ derelict/opengl/agl.d Wed Jun 1 11:03:07 2005
@@ -0,0 +1,18 @@
+module derelict.opengl.agl;
+
+version(darwin)
+{
+private
+{
+ import derelict.opengl.gltypes;
+ import derelict.opengl.internal;
+}
+
+//------------------------------------------------------------------------------
+
+package void loadPlatformGL()
+{
+ // TODO
+}
+
+} // version(darwin)
Index: example.d
===================================================================
--- example.d (revision 113)
+++ example.d (working copy)
@@ -49,6 +49,12 @@
pragma(lib, "libderelictUtil.a");
pragma(lib, "libderelictGL.a");
}
+else version(darwin)
+{
+ // Using GDC on Mac OS X, we need libderelictUtil.a and libderelictGL.a
+ pragma(lib, "libderelictUtil.a");
+ pragma(lib, "libderelictGL.a");
+}
else
{
// Other platforms are not currently supported.
|
|
|
Back to top |
|
|
afb
Joined: 26 Jan 2005 Posts: 137 Location: Sweden
|
Posted: Wed Jun 01, 2005 3:42 am Post subject: |
|
|
Still doesn't link, though:
Code: |
ld: Undefined symbols:
__Class_8derelict4util9exception22SharedLibLoadException
__Class_8derelict4util9exception26SharedLibProcLoadException
__D8derelict6opengl2gl15DerelictGL_LoadFZv
__ModuleInfo_8derelict6opengl2gl
|
Not really sure why, as it built the libraries alright...
(../lib/libderelictUtil.a and ../lib/libderelictGL.a) |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Wed Jun 01, 2005 4:03 am Post subject: |
|
|
Thanks for the work you've done on this, Anders. Wish I had a Mac to help you figure this out. |
|
Back to top |
|
|
afb
Joined: 26 Jan 2005 Posts: 137 Location: Sweden
|
Posted: Wed Jun 01, 2005 7:21 am Post subject: |
|
|
Maybe I didn't mention it here in this particular thread,
but SDL and OpenGL are working just fine with D...
It's just the dynamic library loading and working with the
windows build systems and porting things over that's not. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|