initial commit
This commit is contained in:
172
libs/glfw/lib/macosx/Makefile.macosx.gcc
Normal file
172
libs/glfw/lib/macosx/Makefile.macosx.gcc
Normal file
@ -0,0 +1,172 @@
|
||||
##########################################################################
|
||||
# Makefile for GLFW on Mac OS X using GCC (Apple SDK).
|
||||
#-------------------------------------------------------------------------
|
||||
# To compile GLFW using this makefile, run:
|
||||
# make -f Makefile.macosx.gcc
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# Installation prefix (default to /usr/local)
|
||||
##########################################################################
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Default: Build GLFW static and shared library
|
||||
##########################################################################
|
||||
default: libglfw.a libglfw.dylib
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Compiler settings
|
||||
##########################################################################
|
||||
CC = gcc
|
||||
CFLAGS = -c -I. -I.. -Wall -O2 -fno-common -g
|
||||
|
||||
# Some modules should be optimized for speed (e.g. image decoding)
|
||||
CFLAGS_SPEED = -c -I. -I.. -Wall -O3 -ffast-math -fno-common -g
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Library builder settings
|
||||
##########################################################################
|
||||
AR = ar
|
||||
SED = sed
|
||||
INSTALL = install
|
||||
ARFLAGS = -rcs
|
||||
RANLIB = ranlib
|
||||
DYLIBFLAGS = -framework AGL -framework Carbon -framework OpenGL \
|
||||
-dynamiclib -Wl,-single_module -compatibility_version 1 \
|
||||
-current_version 1 -install_name @executable_path/libglfw.dylib
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Install GLFW header and static library
|
||||
##########################################################################
|
||||
install: libglfw.a libglfw.pc
|
||||
$(INSTALL) -d $(PREFIX)/lib
|
||||
$(INSTALL) -c -m 644 libglfw.a $(PREFIX)/lib/libglfw.a
|
||||
$(RANLIB) $(PREFIX)/lib/libglfw.a
|
||||
$(INSTALL) -d $(PREFIX)/include/GL
|
||||
$(INSTALL) -c -m 644 ../../include/GL/glfw.h $(PREFIX)/include/GL/glfw.h
|
||||
$(INSTALL) -d $(PREFIX)/lib/pkgconfig
|
||||
$(INSTALL) -c -m 644 libglfw.pc $(PREFIX)/lib/pkgconfig/libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Object files for the GLFW library
|
||||
##########################################################################
|
||||
OBJS = \
|
||||
enable.o \
|
||||
fullscreen.o \
|
||||
glext.o \
|
||||
image.o \
|
||||
init.o \
|
||||
input.o \
|
||||
joystick.o \
|
||||
stream.o \
|
||||
tga.o \
|
||||
thread.o \
|
||||
time.o \
|
||||
window.o \
|
||||
macosx_enable.o \
|
||||
macosx_fullscreen.o \
|
||||
macosx_glext.o \
|
||||
macosx_init.o \
|
||||
macosx_joystick.o \
|
||||
macosx_thread.o \
|
||||
macosx_time.o \
|
||||
macosx_window.o
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building libglfw.pc
|
||||
##########################################################################
|
||||
libglfw.pc: libglfw.pc.in
|
||||
$(SED) -e 's,\@PREFIX\@,$(PREFIX),' libglfw.pc.in > libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building static library
|
||||
##########################################################################
|
||||
libglfw.a: $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building shared library
|
||||
##########################################################################
|
||||
libglfw.dylib: $(OBJS)
|
||||
$(CC) -o $@ $(DYLIBFLAGS) $(OBJS)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for cleaning up generated files
|
||||
##########################################################################
|
||||
clean:
|
||||
@rm -f *.o libglfw.a libglfw.dylib libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rules for building library object files
|
||||
##########################################################################
|
||||
enable.o: ../enable.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../enable.c
|
||||
|
||||
fullscreen.o: ../fullscreen.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../fullscreen.c
|
||||
|
||||
glext.o: ../glext.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../glext.c
|
||||
|
||||
image.o: ../image.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ../image.c
|
||||
|
||||
init.o: ../init.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../init.c
|
||||
|
||||
input.o: ../input.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../input.c
|
||||
|
||||
joystick.o: ../joystick.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../joystick.c
|
||||
|
||||
stream.o: ../stream.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../stream.c
|
||||
|
||||
tga.o: ../tga.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ../tga.c
|
||||
|
||||
thread.o: ../thread.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../thread.c
|
||||
|
||||
time.o: ../time.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../time.c
|
||||
|
||||
window.o: ../window.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../window.c
|
||||
|
||||
macosx_enable.o: macosx_enable.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_enable.c
|
||||
|
||||
macosx_fullscreen.o: macosx_fullscreen.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_fullscreen.c
|
||||
|
||||
macosx_glext.o: macosx_glext.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_glext.c
|
||||
|
||||
macosx_init.o: macosx_init.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_init.c
|
||||
|
||||
macosx_joystick.o: macosx_joystick.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_joystick.c
|
||||
|
||||
macosx_thread.o: macosx_thread.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_thread.c
|
||||
|
||||
macosx_time.o: macosx_time.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_time.c
|
||||
|
||||
macosx_window.o: macosx_window.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_window.c
|
166
libs/glfw/lib/macosx/Makefile.macosx.gcc.universal
Normal file
166
libs/glfw/lib/macosx/Makefile.macosx.gcc.universal
Normal file
@ -0,0 +1,166 @@
|
||||
##########################################################################
|
||||
# Makefile for GLFW on Mac OS X using GCC (Apple SDK).
|
||||
#-------------------------------------------------------------------------
|
||||
# To compile GLFW using this makefile, run:
|
||||
# make -f Makefile.macosx.gcc
|
||||
##########################################################################
|
||||
|
||||
##########################################################################
|
||||
# Installation prefix (default to /usr/local)
|
||||
##########################################################################
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Default: Build GLFW static library
|
||||
##########################################################################
|
||||
default: libglfw.a
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Compiler settings
|
||||
##########################################################################
|
||||
CC = gcc
|
||||
FATFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
|
||||
CFLAGS = -c -I. -I.. -Wall -Os -fno-common $(FATFLAGS)
|
||||
|
||||
# Some modules should be optimized for speed (e.g. image decoding)
|
||||
CFLAGS_SPEED = -c -I. -I.. -Wall -O3 -ffast-math -fno-common $(FATFLAGS)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Library builder settings
|
||||
##########################################################################
|
||||
# Static library
|
||||
SED = sed
|
||||
INSTALL = install
|
||||
MKLIB = ar
|
||||
LIBFLAGS = -rcs
|
||||
RANLIB = ranlib
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Install GLFW header and static library
|
||||
##########################################################################
|
||||
install: libglfw.a libglfw.pc
|
||||
$(INSTALL) -d $(PREFIX)/lib
|
||||
$(INSTALL) -c -m 644 libglfw.a $(PREFIX)/lib/libglfw.a
|
||||
$(RANLIB) $(PREFIX)/lib/libglfw.a
|
||||
$(INSTALL) -d $(PREFIX)/include/GL
|
||||
$(INSTALL) -c -m 644 ../../include/GL/glfw.h $(PREFIX)/include/GL/glfw.h
|
||||
$(INSTALL) -d $(PREFIX)/lib/pkgconfig
|
||||
$(INSTALL) -c -m 644 libglfw.pc $(PREFIX)/lib/pkgconfig/libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for cleaning up generated files
|
||||
##########################################################################
|
||||
clean:
|
||||
@rm -f *.o libglfw.a libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Object files which are part of the GLFW library
|
||||
##########################################################################
|
||||
OBJS = \
|
||||
enable.o \
|
||||
fullscreen.o \
|
||||
glext.o \
|
||||
image.o \
|
||||
init.o \
|
||||
input.o \
|
||||
joystick.o \
|
||||
stream.o \
|
||||
tga.o \
|
||||
thread.o \
|
||||
time.o \
|
||||
window.o \
|
||||
macosx_enable.o \
|
||||
macosx_fullscreen.o \
|
||||
macosx_glext.o \
|
||||
macosx_init.o \
|
||||
macosx_joystick.o \
|
||||
macosx_thread.o \
|
||||
macosx_time.o \
|
||||
macosx_window.o
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building libglfw.pc
|
||||
##########################################################################
|
||||
libglfw.pc: libglfw.pc.in
|
||||
$(SED) -e 's,\@PREFIX\@,$(PREFIX),' libglfw.pc.in > libglfw.pc
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rule for building library
|
||||
##########################################################################
|
||||
libglfw.a: $(OBJS)
|
||||
rm -f $@
|
||||
$(MKLIB) $(LIBFLAGS) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Rules for building library object files
|
||||
##########################################################################
|
||||
enable.o: ../enable.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../enable.c
|
||||
|
||||
fullscreen.o: ../fullscreen.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../fullscreen.c
|
||||
|
||||
glext.o: ../glext.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../glext.c
|
||||
|
||||
image.o: ../image.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ../image.c
|
||||
|
||||
init.o: ../init.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../init.c
|
||||
|
||||
input.o: ../input.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../input.c
|
||||
|
||||
joystick.o: ../joystick.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../joystick.c
|
||||
|
||||
stream.o: ../stream.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../stream.c
|
||||
|
||||
tga.o: ../tga.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS_SPEED) -o $@ ../tga.c
|
||||
|
||||
thread.o: ../thread.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../thread.c
|
||||
|
||||
time.o: ../time.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../time.c
|
||||
|
||||
window.o: ../window.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ ../window.c
|
||||
|
||||
macosx_enable.o: macosx_enable.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_enable.c
|
||||
|
||||
macosx_fullscreen.o: macosx_fullscreen.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_fullscreen.c
|
||||
|
||||
macosx_glext.o: macosx_glext.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_glext.c
|
||||
|
||||
macosx_init.o: macosx_init.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_init.c
|
||||
|
||||
macosx_joystick.o: macosx_joystick.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_joystick.c
|
||||
|
||||
macosx_thread.o: macosx_thread.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_thread.c
|
||||
|
||||
macosx_time.o: macosx_time.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_time.c
|
||||
|
||||
macosx_window.o: macosx_window.c ../internal.h platform.h
|
||||
$(CC) $(CFLAGS) -o $@ macosx_window.c
|
||||
|
11
libs/glfw/lib/macosx/libglfw.pc.in
Normal file
11
libs/glfw/lib/macosx/libglfw.pc.in
Normal file
@ -0,0 +1,11 @@
|
||||
prefix=@PREFIX@
|
||||
exec_prefix=@PREFIX@
|
||||
libdir=@PREFIX@/lib
|
||||
includedir=@PREFIX@/include
|
||||
|
||||
Name: GLFW
|
||||
Description: A portable framework for OpenGL development
|
||||
Version: 2.6.0
|
||||
URL: http://glfw.sourceforge.net/
|
||||
Libs: -L${libdir} -lglfw -framework AGL -framework OpenGL -framework Carbon
|
||||
Cflags: -I${includedir}
|
42
libs/glfw/lib/macosx/macosx_enable.c
Normal file
42
libs/glfw/lib/macosx/macosx_enable.c
Normal file
@ -0,0 +1,42 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_enable.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformEnableSystemKeys( void )
|
||||
{
|
||||
// Nothing to do; event handling code checks the status of
|
||||
// _glfwWin.SysKeysDisabled to ensure this behavior.
|
||||
}
|
||||
|
||||
void _glfwPlatformDisableSystemKeys( void )
|
||||
{
|
||||
// Nothing to do; event handling code checks the status of
|
||||
// _glfwWin.SysKeysDisabled to ensure this behavior.
|
||||
}
|
||||
|
126
libs/glfw/lib/macosx/macosx_fullscreen.c
Normal file
126
libs/glfw/lib/macosx/macosx_fullscreen.c
Normal file
@ -0,0 +1,126 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_fullscreen.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
//========================================================================
|
||||
// _glfwVideoModesEqual() - Compares two video modes
|
||||
//========================================================================
|
||||
|
||||
static int _glfwVideoModesEqual( GLFWvidmode* first,
|
||||
GLFWvidmode* second )
|
||||
{
|
||||
if( first->Width != second->Width )
|
||||
return 0;
|
||||
|
||||
if( first->Height != second->Height )
|
||||
return 0;
|
||||
|
||||
if( first->RedBits + first->GreenBits + first->BlueBits !=
|
||||
second->RedBits + second->GreenBits + second->BlueBits )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// _glfwCGToGLFWVideoMode() - Converts a CG mode to a GLFW mode
|
||||
//========================================================================
|
||||
|
||||
static void _glfwCGToGLFWVideoMode( CFDictionaryRef cgMode,
|
||||
GLFWvidmode* glfwMode )
|
||||
{
|
||||
int bitsPerSample;
|
||||
|
||||
CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayWidth ),
|
||||
kCFNumberIntType,
|
||||
&(glfwMode->Width) );
|
||||
CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayHeight ),
|
||||
kCFNumberIntType,
|
||||
&(glfwMode->Height) );
|
||||
|
||||
CFNumberGetValue( CFDictionaryGetValue( cgMode, kCGDisplayBitsPerSample ),
|
||||
kCFNumberIntType,
|
||||
&bitsPerSample );
|
||||
|
||||
glfwMode->RedBits = bitsPerSample;
|
||||
glfwMode->GreenBits = bitsPerSample;
|
||||
glfwMode->BlueBits = bitsPerSample;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetVideoModes() - Get a list of available video modes
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
|
||||
{
|
||||
int i, j, maxModes, numModes;
|
||||
GLFWvidmode mode;
|
||||
CFArrayRef availableModes = CGDisplayAvailableModes( kCGDirectMainDisplay );
|
||||
CFIndex numberOfAvailableModes = CFArrayGetCount( availableModes );
|
||||
|
||||
numModes = 0;
|
||||
maxModes = ( numberOfAvailableModes < maxcount ?
|
||||
numberOfAvailableModes :
|
||||
maxcount );
|
||||
|
||||
for( i = 0; i < maxModes; ++i )
|
||||
{
|
||||
_glfwCGToGLFWVideoMode( CFArrayGetValueAtIndex( availableModes, i ),
|
||||
&mode );
|
||||
|
||||
// Is it a valid mode? (only list depths >= 15 bpp)
|
||||
if( mode.RedBits + mode.GreenBits + mode.BlueBits < 15 )
|
||||
continue;
|
||||
|
||||
// Check for duplicate of current mode in target list
|
||||
for( j = 0; j < numModes; ++j )
|
||||
{
|
||||
if( _glfwVideoModesEqual( &mode, &(list[j]) ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// If empty list or no match found
|
||||
if( numModes == 0 || j == numModes )
|
||||
list[numModes++] = mode;
|
||||
}
|
||||
|
||||
return numModes;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// glfwGetDesktopMode() - Get the desktop video mode
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode )
|
||||
{
|
||||
_glfwCGToGLFWVideoMode( _glfwDesktopVideoMode, mode );
|
||||
}
|
||||
|
52
libs/glfw/lib/macosx/macosx_glext.c
Normal file
52
libs/glfw/lib/macosx/macosx_glext.c
Normal file
@ -0,0 +1,52 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_glext.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
int _glfwPlatformExtensionSupported( const char *extension )
|
||||
{
|
||||
// There are no AGL, CGL or NSGL extensions.
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
void * _glfwPlatformGetProcAddress( const char *procname )
|
||||
{
|
||||
CFStringRef symbolName = CFStringCreateWithCString( kCFAllocatorDefault,
|
||||
procname,
|
||||
kCFStringEncodingASCII );
|
||||
|
||||
void *symbol = CFBundleGetFunctionPointerForName( _glfwLibrary.Libs.OpenGLFramework,
|
||||
symbolName );
|
||||
|
||||
CFRelease( symbolName );
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
194
libs/glfw/lib/macosx/macosx_init.c
Normal file
194
libs/glfw/lib/macosx/macosx_init.c
Normal file
@ -0,0 +1,194 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_init.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
//========================================================================
|
||||
// Global variables
|
||||
//========================================================================
|
||||
|
||||
// KCHR resource pointer for keycode translation
|
||||
void *KCHRPtr;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwInitThreads() - Initialize GLFW thread package
|
||||
//========================================================================
|
||||
|
||||
static void _glfwInitThreads( void )
|
||||
{
|
||||
// Initialize critical section handle
|
||||
(void) pthread_mutex_init( &_glfwThrd.CriticalSection, NULL );
|
||||
|
||||
// The first thread (the main thread) has ID 0
|
||||
_glfwThrd.NextID = 0;
|
||||
|
||||
// Fill out information about the main thread (this thread)
|
||||
_glfwThrd.First.ID = _glfwThrd.NextID ++;
|
||||
_glfwThrd.First.Function = NULL;
|
||||
_glfwThrd.First.PosixID = pthread_self();
|
||||
_glfwThrd.First.Previous = NULL;
|
||||
_glfwThrd.First.Next = NULL;
|
||||
}
|
||||
|
||||
#define NO_BUNDLE_MESSAGE \
|
||||
"Working in unbundled mode. " \
|
||||
"You should build a .app wrapper for your Mac OS X applications.\n"
|
||||
|
||||
#define UNBUNDLED \
|
||||
fprintf(stderr, NO_BUNDLE_MESSAGE); \
|
||||
_glfwLibrary.Unbundled = 1; \
|
||||
return
|
||||
|
||||
void _glfwChangeToResourcesDirectory( void )
|
||||
{
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
||||
char resourcesPath[ _GLFW_MAX_PATH_LENGTH ];
|
||||
|
||||
CFStringRef lastComponent = CFURLCopyLastPathComponent( resourcesURL );
|
||||
if ( kCFCompareEqualTo != CFStringCompare(
|
||||
CFSTR( "Resources" ),
|
||||
lastComponent,
|
||||
0 ) )
|
||||
{
|
||||
UNBUNDLED;
|
||||
}
|
||||
|
||||
CFRelease( lastComponent );
|
||||
|
||||
if( !CFURLGetFileSystemRepresentation( resourcesURL,
|
||||
TRUE,
|
||||
(UInt8*)resourcesPath,
|
||||
_GLFW_MAX_PATH_LENGTH ) )
|
||||
{
|
||||
CFRelease( resourcesURL );
|
||||
UNBUNDLED;
|
||||
}
|
||||
|
||||
CFRelease( resourcesURL );
|
||||
|
||||
if( chdir( resourcesPath ) != 0 )
|
||||
{
|
||||
UNBUNDLED;
|
||||
}
|
||||
}
|
||||
|
||||
int _glfwPlatformInit( void )
|
||||
{
|
||||
struct timeval tv;
|
||||
UInt32 nullDummy = 0;
|
||||
|
||||
_glfwWin.MacWindow = NULL;
|
||||
_glfwWin.AGLContext = NULL;
|
||||
_glfwWin.CGLContext = NULL;
|
||||
_glfwWin.WindowFunctions = NULL;
|
||||
_glfwWin.MouseUPP = NULL;
|
||||
_glfwWin.CommandUPP = NULL;
|
||||
_glfwWin.KeyboardUPP = NULL;
|
||||
_glfwWin.WindowUPP = NULL;
|
||||
|
||||
_glfwInput.Modifiers = 0;
|
||||
|
||||
_glfwLibrary.Unbundled = 0;
|
||||
|
||||
_glfwLibrary.Libs.OpenGLFramework
|
||||
= CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
|
||||
if( _glfwLibrary.Libs.OpenGLFramework == NULL )
|
||||
{
|
||||
fprintf(
|
||||
stderr,
|
||||
"glfwInit failing because you aren't linked to OpenGL\n" );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfwDesktopVideoMode = CGDisplayCurrentMode( kCGDirectMainDisplay );
|
||||
if( _glfwDesktopVideoMode == NULL )
|
||||
{
|
||||
fprintf(
|
||||
stderr,
|
||||
"glfwInit failing because it kind find the desktop display mode\n" );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfwInitThreads();
|
||||
|
||||
_glfwChangeToResourcesDirectory();
|
||||
|
||||
if( !_glfwInstallEventHandlers() )
|
||||
{
|
||||
fprintf(
|
||||
stderr,
|
||||
"glfwInit failing because it can't install event handlers\n" );
|
||||
_glfwPlatformTerminate();
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Ugly hack to reduce the nasty jump that occurs at the first non-
|
||||
// sys keypress, caused by OS X loading certain meta scripts used
|
||||
// for lexical- and raw keycode translation - instead of letting
|
||||
// this happen while our application is running, we do some blunt
|
||||
// function calls in advance just to get the script caching out of
|
||||
// the way BEFORE our window/screen is opened. These calls might
|
||||
// generate err return codes, but we don't care in this case.
|
||||
// NOTE: KCHRPtr is declared globally, because we need it later on.
|
||||
KCHRPtr = (void *)GetScriptVariable( smCurrentScript, smKCHRCache );
|
||||
KeyTranslate( KCHRPtr, 0, &nullDummy );
|
||||
UppercaseText( (char *)&nullDummy, 0, smSystemScript );
|
||||
|
||||
gettimeofday( &tv, NULL );
|
||||
_glfwLibrary.Timer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int _glfwPlatformTerminate( void )
|
||||
{
|
||||
if( _glfwWin.MouseUPP != NULL )
|
||||
{
|
||||
DisposeEventHandlerUPP( _glfwWin.MouseUPP );
|
||||
_glfwWin.MouseUPP = NULL;
|
||||
}
|
||||
if( _glfwWin.CommandUPP != NULL )
|
||||
{
|
||||
DisposeEventHandlerUPP( _glfwWin.CommandUPP );
|
||||
_glfwWin.CommandUPP = NULL;
|
||||
}
|
||||
if( _glfwWin.KeyboardUPP != NULL )
|
||||
{
|
||||
DisposeEventHandlerUPP( _glfwWin.KeyboardUPP );
|
||||
_glfwWin.KeyboardUPP = NULL;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
50
libs/glfw/lib/macosx/macosx_joystick.c
Normal file
50
libs/glfw/lib/macosx/macosx_joystick.c
Normal file
@ -0,0 +1,50 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_joystick.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
// TO DO: use HID manager to implement joystick support.
|
||||
|
||||
int _glfwPlatformGetJoystickParam( int joy, int param )
|
||||
{
|
||||
// GL_FALSE == 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
414
libs/glfw/lib/macosx/macosx_thread.c
Normal file
414
libs/glfw/lib/macosx/macosx_thread.c
Normal file
@ -0,0 +1,414 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_thread.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** GLFW internal functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwNewThread() - This is simply a "wrapper" for calling the user
|
||||
// thread function.
|
||||
//========================================================================
|
||||
|
||||
void * _glfwNewThread( void * arg )
|
||||
{
|
||||
GLFWthreadfun threadfun;
|
||||
_GLFWthread *t;
|
||||
|
||||
// Get pointer to thread information for current thread
|
||||
t = _glfwGetThreadPointer( glfwGetThreadID() );
|
||||
if( t == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get user thread function pointer
|
||||
threadfun = t->Function;
|
||||
|
||||
// Call the user thread function
|
||||
threadfun( arg );
|
||||
|
||||
// Remove thread from thread list
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
_glfwRemoveThread( t );
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
|
||||
// When the thread function returns, the thread will die...
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateThread() - Create a new thread
|
||||
//========================================================================
|
||||
|
||||
GLFWthread _glfwPlatformCreateThread( GLFWthreadfun fun, void *arg )
|
||||
{
|
||||
GLFWthread ID;
|
||||
_GLFWthread *t;
|
||||
int result;
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Create a new thread information memory area
|
||||
t = (_GLFWthread *) malloc( sizeof(_GLFWthread) );
|
||||
if( t == NULL )
|
||||
{
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get a new unique thread id
|
||||
ID = _glfwThrd.NextID ++;
|
||||
|
||||
// Store thread information in the thread list
|
||||
t->Function = fun;
|
||||
t->ID = ID;
|
||||
|
||||
// Create thread
|
||||
result = pthread_create(
|
||||
&t->PosixID, // Thread handle
|
||||
NULL, // Default thread attributes
|
||||
_glfwNewThread, // Thread function (a wrapper function)
|
||||
(void *)arg // Argument to thread is user argument
|
||||
);
|
||||
|
||||
// Did the thread creation fail?
|
||||
if( result != 0 )
|
||||
{
|
||||
free( (void *) t );
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Append thread to thread list
|
||||
_glfwAppendThread( t );
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Return the GLFW thread ID
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyThread() - Kill a thread. NOTE: THIS IS A VERY
|
||||
// DANGEROUS OPERATION, AND SHOULD NOT BE USED EXCEPT IN EXTREME
|
||||
// SITUATIONS!
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyThread( GLFWthread ID )
|
||||
{
|
||||
_GLFWthread *t;
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Get thread information pointer
|
||||
t = _glfwGetThreadPointer( ID );
|
||||
if( t == NULL )
|
||||
{
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return;
|
||||
}
|
||||
|
||||
// Simply murder the process, no mercy!
|
||||
pthread_kill( t->PosixID, SIGKILL );
|
||||
|
||||
// Remove thread from thread list
|
||||
_glfwRemoveThread( t );
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformWaitThread() - Wait for a thread to die
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformWaitThread( GLFWthread ID, int waitmode )
|
||||
{
|
||||
pthread_t thread;
|
||||
_GLFWthread *t;
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Get thread information pointer
|
||||
t = _glfwGetThreadPointer( ID );
|
||||
|
||||
// Is the thread already dead?
|
||||
if( t == NULL )
|
||||
{
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
// If got this far, the thread is alive => polling returns FALSE
|
||||
if( waitmode == GLFW_NOWAIT )
|
||||
{
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Get thread handle
|
||||
thread = t->PosixID;
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Wait for thread to die
|
||||
(void) pthread_join( thread, NULL );
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetThreadID() - Return the thread ID for the current
|
||||
// thread
|
||||
//========================================================================
|
||||
|
||||
GLFWthread _glfwPlatformGetThreadID( void )
|
||||
{
|
||||
_GLFWthread *t;
|
||||
GLFWthread ID = -1;
|
||||
pthread_t posixID;
|
||||
|
||||
// Get current thread ID
|
||||
posixID = pthread_self();
|
||||
|
||||
// Enter critical section
|
||||
ENTER_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Loop through entire list of threads to find the matching POSIX
|
||||
// thread ID
|
||||
for( t = &_glfwThrd.First; t != NULL; t = t->Next )
|
||||
{
|
||||
if( t->PosixID == posixID )
|
||||
{
|
||||
ID = t->ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Leave critical section
|
||||
LEAVE_THREAD_CRITICAL_SECTION
|
||||
|
||||
// Return the found GLFW thread identifier
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateMutex() - Create a mutual exclusion object
|
||||
//========================================================================
|
||||
|
||||
GLFWmutex _glfwPlatformCreateMutex( void )
|
||||
{
|
||||
pthread_mutex_t *mutex;
|
||||
|
||||
// Allocate memory for mutex
|
||||
mutex = (pthread_mutex_t *) malloc( sizeof( pthread_mutex_t ) );
|
||||
if( !mutex )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Initialise a mutex object
|
||||
(void) pthread_mutex_init( mutex, NULL );
|
||||
|
||||
// Cast to GLFWmutex and return
|
||||
return (GLFWmutex) mutex;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyMutex() - Destroy a mutual exclusion object
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyMutex( GLFWmutex mutex )
|
||||
{
|
||||
// Destroy the mutex object
|
||||
pthread_mutex_destroy( (pthread_mutex_t *) mutex );
|
||||
|
||||
// Free memory for mutex object
|
||||
free( (void *) mutex );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformLockMutex() - Request access to a mutex
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformLockMutex( GLFWmutex mutex )
|
||||
{
|
||||
// Wait for mutex to be released
|
||||
(void) pthread_mutex_lock( (pthread_mutex_t *) mutex );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformUnlockMutex() - Release a mutex
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformUnlockMutex( GLFWmutex mutex )
|
||||
{
|
||||
// Release mutex
|
||||
pthread_mutex_unlock( (pthread_mutex_t *) mutex );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformCreateCond() - Create a new condition variable object
|
||||
//========================================================================
|
||||
|
||||
GLFWcond _glfwPlatformCreateCond( void )
|
||||
{
|
||||
pthread_cond_t *cond;
|
||||
|
||||
// Allocate memory for condition variable
|
||||
cond = (pthread_cond_t *) malloc( sizeof(pthread_cond_t) );
|
||||
if( !cond )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Initialise condition variable
|
||||
(void) pthread_cond_init( cond, NULL );
|
||||
|
||||
// Cast to GLFWcond and return
|
||||
return (GLFWcond) cond;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformDestroyCond() - Destroy a condition variable object
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformDestroyCond( GLFWcond cond )
|
||||
{
|
||||
// Destroy the condition variable object
|
||||
(void) pthread_cond_destroy( (pthread_cond_t *) cond );
|
||||
|
||||
// Free memory for condition variable object
|
||||
free( (void *) cond );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformWaitCond() - Wait for a condition to be raised
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformWaitCond( GLFWcond cond, GLFWmutex mutex,
|
||||
double timeout )
|
||||
{
|
||||
struct timeval currenttime;
|
||||
struct timespec wait;
|
||||
long dt_sec, dt_usec;
|
||||
|
||||
// Select infinite or timed wait
|
||||
if( timeout >= GLFW_INFINITY )
|
||||
{
|
||||
// Wait for condition (infinite wait)
|
||||
(void) pthread_cond_wait( (pthread_cond_t *) cond,
|
||||
(pthread_mutex_t *) mutex );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set timeout time, relatvie to current time
|
||||
gettimeofday( ¤ttime, NULL );
|
||||
dt_sec = (long) timeout;
|
||||
dt_usec = (long) ((timeout - (double)dt_sec) * 1000000.0);
|
||||
wait.tv_nsec = (currenttime.tv_usec + dt_usec) * 1000L;
|
||||
if( wait.tv_nsec > 1000000000L )
|
||||
{
|
||||
wait.tv_nsec -= 1000000000L;
|
||||
dt_sec ++;
|
||||
}
|
||||
wait.tv_sec = currenttime.tv_sec + dt_sec;
|
||||
|
||||
// Wait for condition (timed wait)
|
||||
(void) pthread_cond_timedwait( (pthread_cond_t *) cond,
|
||||
(pthread_mutex_t *) mutex, &wait );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformSignalCond() - Signal a condition to one waiting thread
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSignalCond( GLFWcond cond )
|
||||
{
|
||||
// Signal condition
|
||||
(void) pthread_cond_signal( (pthread_cond_t *) cond );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformBroadcastCond() - Broadcast a condition to all waiting
|
||||
// threads
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformBroadcastCond( GLFWcond cond )
|
||||
{
|
||||
// Broadcast condition
|
||||
(void) pthread_cond_broadcast( (pthread_cond_t *) cond );
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// _glfwPlatformGetNumberOfProcessors() - Return the number of processors
|
||||
// in the system.
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformGetNumberOfProcessors( void )
|
||||
{
|
||||
int n;
|
||||
|
||||
// Get number of processors online
|
||||
_glfw_numprocessors( n );
|
||||
return n;
|
||||
}
|
||||
|
112
libs/glfw/lib/macosx/macosx_time.c
Normal file
112
libs/glfw/lib/macosx/macosx_time.c
Normal file
@ -0,0 +1,112 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: macosx_time.c
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
//************************************************************************
|
||||
//**** Platform implementation functions ****
|
||||
//************************************************************************
|
||||
|
||||
//========================================================================
|
||||
// Return timer value in seconds
|
||||
//========================================================================
|
||||
|
||||
double _glfwPlatformGetTime( void )
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday( &tv, NULL );
|
||||
return tv.tv_sec + (double) tv.tv_usec / 1000000.0 - _glfwLibrary.Timer.t0;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set timer value in seconds
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetTime( double time )
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday( &tv, NULL );
|
||||
_glfwLibrary.Timer.t0 = tv.tv_sec + (double) tv.tv_usec / 1000000.0 - time;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Put a thread to sleep for a specified amount of time
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSleep( double time )
|
||||
{
|
||||
if( time == 0.0 )
|
||||
{
|
||||
sched_yield();
|
||||
return;
|
||||
}
|
||||
|
||||
struct timeval currenttime;
|
||||
struct timespec wait;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
long dt_sec, dt_usec;
|
||||
|
||||
// Not all pthread implementations have a pthread_sleep() function. We
|
||||
// do it the portable way, using a timed wait for a condition that we
|
||||
// will never signal. NOTE: The unistd functions sleep/usleep suspends
|
||||
// the entire PROCESS, not a signle thread, which is why we can not
|
||||
// use them to implement glfwSleep.
|
||||
|
||||
// Set timeout time, relatvie to current time
|
||||
gettimeofday( ¤ttime, NULL );
|
||||
dt_sec = (long) time;
|
||||
dt_usec = (long) ((time - (double)dt_sec) * 1000000.0);
|
||||
wait.tv_nsec = (currenttime.tv_usec + dt_usec) * 1000L;
|
||||
if( wait.tv_nsec > 1000000000L )
|
||||
{
|
||||
wait.tv_nsec -= 1000000000L;
|
||||
dt_sec ++;
|
||||
}
|
||||
wait.tv_sec = currenttime.tv_sec + dt_sec;
|
||||
|
||||
// Initialize condition and mutex objects
|
||||
pthread_mutex_init( &mutex, NULL );
|
||||
pthread_cond_init( &cond, NULL );
|
||||
|
||||
// Do a timed wait
|
||||
pthread_mutex_lock( &mutex );
|
||||
pthread_cond_timedwait( &cond, &mutex, &wait );
|
||||
pthread_mutex_unlock( &mutex );
|
||||
|
||||
// Destroy condition and mutex objects
|
||||
pthread_mutex_destroy( &mutex );
|
||||
pthread_cond_destroy( &cond );
|
||||
}
|
||||
|
1279
libs/glfw/lib/macosx/macosx_window.c
Normal file
1279
libs/glfw/lib/macosx/macosx_window.c
Normal file
File diff suppressed because it is too large
Load Diff
349
libs/glfw/lib/macosx/platform.h
Normal file
349
libs/glfw/lib/macosx/platform.h
Normal file
@ -0,0 +1,349 @@
|
||||
//========================================================================
|
||||
// GLFW - An OpenGL framework
|
||||
// File: platform.h
|
||||
// Platform: Mac OS X
|
||||
// API Version: 2.6
|
||||
// WWW: http://glfw.sourceforge.net
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Camilla Berglund
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _platform_h_
|
||||
#define _platform_h_
|
||||
|
||||
|
||||
// This is the Mac OS X version of GLFW
|
||||
#define _GLFW_MAC_OS_X
|
||||
|
||||
|
||||
// Include files
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <AGL/agl.h>
|
||||
#include <sched.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include "../../include/GL/glfw.h"
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Defines
|
||||
//========================================================================
|
||||
|
||||
#define _GLFW_MAX_PATH_LENGTH (8192)
|
||||
|
||||
#define MAC_KEY_ENTER 0x24
|
||||
#define MAC_KEY_RETURN 0x34
|
||||
#define MAC_KEY_ESC 0x35
|
||||
#define MAC_KEY_F1 0x7A
|
||||
#define MAC_KEY_F2 0x78
|
||||
#define MAC_KEY_F3 0x63
|
||||
#define MAC_KEY_F4 0x76
|
||||
#define MAC_KEY_F5 0x60
|
||||
#define MAC_KEY_F6 0x61
|
||||
#define MAC_KEY_F7 0x62
|
||||
#define MAC_KEY_F8 0x64
|
||||
#define MAC_KEY_F9 0x65
|
||||
#define MAC_KEY_F10 0x6D
|
||||
#define MAC_KEY_F11 0x67
|
||||
#define MAC_KEY_F12 0x6F
|
||||
#define MAC_KEY_F13 0x69
|
||||
#define MAC_KEY_F14 0x6B
|
||||
#define MAC_KEY_F15 0x71
|
||||
#define MAC_KEY_UP 0x7E
|
||||
#define MAC_KEY_DOWN 0x7D
|
||||
#define MAC_KEY_LEFT 0x7B
|
||||
#define MAC_KEY_RIGHT 0x7C
|
||||
#define MAC_KEY_TAB 0x30
|
||||
#define MAC_KEY_BACKSPACE 0x33
|
||||
#define MAC_KEY_HELP 0x72
|
||||
#define MAC_KEY_DEL 0x75
|
||||
#define MAC_KEY_PAGEUP 0x74
|
||||
#define MAC_KEY_PAGEDOWN 0x79
|
||||
#define MAC_KEY_HOME 0x73
|
||||
#define MAC_KEY_END 0x77
|
||||
#define MAC_KEY_KP_0 0x52
|
||||
#define MAC_KEY_KP_1 0x53
|
||||
#define MAC_KEY_KP_2 0x54
|
||||
#define MAC_KEY_KP_3 0x55
|
||||
#define MAC_KEY_KP_4 0x56
|
||||
#define MAC_KEY_KP_5 0x57
|
||||
#define MAC_KEY_KP_6 0x58
|
||||
#define MAC_KEY_KP_7 0x59
|
||||
#define MAC_KEY_KP_8 0x5B
|
||||
#define MAC_KEY_KP_9 0x5C
|
||||
#define MAC_KEY_KP_DIVIDE 0x4B
|
||||
#define MAC_KEY_KP_MULTIPLY 0x43
|
||||
#define MAC_KEY_KP_SUBTRACT 0x4E
|
||||
#define MAC_KEY_KP_ADD 0x45
|
||||
#define MAC_KEY_KP_DECIMAL 0x41
|
||||
#define MAC_KEY_KP_EQUAL 0x51
|
||||
#define MAC_KEY_KP_ENTER 0x4C
|
||||
|
||||
//========================================================================
|
||||
// full-screen/desktop-window "virtual" function table
|
||||
//========================================================================
|
||||
|
||||
typedef int ( * GLFWmacopenwindowfun )( int, int, int, int, int, int, int, int, int, int, int, int, int, int, int );
|
||||
typedef void ( * GLFWmacclosewindowfun )( void );
|
||||
typedef void ( * GLFWmacsetwindowtitlefun )( const char * );
|
||||
typedef void ( * GLFWmacsetwindowsizefun )( int, int );
|
||||
typedef void ( * GLFWmacsetwindowposfun )( int, int );
|
||||
typedef void ( * GLFWmaciconifywindowfun )( void );
|
||||
typedef void ( * GLFWmacrestorewindowfun )( void );
|
||||
typedef void ( * GLFWmacrefreshwindowparamsfun )( void );
|
||||
typedef void ( * GLFWmacsetmousecursorposfun )( int, int );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLFWmacopenwindowfun OpenWindow;
|
||||
GLFWmacclosewindowfun CloseWindow;
|
||||
GLFWmacsetwindowtitlefun SetWindowTitle;
|
||||
GLFWmacsetwindowsizefun SetWindowSize;
|
||||
GLFWmacsetwindowposfun SetWindowPos;
|
||||
GLFWmaciconifywindowfun IconifyWindow;
|
||||
GLFWmacrestorewindowfun RestoreWindow;
|
||||
GLFWmacrefreshwindowparamsfun RefreshWindowParams;
|
||||
GLFWmacsetmousecursorposfun SetMouseCursorPos;
|
||||
}
|
||||
_GLFWmacwindowfunctions;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Global variables (GLFW internals)
|
||||
//========================================================================
|
||||
|
||||
GLFWGLOBAL CFDictionaryRef _glfwDesktopVideoMode;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Window structure
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct _GLFWwin_struct _GLFWwin;
|
||||
|
||||
struct _GLFWwin_struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// Window states
|
||||
int Opened; // Flag telling if window is opened or not
|
||||
int Active; // Application active flag
|
||||
int Iconified; // Window iconified flag
|
||||
|
||||
// User callback functions
|
||||
GLFWwindowsizefun WindowSizeCallback;
|
||||
GLFWwindowclosefun WindowCloseCallback;
|
||||
GLFWwindowrefreshfun WindowRefreshCallback;
|
||||
GLFWmousebuttonfun MouseButtonCallback;
|
||||
GLFWmouseposfun MousePosCallback;
|
||||
GLFWmousewheelfun MouseWheelCallback;
|
||||
GLFWkeyfun KeyCallback;
|
||||
GLFWcharfun CharCallback;
|
||||
|
||||
// User selected window settings
|
||||
int Fullscreen; // Fullscreen flag
|
||||
int MouseLock; // Mouse-lock flag
|
||||
int AutoPollEvents; // Auto polling flag
|
||||
int SysKeysDisabled; // System keys disabled flag
|
||||
int RefreshRate; // Refresh rate (for fullscreen mode)
|
||||
int WindowNoResize; // Resize- and maximize gadgets disabled flag
|
||||
int Samples;
|
||||
|
||||
// Window status
|
||||
int Width, Height; // Window width and heigth
|
||||
|
||||
// Extensions & OpenGL version
|
||||
int Has_GL_SGIS_generate_mipmap;
|
||||
int Has_GL_ARB_texture_non_power_of_two;
|
||||
int GLVerMajor,GLVerMinor;
|
||||
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
WindowRef MacWindow;
|
||||
AGLContext AGLContext;
|
||||
CGLContextObj CGLContext;
|
||||
|
||||
EventHandlerUPP MouseUPP;
|
||||
EventHandlerUPP CommandUPP;
|
||||
EventHandlerUPP KeyboardUPP;
|
||||
EventHandlerUPP WindowUPP;
|
||||
|
||||
_GLFWmacwindowfunctions* WindowFunctions;
|
||||
|
||||
// for easy access by _glfwPlatformGetWindowParam
|
||||
int Accelerated;
|
||||
int RedBits, GreenBits, BlueBits, AlphaBits;
|
||||
int DepthBits;
|
||||
int StencilBits;
|
||||
int AccumRedBits, AccumGreenBits, AccumBlueBits, AccumAlphaBits;
|
||||
int AuxBuffers;
|
||||
int Stereo;
|
||||
};
|
||||
|
||||
GLFWGLOBAL _GLFWwin _glfwWin;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// User input status (some of this should go in _GLFWwin)
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
|
||||
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
|
||||
|
||||
// Mouse status
|
||||
int MousePosX, MousePosY;
|
||||
int WheelPos;
|
||||
char MouseButton[ GLFW_MOUSE_BUTTON_LAST+1 ];
|
||||
|
||||
// Keyboard status
|
||||
char Key[ GLFW_KEY_LAST+1 ];
|
||||
int LastChar;
|
||||
|
||||
// User selected settings
|
||||
int StickyKeys;
|
||||
int StickyMouseButtons;
|
||||
int KeyRepeat;
|
||||
|
||||
|
||||
// ========= PLATFORM SPECIFIC PART ======================================
|
||||
|
||||
UInt32 Modifiers;
|
||||
|
||||
} _glfwInput;
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Thread information
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct _GLFWthread_struct _GLFWthread;
|
||||
|
||||
// Thread record (one for each thread)
|
||||
struct _GLFWthread_struct {
|
||||
// Pointer to previous and next threads in linked list
|
||||
_GLFWthread *Previous, *Next;
|
||||
|
||||
// GLFW user side thread information
|
||||
GLFWthread ID;
|
||||
GLFWthreadfun Function;
|
||||
|
||||
// System side thread information
|
||||
pthread_t PosixID;
|
||||
};
|
||||
|
||||
// General thread information
|
||||
GLFWGLOBAL struct {
|
||||
// Critical section lock
|
||||
pthread_mutex_t CriticalSection;
|
||||
|
||||
// Next thread ID to use (increments for every created thread)
|
||||
GLFWthread NextID;
|
||||
|
||||
// First thread in linked list (always the main thread)
|
||||
_GLFWthread First;
|
||||
} _glfwThrd;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Library global data
|
||||
//------------------------------------------------------------------------
|
||||
GLFWGLOBAL struct {
|
||||
|
||||
// Timer data
|
||||
struct {
|
||||
double t0;
|
||||
} Timer;
|
||||
|
||||
struct {
|
||||
// Bundle for dynamically-loading extension function pointers
|
||||
CFBundleRef OpenGLFramework;
|
||||
} Libs;
|
||||
|
||||
int Unbundled;
|
||||
|
||||
} _glfwLibrary;
|
||||
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Macros for encapsulating critical code sections (i.e. making parts
|
||||
// of GLFW thread safe)
|
||||
//========================================================================
|
||||
|
||||
// Define so we can use the same thread code as X11
|
||||
#define _glfw_numprocessors(n) { \
|
||||
int mib[2], ncpu; \
|
||||
size_t len = 1; \
|
||||
mib[0] = CTL_HW; \
|
||||
mib[1] = HW_NCPU; \
|
||||
n = 1; \
|
||||
if( sysctl( mib, 2, &ncpu, &len, NULL, 0 ) != -1 ) \
|
||||
{ \
|
||||
if( len > 0 ) \
|
||||
{ \
|
||||
n = ncpu; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
// Thread list management
|
||||
#define ENTER_THREAD_CRITICAL_SECTION \
|
||||
pthread_mutex_lock( &_glfwThrd.CriticalSection );
|
||||
#define LEAVE_THREAD_CRITICAL_SECTION \
|
||||
pthread_mutex_unlock( &_glfwThrd.CriticalSection );
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Prototypes for platform specific internal functions
|
||||
//========================================================================
|
||||
|
||||
void _glfwChangeToResourcesDirectory( void );
|
||||
|
||||
int _glfwInstallEventHandlers( void );
|
||||
|
||||
//========================================================================
|
||||
// Prototypes for full-screen/desktop-window "virtual" functions
|
||||
//========================================================================
|
||||
|
||||
int _glfwMacFSOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int accumredbits, int accumgreenbits, int accumbluebits, int accumalphabits, int auxbuffers, int stereo, int refreshrate );
|
||||
void _glfwMacFSCloseWindow( void );
|
||||
void _glfwMacFSSetWindowTitle( const char *title );
|
||||
void _glfwMacFSSetWindowSize( int width, int height );
|
||||
void _glfwMacFSSetWindowPos( int x, int y );
|
||||
void _glfwMacFSIconifyWindow( void );
|
||||
void _glfwMacFSRestoreWindow( void );
|
||||
void _glfwMacFSRefreshWindowParams( void );
|
||||
void _glfwMacFSSetMouseCursorPos( int x, int y );
|
||||
|
||||
int _glfwMacDWOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int accumredbits, int accumgreenbits, int accumbluebits, int accumalphabits, int auxbuffers, int stereo, int refreshrate );
|
||||
void _glfwMacDWCloseWindow( void );
|
||||
void _glfwMacDWSetWindowTitle( const char *title );
|
||||
void _glfwMacDWSetWindowSize( int width, int height );
|
||||
void _glfwMacDWSetWindowPos( int x, int y );
|
||||
void _glfwMacDWIconifyWindow( void );
|
||||
void _glfwMacDWRestoreWindow( void );
|
||||
void _glfwMacDWRefreshWindowParams( void );
|
||||
void _glfwMacDWSetMouseCursorPos( int x, int y );
|
||||
|
||||
#endif // _platform_h_
|
Reference in New Issue
Block a user