mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
initial iphone stuff, w.i.p.
This commit is contained in:
parent
ef4a9038df
commit
a08b08f8d3
@ -21,6 +21,164 @@
|
|||||||
|
|
||||||
#define IS_LINUX 1
|
#define IS_LINUX 1
|
||||||
|
|
||||||
|
// Compiler flags
|
||||||
|
|
||||||
|
// How to invoke the C and C++ compilers.
|
||||||
|
#if $[eq $[USE_COMPILER], GCC]
|
||||||
|
#define CC gcc
|
||||||
|
#define CXX g++
|
||||||
|
|
||||||
|
// gcc might run into template limits on some parts of Panda.
|
||||||
|
// I upped this from 25 to build on OS X (GCC 3.3) -- skyler.
|
||||||
|
#define C++FLAGS_GEN -ftemplate-depth-30
|
||||||
|
#else
|
||||||
|
#define CC cc
|
||||||
|
#define CXX CC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Linux doesn't (yet) have any funny architecture flags.
|
||||||
|
#defer ARCH_FLAGS
|
||||||
|
|
||||||
|
// How to compile a C or C++ file into a .o file. $[target] is the
|
||||||
|
// name of the .o file, $[source] is the name of the source file,
|
||||||
|
// $[ipath] is a space-separated list of directories to search for
|
||||||
|
// include files, and $[flags] is a list of additional flags to pass
|
||||||
|
// to the compiler.
|
||||||
|
#defer COMPILE_C $[CC] $[CFLAGS_GEN] $[ARCH_FLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
||||||
|
#defer COMPILE_C++ $[CXX] $[C++FLAGS_GEN] $[ARCH_FLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
||||||
|
|
||||||
|
// What flags should be passed to both C and C++ compilers to enable
|
||||||
|
// debug symbols? This will be supplied when OPTIMIZE (above) is set
|
||||||
|
// to 1, 2, or 3.
|
||||||
|
#defer DEBUGFLAGS -g
|
||||||
|
|
||||||
|
// What flags should be passed to both C and C++ compilers to enable
|
||||||
|
// compiler optimizations? This will be supplied when OPTIMIZE
|
||||||
|
// (above) is set to 2, 3, or 4.
|
||||||
|
#defer OPTFLAGS -O2
|
||||||
|
|
||||||
|
// By convention, any source file that contains the string _no_opt_ in
|
||||||
|
// its filename won't have the above compiler optimizations run for it.
|
||||||
|
#defer no_opt $[findstring _no_opt_,$[source]]
|
||||||
|
|
||||||
|
// What define variables should be passed to the compilers for each
|
||||||
|
// value of OPTIMIZE? We separate this so we can pass these same
|
||||||
|
// options to interrogate, guaranteeing that the correct interfaces
|
||||||
|
// are generated. Do not include -D here; that will be supplied
|
||||||
|
// automatically.
|
||||||
|
#defer CDEFINES_OPT1 _DEBUG $[EXTRA_CDEFS]
|
||||||
|
#defer CDEFINES_OPT2 _DEBUG $[EXTRA_CDEFS]
|
||||||
|
#defer CDEFINES_OPT3 $[EXTRA_CDEFS]
|
||||||
|
#defer CDEFINES_OPT4 NDEBUG $[EXTRA_CDEFS]
|
||||||
|
|
||||||
|
// What additional flags should be passed for each value of OPTIMIZE
|
||||||
|
// (above)? We separate out the compiler-optimization flags, above,
|
||||||
|
// so we can compile certain files that give optimizers trouble (like
|
||||||
|
// the output of lex and yacc) without them, but with all the other
|
||||||
|
// relevant flags.
|
||||||
|
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] -Wall $[DEBUGFLAGS]
|
||||||
|
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] -Wall $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
|
||||||
|
// What additional flags should be passed to both compilers when
|
||||||
|
// building shared (relocatable) sources? Some architectures require
|
||||||
|
// special support for this.
|
||||||
|
#defer CFLAGS_SHARED -fPIC
|
||||||
|
|
||||||
|
// How to generate a C or C++ executable from a collection of .o
|
||||||
|
// files. $[target] is the name of the binary to generate, and
|
||||||
|
// $[sources] is the list of .o files. $[libs] is a space-separated
|
||||||
|
// list of dependent libraries, and $[lpath] is a space-separated list
|
||||||
|
// of directories in which those libraries can be found.
|
||||||
|
#defer LINK_BIN_C $[cc_ld] $[ARCH_FLAGS] -o $[target] $[sources] $[flags] $[lpath:%=-L%] $[libs:%=-l%]\
|
||||||
|
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
||||||
|
#defer LINK_BIN_C++ $[cxx_ld] $[ARCH_FLAGS] \
|
||||||
|
-o $[target] $[sources]\
|
||||||
|
$[flags]\
|
||||||
|
$[lpath:%=-L%] $[libs:%=-l%]\
|
||||||
|
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
||||||
|
|
||||||
|
// How to generate a static C or C++ library. $[target] is the
|
||||||
|
// name of the library to generate, and $[sources] is the list of .o
|
||||||
|
// files that will go into the library.
|
||||||
|
#defer STATIC_LIB_C ar cru $[target] $[sources]
|
||||||
|
#defer STATIC_LIB_C++ ar cru $[target] $[sources]
|
||||||
|
|
||||||
|
// How to run ranlib, if necessary, after generating a static library.
|
||||||
|
// $[target] is the name of the library. Set this to the empty string
|
||||||
|
// if ranlib is not necessary on your platform.
|
||||||
|
#defer RANLIB ranlib $[target]
|
||||||
|
|
||||||
|
// Where to put the so_locations file, used by an Irix MIPSPro
|
||||||
|
// compiler, to generate a map of shared library memory locations.
|
||||||
|
#defer SO_LOCATIONS $[DTOOL_INSTALL]/etc/so_locations
|
||||||
|
|
||||||
|
|
||||||
|
// How to generate a shared C or C++ library. $[source] and $[target]
|
||||||
|
// as above, and $[libs] is a space-separated list of dependent
|
||||||
|
// libraries, and $[lpath] is a space-separated list of directories in
|
||||||
|
// which those libraries can be found.
|
||||||
|
#defer SHARED_LIB_C $[cc_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#define BUNDLE_LIB_C++
|
||||||
|
|
||||||
|
// How to install a data file or executable file. $[local] is the
|
||||||
|
// local name of the file to install, and $[dest] is the name of the
|
||||||
|
// directory to put it in.
|
||||||
|
|
||||||
|
// On Unix systems, we strongly prefer using the install program to
|
||||||
|
// install files. This has nice features like automatically setting
|
||||||
|
// the permissions bits, and also is usually clever enough to install
|
||||||
|
// a running program without crashing the running instance. However,
|
||||||
|
// it doesn't understanding installing a program from a subdirectory,
|
||||||
|
// so we have to cd into the source directory first.
|
||||||
|
#defer install_dash_p $[if $[KEEP_TIMESTAMPS],-p,]
|
||||||
|
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] $[install_dash_p] $[notdir $[local]] $[dest]/
|
||||||
|
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] $[install_dash_p] $[notdir $[local]] $[dest]/
|
||||||
|
|
||||||
|
// Variable definitions for building with the Irix MIPSPro compiler.
|
||||||
|
#if $[eq $[USE_COMPILER], MIPS]
|
||||||
|
#define CC cc -n32 -mips3
|
||||||
|
#define CXX CC -n32 -mips3
|
||||||
|
|
||||||
|
// Turn off a few annoying warning messages.
|
||||||
|
// 1174 - function 'blah' was declared but never used
|
||||||
|
// 1201 - trailing comma is nonstandard.
|
||||||
|
// 1209 - controlling expression is constant, e.g. if (0) { ... }
|
||||||
|
// 1234 - access control not specified, 'public' by default
|
||||||
|
// 1355 - extra ";" ignored
|
||||||
|
// 1375 - destructor for base class is not virtual.
|
||||||
|
// this one actually is bad. But we got alot of them from the classes
|
||||||
|
// that we've derived from STL collections. Beware of this.
|
||||||
|
// 3322 - omission of explicit type is nonstandard ("int" assumed)
|
||||||
|
#define WOFF_LIST -woff 1174,1201,1209,1234,1355,1375,3322
|
||||||
|
|
||||||
|
// Linker warnings
|
||||||
|
// 85 - definition of SOMESYMBOL in SOMELIB preempts that of definition in
|
||||||
|
// SOMEOTHERLIB.
|
||||||
|
#define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
|
||||||
|
|
||||||
|
#defer OPTFLAGS -O2 -OPT:Olimit=2500
|
||||||
|
|
||||||
|
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] $[WOFF_LIST] -g
|
||||||
|
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] $[WOFF_LIST]
|
||||||
|
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[WOFF_LIST]
|
||||||
|
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[WOFF_LIST]
|
||||||
|
|
||||||
|
#defer CFLAGS_SHARED
|
||||||
|
|
||||||
|
#defer STATIC_LIB_C $[CC] -ar -o $[target] $[sources]
|
||||||
|
#defer STATIC_LIB_C++ $[CXX] -ar -o $[target] $[sources]
|
||||||
|
#defer RANLIB
|
||||||
|
|
||||||
|
#defer SHARED_FLAGS -Wl,-none -Wl,-update_registry,$[SO_LOCATIONS]
|
||||||
|
#defer SHARED_LIB_C $[cc_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// What additional flags should we pass to interrogate?
|
// What additional flags should we pass to interrogate?
|
||||||
#if $[eq $[shell uname -m], x86_64] // if Linux is 64bit
|
#if $[eq $[shell uname -m], x86_64] // if Linux is 64bit
|
||||||
#define SYSTEM_IGATE_FLAGS -D_LP64 -D__const=const -Dvolatile -Dmutable
|
#define SYSTEM_IGATE_FLAGS -D_LP64 -D__const=const -Dvolatile -Dmutable
|
||||||
@ -173,4 +331,5 @@
|
|||||||
|
|
||||||
// The dynamic library file extension (usually .so .dll or .dylib):
|
// The dynamic library file extension (usually .so .dll or .dylib):
|
||||||
#define DYNAMIC_LIB_EXT .so
|
#define DYNAMIC_LIB_EXT .so
|
||||||
|
#define STATIC_LIB_EXT .a
|
||||||
#define BUNDLE_EXT
|
#define BUNDLE_EXT
|
||||||
|
@ -21,6 +21,157 @@
|
|||||||
|
|
||||||
#define IS_OSX 1
|
#define IS_OSX 1
|
||||||
|
|
||||||
|
// Compiler flags
|
||||||
|
|
||||||
|
#define CC gcc
|
||||||
|
#define CXX g++
|
||||||
|
#define C++FLAGS_GEN -ftemplate-depth-30
|
||||||
|
|
||||||
|
// Configure for universal binaries on OSX.
|
||||||
|
#defer ARCH_FLAGS $[if $[UNIVERSAL_BINARIES],-arch i386 -arch ppc,]
|
||||||
|
#define OSX_CDEFS
|
||||||
|
#define OSX_CFLAGS
|
||||||
|
|
||||||
|
// How to compile a C or C++ file into a .o file. $[target] is the
|
||||||
|
// name of the .o file, $[source] is the name of the source file,
|
||||||
|
// $[ipath] is a space-separated list of directories to search for
|
||||||
|
// include files, and $[flags] is a list of additional flags to pass
|
||||||
|
// to the compiler.
|
||||||
|
|
||||||
|
#defer COMPILE_C $[CC] $[CFLAGS_GEN] $[ARCH_FLAGS] $[OSX_CFLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
||||||
|
#defer COMPILE_C++ $[CXX] $[C++FLAGS_GEN] $[ARCH_FLAGS] $[OSX_CFLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
||||||
|
|
||||||
|
// What flags should be passed to both C and C++ compilers to enable
|
||||||
|
// debug symbols? This will be supplied when OPTIMIZE (above) is set
|
||||||
|
// to 1, 2, or 3.
|
||||||
|
#defer DEBUGFLAGS -g
|
||||||
|
|
||||||
|
// What flags should be passed to both C and C++ compilers to enable
|
||||||
|
// compiler optimizations? This will be supplied when OPTIMIZE
|
||||||
|
// (above) is set to 2, 3, or 4.
|
||||||
|
#defer OPTFLAGS -O2
|
||||||
|
|
||||||
|
// By convention, any source file that contains the string _no_opt_ in
|
||||||
|
// its filename won't have the above compiler optimizations run for it.
|
||||||
|
#defer no_opt $[findstring _no_opt_,$[source]]
|
||||||
|
|
||||||
|
// What define variables should be passed to the compilers for each
|
||||||
|
// value of OPTIMIZE? We separate this so we can pass these same
|
||||||
|
// options to interrogate, guaranteeing that the correct interfaces
|
||||||
|
// are generated. Do not include -D here; that will be supplied
|
||||||
|
// automatically.
|
||||||
|
#defer CDEFINES_OPT1 _DEBUG $[EXTRA_CDEFS] $[OSX_CDEFS] $[if $[LINK_ALL_STATIC],LINK_ALL_STATIC]
|
||||||
|
#defer CDEFINES_OPT2 _DEBUG $[EXTRA_CDEFS] $[OSX_CDEFS] $[if $[LINK_ALL_STATIC],LINK_ALL_STATIC]
|
||||||
|
#defer CDEFINES_OPT3 $[EXTRA_CDEFS] $[OSX_CDEFS] $[if $[LINK_ALL_STATIC],LINK_ALL_STATIC]
|
||||||
|
#defer CDEFINES_OPT4 NDEBUG $[EXTRA_CDEFS] $[OSX_CDEFS] $[if $[LINK_ALL_STATIC],LINK_ALL_STATIC]
|
||||||
|
|
||||||
|
// What additional flags should be passed for each value of OPTIMIZE
|
||||||
|
// (above)? We separate out the compiler-optimization flags, above,
|
||||||
|
// so we can compile certain files that give optimizers trouble (like
|
||||||
|
// the output of lex and yacc) without them, but with all the other
|
||||||
|
// relevant flags.
|
||||||
|
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] -Wall $[DEBUGFLAGS]
|
||||||
|
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] -Wall $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[if $[no_opt],,$[OPTFLAGS]]
|
||||||
|
|
||||||
|
// What additional flags should be passed to both compilers when
|
||||||
|
// building shared (relocatable) sources? Some architectures require
|
||||||
|
// special support for this.
|
||||||
|
#defer CFLAGS_SHARED -fPIC
|
||||||
|
|
||||||
|
// How to generate a C or C++ executable from a collection of .o
|
||||||
|
// files. $[target] is the name of the binary to generate, and
|
||||||
|
// $[sources] is the list of .o files. $[libs] is a space-separated
|
||||||
|
// list of dependent libraries, and $[lpath] is a space-separated list
|
||||||
|
// of directories in which those libraries can be found.
|
||||||
|
#defer LINK_BIN_C $[cc_ld] $[ARCH_FLAGS] $[OSX_CFLAGS] -o $[target] $[sources] $[flags] $[lpath:%=-L%] $[libs:%=-l%]\
|
||||||
|
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
||||||
|
#defer LINK_BIN_C++ $[cxx_ld] $[ARCH_FLAGS] $[OSX_CFLAGS] \
|
||||||
|
-o $[target] $[sources]\
|
||||||
|
$[flags]\
|
||||||
|
$[lpath:%=-L%] $[libs:%=-l%]\
|
||||||
|
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
||||||
|
|
||||||
|
// How to generate a static C or C++ library. $[target] is the
|
||||||
|
// name of the library to generate, and $[sources] is the list of .o
|
||||||
|
// files that will go into the library.
|
||||||
|
#defer STATIC_LIB_C libtool -static -o $[target] $[sources]
|
||||||
|
#defer STATIC_LIB_C++ libtool -static -o $[target] $[sources]
|
||||||
|
|
||||||
|
// How to run ranlib, if necessary, after generating a static library.
|
||||||
|
// $[target] is the name of the library. Set this to the empty string
|
||||||
|
// if ranlib is not necessary on your platform.
|
||||||
|
#defer RANLIB ranlib $[target]
|
||||||
|
|
||||||
|
// Where to put the so_locations file, used by an Irix MIPSPro
|
||||||
|
// compiler, to generate a map of shared library memory locations.
|
||||||
|
#defer SO_LOCATIONS $[DTOOL_INSTALL]/etc/so_locations
|
||||||
|
|
||||||
|
|
||||||
|
// How to generate a shared C or C++ library. $[source] and $[target]
|
||||||
|
// as above, and $[libs] is a space-separated list of dependent
|
||||||
|
// libraries, and $[lpath] is a space-separated list of directories in
|
||||||
|
// which those libraries can be found.
|
||||||
|
#defer SHARED_LIB_C $[cc_ld] $[ARCH_FLAGS] $[OSX_CFLAGS] -o $[target] -dynamiclib -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
||||||
|
#defer SHARED_LIB_C++ $[cxx_ld] $[ARCH_FLAGS] $[OSX_CFLAGS] -undefined dynamic_lookup -dynamic -dynamiclib -o $[target] -dynamiclib -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
||||||
|
#defer BUNDLE_LIB_C++ $[cxx_ld] $[ARCH_FLAGS] $[OSX_CFLAGS] -undefined dynamic_lookup -bundle -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
||||||
|
|
||||||
|
// How to install a data file or executable file. $[local] is the
|
||||||
|
// local name of the file to install, and $[dest] is the name of the
|
||||||
|
// directory to put it in.
|
||||||
|
|
||||||
|
// On Unix systems, we strongly prefer using the install program to
|
||||||
|
// install files. This has nice features like automatically setting
|
||||||
|
// the permissions bits, and also is usually clever enough to install
|
||||||
|
// a running program without crashing the running instance. However,
|
||||||
|
// it doesn't understanding installing a program from a subdirectory,
|
||||||
|
// so we have to cd into the source directory first.
|
||||||
|
#defer install_dash_p $[if $[KEEP_TIMESTAMPS],-p,]
|
||||||
|
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] $[install_dash_p] $[notdir $[local]] $[dest]/
|
||||||
|
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] $[install_dash_p] $[notdir $[local]] $[dest]/
|
||||||
|
|
||||||
|
// Variable definitions for building with the Irix MIPSPro compiler.
|
||||||
|
#if $[eq $[USE_COMPILER], MIPS]
|
||||||
|
#define CC cc -n32 -mips3
|
||||||
|
#define CXX CC -n32 -mips3
|
||||||
|
|
||||||
|
// Turn off a few annoying warning messages.
|
||||||
|
// 1174 - function 'blah' was declared but never used
|
||||||
|
// 1201 - trailing comma is nonstandard.
|
||||||
|
// 1209 - controlling expression is constant, e.g. if (0) { ... }
|
||||||
|
// 1234 - access control not specified, 'public' by default
|
||||||
|
// 1355 - extra ";" ignored
|
||||||
|
// 1375 - destructor for base class is not virtual.
|
||||||
|
// this one actually is bad. But we got alot of them from the classes
|
||||||
|
// that we've derived from STL collections. Beware of this.
|
||||||
|
// 3322 - omission of explicit type is nonstandard ("int" assumed)
|
||||||
|
#define WOFF_LIST -woff 1174,1201,1209,1234,1355,1375,3322
|
||||||
|
|
||||||
|
// Linker warnings
|
||||||
|
// 85 - definition of SOMESYMBOL in SOMELIB preempts that of definition in
|
||||||
|
// SOMEOTHERLIB.
|
||||||
|
#define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
|
||||||
|
|
||||||
|
#defer OPTFLAGS -O2 -OPT:Olimit=2500
|
||||||
|
|
||||||
|
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] $[WOFF_LIST] -g
|
||||||
|
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] $[WOFF_LIST]
|
||||||
|
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[WOFF_LIST]
|
||||||
|
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[WOFF_LIST]
|
||||||
|
|
||||||
|
#defer CFLAGS_SHARED
|
||||||
|
|
||||||
|
#defer STATIC_LIB_C $[CC] -ar -o $[target] $[sources]
|
||||||
|
#defer STATIC_LIB_C++ $[CXX] -ar -o $[target] $[sources]
|
||||||
|
#defer RANLIB
|
||||||
|
|
||||||
|
#defer SHARED_FLAGS -Wl,-none -Wl,-update_registry,$[SO_LOCATIONS]
|
||||||
|
#defer SHARED_LIB_C $[cc_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Assume that OSX has OpenGL available.
|
// Assume that OSX has OpenGL available.
|
||||||
#define HAVE_GL 1
|
#define HAVE_GL 1
|
||||||
|
|
||||||
@ -169,6 +320,7 @@
|
|||||||
|
|
||||||
// The dynamic library file extension (usually .so .dll or .dylib):
|
// The dynamic library file extension (usually .so .dll or .dylib):
|
||||||
#define DYNAMIC_LIB_EXT .dylib
|
#define DYNAMIC_LIB_EXT .dylib
|
||||||
|
#define STATIC_LIB_EXT .a
|
||||||
|
|
||||||
// If you need to build .so files in addition to .dylibs, declare this
|
// If you need to build .so files in addition to .dylibs, declare this
|
||||||
// too. Python 2.4 on OSX 10.4 seems to require this (it won't import
|
// too. Python 2.4 on OSX 10.4 seems to require this (it won't import
|
||||||
|
182
dtool/Config.pp
182
dtool/Config.pp
@ -372,6 +372,13 @@
|
|||||||
// for now.
|
// for now.
|
||||||
#defer DO_PIPELINING
|
#defer DO_PIPELINING
|
||||||
|
|
||||||
|
// Panda contains some experimental code to compile for IPhone. This
|
||||||
|
// requires the Apple IPhone SDK, which is currently only available
|
||||||
|
// for OS X platforms. Set this to either "iPhoneSimulator" or
|
||||||
|
// "iPhoneOS". Note that this is still *experimental* and incomplete!
|
||||||
|
// Don't enable this unless you know what you're doing!
|
||||||
|
#define BUILD_IPHONE
|
||||||
|
|
||||||
// Do you want to use one of the alternative malloc implementations?
|
// Do you want to use one of the alternative malloc implementations?
|
||||||
// This is almost always a good idea on Windows, where the standard
|
// This is almost always a good idea on Windows, where the standard
|
||||||
// malloc implementation appears to be pretty poor, but probably
|
// malloc implementation appears to be pretty poor, but probably
|
||||||
@ -957,181 +964,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
// The following variables are only meaningful when BUILD_TYPE is
|
|
||||||
// "unix". These define the commands to invoke the compiler, linker,
|
|
||||||
// etc.
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// How to invoke the C and C++ compilers.
|
|
||||||
#if $[eq $[USE_COMPILER], GCC]
|
|
||||||
#define CC gcc
|
|
||||||
#define CXX g++
|
|
||||||
|
|
||||||
// gcc might run into template limits on some parts of Panda.
|
|
||||||
// I upped this from 25 to build on OS X (GCC 3.3) -- skyler.
|
|
||||||
#define C++FLAGS_GEN -ftemplate-depth-30
|
|
||||||
#else
|
|
||||||
#define CC cc
|
|
||||||
#define CXX CC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Configure for universal binaries on OSX.
|
|
||||||
#defer ARCH_FLAGS $[if $[and $[OSX_PLATFORM],$[UNIVERSAL_BINARIES]],-arch i386 -arch ppc,]
|
|
||||||
|
|
||||||
// How to compile a C or C++ file into a .o file. $[target] is the
|
|
||||||
// name of the .o file, $[source] is the name of the source file,
|
|
||||||
// $[ipath] is a space-separated list of directories to search for
|
|
||||||
// include files, and $[flags] is a list of additional flags to pass
|
|
||||||
// to the compiler.
|
|
||||||
#defer COMPILE_C $[CC] $[CFLAGS_GEN] $[ARCH_FLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
|
||||||
#defer COMPILE_C++ $[CXX] $[C++FLAGS_GEN] $[ARCH_FLAGS] -c -o $[target] $[ipath:%=-I%] $[flags] $[source]
|
|
||||||
|
|
||||||
// What flags should be passed to both C and C++ compilers to enable
|
|
||||||
// debug symbols? This will be supplied when OPTIMIZE (above) is set
|
|
||||||
// to 1, 2, or 3.
|
|
||||||
#defer DEBUGFLAGS -g
|
|
||||||
|
|
||||||
// What flags should be passed to both C and C++ compilers to enable
|
|
||||||
// compiler optimizations? This will be supplied when OPTIMIZE
|
|
||||||
// (above) is set to 2, 3, or 4.
|
|
||||||
#defer OPTFLAGS -O2
|
|
||||||
|
|
||||||
// By convention, any source file that contains the string _no_opt_ in
|
|
||||||
// its filename won't have the above compiler optimizations run for it.
|
|
||||||
#defer no_opt $[findstring _no_opt_,$[source]]
|
|
||||||
|
|
||||||
// What define variables should be passed to the compilers for each
|
|
||||||
// value of OPTIMIZE? We separate this so we can pass these same
|
|
||||||
// options to interrogate, guaranteeing that the correct interfaces
|
|
||||||
// are generated. Do not include -D here; that will be supplied
|
|
||||||
// automatically.
|
|
||||||
#defer CDEFINES_OPT1 _DEBUG $[EXTRA_CDEFS]
|
|
||||||
#defer CDEFINES_OPT2 _DEBUG $[EXTRA_CDEFS]
|
|
||||||
#defer CDEFINES_OPT3 $[EXTRA_CDEFS]
|
|
||||||
#defer CDEFINES_OPT4 NDEBUG $[EXTRA_CDEFS]
|
|
||||||
|
|
||||||
// What additional flags should be passed for each value of OPTIMIZE
|
|
||||||
// (above)? We separate out the compiler-optimization flags, above,
|
|
||||||
// so we can compile certain files that give optimizers trouble (like
|
|
||||||
// the output of lex and yacc) without them, but with all the other
|
|
||||||
// relevant flags.
|
|
||||||
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] -Wall $[DEBUGFLAGS]
|
|
||||||
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] -Wall $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
|
||||||
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[DEBUGFLAGS] $[if $[no_opt],,$[OPTFLAGS]]
|
|
||||||
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[if $[no_opt],,$[OPTFLAGS]]
|
|
||||||
|
|
||||||
// What additional flags should be passed to both compilers when
|
|
||||||
// building shared (relocatable) sources? Some architectures require
|
|
||||||
// special support for this.
|
|
||||||
#defer CFLAGS_SHARED -fPIC
|
|
||||||
|
|
||||||
// How to generate a C or C++ executable from a collection of .o
|
|
||||||
// files. $[target] is the name of the binary to generate, and
|
|
||||||
// $[sources] is the list of .o files. $[libs] is a space-separated
|
|
||||||
// list of dependent libraries, and $[lpath] is a space-separated list
|
|
||||||
// of directories in which those libraries can be found.
|
|
||||||
#defer LINK_BIN_C $[cc_ld] $[ARCH_FLAGS] -o $[target] $[sources] $[flags] $[lpath:%=-L%] $[libs:%=-l%]\
|
|
||||||
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
|
||||||
#defer LINK_BIN_C++ $[cxx_ld] $[ARCH_FLAGS] \
|
|
||||||
-o $[target] $[sources]\
|
|
||||||
$[flags]\
|
|
||||||
$[lpath:%=-L%] $[libs:%=-l%]\
|
|
||||||
$[fpath:%=-Wl,-F%] $[patsubst %,-framework %, $[bin_frameworks]]
|
|
||||||
|
|
||||||
// How to generate a static C or C++ library. $[target] is the
|
|
||||||
// name of the library to generate, and $[sources] is the list of .o
|
|
||||||
// files that will go into the library.
|
|
||||||
#if $[OSX_PLATFORM]
|
|
||||||
#defer STATIC_LIB_C libtool -static -o $[target] $[sources]
|
|
||||||
#defer STATIC_LIB_C++ libtool -static -o $[target] $[sources]
|
|
||||||
//#elif $[eq $[PLATFORM], FreeBSD]
|
|
||||||
// #defer STATIC_LIB_C libtool --mode=link -static -o $[target] $[sources]
|
|
||||||
// #defer STATIC_LIB_C++ libtool --mode=link -static -o $[target] $[sources]
|
|
||||||
#else
|
|
||||||
#defer STATIC_LIB_C ar cru $[target] $[sources]
|
|
||||||
#defer STATIC_LIB_C++ ar cru $[target] $[sources]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// How to run ranlib, if necessary, after generating a static library.
|
|
||||||
// $[target] is the name of the library. Set this to the empty string
|
|
||||||
// if ranlib is not necessary on your platform.
|
|
||||||
#defer RANLIB ranlib $[target]
|
|
||||||
|
|
||||||
// Where to put the so_locations file, used by an Irix MIPSPro
|
|
||||||
// compiler, to generate a map of shared library memory locations.
|
|
||||||
#defer SO_LOCATIONS $[DTOOL_INSTALL]/etc/so_locations
|
|
||||||
|
|
||||||
|
|
||||||
// How to generate a shared C or C++ library. $[source] and $[target]
|
|
||||||
// as above, and $[libs] is a space-separated list of dependent
|
|
||||||
// libraries, and $[lpath] is a space-separated list of directories in
|
|
||||||
// which those libraries can be found.
|
|
||||||
#if $[OSX_PLATFORM]
|
|
||||||
#defer SHARED_LIB_C $[cc_ld] $[ARCH_FLAGS] -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
|
||||||
#defer SHARED_LIB_C++ $[cxx_ld] $[ARCH_FLAGS] -undefined dynamic_lookup -dynamic -dynamiclib -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
|
||||||
#defer BUNDLE_LIB_C++ $[cxx_ld] $[ARCH_FLAGS] -undefined dynamic_lookup -bundle -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
|
|
||||||
#else
|
|
||||||
#defer SHARED_LIB_C $[cc_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
|
||||||
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[LFLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
|
||||||
#define BUNDLE_LIB_C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// How to install a data file or executable file. $[local] is the
|
|
||||||
// local name of the file to install, and $[dest] is the name of the
|
|
||||||
// directory to put it in.
|
|
||||||
|
|
||||||
// On Unix systems, we strongly prefer using the install program to
|
|
||||||
// install files. This has nice features like automatically setting
|
|
||||||
// the permissions bits, and also is usually clever enough to install
|
|
||||||
// a running program without crashing the running instance. However,
|
|
||||||
// it doesn't understanding installing a program from a subdirectory,
|
|
||||||
// so we have to cd into the source directory first.
|
|
||||||
#defer install_dash_p $[if $[KEEP_TIMESTAMPS],-p,]
|
|
||||||
#defer INSTALL $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_DATA] $[install_dash_p] $[notdir $[local]] $[dest]/
|
|
||||||
#defer INSTALL_PROG $[if $[ne $[dir $[local]], ./],cd ./$[dir $[local]] &&] install -m $[INSTALL_UMASK_PROG] $[install_dash_p] $[notdir $[local]] $[dest]/
|
|
||||||
|
|
||||||
// Variable definitions for building with the Irix MIPSPro compiler.
|
|
||||||
#if $[eq $[USE_COMPILER], MIPS]
|
|
||||||
#define CC cc -n32 -mips3
|
|
||||||
#define CXX CC -n32 -mips3
|
|
||||||
|
|
||||||
// Turn off a few annoying warning messages.
|
|
||||||
// 1174 - function 'blah' was declared but never used
|
|
||||||
// 1201 - trailing comma is nonstandard.
|
|
||||||
// 1209 - controlling expression is constant, e.g. if (0) { ... }
|
|
||||||
// 1234 - access control not specified, 'public' by default
|
|
||||||
// 1355 - extra ";" ignored
|
|
||||||
// 1375 - destructor for base class is not virtual.
|
|
||||||
// this one actually is bad. But we got alot of them from the classes
|
|
||||||
// that we've derived from STL collections. Beware of this.
|
|
||||||
// 3322 - omission of explicit type is nonstandard ("int" assumed)
|
|
||||||
#define WOFF_LIST -woff 1174,1201,1209,1234,1355,1375,3322
|
|
||||||
|
|
||||||
// Linker warnings
|
|
||||||
// 85 - definition of SOMESYMBOL in SOMELIB preempts that of definition in
|
|
||||||
// SOMEOTHERLIB.
|
|
||||||
#define WOFF_LIST $[WOFF_LIST] -Wl,-LD_MSG:off=85
|
|
||||||
|
|
||||||
#defer OPTFLAGS -O2 -OPT:Olimit=2500
|
|
||||||
|
|
||||||
#defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=-D%] $[WOFF_LIST] -g
|
|
||||||
#defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=-D%] $[WOFF_LIST]
|
|
||||||
#defer CFLAGS_OPT3 $[CDEFINES_OPT3:%=-D%] $[WOFF_LIST]
|
|
||||||
#defer CFLAGS_OPT4 $[CDEFINES_OPT4:%=-D%] $[WOFF_LIST]
|
|
||||||
|
|
||||||
#defer CFLAGS_SHARED
|
|
||||||
|
|
||||||
#defer STATIC_LIB_C $[CC] -ar -o $[target] $[sources]
|
|
||||||
#defer STATIC_LIB_C++ $[CXX] -ar -o $[target] $[sources]
|
|
||||||
#defer RANLIB
|
|
||||||
|
|
||||||
#defer SHARED_FLAGS -Wl,-none -Wl,-update_registry,$[SO_LOCATIONS]
|
|
||||||
#defer SHARED_LIB_C $[cc_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
|
||||||
#defer SHARED_LIB_C++ $[cxx_ld] -shared $[SHARED_FLAGS] -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// There are also some additional variables that control specific
|
// There are also some additional variables that control specific
|
||||||
// compiler/platform features or characteristics, defined in the
|
// compiler/platform features or characteristics, defined in the
|
||||||
|
@ -609,6 +609,6 @@ $[cdefine USE_STL_ALLOCATOR]
|
|||||||
$[cdefine IS_OSX]
|
$[cdefine IS_OSX]
|
||||||
$[cdefine IS_LINUX]
|
$[cdefine IS_LINUX]
|
||||||
$[cdefine IS_FREEBSD]
|
$[cdefine IS_FREEBSD]
|
||||||
|
$[cdefine BUILD_IPHONE]
|
||||||
|
|
||||||
#end dtool_config.h
|
#end dtool_config.h
|
||||||
|
@ -100,6 +100,8 @@
|
|||||||
#print Environment variable PPREMAKE_CONFIG not set; using defaults.
|
#print Environment variable PPREMAKE_CONFIG not set; using defaults.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include $[THISDIRPREFIX]pptempl/PostConfig.pp
|
||||||
|
|
||||||
// Now evaluate all of our deferred variable definitions from
|
// Now evaluate all of our deferred variable definitions from
|
||||||
// Config.pp.
|
// Config.pp.
|
||||||
#set PYTHON_IPATH $[unixfilename $[PYTHON_IPATH]]
|
#set PYTHON_IPATH $[unixfilename $[PYTHON_IPATH]]
|
||||||
|
@ -53,6 +53,11 @@
|
|||||||
#define lib_is_static 1
|
#define lib_is_static 1
|
||||||
#end static_lib_target
|
#end static_lib_target
|
||||||
#endif
|
#endif
|
||||||
|
#if $[LINK_ALL_STATIC]
|
||||||
|
#forscopes ss_lib_target lib_target
|
||||||
|
#define lib_is_static 1
|
||||||
|
#end ss_lib_target lib_target
|
||||||
|
#endif
|
||||||
|
|
||||||
#forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
|
#forscopes metalib_target lib_target noinst_lib_target test_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target
|
||||||
// We can optimize quite a bit by evaluating now several of the key
|
// We can optimize quite a bit by evaluating now several of the key
|
||||||
|
@ -432,6 +432,16 @@
|
|||||||
#defer shared_lib_c++ $[SHARED_LIB_C++]
|
#defer shared_lib_c++ $[SHARED_LIB_C++]
|
||||||
#endif // USE_TAU
|
#endif // USE_TAU
|
||||||
|
|
||||||
|
#defer dynamic_lib_ext $[DYNAMIC_LIB_EXT]
|
||||||
|
#defer bundle_ext $[BUNDLE_EXT]
|
||||||
|
|
||||||
|
#if $[LINK_ALL_STATIC]
|
||||||
|
#defer shared_lib_c $[STATIC_LIB_C]
|
||||||
|
#defer shared_lib_c++ $[STATIC_LIB_C++]
|
||||||
|
#defer dynamic_lib_ext $[STATIC_LIB_EXT]
|
||||||
|
#defer bundle_ext
|
||||||
|
#endif // LINK_ALL_STATIC
|
||||||
|
|
||||||
|
|
||||||
// This takes advantage of the above two variables to get the actual
|
// This takes advantage of the above two variables to get the actual
|
||||||
// list of local libraries we are to link with, eliminating those that
|
// list of local libraries we are to link with, eliminating those that
|
||||||
|
29
dtool/pptempl/PostConfig.pp
Normal file
29
dtool/pptempl/PostConfig.pp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// This file is included after including all of $DTOOL/Config.pp and
|
||||||
|
// the user's personal Config.pp file. It makes decisions necessary
|
||||||
|
// following the user's Config settings.
|
||||||
|
|
||||||
|
#if $[and $[OSX_PLATFORM],$[BUILD_IPHONE]]
|
||||||
|
//#define IPH_PLATFORM iPhoneSimulator
|
||||||
|
#define IPH_PLATFORM $[BUILD_IPHONE]
|
||||||
|
#define IPH_VERSION 2.0
|
||||||
|
|
||||||
|
#if $[eq $[IPH_PLATFORM], iPhoneOS]
|
||||||
|
#define ARCH_FLAGS -arch armv6
|
||||||
|
#define osflags -miphoneos-version-min=2.0
|
||||||
|
#elif $[eq $[IPH_PLATFORM], iPhoneSimulator]
|
||||||
|
#define ARCH_FLAGS -arch i386
|
||||||
|
#define osflags -mmacosx-version-min=10.5
|
||||||
|
#else
|
||||||
|
#error Inappropriate value for BUILD_IPHONE.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define dev /Developer/Platforms/$[IPH_PLATFORM].platform/Developer
|
||||||
|
#define env env MACOSX_DEPLOYMENT_TARGET=10.5 PATH="$[dev]/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
||||||
|
#define CC $[env] $[dev]/usr/bin/gcc-4.0
|
||||||
|
#define CXX $[env] $[dev]/usr/bin/g++-4.0
|
||||||
|
#define OSX_CDEFS __IPHONE_OS_VERSION_MIN_REQUIRED=20000
|
||||||
|
#define OSX_CFLAGS -isysroot $[dev]/SDKs/$[IPH_PLATFORM]$[IPH_VERSION].sdk $[osflags] -gdwarf-2
|
||||||
|
|
||||||
|
#defer ODIR_SUFFIX -$[IPH_PLATFORM]
|
||||||
|
|
||||||
|
#endif
|
@ -40,10 +40,10 @@
|
|||||||
// $[bin_targets] the list of binaries. $[test_bin_targets] is the
|
// $[bin_targets] the list of binaries. $[test_bin_targets] is the
|
||||||
// list of binaries that are to be built only when specifically asked
|
// list of binaries that are to be built only when specifically asked
|
||||||
// for.
|
// for.
|
||||||
#define lib_targets $[active_target(metalib_target lib_target ss_lib_target noinst_lib_target):%=$[ODIR]/lib%$[DYNAMIC_LIB_EXT]]
|
#define lib_targets $[active_target(metalib_target lib_target ss_lib_target noinst_lib_target):%=$[ODIR]/lib%$[dynamic_lib_ext]]
|
||||||
#define bundle_targets
|
#define bundle_targets
|
||||||
#if $[BUNDLE_EXT]
|
#if $[bundle_ext]
|
||||||
#define bundle_targets $[active_target(metalib_target):%=$[ODIR]/lib%$[BUNDLE_EXT]]
|
#define bundle_targets $[active_target(metalib_target):%=$[ODIR]/lib%$[bundle_ext]]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define static_lib_targets $[active_target(static_lib_target):%=$[ODIR]/lib%.a]
|
#define static_lib_targets $[active_target(static_lib_target):%=$[ODIR]/lib%.a]
|
||||||
@ -114,7 +114,8 @@
|
|||||||
|
|
||||||
// And $[frameworks] is the set of OSX-style frameworks we will link with.
|
// And $[frameworks] is the set of OSX-style frameworks we will link with.
|
||||||
#defer frameworks $[unique $[get_frameworks]]
|
#defer frameworks $[unique $[get_frameworks]]
|
||||||
#defer bin_frameworks $[unique $[get_frameworks]]
|
#defer bin_frameworks $[unique $[all_libs $[get_frameworks],$[complete_local_libs]]]
|
||||||
|
//#defer bin_frameworks $[unique $[get_frameworks]]
|
||||||
|
|
||||||
// This is the set of files we might copy into *.prebuilt, if we have
|
// This is the set of files we might copy into *.prebuilt, if we have
|
||||||
// bison and flex (or copy from *.prebuilt if we don't have them).
|
// bison and flex (or copy from *.prebuilt if we don't have them).
|
||||||
@ -342,21 +343,21 @@ igate : $[get_igatedb(metalib_target lib_target ss_lib_target)]
|
|||||||
#define cxx_ld $[or $[get_ld],$[CXX]]
|
#define cxx_ld $[or $[get_ld],$[CXX]]
|
||||||
|
|
||||||
#define varname $[subst -,_,lib$[TARGET]_so]
|
#define varname $[subst -,_,lib$[TARGET]_so]
|
||||||
$[varname] = $[sources] $[if $[not $[BUNDLE_EXT]],$[interrogate_sources]]
|
$[varname] = $[sources] $[if $[not $[bundle_ext]],$[interrogate_sources]]
|
||||||
#define target $[ODIR]/lib$[TARGET]$[DYNAMIC_LIB_EXT]
|
#define target $[ODIR]/lib$[TARGET]$[dynamic_lib_ext]
|
||||||
#define sources $($[varname])
|
#define sources $($[varname])
|
||||||
|
|
||||||
$[target] : $[sources] $[static_lib_dependencies]
|
$[target] : $[sources] $[static_lib_dependencies]
|
||||||
#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
|
#if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
|
||||||
$[TAB] $[shared_lib_c++]
|
$[TAB] $[shared_lib_c++]
|
||||||
#else
|
#else
|
||||||
$[TAB] $[shared_lib_c]
|
$[TAB] $[shared_lib_c]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if $[BUNDLE_EXT]
|
#if $[bundle_ext]
|
||||||
// Also generate the bundles (on OSX only).
|
// Also generate the bundles (on OSX only).
|
||||||
#define target $[ODIR]/lib$[TARGET]$[BUNDLE_EXT]
|
#define target $[ODIR]/lib$[TARGET]$[bundle_ext]
|
||||||
#define sources $[interrogate_sources] $[ODIR]/lib$[TARGET]$[DYNAMIC_LIB_EXT]
|
#define sources $[interrogate_sources] $[ODIR]/lib$[TARGET]$[dynamic_lib_ext]
|
||||||
$[target] : $[sources] $[static_lib_dependencies]
|
$[target] : $[sources] $[static_lib_dependencies]
|
||||||
$[TAB] $[BUNDLE_LIB_C++]
|
$[TAB] $[BUNDLE_LIB_C++]
|
||||||
#endif // BUNDLE_EXT
|
#endif // BUNDLE_EXT
|
||||||
@ -365,8 +366,8 @@ $[TAB] $[BUNDLE_LIB_C++]
|
|||||||
// Here are the rules to install and uninstall the library and
|
// Here are the rules to install and uninstall the library and
|
||||||
// everything that goes along with it.
|
// everything that goes along with it.
|
||||||
#define installed_files \
|
#define installed_files \
|
||||||
$[install_lib_dir]/lib$[TARGET]$[DYNAMIC_LIB_EXT] \
|
$[install_lib_dir]/lib$[TARGET]$[dynamic_lib_ext] \
|
||||||
$[if $[BUNDLE_EXT],$[install_lib_dir]/lib$[TARGET]$[BUNDLE_EXT]] \
|
$[if $[bundle_ext],$[install_lib_dir]/lib$[TARGET]$[bundle_ext]] \
|
||||||
$[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
|
$[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
|
||||||
$[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
|
$[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
|
||||||
$[INSTALL_DATA:%=$[install_data_dir]/%] \
|
$[INSTALL_DATA:%=$[install_data_dir]/%] \
|
||||||
@ -380,14 +381,14 @@ uninstall-lib$[TARGET] :
|
|||||||
$[TAB] rm -f $[sort $[installed_files]]
|
$[TAB] rm -f $[sort $[installed_files]]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
$[install_lib_dir]/lib$[TARGET]$[DYNAMIC_LIB_EXT] : $[ODIR]/lib$[TARGET]$[DYNAMIC_LIB_EXT]
|
$[install_lib_dir]/lib$[TARGET]$[dynamic_lib_ext] : $[ODIR]/lib$[TARGET]$[dynamic_lib_ext]
|
||||||
#define local $[ODIR]/lib$[TARGET]$[DYNAMIC_LIB_EXT]
|
#define local $[ODIR]/lib$[TARGET]$[dynamic_lib_ext]
|
||||||
#define dest $[install_lib_dir]
|
#define dest $[install_lib_dir]
|
||||||
$[TAB] $[INSTALL]
|
$[TAB] $[INSTALL]
|
||||||
|
|
||||||
#if $[BUNDLE_EXT]
|
#if $[bundle_ext]
|
||||||
$[install_lib_dir]/lib$[TARGET]$[BUNDLE_EXT] : $[ODIR]/lib$[TARGET]$[BUNDLE_EXT]
|
$[install_lib_dir]/lib$[TARGET]$[bundle_ext] : $[ODIR]/lib$[TARGET]$[bundle_ext]
|
||||||
#define local $[ODIR]/lib$[TARGET]$[BUNDLE_EXT]
|
#define local $[ODIR]/lib$[TARGET]$[bundle_ext]
|
||||||
#define dest $[install_lib_dir]
|
#define dest $[install_lib_dir]
|
||||||
$[TAB] $[INSTALL]
|
$[TAB] $[INSTALL]
|
||||||
#endif // BUNDLE_EXT
|
#endif // BUNDLE_EXT
|
||||||
@ -454,10 +455,10 @@ $[TAB] $[INTERROGATE_MODULE] -oc $[target] -module "$[igatemod]" -library "$[iga
|
|||||||
#forscopes noinst_lib_target
|
#forscopes noinst_lib_target
|
||||||
#define varname $[subst -,_,lib$[TARGET]_so]
|
#define varname $[subst -,_,lib$[TARGET]_so]
|
||||||
$[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
|
$[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
|
||||||
#define target $[ODIR]/lib$[TARGET]$[DYNAMIC_LIB_EXT]
|
#define target $[ODIR]/lib$[TARGET]$[dynamic_lib_ext]
|
||||||
#define sources $($[varname])
|
#define sources $($[varname])
|
||||||
$[target] : $[sources] $[static_lib_dependencies]
|
$[target] : $[sources] $[static_lib_dependencies]
|
||||||
#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
|
#if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
|
||||||
$[TAB] $[shared_lib_c++]
|
$[TAB] $[shared_lib_c++]
|
||||||
#else
|
#else
|
||||||
$[TAB] $[shared_lib_c]
|
$[TAB] $[shared_lib_c]
|
||||||
@ -479,7 +480,7 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
|
|||||||
#define target $[ODIR]/lib$[TARGET]$[dllext].a
|
#define target $[ODIR]/lib$[TARGET]$[dllext].a
|
||||||
#define sources $($[varname])
|
#define sources $($[varname])
|
||||||
$[target] : $[sources]
|
$[target] : $[sources]
|
||||||
#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
|
#if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
|
||||||
$[TAB] $[STATIC_LIB_C++]
|
$[TAB] $[STATIC_LIB_C++]
|
||||||
#else
|
#else
|
||||||
$[TAB] $[STATIC_LIB_C]
|
$[TAB] $[STATIC_LIB_C]
|
||||||
@ -558,7 +559,7 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
|
|||||||
#define cxx_ld $[or $[get_ld],$[CXX]]
|
#define cxx_ld $[or $[get_ld],$[CXX]]
|
||||||
#define flags $[lflags]
|
#define flags $[lflags]
|
||||||
$[target] : $[sources] $[static_lib_dependencies]
|
$[target] : $[sources] $[static_lib_dependencies]
|
||||||
#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
|
#if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
|
||||||
$[TAB] $[link_bin_c++]
|
$[TAB] $[link_bin_c++]
|
||||||
#else
|
#else
|
||||||
$[TAB] $[link_bin_c]
|
$[TAB] $[link_bin_c]
|
||||||
@ -603,7 +604,7 @@ $[varname] = $[patsubst %,$[%_obj],$[compile_sources]]
|
|||||||
#define cxx_ld $[or $[get_ld],$[CXX]]
|
#define cxx_ld $[or $[get_ld],$[CXX]]
|
||||||
#define flags $[lflags]
|
#define flags $[lflags]
|
||||||
$[target] : $[sources] $[static_lib_dependencies]
|
$[target] : $[sources] $[static_lib_dependencies]
|
||||||
#if $[filter %.cxx %.yxx %.lxx,$[get_sources]]
|
#if $[filter %.mm %.cxx %.yxx %.lxx,$[get_sources]]
|
||||||
$[TAB] $[link_bin_c++]
|
$[TAB] $[link_bin_c++]
|
||||||
#else
|
#else
|
||||||
$[TAB] $[link_bin_c]
|
$[TAB] $[link_bin_c]
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#define UNIX_SYS_LIBS dl
|
#define UNIX_SYS_LIBS dl
|
||||||
#endif
|
#endif
|
||||||
#define WIN_SYS_LIBS shell32.lib
|
#define WIN_SYS_LIBS shell32.lib
|
||||||
|
#define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE]],AppKit]
|
||||||
|
|
||||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
|
||||||
|
|
||||||
@ -12,7 +13,9 @@
|
|||||||
checkPandaVersion.h \
|
checkPandaVersion.h \
|
||||||
config_dtoolutil.h \
|
config_dtoolutil.h \
|
||||||
executionEnvironment.I executionEnvironment.h filename.I \
|
executionEnvironment.I executionEnvironment.h filename.I \
|
||||||
filename.h load_dso.h dSearchPath.I dSearchPath.h \
|
filename.h \
|
||||||
|
$[if $[IS_OSX],filename_assist.mm filename_assist.h,] \
|
||||||
|
load_dso.h dSearchPath.I dSearchPath.h \
|
||||||
pandaFileStream.h pandaFileStream.I \
|
pandaFileStream.h pandaFileStream.I \
|
||||||
pandaFileStreamBuf.h \
|
pandaFileStreamBuf.h \
|
||||||
pandaSystem.h pandaVersion.h \
|
pandaSystem.h pandaVersion.h \
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// This is for _NSGetExecutablePath() and _NSGetEnviron().
|
// This is for _NSGetExecutablePath() and _NSGetEnviron().
|
||||||
#include <mach-o/dyld.h>
|
#include <mach-o/dyld.h>
|
||||||
#include <crt_externs.h>
|
//#include <crt_externs.h>
|
||||||
#define environ (*_NSGetEnviron())
|
#define environ (*_NSGetEnviron())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -192,9 +192,13 @@ ns_get_environment_variable(const string &var) const {
|
|||||||
|
|
||||||
// Some special case variables. We virtually stuff these values
|
// Some special case variables. We virtually stuff these values
|
||||||
// into the Panda environment, shadowing whatever values they have
|
// into the Panda environment, shadowing whatever values they have
|
||||||
// the true environment, so they can be used in config files.
|
// in the true environment, so they can be used in config files.
|
||||||
if (var == "TEMP") {
|
if (var == "HOME") {
|
||||||
|
return Filename::get_home_directory().to_os_specific();
|
||||||
|
} else if (var == "TEMP") {
|
||||||
return Filename::get_temp_directory().to_os_specific();
|
return Filename::get_temp_directory().to_os_specific();
|
||||||
|
} else if (var == "APP") {
|
||||||
|
return Filename::get_app_directory().to_os_specific();
|
||||||
} else if (var == "USER_APPDATA") {
|
} else if (var == "USER_APPDATA") {
|
||||||
return Filename::get_user_appdata_directory().to_os_specific();
|
return Filename::get_user_appdata_directory().to_os_specific();
|
||||||
} else if (var == "COMMON_APPDATA") {
|
} else if (var == "COMMON_APPDATA") {
|
||||||
@ -476,8 +480,8 @@ read_args() {
|
|||||||
// And on Mac, we have _NSGetExecutablePath.
|
// And on Mac, we have _NSGetExecutablePath.
|
||||||
if (_binary_name.empty()) {
|
if (_binary_name.empty()) {
|
||||||
char *pathbuf = new char[PATH_MAX];
|
char *pathbuf = new char[PATH_MAX];
|
||||||
uint32_t *bufsize;
|
uint32_t bufsize = PATH_MAX;
|
||||||
if (_NSGetExecutablePath(pathbuf, bufsize) == 0) {
|
if (_NSGetExecutablePath(pathbuf, &bufsize) == 0) {
|
||||||
_binary_name = pathbuf;
|
_binary_name = pathbuf;
|
||||||
}
|
}
|
||||||
delete[] pathbuf;
|
delete[] pathbuf;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
|
#include "filename_assist.h"
|
||||||
#include "dSearchPath.h"
|
#include "dSearchPath.h"
|
||||||
#include "executionEnvironment.h"
|
#include "executionEnvironment.h"
|
||||||
#include "vector_string.h"
|
#include "vector_string.h"
|
||||||
@ -47,8 +48,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool Filename::_got_home_directory;
|
||||||
|
Filename Filename::_home_directory;
|
||||||
bool Filename::_got_temp_directory;
|
bool Filename::_got_temp_directory;
|
||||||
Filename Filename::_temp_directory;
|
Filename Filename::_temp_directory;
|
||||||
|
bool Filename::_got_app_directory;
|
||||||
|
Filename Filename::_app_directory;
|
||||||
bool Filename::_got_user_appdata_directory;
|
bool Filename::_got_user_appdata_directory;
|
||||||
Filename Filename::_user_appdata_directory;
|
Filename Filename::_user_appdata_directory;
|
||||||
bool Filename::_got_common_appdata_directory;
|
bool Filename::_got_common_appdata_directory;
|
||||||
@ -439,6 +444,63 @@ temporary(const string &dirname, const string &prefix, const string &suffix,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_home_directory
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a path to the user's home directory, if such
|
||||||
|
// a thing makes sense in the current OS, or to the
|
||||||
|
// nearest equivalent. This may or may not be directly
|
||||||
|
// writable by the application.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
const Filename &Filename::
|
||||||
|
get_home_directory() {
|
||||||
|
if (!_got_home_directory) {
|
||||||
|
// In all environments, check $HOME first.
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
if (home != (char *)NULL) {
|
||||||
|
_home_directory = from_os_specific(home);
|
||||||
|
if (_home_directory.is_directory()) {
|
||||||
|
if (_home_directory.make_canonical()) {
|
||||||
|
_got_home_directory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_got_home_directory) {
|
||||||
|
return _home_directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
char buffer[MAX_PATH];
|
||||||
|
|
||||||
|
// On Windows, fall back to the "My Documents" folder.
|
||||||
|
if (SHGetSpecialFolderPath(NULL, buffer, CSIDL_PERSONAL, true)) {
|
||||||
|
_user_appdata_directory = from_os_specific(buffer);
|
||||||
|
if (_user_appdata_directory.is_directory()) {
|
||||||
|
if (_user_appdata_directory.make_canonical()) {
|
||||||
|
_got_user_appdata_directory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(IS_OSX)
|
||||||
|
_home_directory = get_osx_home_directory();
|
||||||
|
_got_home_directory = true;
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Posix case: check /etc/passwd?
|
||||||
|
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
if (!_got_home_directory) {
|
||||||
|
// Fallback case.
|
||||||
|
_home_directory = ExecutionEnvironment::get_cwd();
|
||||||
|
_got_home_directory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _home_directory;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::get_temp_directory
|
// Function: Filename::get_temp_directory
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -460,6 +522,10 @@ get_temp_directory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(IS_OSX)
|
||||||
|
_temp_directory = get_osx_temp_directory();
|
||||||
|
_got_temp_directory = true;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Posix case.
|
// Posix case.
|
||||||
_temp_directory = "/tmp";
|
_temp_directory = "/tmp";
|
||||||
@ -476,6 +542,47 @@ get_temp_directory() {
|
|||||||
return _temp_directory;
|
return _temp_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::get_app_directory
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a path to the current application's
|
||||||
|
// directory, as nearly as this can be determined.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
const Filename &Filename::
|
||||||
|
get_app_directory() {
|
||||||
|
if (!_got_app_directory) {
|
||||||
|
#if defined(IS_OSX)
|
||||||
|
_app_directory = get_osx_app_directory();
|
||||||
|
_got_app_directory = !_app_directory.empty();
|
||||||
|
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
|
if (!_got_app_directory) {
|
||||||
|
// Fallback case.
|
||||||
|
Filename binary_name = ExecutionEnvironment::get_binary_name();
|
||||||
|
if (!binary_name.empty()) {
|
||||||
|
_app_directory = binary_name.get_dirname();
|
||||||
|
_got_app_directory = !_app_directory.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!_got_app_directory) {
|
||||||
|
// Another fallback.
|
||||||
|
Filename dtool_name = ExecutionEnvironment::get_dtool_name();
|
||||||
|
if (!dtool_name.empty()) {
|
||||||
|
_app_directory = dtool_name.get_dirname();
|
||||||
|
_got_app_directory = !_app_directory.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!_got_app_directory) {
|
||||||
|
// The final fallback.
|
||||||
|
_app_directory = ExecutionEnvironment::get_cwd();
|
||||||
|
_got_app_directory = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _app_directory;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::get_user_appdata_directory
|
// Function: Filename::get_user_appdata_directory
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -499,17 +606,15 @@ get_user_appdata_directory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(IS_OSX)
|
||||||
|
_user_appdata_directory = get_osx_user_appdata_directory();
|
||||||
|
_got_user_appdata_directory = true;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Posix case.
|
// Posix case.
|
||||||
char *home = getenv("HOME");
|
_user_appdata_directory = get_home_directory();
|
||||||
if (home != (char *)NULL) {
|
_got_user_appdata_directory = true;
|
||||||
_user_appdata_directory = from_os_specific(home);
|
|
||||||
if (_user_appdata_directory.is_directory()) {
|
|
||||||
if (_user_appdata_directory.make_canonical()) {
|
|
||||||
_got_user_appdata_directory = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
if (!_got_user_appdata_directory) {
|
if (!_got_user_appdata_directory) {
|
||||||
@ -544,6 +649,10 @@ get_common_appdata_directory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(IS_OSX)
|
||||||
|
_common_appdata_directory = get_osx_common_appdata_directory();
|
||||||
|
_got_common_appdata_directory = true;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Posix case.
|
// Posix case.
|
||||||
_common_appdata_directory = "/var";
|
_common_appdata_directory = "/var";
|
||||||
|
@ -84,7 +84,9 @@ PUBLISHED:
|
|||||||
const string &suffix = string(),
|
const string &suffix = string(),
|
||||||
Type type = T_general);
|
Type type = T_general);
|
||||||
|
|
||||||
|
static const Filename &get_home_directory();
|
||||||
static const Filename &get_temp_directory();
|
static const Filename &get_temp_directory();
|
||||||
|
static const Filename &get_app_directory();
|
||||||
static const Filename &get_user_appdata_directory();
|
static const Filename &get_user_appdata_directory();
|
||||||
static const Filename &get_common_appdata_directory();
|
static const Filename &get_common_appdata_directory();
|
||||||
|
|
||||||
@ -230,8 +232,12 @@ protected:
|
|||||||
|
|
||||||
int _flags;
|
int _flags;
|
||||||
|
|
||||||
|
static bool _got_home_directory;
|
||||||
|
static Filename _home_directory;
|
||||||
static bool _got_temp_directory;
|
static bool _got_temp_directory;
|
||||||
static Filename _temp_directory;
|
static Filename _temp_directory;
|
||||||
|
static bool _got_app_directory;
|
||||||
|
static Filename _app_directory;
|
||||||
static bool _got_user_appdata_directory;
|
static bool _got_user_appdata_directory;
|
||||||
static Filename _user_appdata_directory;
|
static Filename _user_appdata_directory;
|
||||||
static bool _got_common_appdata_directory;
|
static bool _got_common_appdata_directory;
|
||||||
|
32
dtool/src/dtoolutil/filename_assist.h
Normal file
32
dtool/src/dtoolutil/filename_assist.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Filename: filename_assist.h
|
||||||
|
// Created by: drose (13Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef FILENAME_ASSIST_H
|
||||||
|
#define FILENAME_ASSIST_H
|
||||||
|
|
||||||
|
#include "dtoolbase.h"
|
||||||
|
|
||||||
|
// A helper module on OSX to call some Objective-C Cocoa functions.
|
||||||
|
|
||||||
|
#ifdef IS_OSX
|
||||||
|
|
||||||
|
string get_osx_home_directory();
|
||||||
|
string get_osx_temp_directory();
|
||||||
|
string get_osx_app_directory();
|
||||||
|
string get_osx_user_appdata_directory();
|
||||||
|
string get_osx_common_appdata_directory();
|
||||||
|
|
||||||
|
#endif // IS_OSX
|
||||||
|
|
||||||
|
#endif
|
157
dtool/src/dtoolutil/filename_assist.mm
Normal file
157
dtool/src/dtoolutil/filename_assist.mm
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
// Filename: filename_assist.mm
|
||||||
|
// Created by: drose (13Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "filename_assist.h"
|
||||||
|
|
||||||
|
#ifdef IS_OSX
|
||||||
|
|
||||||
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#ifndef BUILD_IPHONE
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NSString_to_cpp_string
|
||||||
|
// Description: Copy the Objective-C string to a C++ string.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
static string
|
||||||
|
NSString_to_cpp_string(NSString *str) {
|
||||||
|
size_t length = [str length];
|
||||||
|
string result;
|
||||||
|
for (size_t i = 0; i < length; ++i) {
|
||||||
|
result += (char)[str characterAtIndex: i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: call_NSSearchPathForDirectories
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
static string
|
||||||
|
call_NSSearchPathForDirectories(NSSearchPathDirectory dirkey, NSSearchPathDomainMask domain) {
|
||||||
|
// Ensure that Carbon has been initialized, and that we have an
|
||||||
|
// auto-release pool. Unfortunately, this very important function
|
||||||
|
// doesn't exist on the IPhone.
|
||||||
|
#ifndef BUILD_IPHONE
|
||||||
|
NSApplicationLoad();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(dirkey, domain, YES);
|
||||||
|
string result;
|
||||||
|
if ([paths count] != 0) {
|
||||||
|
result = NSString_to_cpp_string([paths objectAtIndex:0]);
|
||||||
|
}
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_osx_home_directory
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string
|
||||||
|
get_osx_home_directory() {
|
||||||
|
#ifndef BUILD_IPHONE
|
||||||
|
NSApplicationLoad();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
NSString *dir = NSHomeDirectory();
|
||||||
|
string result = NSString_to_cpp_string(dir);
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_osx_app_directory
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string
|
||||||
|
get_osx_app_directory() {
|
||||||
|
#ifndef BUILD_IPHONE
|
||||||
|
NSApplicationLoad();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
string result;
|
||||||
|
NSBundle *bundle = [NSBundle mainBundle];
|
||||||
|
if (bundle != nil) {
|
||||||
|
NSString *dir = [bundle bundlePath];
|
||||||
|
result = NSString_to_cpp_string(dir);
|
||||||
|
}
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_NSCachesDirectory
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string
|
||||||
|
get_osx_temp_directory() {
|
||||||
|
#ifndef BUILD_IPHONE
|
||||||
|
NSApplicationLoad();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
NSString *dir = NSTemporaryDirectory();
|
||||||
|
if (dir == nil) {
|
||||||
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
||||||
|
dir = [paths objectAtIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
string result = NSString_to_cpp_string(dir);
|
||||||
|
[pool release];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_osx_user_appdata_directory
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string
|
||||||
|
get_osx_user_appdata_directory() {
|
||||||
|
string result = call_NSSearchPathForDirectories(NSDocumentDirectory, NSUserDomainMask);
|
||||||
|
if (!result.empty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return get_osx_home_directory();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_osx_common_appdata_directory
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string
|
||||||
|
get_osx_common_appdata_directory() {
|
||||||
|
string result = call_NSSearchPathForDirectories(NSDocumentDirectory, NSLocalDomainMask);
|
||||||
|
if (!result.empty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return get_osx_user_appdata_directory();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // IS_OSX
|
@ -181,6 +181,10 @@
|
|||||||
#define WIN_SYS_LIBS \
|
#define WIN_SYS_LIBS \
|
||||||
advapi32.lib ws2_32.lib $[WIN_SYS_LIBS]
|
advapi32.lib ws2_32.lib $[WIN_SYS_LIBS]
|
||||||
|
|
||||||
|
// These frameworks are used by dtoolutil; we redefine it here
|
||||||
|
// so it gets into the panda build system.
|
||||||
|
#define OSX_SYS_FRAMEWORKS Foundation $[if $[not $[BUILD_IPHONE_DEVKIT]],AppKit]
|
||||||
|
|
||||||
#end lib_target
|
#end lib_target
|
||||||
|
|
||||||
#begin test_bin_target
|
#begin test_bin_target
|
||||||
|
@ -1510,7 +1510,7 @@ task_event(GenericAsyncTask *task, void *data) {
|
|||||||
AsyncTask::DoneStatus PandaFramework::
|
AsyncTask::DoneStatus PandaFramework::
|
||||||
task_igloop(GenericAsyncTask *task, void *data) {
|
task_igloop(GenericAsyncTask *task, void *data) {
|
||||||
PandaFramework *self = (PandaFramework *)data;
|
PandaFramework *self = (PandaFramework *)data;
|
||||||
|
|
||||||
if (self->_engine != (GraphicsEngine *)NULL) {
|
if (self->_engine != (GraphicsEngine *)NULL) {
|
||||||
self->_engine->render_frame();
|
self->_engine->render_frame();
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,8 @@ open_window(const WindowProperties &props, GraphicsEngine *engine,
|
|||||||
FrameBufferProperties::get_default(),
|
FrameBufferProperties::get_default(),
|
||||||
props, GraphicsPipe::BF_require_window,
|
props, GraphicsPipe::BF_require_window,
|
||||||
gsg, NULL);
|
gsg, NULL);
|
||||||
|
framework_cat.info()
|
||||||
|
<< "winout = " << winout << "\n";
|
||||||
|
|
||||||
if (winout != (GraphicsOutput *)NULL) {
|
if (winout != (GraphicsOutput *)NULL) {
|
||||||
_window = DCAST(GraphicsWindow, winout);
|
_window = DCAST(GraphicsWindow, winout);
|
||||||
|
@ -22,7 +22,6 @@ INLINE CLP(GeomContext)::
|
|||||||
CLP(GeomContext)(Geom *geom) :
|
CLP(GeomContext)(Geom *geom) :
|
||||||
GeomContext(geom)
|
GeomContext(geom)
|
||||||
{
|
{
|
||||||
_deprecated_index = 0;
|
|
||||||
#ifdef DO_PSTATS
|
#ifdef DO_PSTATS
|
||||||
_num_verts = 0;
|
_num_verts = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,6 +37,12 @@ CLP(GeomContext)::
|
|||||||
bool CLP(GeomContext)::
|
bool CLP(GeomContext)::
|
||||||
get_display_list(GLuint &index, const CLP(GeomMunger) *munger,
|
get_display_list(GLuint &index, const CLP(GeomMunger) *munger,
|
||||||
UpdateSeq modified) {
|
UpdateSeq modified) {
|
||||||
|
#ifdef OPENGLES_1
|
||||||
|
// Display lists not supported by OpenGL ES.
|
||||||
|
nassertr(false, false);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#else
|
||||||
DisplayList &dl = _display_lists[(CLP(GeomMunger) *)munger];
|
DisplayList &dl = _display_lists[(CLP(GeomMunger) *)munger];
|
||||||
bool list_current = (dl._modified == modified);
|
bool list_current = (dl._modified == modified);
|
||||||
if (dl._index == 0) {
|
if (dl._index == 0) {
|
||||||
@ -50,6 +56,7 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger,
|
|||||||
index = dl._index;
|
index = dl._index;
|
||||||
dl._modified = modified;
|
dl._modified = modified;
|
||||||
return list_current;
|
return list_current;
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -61,15 +68,11 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger,
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GeomContext)::
|
void CLP(GeomContext)::
|
||||||
release_display_lists() {
|
release_display_lists() {
|
||||||
if (_deprecated_index != 0) {
|
#ifdef OPENGLES_1
|
||||||
if (GLCAT.is_debug()) {
|
// Display lists not supported by OpenGL ES.
|
||||||
GLCAT.debug()
|
nassertv(_display_lists.empty());
|
||||||
<< "releasing index " << _deprecated_index << "\n";
|
|
||||||
}
|
|
||||||
GLP(DeleteLists)(_deprecated_index, 1);
|
|
||||||
_deprecated_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#else
|
||||||
DisplayLists::iterator dli;
|
DisplayLists::iterator dli;
|
||||||
for (dli = _display_lists.begin();
|
for (dli = _display_lists.begin();
|
||||||
dli != _display_lists.end();
|
dli != _display_lists.end();
|
||||||
@ -88,6 +91,7 @@ release_display_lists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_display_lists.clear();
|
_display_lists.clear();
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -38,9 +38,6 @@ public:
|
|||||||
|
|
||||||
void remove_munger(CLP(GeomMunger) *munger);
|
void remove_munger(CLP(GeomMunger) *munger);
|
||||||
|
|
||||||
// This is used only for the old Geom interface.
|
|
||||||
GLuint _deprecated_index;
|
|
||||||
|
|
||||||
// The different variants of the display list, for storing the
|
// The different variants of the display list, for storing the
|
||||||
// different states the geom might have been rendered in (each using
|
// different states the geom might have been rendered in (each using
|
||||||
// a different munger).
|
// a different munger).
|
||||||
|
@ -177,7 +177,6 @@ check_fbo() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsBuffer)::
|
void CLP(GraphicsBuffer)::
|
||||||
rebuild_bitplanes() {
|
rebuild_bitplanes() {
|
||||||
|
|
||||||
check_host_valid();
|
check_host_valid();
|
||||||
if (_gsg == 0) {
|
if (_gsg == 0) {
|
||||||
return;
|
return;
|
||||||
@ -380,7 +379,6 @@ rebuild_bitplanes() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsBuffer)::
|
void CLP(GraphicsBuffer)::
|
||||||
bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum attachpoint) {
|
bind_slot(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum attachpoint) {
|
||||||
|
|
||||||
CLP(GraphicsStateGuardian) *glgsg;
|
CLP(GraphicsStateGuardian) *glgsg;
|
||||||
DCAST_INTO_V(glgsg, _gsg);
|
DCAST_INTO_V(glgsg, _gsg);
|
||||||
|
|
||||||
|
@ -13,30 +13,6 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GLGraphicsStateGuardian::draw_display_list
|
|
||||||
// Access: Public
|
|
||||||
// Description: If the GeomContext is non-NULL and contains a valid
|
|
||||||
// display list, uses it to draw the geometry if
|
|
||||||
// appropriate, and returns true. If the display list
|
|
||||||
// is absent or cannot be used for some reason, does
|
|
||||||
// nothing and returns false.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool CLP(GraphicsStateGuardian)::
|
|
||||||
draw_display_list(GeomContext *gc) {
|
|
||||||
if (gc != (GeomContext *)NULL && _vertex_colors_enabled) {
|
|
||||||
_draw_primitive_pcollector.start();
|
|
||||||
CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc);
|
|
||||||
GLP(CallList)(ggc->_deprecated_index);
|
|
||||||
#ifdef DO_PSTATS
|
|
||||||
_vertices_display_list_pcollector.add_level(ggc->_num_verts);
|
|
||||||
#endif
|
|
||||||
_draw_primitive_pcollector.stop();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GLGraphicsStateGuardian::report_errors
|
// Function: GLGraphicsStateGuardian::report_errors
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
@ -280,6 +256,7 @@ enable_point_smooth(bool val) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void CLP(GraphicsStateGuardian)::
|
INLINE void CLP(GraphicsStateGuardian)::
|
||||||
enable_polygon_smooth(bool val) {
|
enable_polygon_smooth(bool val) {
|
||||||
|
#ifndef OPENGLES_1 // GL_POLYGON_SMOOTH not supported in OpenGL ES.
|
||||||
if (_polygon_smooth_enabled != val) {
|
if (_polygon_smooth_enabled != val) {
|
||||||
_polygon_smooth_enabled = val;
|
_polygon_smooth_enabled = val;
|
||||||
if (val) {
|
if (val) {
|
||||||
@ -288,6 +265,7 @@ enable_polygon_smooth(bool val) {
|
|||||||
GLP(Disable)(GL_POLYGON_SMOOTH);
|
GLP(Disable)(GL_POLYGON_SMOOTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -502,16 +480,16 @@ enable_polygon_offset(bool val) {
|
|||||||
<< "glEnable(GL_POLYGON_OFFSET_*)" << endl;
|
<< "glEnable(GL_POLYGON_OFFSET_*)" << endl;
|
||||||
#endif
|
#endif
|
||||||
GLP(Enable)(GL_POLYGON_OFFSET_FILL);
|
GLP(Enable)(GL_POLYGON_OFFSET_FILL);
|
||||||
GLP(Enable)(GL_POLYGON_OFFSET_LINE);
|
//GLP(Enable)(GL_POLYGON_OFFSET_LINE); // not widely supported anyway
|
||||||
GLP(Enable)(GL_POLYGON_OFFSET_POINT);
|
//GLP(Enable)(GL_POLYGON_OFFSET_POINT);
|
||||||
} else {
|
} else {
|
||||||
#ifdef GSG_VERBOSE
|
#ifdef GSG_VERBOSE
|
||||||
GLCAT.spam()
|
GLCAT.spam()
|
||||||
<< "glDisable(GL_POLYGON_OFFSET_*)" << endl;
|
<< "glDisable(GL_POLYGON_OFFSET_*)" << endl;
|
||||||
#endif
|
#endif
|
||||||
GLP(Disable)(GL_POLYGON_OFFSET_FILL);
|
GLP(Disable)(GL_POLYGON_OFFSET_FILL);
|
||||||
GLP(Disable)(GL_POLYGON_OFFSET_LINE);
|
//GLP(Disable)(GL_POLYGON_OFFSET_LINE); // not widely supported anyway
|
||||||
GLP(Disable)(GL_POLYGON_OFFSET_POINT);
|
//GLP(Disable)(GL_POLYGON_OFFSET_POINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1072,6 +1072,7 @@ reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLint max_elements_vertices = 0, max_elements_indices = 0;
|
GLint max_elements_vertices = 0, max_elements_indices = 0;
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(GetIntegerv)(GL_MAX_ELEMENTS_VERTICES, &max_elements_vertices);
|
GLP(GetIntegerv)(GL_MAX_ELEMENTS_VERTICES, &max_elements_vertices);
|
||||||
GLP(GetIntegerv)(GL_MAX_ELEMENTS_INDICES, &max_elements_indices);
|
GLP(GetIntegerv)(GL_MAX_ELEMENTS_INDICES, &max_elements_indices);
|
||||||
if (max_elements_vertices > 0) {
|
if (max_elements_vertices > 0) {
|
||||||
@ -1080,6 +1081,7 @@ reset() {
|
|||||||
if (max_elements_indices > 0) {
|
if (max_elements_indices > 0) {
|
||||||
_max_vertices_per_primitive = max_elements_indices;
|
_max_vertices_per_primitive = max_elements_indices;
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
if (GLCAT.is_debug()) {
|
if (GLCAT.is_debug()) {
|
||||||
GLCAT.debug()
|
GLCAT.debug()
|
||||||
@ -1199,7 +1201,9 @@ reset() {
|
|||||||
GLP(FrontFace)(GL_CCW);
|
GLP(FrontFace)(GL_CCW);
|
||||||
GLP(Disable)(GL_LINE_SMOOTH);
|
GLP(Disable)(GL_LINE_SMOOTH);
|
||||||
GLP(Disable)(GL_POINT_SMOOTH);
|
GLP(Disable)(GL_POINT_SMOOTH);
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Disable)(GL_POLYGON_SMOOTH);
|
GLP(Disable)(GL_POLYGON_SMOOTH);
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
if (_supports_multisample) {
|
if (_supports_multisample) {
|
||||||
GLP(Disable)(GL_MULTISAMPLE);
|
GLP(Disable)(GL_MULTISAMPLE);
|
||||||
@ -1221,8 +1225,10 @@ reset() {
|
|||||||
_decal_level = 0;
|
_decal_level = 0;
|
||||||
_tex_gen_point_sprite = false;
|
_tex_gen_point_sprite = false;
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1
|
||||||
// Dither is on by default in GL; let's turn it off
|
// Dither is on by default in GL; let's turn it off
|
||||||
GLP(Disable)(GL_DITHER);
|
GLP(Disable)(GL_DITHER);
|
||||||
|
#endif // OPENGLES_1
|
||||||
_dithering_enabled = false;
|
_dithering_enabled = false;
|
||||||
|
|
||||||
_current_shader = (Shader *)NULL;
|
_current_shader = (Shader *)NULL;
|
||||||
@ -1459,7 +1465,9 @@ clear(DrawableRegion *clearable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clearable->get_clear_depth_active()) {
|
if (clearable->get_clear_depth_active()) {
|
||||||
|
#ifndef OPENGLES_1 // Temporary: need glClearDepthf() instead for OpenGL ES.
|
||||||
GLP(ClearDepth)(clearable->get_clear_depth());
|
GLP(ClearDepth)(clearable->get_clear_depth());
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(DepthMask)(GL_TRUE);
|
GLP(DepthMask)(GL_TRUE);
|
||||||
_state_mask.clear_bit(DepthWriteAttrib::get_class_slot());
|
_state_mask.clear_bit(DepthWriteAttrib::get_class_slot());
|
||||||
mask |= GL_DEPTH_BUFFER_BIT;
|
mask |= GL_DEPTH_BUFFER_BIT;
|
||||||
@ -1666,7 +1674,7 @@ begin_frame(Thread *current_thread) {
|
|||||||
ui != _usage_textures.end();
|
ui != _usage_textures.end();
|
||||||
++ui) {
|
++ui) {
|
||||||
GLuint index = (*ui).second;
|
GLuint index = (*ui).second;
|
||||||
GLP(DeleteLists)(index, 1);
|
GLP(DeleteTextures)(1, &index);
|
||||||
}
|
}
|
||||||
_usage_textures.clear();
|
_usage_textures.clear();
|
||||||
_show_texture_usage_max_size = max_size;
|
_show_texture_usage_max_size = max_size;
|
||||||
@ -1767,6 +1775,7 @@ end_frame(Thread *current_thread) {
|
|||||||
_vertices_immediate_pcollector.flush_level();
|
_vertices_immediate_pcollector.flush_level();
|
||||||
|
|
||||||
// Now is a good time to delete any pending display lists.
|
// Now is a good time to delete any pending display lists.
|
||||||
|
#ifndef OPENGLES_1
|
||||||
{
|
{
|
||||||
LightMutexHolder holder(_lock);
|
LightMutexHolder holder(_lock);
|
||||||
if (!_deleted_display_lists.empty()) {
|
if (!_deleted_display_lists.empty()) {
|
||||||
@ -1798,6 +1807,7 @@ end_frame(Thread *current_thread) {
|
|||||||
_deleted_queries.clear();
|
_deleted_queries.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// Calling glFlush() at the end of the frame is particularly
|
// Calling glFlush() at the end of the frame is particularly
|
||||||
// necessary if this is a single-buffered visual, so that the frame
|
// necessary if this is a single-buffered visual, so that the frame
|
||||||
@ -1962,6 +1972,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
GLP(LoadIdentity)();
|
GLP(LoadIdentity)();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // Display lists not supported by OpenGL ES.
|
||||||
if (geom_reader->get_usage_hint() == Geom::UH_static &&
|
if (geom_reader->get_usage_hint() == Geom::UH_static &&
|
||||||
_data_reader->get_usage_hint() == Geom::UH_static &&
|
_data_reader->get_usage_hint() == Geom::UH_static &&
|
||||||
display_lists && (!hardware_animation || display_list_animation)) {
|
display_lists && (!hardware_animation || display_list_animation)) {
|
||||||
@ -1976,6 +1987,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
nassertr(gc != (GeomContext *)NULL, false);
|
nassertr(gc != (GeomContext *)NULL, false);
|
||||||
CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc);
|
CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc);
|
||||||
const CLP(GeomMunger) *gmunger = DCAST(CLP(GeomMunger), _munger);
|
const CLP(GeomMunger) *gmunger = DCAST(CLP(GeomMunger), _munger);
|
||||||
|
|
||||||
UpdateSeq modified = max(geom_reader->get_modified(), _data_reader->get_modified());
|
UpdateSeq modified = max(geom_reader->get_modified(), _data_reader->get_modified());
|
||||||
if (ggc->get_display_list(_geom_display_list, gmunger, modified)) {
|
if (ggc->get_display_list(_geom_display_list, gmunger, modified)) {
|
||||||
// If it hasn't been modified, just play the display list again.
|
// If it hasn't been modified, just play the display list again.
|
||||||
@ -2022,6 +2034,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// Enable the appropriate vertex arrays, and disable any
|
// Enable the appropriate vertex arrays, and disable any
|
||||||
// extra vertex arrays used by the previous rendering mode.
|
// extra vertex arrays used by the previous rendering mode.
|
||||||
@ -2684,6 +2697,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
end_draw_primitives() {
|
end_draw_primitives() {
|
||||||
|
#ifndef OPENGLES_1 // Display lists not supported by OpenGL ES.
|
||||||
if (_geom_display_list != 0) {
|
if (_geom_display_list != 0) {
|
||||||
// If we were building a display list, close it now.
|
// If we were building a display list, close it now.
|
||||||
GLP(EndList)();
|
GLP(EndList)();
|
||||||
@ -2695,6 +2709,7 @@ end_draw_primitives() {
|
|||||||
_primitive_batches_display_list_pcollector.add_level(1);
|
_primitive_batches_display_list_pcollector.add_level(1);
|
||||||
}
|
}
|
||||||
_geom_display_list = 0;
|
_geom_display_list = 0;
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// Clean up the vertex blending state.
|
// Clean up the vertex blending state.
|
||||||
if (_vertex_blending_enabled) {
|
if (_vertex_blending_enabled) {
|
||||||
@ -2738,6 +2753,7 @@ end_draw_primitives() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
TextureContext *CLP(GraphicsStateGuardian)::
|
TextureContext *CLP(GraphicsStateGuardian)::
|
||||||
prepare_texture(Texture *tex) {
|
prepare_texture(Texture *tex) {
|
||||||
|
report_my_gl_errors();
|
||||||
// Make sure we'll support this texture when it's rendered. Don't
|
// Make sure we'll support this texture when it's rendered. Don't
|
||||||
// bother to prepare it if we won't.
|
// bother to prepare it if we won't.
|
||||||
switch (tex->get_texture_type()) {
|
switch (tex->get_texture_type()) {
|
||||||
@ -2760,7 +2776,9 @@ prepare_texture(Texture *tex) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report_my_gl_errors();
|
||||||
CLP(TextureContext) *gtc = new CLP(TextureContext)(_prepared_objects, tex);
|
CLP(TextureContext) *gtc = new CLP(TextureContext)(_prepared_objects, tex);
|
||||||
|
report_my_gl_errors();
|
||||||
GLP(GenTextures)(1, >c->_index);
|
GLP(GenTextures)(1, >c->_index);
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
|
||||||
@ -3333,6 +3351,10 @@ setup_primitive(const unsigned char *&client_pointer,
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
begin_occlusion_query() {
|
begin_occlusion_query() {
|
||||||
|
#ifdef OPENGLES_1 // Occlusion queries not supported by OpenGL ES.
|
||||||
|
nassertv(false);
|
||||||
|
|
||||||
|
#else
|
||||||
nassertv(_supports_occlusion_query);
|
nassertv(_supports_occlusion_query);
|
||||||
nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL);
|
nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL);
|
||||||
PT(CLP(OcclusionQueryContext)) query = new CLP(OcclusionQueryContext)(this);
|
PT(CLP(OcclusionQueryContext)) query = new CLP(OcclusionQueryContext)(this);
|
||||||
@ -3348,6 +3370,7 @@ begin_occlusion_query() {
|
|||||||
_current_occlusion_query = query;
|
_current_occlusion_query = query;
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -3361,6 +3384,11 @@ begin_occlusion_query() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PT(OcclusionQueryContext) CLP(GraphicsStateGuardian)::
|
PT(OcclusionQueryContext) CLP(GraphicsStateGuardian)::
|
||||||
end_occlusion_query() {
|
end_occlusion_query() {
|
||||||
|
#ifdef OPENGLES_1 // Occlusion queries not supported by OpenGL ES.
|
||||||
|
nassertr(false, NULL);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#else
|
||||||
nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL);
|
nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL);
|
||||||
PT(OcclusionQueryContext) result = _current_occlusion_query;
|
PT(OcclusionQueryContext) result = _current_occlusion_query;
|
||||||
|
|
||||||
@ -3391,6 +3419,7 @@ end_occlusion_query() {
|
|||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -3700,7 +3729,7 @@ framebuffer_copy_to_ram(Texture *tex, int z, const DisplayRegion *dr,
|
|||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
apply_fog(Fog *fog) {
|
apply_fog(Fog *fog) {
|
||||||
Fog::Mode fmode = fog->get_mode();
|
Fog::Mode fmode = fog->get_mode();
|
||||||
GLP(Fogi)(GL_FOG_MODE, get_fog_mode_type(fmode));
|
GLP(Fogf)(GL_FOG_MODE, get_fog_mode_type(fmode));
|
||||||
|
|
||||||
if (fmode == Fog::M_linear) {
|
if (fmode == Fog::M_linear) {
|
||||||
float onset, opaque;
|
float onset, opaque;
|
||||||
@ -3821,6 +3850,7 @@ do_issue_render_mode() {
|
|||||||
_point_size = target_render_mode->get_thickness();
|
_point_size = target_render_mode->get_thickness();
|
||||||
_point_perspective = target_render_mode->get_perspective();
|
_point_perspective = target_render_mode->get_perspective();
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // glPolygonMode not supported by OpenGL ES.
|
||||||
switch (_render_mode) {
|
switch (_render_mode) {
|
||||||
case RenderModeAttrib::M_unchanged:
|
case RenderModeAttrib::M_unchanged:
|
||||||
case RenderModeAttrib::M_filled:
|
case RenderModeAttrib::M_filled:
|
||||||
@ -3840,6 +3870,7 @@ do_issue_render_mode() {
|
|||||||
GLCAT.error()
|
GLCAT.error()
|
||||||
<< "Unknown render mode " << (int)_render_mode << endl;
|
<< "Unknown render mode " << (int)_render_mode << endl;
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// The thickness affects both the line width and the point size.
|
// The thickness affects both the line width and the point size.
|
||||||
GLP(LineWidth)(_point_size);
|
GLP(LineWidth)(_point_size);
|
||||||
@ -3887,19 +3918,25 @@ do_issue_antialias() {
|
|||||||
case AntialiasAttrib::M_faster:
|
case AntialiasAttrib::M_faster:
|
||||||
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
||||||
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_FASTEST);
|
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_FASTEST);
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
|
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
|
||||||
|
#endif // OPENGLES_1
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AntialiasAttrib::M_better:
|
case AntialiasAttrib::M_better:
|
||||||
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||||
|
#endif // OPENGLES_1
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
|
GLP(Hint)(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
|
||||||
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_DONT_CARE);
|
GLP(Hint)(GL_POINT_SMOOTH_HINT, GL_DONT_CARE);
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
|
GLP(Hint)(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
|
||||||
|
#endif // OPENGLES_1
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4117,7 +4154,11 @@ do_issue_material() {
|
|||||||
}
|
}
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT;
|
GLenum face = material->get_twoside() ? GL_FRONT_AND_BACK : GL_FRONT;
|
||||||
|
#else
|
||||||
|
static const GLenum face = GL_FRONT_AND_BACK;
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
GLP(Materialfv)(face, GL_SPECULAR, material->get_specular().get_data());
|
GLP(Materialfv)(face, GL_SPECULAR, material->get_specular().get_data());
|
||||||
GLP(Materialfv)(face, GL_EMISSION, material->get_emission().get_data());
|
GLP(Materialfv)(face, GL_EMISSION, material->get_emission().get_data());
|
||||||
@ -4138,7 +4179,9 @@ do_issue_material() {
|
|||||||
GLP(Disable)(GL_COLOR_MATERIAL);
|
GLP(Disable)(GL_COLOR_MATERIAL);
|
||||||
GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data());
|
GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data());
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(ColorMaterial)(face, GL_DIFFUSE);
|
GLP(ColorMaterial)(face, GL_DIFFUSE);
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(Enable)(GL_COLOR_MATERIAL);
|
GLP(Enable)(GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4150,7 +4193,9 @@ do_issue_material() {
|
|||||||
GLP(Disable)(GL_COLOR_MATERIAL);
|
GLP(Disable)(GL_COLOR_MATERIAL);
|
||||||
GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data());
|
GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data());
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(ColorMaterial)(face, GL_AMBIENT);
|
GLP(ColorMaterial)(face, GL_AMBIENT);
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(Enable)(GL_COLOR_MATERIAL);
|
GLP(Enable)(GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4162,13 +4207,17 @@ do_issue_material() {
|
|||||||
GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data());
|
GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data());
|
||||||
GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data());
|
GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data());
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(ColorMaterial)(face, GL_AMBIENT_AND_DIFFUSE);
|
GLP(ColorMaterial)(face, GL_AMBIENT_AND_DIFFUSE);
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(Enable)(GL_COLOR_MATERIAL);
|
GLP(Enable)(GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local());
|
GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local());
|
||||||
GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
|
GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside());
|
||||||
|
#endif // OPENGLES_1
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4789,7 +4838,7 @@ get_extension_func(const char *, const char *) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
set_draw_buffer(int rbtype) {
|
set_draw_buffer(int rbtype) {
|
||||||
|
#ifndef OPENGLES_1 // Draw buffers not supported by OpenGL ES.
|
||||||
if (_current_fbo) {
|
if (_current_fbo) {
|
||||||
|
|
||||||
GLuint buffers[16];
|
GLuint buffers[16];
|
||||||
@ -4861,6 +4910,7 @@ set_draw_buffer(int rbtype) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// Also ensure that any global color channels are masked out.
|
// Also ensure that any global color channels are masked out.
|
||||||
if (CLP(color_mask)) {
|
if (CLP(color_mask)) {
|
||||||
@ -4883,7 +4933,7 @@ set_draw_buffer(int rbtype) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
set_read_buffer(int rbtype) {
|
set_read_buffer(int rbtype) {
|
||||||
|
#ifndef OPENGLES_1 // Draw buffers not supported by OpenGL ES.
|
||||||
if (rbtype & (RenderBuffer::T_depth | RenderBuffer::T_stencil)) {
|
if (rbtype & (RenderBuffer::T_depth | RenderBuffer::T_stencil)) {
|
||||||
// Special case: don't have to call ReadBuffer for these.
|
// Special case: don't have to call ReadBuffer for these.
|
||||||
return;
|
return;
|
||||||
@ -4954,6 +5004,7 @@ set_read_buffer(int rbtype) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6091,8 +6142,10 @@ bind_clip_plane(const NodePath &plane, int plane_id) {
|
|||||||
DCAST_INTO_V(plane_node, plane.node());
|
DCAST_INTO_V(plane_node, plane.node());
|
||||||
Planef xformed_plane = plane_node->get_plane() * transform->get_mat();
|
Planef xformed_plane = plane_node->get_plane() * transform->get_mat();
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // Temporary: need glClipPlanef() instead for OpenGL ES.
|
||||||
Planed double_plane(LCAST(double, xformed_plane));
|
Planed double_plane(LCAST(double, xformed_plane));
|
||||||
GLP(ClipPlane)(id, double_plane.get_data());
|
GLP(ClipPlane)(id, double_plane.get_data());
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
}
|
}
|
||||||
@ -6533,7 +6586,9 @@ update_standard_texture_bindings() {
|
|||||||
_glActiveTexture(GL_TEXTURE0 + i);
|
_glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
|
||||||
// First, turn off the previous texture mode.
|
// First, turn off the previous texture mode.
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Disable)(GL_TEXTURE_1D);
|
GLP(Disable)(GL_TEXTURE_1D);
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(Disable)(GL_TEXTURE_2D);
|
GLP(Disable)(GL_TEXTURE_2D);
|
||||||
if (_supports_3d_texture) {
|
if (_supports_3d_texture) {
|
||||||
GLP(Disable)(GL_TEXTURE_3D);
|
GLP(Disable)(GL_TEXTURE_3D);
|
||||||
@ -6686,7 +6741,9 @@ update_standard_texture_bindings() {
|
|||||||
// Disable the texture stages that are no longer used.
|
// Disable the texture stages that are no longer used.
|
||||||
for (i = num_stages; i < _num_active_texture_stages; i++) {
|
for (i = num_stages; i < _num_active_texture_stages; i++) {
|
||||||
_glActiveTexture(GL_TEXTURE0 + i);
|
_glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(Disable)(GL_TEXTURE_1D);
|
GLP(Disable)(GL_TEXTURE_1D);
|
||||||
|
#endif // OPENGLES_1
|
||||||
GLP(Disable)(GL_TEXTURE_2D);
|
GLP(Disable)(GL_TEXTURE_2D);
|
||||||
if (_supports_3d_texture) {
|
if (_supports_3d_texture) {
|
||||||
GLP(Disable)(GL_TEXTURE_3D);
|
GLP(Disable)(GL_TEXTURE_3D);
|
||||||
@ -6933,6 +6990,10 @@ do_issue_tex_matrix() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
do_issue_tex_gen() {
|
do_issue_tex_gen() {
|
||||||
|
#ifdef OPENGLES_1
|
||||||
|
// Temporary hack
|
||||||
|
return;
|
||||||
|
#endif // OPENGLES_1
|
||||||
bool force_normal = false;
|
bool force_normal = false;
|
||||||
|
|
||||||
nassertv(_num_active_texture_stages <= _max_texture_stages);
|
nassertv(_num_active_texture_stages <= _max_texture_stages);
|
||||||
@ -6962,6 +7023,7 @@ do_issue_tex_gen() {
|
|||||||
GLP(TexEnvi)(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_FALSE);
|
GLP(TexEnvi)(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // TexGen not supported by OpenGL ES.
|
||||||
TexGenAttrib::Mode mode = _target_tex_gen->get_mode(stage);
|
TexGenAttrib::Mode mode = _target_tex_gen->get_mode(stage);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case TexGenAttrib::M_off:
|
case TexGenAttrib::M_off:
|
||||||
@ -7176,6 +7238,7 @@ do_issue_tex_gen() {
|
|||||||
case TexGenAttrib::M_unused:
|
case TexGenAttrib::M_unused:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_point_sprites != _tex_gen_point_sprite) {
|
if (got_point_sprites != _tex_gen_point_sprite) {
|
||||||
@ -7217,9 +7280,11 @@ specify_texture(CLP(TextureContext) *gtc) {
|
|||||||
get_texture_wrap_mode(tex->get_wrap_w()));
|
get_texture_wrap_mode(tex->get_wrap_w()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1
|
||||||
Colorf border_color = tex->get_border_color();
|
Colorf border_color = tex->get_border_color();
|
||||||
GLP(TexParameterfv)(target, GL_TEXTURE_BORDER_COLOR,
|
GLP(TexParameterfv)(target, GL_TEXTURE_BORDER_COLOR,
|
||||||
border_color.get_data());
|
border_color.get_data());
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
Texture::FilterType minfilter = tex->get_effective_minfilter();
|
Texture::FilterType minfilter = tex->get_effective_minfilter();
|
||||||
Texture::FilterType magfilter = tex->get_effective_magfilter();
|
Texture::FilterType magfilter = tex->get_effective_magfilter();
|
||||||
@ -7302,6 +7367,7 @@ apply_texture(TextureContext *tc) {
|
|||||||
if (target == GL_NONE) {
|
if (target == GL_NONE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
report_my_gl_errors();
|
||||||
GLP(BindTexture)(target, gtc->_index);
|
GLP(BindTexture)(target, gtc->_index);
|
||||||
|
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
@ -7672,6 +7738,10 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
|
|
||||||
int highest_level = 0;
|
int highest_level = 0;
|
||||||
|
|
||||||
|
#ifdef OPENGLES_1 // OpenGL ES doesn't support texture subloads.
|
||||||
|
static const bool needs_reload = true;
|
||||||
|
|
||||||
|
#else
|
||||||
bool needs_reload = false;
|
bool needs_reload = false;
|
||||||
if (!gtc->_already_applied ||
|
if (!gtc->_already_applied ||
|
||||||
gtc->_uses_mipmaps != uses_mipmaps ||
|
gtc->_uses_mipmaps != uses_mipmaps ||
|
||||||
@ -7782,6 +7852,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
needs_reload = true;
|
needs_reload = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
if (needs_reload) {
|
if (needs_reload) {
|
||||||
// Load the image up from scratch, creating a new GL Texture
|
// Load the image up from scratch, creating a new GL Texture
|
||||||
@ -7841,6 +7912,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
#endif
|
#endif
|
||||||
switch (texture_target) {
|
switch (texture_target) {
|
||||||
case GL_TEXTURE_1D:
|
case GL_TEXTURE_1D:
|
||||||
|
#ifndef OPENGLES_1 // 1-d textures not supported by OpenGL ES. Fall through.
|
||||||
if (image_compression == Texture::CM_off) {
|
if (image_compression == Texture::CM_off) {
|
||||||
GLP(TexImage1D)(page_target, n - mipmap_bias, internal_format,
|
GLP(TexImage1D)(page_target, n - mipmap_bias, internal_format,
|
||||||
width, 0,
|
width, 0,
|
||||||
@ -7850,7 +7922,9 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
0, image_size, image_ptr);
|
0, image_size, image_ptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif // OPENGLES_1 // OpenGL ES will fall through.
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // 3-d textures not supported by OpenGL ES. Fall through.
|
||||||
case GL_TEXTURE_3D:
|
case GL_TEXTURE_3D:
|
||||||
if (_supports_3d_texture) {
|
if (_supports_3d_texture) {
|
||||||
if (image_compression == Texture::CM_off) {
|
if (image_compression == Texture::CM_off) {
|
||||||
@ -7867,6 +7941,7 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif // OPENGLES_1 // OpenGL ES will fall through.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (image_compression == Texture::CM_off) {
|
if (image_compression == Texture::CM_off) {
|
||||||
@ -7991,6 +8066,16 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
size_t CLP(GraphicsStateGuardian)::
|
size_t CLP(GraphicsStateGuardian)::
|
||||||
get_texture_memory_size(Texture *tex) {
|
get_texture_memory_size(Texture *tex) {
|
||||||
|
#ifdef OPENGLES_1 // Texture querying not supported on OpenGL ES.
|
||||||
|
int width = tex->get_x_size();
|
||||||
|
int height = tex->get_y_size();
|
||||||
|
int depth = 1;
|
||||||
|
int scale = 1;
|
||||||
|
bool has_mipmaps = tex->uses_mipmaps();
|
||||||
|
|
||||||
|
size_t num_bytes = 2; // Temporary assumption?
|
||||||
|
|
||||||
|
#else
|
||||||
GLenum target = get_texture_target(tex->get_texture_type());
|
GLenum target = get_texture_target(tex->get_texture_type());
|
||||||
|
|
||||||
GLenum page_target = target;
|
GLenum page_target = target;
|
||||||
@ -8003,12 +8088,13 @@ get_texture_memory_size(Texture *tex) {
|
|||||||
|
|
||||||
GLint minfilter;
|
GLint minfilter;
|
||||||
GLP(GetTexParameteriv)(target, GL_TEXTURE_MIN_FILTER, &minfilter);
|
GLP(GetTexParameteriv)(target, GL_TEXTURE_MIN_FILTER, &minfilter);
|
||||||
|
bool has_mipmaps = is_mipmap_filter(minfilter);
|
||||||
|
|
||||||
|
report_my_gl_errors();
|
||||||
|
|
||||||
GLint internal_format;
|
GLint internal_format;
|
||||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
||||||
|
|
||||||
report_my_gl_errors();
|
|
||||||
|
|
||||||
if (is_compressed_format(internal_format)) {
|
if (is_compressed_format(internal_format)) {
|
||||||
// Try to get the compressed size.
|
// Try to get the compressed size.
|
||||||
GLint image_size;
|
GLint image_size;
|
||||||
@ -8062,9 +8148,10 @@ get_texture_memory_size(Texture *tex) {
|
|||||||
|
|
||||||
size_t num_bits = (red_size + green_size + blue_size + alpha_size + luminance_size + intensity_size + depth_size);
|
size_t num_bits = (red_size + green_size + blue_size + alpha_size + luminance_size + intensity_size + depth_size);
|
||||||
size_t num_bytes = (num_bits + 7) / 8;
|
size_t num_bytes = (num_bits + 7) / 8;
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
size_t result = num_bytes * width * height * depth * scale;
|
size_t result = num_bytes * width * height * depth * scale;
|
||||||
if (is_mipmap_filter(minfilter)) {
|
if (has_mipmaps) {
|
||||||
result = (result * 4) / 3;
|
result = (result * 4) / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8079,6 +8166,7 @@ get_texture_memory_size(Texture *tex) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CLP(GraphicsStateGuardian)::
|
void CLP(GraphicsStateGuardian)::
|
||||||
check_nonresident_texture(BufferContextChain &chain) {
|
check_nonresident_texture(BufferContextChain &chain) {
|
||||||
|
#ifndef OPENGLES_1 // Residency queries not supported by OpenGL ES.
|
||||||
size_t num_textures = chain.get_count();
|
size_t num_textures = chain.get_count();
|
||||||
if (num_textures == 0) {
|
if (num_textures == 0) {
|
||||||
return;
|
return;
|
||||||
@ -8109,6 +8197,7 @@ check_nonresident_texture(BufferContextChain &chain) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -8150,7 +8239,8 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
page_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
page_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint width = 1, height = 1, depth = 1;
|
GLint width = gtc->_width, height = gtc->_height, depth = gtc->_depth;
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_WIDTH, &width);
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_WIDTH, &width);
|
||||||
if (target != GL_TEXTURE_1D) {
|
if (target != GL_TEXTURE_1D) {
|
||||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
||||||
@ -8160,6 +8250,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
} else if (target == GL_TEXTURE_CUBE_MAP) {
|
} else if (target == GL_TEXTURE_CUBE_MAP) {
|
||||||
depth = 6;
|
depth = 6;
|
||||||
}
|
}
|
||||||
|
#endif // OPENGLES_1
|
||||||
report_my_gl_errors();
|
report_my_gl_errors();
|
||||||
|
|
||||||
if (width <= 0 || height <= 0 || depth <= 0) {
|
if (width <= 0 || height <= 0 || depth <= 0) {
|
||||||
@ -8168,8 +8259,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLint internal_format = 0;
|
GLint internal_format = GL_RGBA;
|
||||||
|
#ifndef OPENGLES_1
|
||||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
// Make sure we were able to query those parameters properly.
|
// Make sure we were able to query those parameters properly.
|
||||||
GLenum error_code = GLP(GetError)();
|
GLenum error_code = GLP(GetError)();
|
||||||
@ -8364,6 +8457,10 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
|
|||||||
Texture *tex, GLenum target, GLenum page_target,
|
Texture *tex, GLenum target, GLenum page_target,
|
||||||
Texture::ComponentType type,
|
Texture::ComponentType type,
|
||||||
Texture::CompressionMode compression, int n) {
|
Texture::CompressionMode compression, int n) {
|
||||||
|
#ifdef OPENGLES_1 // Extracting texture data unsupported in OpenGL ES.
|
||||||
|
nassertr(false, false);
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
if (target == GL_TEXTURE_CUBE_MAP) {
|
if (target == GL_TEXTURE_CUBE_MAP) {
|
||||||
// A cube map, compressed or uncompressed. This we must extract
|
// A cube map, compressed or uncompressed. This we must extract
|
||||||
// one page at a time.
|
// one page at a time.
|
||||||
@ -8456,7 +8553,7 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
|
|||||||
// aside. If it does, we assume the driver might have
|
// aside. If it does, we assume the driver might have
|
||||||
// overfilled even our provided extra buffer.
|
// overfilled even our provided extra buffer.
|
||||||
nassertr(count != extra_space, true)
|
nassertr(count != extra_space, true)
|
||||||
#endif
|
#endif // NDEBUG
|
||||||
} else {
|
} else {
|
||||||
_glGetCompressedTexImage(target, n, image.p());
|
_glGetCompressedTexImage(target, n, image.p());
|
||||||
}
|
}
|
||||||
@ -8474,6 +8571,7 @@ extract_texture_image(PTA_uchar &image, size_t &page_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif // OPENGLES_1
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -77,7 +77,7 @@ typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint lev
|
|||||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
|
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
|
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||||
typedef void (APIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
|
typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
|
||||||
typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||||
typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
|
typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
|
||||||
typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
|
typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
|
||||||
@ -98,6 +98,9 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum
|
|||||||
typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||||
typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
|
typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
|
||||||
typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
|
typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
|
||||||
|
typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
|
||||||
|
typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
|
||||||
|
typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||||
#endif // __EDG__
|
#endif // __EDG__
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -142,8 +145,6 @@ public:
|
|||||||
bool force);
|
bool force);
|
||||||
virtual void end_draw_primitives();
|
virtual void end_draw_primitives();
|
||||||
|
|
||||||
INLINE bool draw_display_list(GeomContext *gc);
|
|
||||||
|
|
||||||
virtual TextureContext *prepare_texture(Texture *tex);
|
virtual TextureContext *prepare_texture(Texture *tex);
|
||||||
virtual bool update_texture(TextureContext *tc, bool force);
|
virtual bool update_texture(TextureContext *tc, bool force);
|
||||||
virtual void release_texture(TextureContext *tc);
|
virtual void release_texture(TextureContext *tc);
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "lightMutexHolder.h"
|
#include "lightMutexHolder.h"
|
||||||
#include "pStatTimer.h"
|
#include "pStatTimer.h"
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // Occlusion queries not supported by OpenGL ES.
|
||||||
|
|
||||||
TypeHandle CLP(OcclusionQueryContext)::_type_handle;
|
TypeHandle CLP(OcclusionQueryContext)::_type_handle;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -111,3 +113,5 @@ get_num_fragments() const {
|
|||||||
glgsg->report_my_gl_errors();
|
glgsg->report_my_gl_errors();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
class GraphicsStateGuardian;
|
class GraphicsStateGuardian;
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1 // Occlusion queries not supported by OpenGL ES.
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : GLOcclusionQueryContext
|
// Class : GLOcclusionQueryContext
|
||||||
// Description :
|
// Description :
|
||||||
@ -55,3 +57,5 @@ private:
|
|||||||
|
|
||||||
#include "glOcclusionQueryContext_src.I"
|
#include "glOcclusionQueryContext_src.I"
|
||||||
|
|
||||||
|
#endif // OPENGLES_1
|
||||||
|
|
||||||
|
@ -147,11 +147,15 @@ void CLP(init_classes)() {
|
|||||||
CLP(GeomMunger)::init_type();
|
CLP(GeomMunger)::init_type();
|
||||||
CLP(GraphicsStateGuardian)::init_type();
|
CLP(GraphicsStateGuardian)::init_type();
|
||||||
CLP(IndexBufferContext)::init_type();
|
CLP(IndexBufferContext)::init_type();
|
||||||
CLP(OcclusionQueryContext)::init_type();
|
|
||||||
CLP(ShaderContext)::init_type();
|
CLP(ShaderContext)::init_type();
|
||||||
CLP(TextureContext)::init_type();
|
CLP(TextureContext)::init_type();
|
||||||
CLP(VertexBufferContext)::init_type();
|
CLP(VertexBufferContext)::init_type();
|
||||||
CLP(GraphicsBuffer)::init_type();
|
CLP(GraphicsBuffer)::init_type();
|
||||||
|
|
||||||
|
#ifndef OPENGLES_1
|
||||||
|
CLP(OcclusionQueryContext)::init_type();
|
||||||
|
#endif
|
||||||
|
|
||||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||||
ps->add_system(GLSYSTEM_NAME);
|
ps->add_system(GLSYSTEM_NAME);
|
||||||
|
|
||||||
|
35
panda/src/iphone/Sources.pp
Normal file
35
panda/src/iphone/Sources.pp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#define BUILD_DIRECTORY $[BUILD_IPHONE_DEVKIT]
|
||||||
|
|
||||||
|
#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
|
||||||
|
dtoolutil:c dtoolbase:c dtool:m prc:c
|
||||||
|
|
||||||
|
#define OSX_SYS_FRAMEWORKS Foundation QuartzCore UIKit OpenGLES
|
||||||
|
#define BUILDING_DLL BUILDING_PANDAGL
|
||||||
|
|
||||||
|
#begin bin_target
|
||||||
|
#define TARGET iphone_pview
|
||||||
|
#define LOCAL_LIBS \
|
||||||
|
framework putil collide pgraph chan text \
|
||||||
|
pnmimage pnmimagetypes event effects gobj display \
|
||||||
|
mathutil putil express dgraph device tform \
|
||||||
|
linmath pstatclient panda glstuff
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
config_iphone.h config_iphone.mm \
|
||||||
|
pview_delegate.h pview_delegate.mm \
|
||||||
|
viewController.h viewController.mm \
|
||||||
|
eaglView.h eaglView.mm \
|
||||||
|
glesext_shadow.h \
|
||||||
|
glesgsg.h glesgsg.mm \
|
||||||
|
iPhoneGraphicsPipe.h iPhoneGraphicsPipe.mm \
|
||||||
|
iPhoneGraphicsStateGuardian.h iPhoneGraphicsStateGuardian.mm \
|
||||||
|
iPhoneGraphicsWindow.h iPhoneGraphicsWindow.I iPhoneGraphicsWindow.mm \
|
||||||
|
main.mm
|
||||||
|
|
||||||
|
#end bin_target
|
||||||
|
|
||||||
|
//#begin bin_target
|
||||||
|
// #define TARGET iphone_pview
|
||||||
|
// #define SOURCES main.mm
|
||||||
|
//#end bin_target
|
||||||
|
|
25
panda/src/iphone/config_iphone.h
Normal file
25
panda/src/iphone/config_iphone.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef CONFIG_IPHONE_H
|
||||||
|
#define CONFIG_IPHONE_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "notifyCategoryProxy.h"
|
||||||
|
#include "configVariableBool.h"
|
||||||
|
#include "configVariableInt.h"
|
||||||
|
|
||||||
|
NotifyCategoryDecl(iphone, EXPCL_PANDAGL, EXPTP_PANDAGL);
|
||||||
|
|
||||||
|
extern EXPCL_PANDAGL void init_libiphone();
|
||||||
|
extern "C" EXPCL_PANDAGL int get_pipe_type_iphone();
|
||||||
|
|
||||||
|
#endif // CONFIG_IPHONE_H
|
69
panda/src/iphone/config_iphone.mm
Normal file
69
panda/src/iphone/config_iphone.mm
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Filename: config_iphone.cxx
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "config_iphone.h"
|
||||||
|
#include "iPhoneGraphicsPipe.h"
|
||||||
|
#include "iPhoneGraphicsStateGuardian.h"
|
||||||
|
#include "iPhoneGraphicsWindow.h"
|
||||||
|
|
||||||
|
#include "graphicsPipeSelection.h"
|
||||||
|
#include "dconfig.h"
|
||||||
|
#include "pandaSystem.h"
|
||||||
|
|
||||||
|
|
||||||
|
Configure(config_iphone);
|
||||||
|
|
||||||
|
NotifyCategoryDef(iphone, "display");
|
||||||
|
|
||||||
|
ConfigureFn(config_iphone) {
|
||||||
|
init_libiphone();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: init_libiphone
|
||||||
|
// Description: Initializes the library. This must be called at
|
||||||
|
// least once before any of the functions or classes in
|
||||||
|
// this library can be used. Normally it will be
|
||||||
|
// called by the static initializers and need not be
|
||||||
|
// called explicitly, but special cases exist.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void
|
||||||
|
init_libiphone() {
|
||||||
|
static bool initialized = false;
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
IPhoneGraphicsPipe::init_type();
|
||||||
|
IPhoneGraphicsWindow::init_type();
|
||||||
|
IPhoneGraphicsStateGuardian::init_type();
|
||||||
|
|
||||||
|
GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
|
||||||
|
selection->add_pipe_type(IPhoneGraphicsPipe::get_class_type(), IPhoneGraphicsPipe::pipe_constructor);
|
||||||
|
|
||||||
|
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||||
|
ps->set_system_tag("OpenGL", "window_system", "IPhone");
|
||||||
|
ps->set_system_tag("OpenGL ES", "window_system", "IPhone");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_pipe_type_iphone
|
||||||
|
// Description: Returns the TypeHandle index of the recommended
|
||||||
|
// graphics pipe type defined by this module.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int
|
||||||
|
get_pipe_type_iphone() {
|
||||||
|
return IPhoneGraphicsPipe::get_class_type().get_index();
|
||||||
|
}
|
43
panda/src/iphone/eaglView.h
Normal file
43
panda/src/iphone/eaglView.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Filename: eaglView.h
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <OpenGLES/EAGL.h>
|
||||||
|
#import <OpenGLES/ES1/gl.h>
|
||||||
|
#import <OpenGLES/ES1/glext.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
|
||||||
|
The view content is basically an EAGL surface you render your OpenGL scene into.
|
||||||
|
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
||||||
|
*/
|
||||||
|
@interface EAGLView : UIView {
|
||||||
|
|
||||||
|
@private
|
||||||
|
/* The pixel dimensions of the backbuffer */
|
||||||
|
GLint backingWidth;
|
||||||
|
GLint backingHeight;
|
||||||
|
|
||||||
|
EAGLContext *context;
|
||||||
|
|
||||||
|
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
|
||||||
|
GLuint viewRenderbuffer, viewFramebuffer;
|
||||||
|
|
||||||
|
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
|
||||||
|
GLuint depthRenderbuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)presentView;
|
||||||
|
|
||||||
|
@end
|
130
panda/src/iphone/eaglView.mm
Normal file
130
panda/src/iphone/eaglView.mm
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
// Filename: eaglView.mm
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
#import <OpenGLES/EAGLDrawable.h>
|
||||||
|
|
||||||
|
#import "EAGLView.h"
|
||||||
|
|
||||||
|
#define USE_DEPTH_BUFFER 0
|
||||||
|
|
||||||
|
// A class extension to declare private methods
|
||||||
|
@interface EAGLView ()
|
||||||
|
|
||||||
|
@property (nonatomic, retain) EAGLContext *context;
|
||||||
|
|
||||||
|
- (BOOL) createFramebuffer;
|
||||||
|
- (void) destroyFramebuffer;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation EAGLView
|
||||||
|
|
||||||
|
@synthesize context;
|
||||||
|
|
||||||
|
|
||||||
|
// You must implement this method
|
||||||
|
+ (Class)layerClass {
|
||||||
|
return [CAEAGLLayer class];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (id)initWithFrame:(CGRect)frame {
|
||||||
|
|
||||||
|
if ((self = [super initWithFrame:frame])) {
|
||||||
|
// Get the layer
|
||||||
|
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||||
|
|
||||||
|
eaglLayer.opaque = YES;
|
||||||
|
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
|
||||||
|
|
||||||
|
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||||
|
|
||||||
|
if (!context || ![EAGLContext setCurrentContext:context]) {
|
||||||
|
[self release];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)presentView {
|
||||||
|
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)layoutSubviews {
|
||||||
|
[EAGLContext setCurrentContext:context];
|
||||||
|
[self destroyFramebuffer];
|
||||||
|
[self createFramebuffer];
|
||||||
|
// [self drawView];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (BOOL)createFramebuffer {
|
||||||
|
|
||||||
|
glGenFramebuffersOES(1, &viewFramebuffer);
|
||||||
|
glGenRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
|
|
||||||
|
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
|
||||||
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
|
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
|
||||||
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
|
||||||
|
|
||||||
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||||
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||||
|
|
||||||
|
if (USE_DEPTH_BUFFER) {
|
||||||
|
glGenRenderbuffersOES(1, &depthRenderbuffer);
|
||||||
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||||
|
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
|
||||||
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||||
|
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)destroyFramebuffer {
|
||||||
|
|
||||||
|
glDeleteFramebuffersOES(1, &viewFramebuffer);
|
||||||
|
viewFramebuffer = 0;
|
||||||
|
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
|
viewRenderbuffer = 0;
|
||||||
|
|
||||||
|
if(depthRenderbuffer) {
|
||||||
|
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
||||||
|
depthRenderbuffer = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
|
||||||
|
if ([EAGLContext currentContext] == context) {
|
||||||
|
[EAGLContext setCurrentContext:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
[context release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
173
panda/src/iphone/glesext_shadow.h
Normal file
173
panda/src/iphone/glesext_shadow.h
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
// Filename: glesext_shadow.h
|
||||||
|
// Created by: drose (09Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is designed to #define the extension symbols that aren't
|
||||||
|
// used for OpenGL ES, just so we can compile the glstuff module.
|
||||||
|
// These symbols have to be defined, even if they are never actually
|
||||||
|
// used at runtime; and it doesn't particularly matter what their
|
||||||
|
// defined value is.
|
||||||
|
|
||||||
|
#define GL_ACCUM_ALPHA_BITS 0
|
||||||
|
#define GL_ACCUM_BLUE_BITS 1
|
||||||
|
#define GL_ACCUM_BUFFER_BIT 2
|
||||||
|
#define GL_ACCUM_GREEN_BITS 3
|
||||||
|
#define GL_ACCUM_RED_BITS 4
|
||||||
|
#define GL_AUX_BUFFERS 5
|
||||||
|
#define GL_BACK_LEFT 6
|
||||||
|
#define GL_BACK_RIGHT 7
|
||||||
|
#define GL_BGR 8
|
||||||
|
#define GL_BLUE 9
|
||||||
|
#define GL_CLAMP 10
|
||||||
|
#define GL_CLAMP_TO_BORDER 11
|
||||||
|
#define GL_COLOR_ATTACHMENT0_EXT 12
|
||||||
|
#define GL_COLOR_ATTACHMENT1_EXT 13
|
||||||
|
#define GL_COLOR_INDEX 14
|
||||||
|
#define GL_COMPARE_R_TO_TEXTURE_ARB 15
|
||||||
|
#define GL_COMPILE 16
|
||||||
|
#define GL_COMPILE_AND_EXECUTE 17
|
||||||
|
#define GL_COMPRESSED_ALPHA 18
|
||||||
|
#define GL_COMPRESSED_LUMINANCE 19
|
||||||
|
#define GL_COMPRESSED_LUMINANCE_ALPHA 20
|
||||||
|
#define GL_COMPRESSED_RGB 21
|
||||||
|
#define GL_COMPRESSED_RGBA 22
|
||||||
|
#define GL_COMPRESSED_RGBA_FXT1_3DFX 23
|
||||||
|
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 24
|
||||||
|
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 25
|
||||||
|
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 26
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 27
|
||||||
|
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 28
|
||||||
|
#define GL_CONSTANT_ALPHA 29
|
||||||
|
#define GL_CONSTANT_COLOR 30
|
||||||
|
#define GL_COORD_REPLACE_ARB 31
|
||||||
|
#define GL_DECR_WRAP 32
|
||||||
|
#define GL_DEPTH_ATTACHMENT_EXT 33
|
||||||
|
#define GL_DEPTH_COMPONENT 34
|
||||||
|
#define GL_DEPTH_STENCIL_EXT 35
|
||||||
|
#define GL_DEPTH_TEXTURE_MODE_ARB 36
|
||||||
|
#define GL_DOUBLEBUFFER 37
|
||||||
|
#define GL_EYE_LINEAR 38
|
||||||
|
#define GL_EYE_PLANE 39
|
||||||
|
#define GL_FILL 40
|
||||||
|
#define GL_FRAMEBUFFER_COMPLETE_EXT 41
|
||||||
|
#define GL_FRAMEBUFFER_EXT 42
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 43
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 44
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 45
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 46
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 47
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 48
|
||||||
|
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 49
|
||||||
|
#define GL_FRONT_LEFT 50
|
||||||
|
#define GL_FRONT_RIGHT 51
|
||||||
|
#define GL_FUNC_ADD 52
|
||||||
|
#define GL_FUNC_REVERSE_SUBTRACT 53
|
||||||
|
#define GL_FUNC_SUBTRACT 54
|
||||||
|
#define GL_GREEN 55
|
||||||
|
#define GL_INCR_WRAP 56
|
||||||
|
#define GL_INDEX_BITS 57
|
||||||
|
#define GL_INTENSITY 58
|
||||||
|
#define GL_LEFT 59
|
||||||
|
#define GL_LIGHT_MODEL_LOCAL_VIEWER 60
|
||||||
|
#define GL_LINE 61
|
||||||
|
#define GL_MATRIX_INDEX_ARRAY_ARB 62
|
||||||
|
#define GL_MATRIX_PALETTE_ARB 63
|
||||||
|
#define GL_MAX 64
|
||||||
|
#define GL_MAX_3D_TEXTURE_SIZE 65
|
||||||
|
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 66
|
||||||
|
#define GL_MAX_DRAW_BUFFERS 67
|
||||||
|
#define GL_MAX_ELEMENTS_INDICES 68
|
||||||
|
#define GL_MAX_ELEMENTS_VERTICES 69
|
||||||
|
#define GL_MAX_PALETTE_MATRICES_ARB 70
|
||||||
|
#define GL_MAX_VERTEX_UNITS_ARB 71
|
||||||
|
#define GL_MIN 72
|
||||||
|
#define GL_MIRRORED_REPEAT 73
|
||||||
|
#define GL_MIRROR_CLAMP_EXT 74
|
||||||
|
#define GL_MIRROR_CLAMP_TO_BORDER_EXT 75
|
||||||
|
#define GL_MIRROR_CLAMP_TO_EDGE_EXT 76
|
||||||
|
#define GL_MODELVIEW0_ARB 77
|
||||||
|
#define GL_MODELVIEW1_ARB 78
|
||||||
|
#define GL_MODELVIEW2_ARB 79
|
||||||
|
#define GL_NONE 80
|
||||||
|
#define GL_NORMAL_MAP 81
|
||||||
|
#define GL_OBJECT_LINEAR 82
|
||||||
|
#define GL_OBJECT_PLANE 83
|
||||||
|
#define GL_ONE_MINUS_CONSTANT_ALPHA 84
|
||||||
|
#define GL_ONE_MINUS_CONSTANT_COLOR 85
|
||||||
|
#define GL_POINT 86
|
||||||
|
#define GL_POINT_SPRITE_ARB 87
|
||||||
|
#define GL_POLYGON_SMOOTH 88
|
||||||
|
#define GL_POLYGON_SMOOTH_HINT 89
|
||||||
|
#define GL_Q 90
|
||||||
|
#define GL_QUERY_COUNTER_BITS 91
|
||||||
|
#define GL_R 92
|
||||||
|
#define GL_R3_G3_B2 93
|
||||||
|
#define GL_RED 94
|
||||||
|
#define GL_REFLECTION_MAP 95
|
||||||
|
#define GL_RENDERBUFFER_EXT 96
|
||||||
|
#define GL_RGB12 97
|
||||||
|
#define GL_RGB5 98
|
||||||
|
#define GL_RGB5_A1 99
|
||||||
|
#define GL_RGB8 100
|
||||||
|
#define GL_RGBA12 101
|
||||||
|
#define GL_RGBA16F_ARB 102
|
||||||
|
#define GL_RGBA32F_ARB 103
|
||||||
|
#define GL_RGBA4 104
|
||||||
|
#define GL_RGBA8 105
|
||||||
|
#define GL_RGBA8_EXT 106
|
||||||
|
#define GL_RIGHT 107
|
||||||
|
#define GL_S 108
|
||||||
|
#define GL_SAMPLES_PASSED 109
|
||||||
|
#define GL_SPHERE_MAP 110
|
||||||
|
#define GL_STENCIL_ATTACHMENT_EXT 111
|
||||||
|
#define GL_STENCIL_TEST_TWO_SIDE_EXT 112
|
||||||
|
#define GL_STEREO 113
|
||||||
|
#define GL_STREAM_DRAW 114
|
||||||
|
#define GL_T 115
|
||||||
|
#define GL_TEXTURE_1D 116
|
||||||
|
#define GL_TEXTURE_3D 117
|
||||||
|
#define GL_TEXTURE_ALPHA_SIZE 118
|
||||||
|
#define GL_TEXTURE_BLUE_SIZE 119
|
||||||
|
#define GL_TEXTURE_BORDER_COLOR 120
|
||||||
|
#define GL_TEXTURE_COMPARE_FUNC_ARB 121
|
||||||
|
#define GL_TEXTURE_COMPARE_MODE_ARB 122
|
||||||
|
#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 123
|
||||||
|
#define GL_TEXTURE_COMPRESSION_HINT 124
|
||||||
|
#define GL_TEXTURE_CUBE_MAP 125
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 126
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 127
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 128
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 129
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 130
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 131
|
||||||
|
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 132
|
||||||
|
#define GL_TEXTURE_DEPTH 133
|
||||||
|
#define GL_TEXTURE_GEN_MODE 134
|
||||||
|
#define GL_TEXTURE_GEN_Q 135
|
||||||
|
#define GL_TEXTURE_GEN_R 136
|
||||||
|
#define GL_TEXTURE_GEN_S 137
|
||||||
|
#define GL_TEXTURE_GEN_T 138
|
||||||
|
#define GL_TEXTURE_GREEN_SIZE 139
|
||||||
|
#define GL_TEXTURE_HEIGHT 140
|
||||||
|
#define GL_TEXTURE_INTENSITY_SIZE 141
|
||||||
|
#define GL_TEXTURE_INTERNAL_FORMAT 142
|
||||||
|
#define GL_TEXTURE_LUMINANCE_SIZE 143
|
||||||
|
#define GL_TEXTURE_MAX_LEVEL 144
|
||||||
|
#define GL_TEXTURE_RED_SIZE 145
|
||||||
|
#define GL_TEXTURE_WIDTH 146
|
||||||
|
#define GL_TEXTURE_WRAP_R 147
|
||||||
|
#define GL_UNSIGNED_INT 148
|
||||||
|
#define GL_UNSIGNED_INT_24_8_EXT 149
|
||||||
|
#define GL_VERTEX_BLEND_ARB 150
|
||||||
|
#define GL_WEIGHT_ARRAY_ARB 151
|
||||||
|
#define GL_WEIGHT_SUM_UNITY_ARB 152
|
48
panda/src/iphone/glesgsg.h
Normal file
48
panda/src/iphone/glesgsg.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Filename: glesgsg.h
|
||||||
|
// Created by: drose (09Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef GLESGSG_H
|
||||||
|
#define GLESGSG_H
|
||||||
|
|
||||||
|
// This header file compiles a GSG for the limited subset of OpenGL
|
||||||
|
// that is OpenGL ES.
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "config_iphone.h"
|
||||||
|
|
||||||
|
#define GLP(name) gl##name
|
||||||
|
#define GLUP(name) glu##name
|
||||||
|
#define CLP(name) GLES##name
|
||||||
|
#define GLPREFIX_QUOTED "gl"
|
||||||
|
#define CLASSPREFIX_QUOTED "GLES"
|
||||||
|
#define GLSYSTEM_NAME "OpenGL ES"
|
||||||
|
#define CONFIGOBJ config_iphone
|
||||||
|
#define GLCAT iphone_cat
|
||||||
|
#define EXPCL_GL EXPCL_PANDAGL
|
||||||
|
#define EXPTP_GL EXPTP_PANDAGL
|
||||||
|
#define OPENGLES_1
|
||||||
|
#undef HAVE_GLU
|
||||||
|
|
||||||
|
#include <OpenGLES/ES1/gl.h>
|
||||||
|
#include <OpenGLES/ES1/glext.h>
|
||||||
|
|
||||||
|
#include "glesext_shadow.h"
|
||||||
|
|
||||||
|
#undef SUPPORT_IMMEDIATE_MODE
|
||||||
|
#define APIENTRY
|
||||||
|
#define APIENTRYP *
|
||||||
|
|
||||||
|
#include "glstuff_src.h"
|
||||||
|
|
||||||
|
#endif // GLESGSG_H
|
16
panda/src/iphone/glesgsg.mm
Normal file
16
panda/src/iphone/glesgsg.mm
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Filename: glesgsg.cxx
|
||||||
|
// Created by: drose (09Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "glesgsg.h"
|
||||||
|
#include "glstuff_src.cxx"
|
79
panda/src/iphone/iPhoneGraphicsPipe.h
Normal file
79
panda/src/iphone/iPhoneGraphicsPipe.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Filename: iPhoneGraphicsPipe.h
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IPHONEGRAPHICSPIPE_H
|
||||||
|
#define IPHONEGRAPHICSPIPE_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "graphicsPipe.h"
|
||||||
|
#import "viewController.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
class IPhoneGraphicsStateGuardian;
|
||||||
|
class PNMImage;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : IPhoneGraphicsPipe
|
||||||
|
// Description : This graphics pipe represents the interface for
|
||||||
|
// creating OpenGL graphics windows on the various
|
||||||
|
// IPHONE's.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EXPCL_PANDAGL IPhoneGraphicsPipe : public GraphicsPipe {
|
||||||
|
public:
|
||||||
|
IPhoneGraphicsPipe();
|
||||||
|
virtual ~IPhoneGraphicsPipe();
|
||||||
|
|
||||||
|
virtual string get_interface_name() const;
|
||||||
|
static PT(GraphicsPipe) pipe_constructor();
|
||||||
|
virtual PreferredWindowThread get_preferred_window_thread() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual PT(GraphicsOutput) make_output(const string &name,
|
||||||
|
const FrameBufferProperties &fb_prop,
|
||||||
|
const WindowProperties &win_prop,
|
||||||
|
int flags,
|
||||||
|
GraphicsEngine *engine,
|
||||||
|
GraphicsStateGuardian *gsg,
|
||||||
|
GraphicsOutput *host,
|
||||||
|
int retry,
|
||||||
|
bool &precertify);
|
||||||
|
|
||||||
|
public:
|
||||||
|
UIWindow *_window;
|
||||||
|
ControllerDemoViewController *_view_controller;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static IPhoneGraphicsPipe *_global_ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GraphicsPipe::init_type();
|
||||||
|
register_type(_type_handle, "IPhoneGraphicsPipe",
|
||||||
|
GraphicsPipe::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
|
friend class IPhoneGraphicsBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
142
panda/src/iphone/iPhoneGraphicsPipe.mm
Normal file
142
panda/src/iphone/iPhoneGraphicsPipe.mm
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Filename: iPhoneGraphicsPipe.mm
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "iPhoneGraphicsPipe.h"
|
||||||
|
#include "config_iphone.h"
|
||||||
|
#include "iPhoneGraphicsWindow.h"
|
||||||
|
#include "iPhoneGraphicsStateGuardian.h"
|
||||||
|
#include "pnmImage.h"
|
||||||
|
#include "graphicsOutput.h"
|
||||||
|
|
||||||
|
IPhoneGraphicsPipe *IPhoneGraphicsPipe::_global_ptr;
|
||||||
|
TypeHandle IPhoneGraphicsPipe::_type_handle;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsPipe::
|
||||||
|
IPhoneGraphicsPipe() {
|
||||||
|
CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ];
|
||||||
|
|
||||||
|
_window = [ [ UIWindow alloc ] initWithFrame: screenBounds ];
|
||||||
|
_view_controller = [ [ ControllerDemoViewController alloc ] init ];
|
||||||
|
|
||||||
|
[ _window addSubview:_view_controller.view ];
|
||||||
|
[ _window makeKeyAndVisible ];
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsPipe::
|
||||||
|
~IPhoneGraphicsPipe() {
|
||||||
|
[_view_controller release];
|
||||||
|
[_window release];
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::get_interface_name
|
||||||
|
// Access: Published, Virtual
|
||||||
|
// Description: Returns the name of the rendering interface
|
||||||
|
// associated with this GraphicsPipe. This is used to
|
||||||
|
// present to the user to allow him/her to choose
|
||||||
|
// between several possible GraphicsPipes available on a
|
||||||
|
// particular platform, so the name should be meaningful
|
||||||
|
// and unique for a given platform.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string IPhoneGraphicsPipe::
|
||||||
|
get_interface_name() const {
|
||||||
|
return "OpenGL ES";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::pipe_constructor
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: This function is passed to the GraphicsPipeSelection
|
||||||
|
// object to allow the user to make a default
|
||||||
|
// IPhoneGraphicsPipe.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(GraphicsPipe) IPhoneGraphicsPipe::
|
||||||
|
pipe_constructor() {
|
||||||
|
// There is only one IPhoneGraphicsPipe in the universe for any
|
||||||
|
// given application. Even if you ask for a new one, you just get
|
||||||
|
// the same one you had before.
|
||||||
|
if (_global_ptr == (IPhoneGraphicsPipe *)NULL) {
|
||||||
|
_global_ptr = new IPhoneGraphicsPipe;
|
||||||
|
_global_ptr->ref();
|
||||||
|
}
|
||||||
|
return _global_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::get_preferred_window_thread
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns an indication of the thread in which this
|
||||||
|
// GraphicsPipe requires its window processing to be
|
||||||
|
// performed: typically either the app thread (e.g. X)
|
||||||
|
// or the draw thread (Windows).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
GraphicsPipe::PreferredWindowThread
|
||||||
|
IPhoneGraphicsPipe::get_preferred_window_thread() const {
|
||||||
|
return PWT_app;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsPipe::make_output
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Creates a new window on the pipe, if possible.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(GraphicsOutput) IPhoneGraphicsPipe::
|
||||||
|
make_output(const string &name,
|
||||||
|
const FrameBufferProperties &fb_prop,
|
||||||
|
const WindowProperties &win_prop,
|
||||||
|
int flags,
|
||||||
|
GraphicsEngine *engine,
|
||||||
|
GraphicsStateGuardian *gsg,
|
||||||
|
GraphicsOutput *host,
|
||||||
|
int retry,
|
||||||
|
bool &precertify) {
|
||||||
|
if (!_is_valid) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPhoneGraphicsStateGuardian *iphonegsg = 0;
|
||||||
|
if (gsg != 0) {
|
||||||
|
DCAST_INTO_R(iphonegsg, gsg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// First thing to try: an IPhoneGraphicsWindow
|
||||||
|
|
||||||
|
if (retry == 0) {
|
||||||
|
if (((flags&BF_require_parasite)!=0)||
|
||||||
|
((flags&BF_refuse_window)!=0)||
|
||||||
|
((flags&BF_resizeable)!=0)||
|
||||||
|
((flags&BF_size_track_host)!=0)||
|
||||||
|
((flags&BF_can_bind_color)!=0)||
|
||||||
|
((flags&BF_can_bind_every)!=0)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return new IPhoneGraphicsWindow(engine, this, name, fb_prop, win_prop,
|
||||||
|
flags, gsg, host);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing else left to try.
|
||||||
|
return NULL;
|
||||||
|
}
|
75
panda/src/iphone/iPhoneGraphicsStateGuardian.h
Normal file
75
panda/src/iphone/iPhoneGraphicsStateGuardian.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Filename: iPhoneGraphicsStateGuardian.h
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IPHONEGRAPHICSSTATEGUARDIAN_H
|
||||||
|
#define IPHONEGRAPHICSSTATEGUARDIAN_H
|
||||||
|
//#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "glesgsg.h"
|
||||||
|
|
||||||
|
#include "iPhoneGraphicsWindow.h"
|
||||||
|
|
||||||
|
class IPhoneGraphicsWindow;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : IPhoneGraphicsStateGuardian
|
||||||
|
// Description :
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class IPhoneGraphicsStateGuardian : public GLESGraphicsStateGuardian {
|
||||||
|
public:
|
||||||
|
IPhoneGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||||
|
IPhoneGraphicsStateGuardian *share_with);
|
||||||
|
virtual ~IPhoneGraphicsStateGuardian();
|
||||||
|
virtual void reset();
|
||||||
|
|
||||||
|
void draw_resize_box();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void *get_extension_func(const char *prefix, const char *name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void describe_pixel_format(FrameBufferProperties &fb_props);
|
||||||
|
|
||||||
|
// We have to save a pointer to the GSG we intend to share texture
|
||||||
|
// context with, since we don't create our own context in the
|
||||||
|
// constructor.
|
||||||
|
PT(IPhoneGraphicsStateGuardian) _share_with;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GLint _shared_buffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GLESGraphicsStateGuardian::init_type();
|
||||||
|
register_type(_type_handle, "IPhoneGraphicsStateGuardian",
|
||||||
|
GLESGraphicsStateGuardian::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
|
friend class IPhoneGraphicsBuffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
99
panda/src/iphone/iPhoneGraphicsStateGuardian.mm
Normal file
99
panda/src/iphone/iPhoneGraphicsStateGuardian.mm
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
// Filename: iPhoneGraphicsStateGuardian.cxx
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "iPhoneGraphicsStateGuardian.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
#include "config_iphone.h"
|
||||||
|
#include "depthWriteAttrib.h"
|
||||||
|
#include "depthTestAttrib.h"
|
||||||
|
#include "textureAttrib.h"
|
||||||
|
#include "pnmImage.h"
|
||||||
|
#include "glesgsg.h"
|
||||||
|
|
||||||
|
#import <mach-o/dyld.h>
|
||||||
|
|
||||||
|
TypeHandle IPhoneGraphicsStateGuardian::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::get_extension_func
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns the pointer to the GL extension function with
|
||||||
|
// the indicated name. It is the responsibility of the
|
||||||
|
// caller to ensure that the required extension is
|
||||||
|
// defined in the OpenGL runtime prior to calling this;
|
||||||
|
// it is an error to call this for a function that is
|
||||||
|
// not defined.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void *IPhoneGraphicsStateGuardian::
|
||||||
|
get_extension_func(const char *prefix, const char *name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsStateGuardian::
|
||||||
|
IPhoneGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||||
|
IPhoneGraphicsStateGuardian *share_with) :
|
||||||
|
GLESGraphicsStateGuardian(engine, pipe),
|
||||||
|
_share_with(share_with)
|
||||||
|
{
|
||||||
|
_shared_buffer = 1011;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::Destructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsStateGuardian::
|
||||||
|
~IPhoneGraphicsStateGuardian() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::reset
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Resets all internal state as if the gsg were newly
|
||||||
|
// created.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsStateGuardian::
|
||||||
|
reset() {
|
||||||
|
GLESGraphicsStateGuardian::reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::draw_resize_box
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Draws an OSX-style resize icon in the bottom right
|
||||||
|
// corner of the current display region. This is
|
||||||
|
// normally done automatically at the end of each frame
|
||||||
|
// when the window is indicated as resizable, since the
|
||||||
|
// 3-D graphics overlay the normal, OS-drawn resize icon
|
||||||
|
// and the user won't be able see it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsStateGuardian::
|
||||||
|
draw_resize_box() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsStateGuardian::describe_pixel_format
|
||||||
|
// Access: Private
|
||||||
|
// Description: Fills in the fb_props member with the appropriate
|
||||||
|
// values according to the chosen pixel format.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsStateGuardian::
|
||||||
|
describe_pixel_format(FrameBufferProperties &fb_props) {
|
||||||
|
}
|
14
panda/src/iphone/iPhoneGraphicsWindow.I
Normal file
14
panda/src/iphone/iPhoneGraphicsWindow.I
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Filename: iPhoneGraphicsWindow.h
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
82
panda/src/iphone/iPhoneGraphicsWindow.h
Normal file
82
panda/src/iphone/iPhoneGraphicsWindow.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// Filename: iPhoneGraphicsWindow.h
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef IPHONEGRAPHICSWINDOW_H
|
||||||
|
#define IPHONEGRAPHICSWINDOW_H
|
||||||
|
|
||||||
|
#include "pandabase.h"
|
||||||
|
#include "graphicsWindow.h"
|
||||||
|
#include "buttonHandle.h"
|
||||||
|
#include "glesgsg.h"
|
||||||
|
#import "eaglView.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : IPhoneGraphicsWindow
|
||||||
|
// Description : An interface to the osx/ system for managing GL
|
||||||
|
// windows under X.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class IPhoneGraphicsWindow : public GraphicsWindow {
|
||||||
|
public:
|
||||||
|
IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||||
|
const string &name,
|
||||||
|
const FrameBufferProperties &fb_prop,
|
||||||
|
const WindowProperties &win_prop,
|
||||||
|
int flags,
|
||||||
|
GraphicsStateGuardian *gsg,
|
||||||
|
GraphicsOutput *host);
|
||||||
|
virtual ~IPhoneGraphicsWindow();
|
||||||
|
|
||||||
|
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
|
||||||
|
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
||||||
|
virtual void begin_flip();
|
||||||
|
virtual void end_flip();
|
||||||
|
virtual void process_events();
|
||||||
|
|
||||||
|
virtual void set_properties_now(WindowProperties &properties);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void close_window();
|
||||||
|
virtual bool open_window();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void system_close_window();
|
||||||
|
void system_set_window_foreground(bool foreground);
|
||||||
|
|
||||||
|
void set_pointer_in_window(int x, int y);
|
||||||
|
void set_pointer_out_of_window();
|
||||||
|
|
||||||
|
private:
|
||||||
|
EAGLView *_gl_view;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
GraphicsWindow::init_type();
|
||||||
|
register_type(_type_handle, "IPhoneGraphicsWindow",
|
||||||
|
GraphicsWindow::get_class_type());
|
||||||
|
}
|
||||||
|
virtual TypeHandle get_type() const {
|
||||||
|
return get_class_type();
|
||||||
|
}
|
||||||
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static TypeHandle _type_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "iPhoneGraphicsWindow.I"
|
||||||
|
|
||||||
|
#endif
|
264
panda/src/iphone/iPhoneGraphicsWindow.mm
Normal file
264
panda/src/iphone/iPhoneGraphicsWindow.mm
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
// Filename: iPhoneGraphicsWindow.mm
|
||||||
|
// Created by: drose (08Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// We include these system header files first, because there is a
|
||||||
|
// namescope conflict between them and some other header file that
|
||||||
|
// gets included later (in particular, TCP_NODELAY must not be a
|
||||||
|
// #define symbol for these headers to be included properly).
|
||||||
|
|
||||||
|
//#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#include <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#include "iPhoneGraphicsWindow.h"
|
||||||
|
#include "config_iphone.h"
|
||||||
|
#include "iPhoneGraphicsPipe.h"
|
||||||
|
#include "pStatTimer.h"
|
||||||
|
#include "glesgsg.h"
|
||||||
|
#include "keyboardButton.h"
|
||||||
|
#include "mouseButton.h"
|
||||||
|
#include "iPhoneGraphicsStateGuardian.h"
|
||||||
|
#include "iPhoneGraphicsPipe.h"
|
||||||
|
#include "throw_event.h"
|
||||||
|
#include "pnmImage.h"
|
||||||
|
#include "virtualFileSystem.h"
|
||||||
|
#include "config_util.h"
|
||||||
|
#include "pset.h"
|
||||||
|
#include "pmutex.h"
|
||||||
|
|
||||||
|
TypeHandle IPhoneGraphicsWindow::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsWindow::
|
||||||
|
IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||||
|
const string &name,
|
||||||
|
const FrameBufferProperties &fb_prop,
|
||||||
|
const WindowProperties &win_prop,
|
||||||
|
int flags,
|
||||||
|
GraphicsStateGuardian *gsg,
|
||||||
|
GraphicsOutput *host) :
|
||||||
|
GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
|
||||||
|
{
|
||||||
|
_gl_view = nil;
|
||||||
|
|
||||||
|
GraphicsWindowInputDevice device =
|
||||||
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard/mouse");
|
||||||
|
_input_devices.push_back(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::Destructor
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
IPhoneGraphicsWindow::
|
||||||
|
~IPhoneGraphicsWindow() {
|
||||||
|
if (_gl_view != nil) {
|
||||||
|
[ _gl_view release ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::set_pointer_in_window
|
||||||
|
// Access: Private
|
||||||
|
// Description: Indicates the mouse pointer is seen within the
|
||||||
|
// window.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
set_pointer_in_window(int x, int y) {
|
||||||
|
_input_devices[0].set_pointer_in_window(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::set_pointer_out_of_window
|
||||||
|
// Access: Private
|
||||||
|
// Description: Indicates the mouse pointer is no longer within the
|
||||||
|
// window.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
set_pointer_out_of_window() {
|
||||||
|
_input_devices[0].set_pointer_out_of_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::begin_frame
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// before beginning rendering for a given frame. It
|
||||||
|
// should do whatever setup is required, and return true
|
||||||
|
// if the frame should be rendered, or false if it
|
||||||
|
// should be skipped.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool IPhoneGraphicsWindow::
|
||||||
|
begin_frame(FrameMode mode, Thread *current_thread) {
|
||||||
|
PStatTimer timer(_make_current_pcollector);
|
||||||
|
|
||||||
|
begin_frame_spam(mode);
|
||||||
|
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||||
|
// not powered up .. just abort..
|
||||||
|
iphone_cat.info() << "no gsg\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gsg->reset_if_new();
|
||||||
|
_gsg->set_current_properties(&get_fb_properties());
|
||||||
|
|
||||||
|
return _gsg->begin_frame(current_thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::end_frame
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// after rendering is completed for a given frame. It
|
||||||
|
// should do whatever finalization is required.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
end_frame(FrameMode mode, Thread *current_thread) {
|
||||||
|
end_frame_spam(mode);
|
||||||
|
|
||||||
|
if (mode == FM_render) {
|
||||||
|
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||||
|
|
||||||
|
copy_to_textures();
|
||||||
|
|
||||||
|
_gsg->end_frame(current_thread);
|
||||||
|
|
||||||
|
if (_gl_view != nil) {
|
||||||
|
[_gl_view presentView];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::begin_flip
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// after end_frame() has been called on all windows, to
|
||||||
|
// initiate the exchange of the front and back buffers.
|
||||||
|
//
|
||||||
|
// This should instruct the window to prepare for the
|
||||||
|
// flip at the next video sync, but it should not wait.
|
||||||
|
//
|
||||||
|
// We have the two separate functions, begin_flip() and
|
||||||
|
// end_flip(), to make it easier to flip all of the
|
||||||
|
// windows at the same time.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
end_flip() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
begin_flip() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::close_window
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Closes the window right now. Called from the window
|
||||||
|
// thread.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
close_window() {
|
||||||
|
// system_close_window();
|
||||||
|
|
||||||
|
WindowProperties properties;
|
||||||
|
properties.set_open(false);
|
||||||
|
system_changed_properties(properties);
|
||||||
|
|
||||||
|
// release_system_resources(false);
|
||||||
|
_gsg.clear();
|
||||||
|
_active = false;
|
||||||
|
GraphicsWindow::close_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::open_window
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Opens the window right now. Called from the window
|
||||||
|
// thread. Returns true if the window is successfully
|
||||||
|
// opened, or false if there was a problem.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool IPhoneGraphicsWindow::
|
||||||
|
open_window() {
|
||||||
|
iphone_cat.info() << "open_window\n";
|
||||||
|
|
||||||
|
nassertr(_gsg == (GraphicsStateGuardian *)NULL, false);
|
||||||
|
|
||||||
|
_gl_view = [ [ EAGLView alloc ] initWithFrame:
|
||||||
|
[ [ UIScreen mainScreen ] applicationFrame ]
|
||||||
|
];
|
||||||
|
IPhoneGraphicsPipe *iphonepipe = DCAST(IPhoneGraphicsPipe, _pipe);
|
||||||
|
nassertr(iphonepipe != NULL, false);
|
||||||
|
|
||||||
|
iphonepipe->_view_controller.view = _gl_view;
|
||||||
|
[ _gl_view layoutSubviews ];
|
||||||
|
|
||||||
|
WindowProperties req_properties = _properties;
|
||||||
|
|
||||||
|
_gsg = new IPhoneGraphicsStateGuardian(_engine, _pipe, NULL);
|
||||||
|
|
||||||
|
_properties.set_foreground(true);
|
||||||
|
_properties.set_minimized(false);
|
||||||
|
_properties.set_open(true);
|
||||||
|
_is_valid = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::process_events
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Required event upcall, used to dispatch window and
|
||||||
|
// application events back into panda.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
process_events() {
|
||||||
|
GraphicsWindow::process_events();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: IPhoneGraphicsWindow::set_properties_now
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Applies the requested set of properties to the
|
||||||
|
// window, if possible, for instance to request a change
|
||||||
|
// in size or minimization status.
|
||||||
|
//
|
||||||
|
// The window properties are applied immediately, rather
|
||||||
|
// than waiting until the next frame. This implies that
|
||||||
|
// this method may *only* be called from within the
|
||||||
|
// window thread.
|
||||||
|
//
|
||||||
|
// The properties that have been applied are cleared
|
||||||
|
// from the structure by this function; so on return,
|
||||||
|
// whatever remains in the properties structure are
|
||||||
|
// those that were unchanged for some reason (probably
|
||||||
|
// because the underlying interface does not support
|
||||||
|
// changing that property on an open window).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void IPhoneGraphicsWindow::
|
||||||
|
set_properties_now(WindowProperties &properties) {
|
||||||
|
if (iphone_cat.is_debug()) {
|
||||||
|
iphone_cat.debug()
|
||||||
|
<< "------------------------------------------------------\n";
|
||||||
|
iphone_cat.debug()
|
||||||
|
<< "set_properties_now " << properties << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsWindow::set_properties_now(properties);
|
||||||
|
}
|
49
panda/src/iphone/main.mm
Normal file
49
panda/src/iphone/main.mm
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Filename: main.mm
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
extern "C" int main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
// This is weird and hacky. We have our main application not link
|
||||||
|
// statically with any Panda code. Instead, it dynamically loads in
|
||||||
|
// the required Panda code during main().
|
||||||
|
|
||||||
|
// We need to do this to avoid static-init ordering issues. Cocoa
|
||||||
|
// doesn't fully initialize all its low-level memory-allocation
|
||||||
|
// stuff until main begins or NSApplicationLoad() is called, but
|
||||||
|
// unfortunately NSApplicationLoad() doesn't exist on the IPhone.
|
||||||
|
// So on the IPhone, we have to be sure we don't make any calls into
|
||||||
|
// Panda (which might make a low-level Cocoa call) until after we
|
||||||
|
// have started main().
|
||||||
|
|
||||||
|
setenv("DYLD_LIBRARY_PATH", "/Applications/pview.app", 1);
|
||||||
|
|
||||||
|
void *answer = dlopen("/Applications/pview.app/libiphone_pview.dylib", RTLD_NOW | RTLD_LOCAL);
|
||||||
|
if (answer == (void *)NULL) {
|
||||||
|
std::cerr << "Couldn't load dylib\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
/* Call with the name of our application delegate class */
|
||||||
|
int retVal = UIApplicationMain(argc, argv, nil, @"ControllerDemoAppDelegate");
|
||||||
|
[pool release];
|
||||||
|
return retVal;
|
||||||
|
}
|
29
panda/src/iphone/pview_delegate.h
Normal file
29
panda/src/iphone/pview_delegate.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Filename: pview_delegate.h
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@class ControllerDemoViewController;
|
||||||
|
@interface ControllerDemoAppDelegate : NSObject <UIApplicationDelegate> {
|
||||||
|
NSTimer *animationTimer;
|
||||||
|
NSTimeInterval animationInterval;
|
||||||
|
}
|
||||||
|
@property (nonatomic, assign) NSTimer *animationTimer;
|
||||||
|
@property NSTimeInterval animationInterval;
|
||||||
|
|
||||||
|
- (void)startAnimation;
|
||||||
|
- (void)stopAnimation;
|
||||||
|
- (void)drawView;
|
||||||
|
|
||||||
|
@end
|
83
panda/src/iphone/pview_delegate.mm
Normal file
83
panda/src/iphone/pview_delegate.mm
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// Filename: pview_delegate.mm
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import "pview_delegate.h"
|
||||||
|
#import "viewController.h"
|
||||||
|
#include "config_iphone.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
#include "pandaFramework.h"
|
||||||
|
|
||||||
|
@implementation ControllerDemoAppDelegate
|
||||||
|
|
||||||
|
@synthesize animationTimer;
|
||||||
|
@synthesize animationInterval;
|
||||||
|
|
||||||
|
PandaFramework framework;
|
||||||
|
|
||||||
|
- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
||||||
|
int argc = 0;
|
||||||
|
char **argv = NULL;
|
||||||
|
framework.open_framework(argc, argv);
|
||||||
|
|
||||||
|
WindowFramework *window = framework.open_window();
|
||||||
|
if (window != (WindowFramework *)NULL) {
|
||||||
|
window->enable_keyboard();
|
||||||
|
window->setup_trackball();
|
||||||
|
framework.get_models().instance_to(window->get_render());
|
||||||
|
|
||||||
|
window->load_default_model(framework.get_models());
|
||||||
|
window->center_trackball(framework.get_models());
|
||||||
|
}
|
||||||
|
|
||||||
|
animationInterval = 1.0 / 60.0;
|
||||||
|
[self startAnimation];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)startAnimation {
|
||||||
|
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)stopAnimation {
|
||||||
|
self.animationTimer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)setAnimationTimer:(NSTimer *)newTimer {
|
||||||
|
[animationTimer invalidate];
|
||||||
|
animationTimer = newTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)setAnimationInterval:(NSTimeInterval)interval {
|
||||||
|
|
||||||
|
animationInterval = interval;
|
||||||
|
if (animationTimer) {
|
||||||
|
[self stopAnimation];
|
||||||
|
[self startAnimation];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawView {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
|
framework.do_frame(current_thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[self stopAnimation];
|
||||||
|
framework.close_framework();
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
22
panda/src/iphone/viewController.h
Normal file
22
panda/src/iphone/viewController.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Filename: viewController.h
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <UIKit/UITextView.h>
|
||||||
|
|
||||||
|
@interface ControllerDemoViewController : UIViewController {
|
||||||
|
// NSString *helloWorld, *woahDizzy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
78
panda/src/iphone/viewController.mm
Normal file
78
panda/src/iphone/viewController.mm
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// Filename: viewController.mm
|
||||||
|
// Created by: drose (10Apr09)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the revised BSD
|
||||||
|
// license. You should have received a copy of this license along
|
||||||
|
// with this source code in a file named "LICENSE."
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#import "viewController.h"
|
||||||
|
|
||||||
|
@implementation ControllerDemoViewController
|
||||||
|
|
||||||
|
- (id)init {
|
||||||
|
|
||||||
|
self = [ super init ];
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (self != nil) {
|
||||||
|
helloWorld = [ [ NSString alloc ] initWithString: @"Hello, World!" ];
|
||||||
|
woahDizzy = [ [ NSString alloc ] initWithString: @"Woah, I'm Dizzy!" ];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)loadView {
|
||||||
|
|
||||||
|
[ super loadView ];
|
||||||
|
|
||||||
|
/*
|
||||||
|
glView = [ [ EAGLView alloc ] initWithFrame:
|
||||||
|
[ [ UIScreen mainScreen ] applicationFrame ]
|
||||||
|
];
|
||||||
|
// [ glView startAnimation ];
|
||||||
|
|
||||||
|
self.view = glView;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
-(BOOL)shouldAutorotateToInterfaceOrientation:
|
||||||
|
(UIInterfaceOrientation)interfaceOrientation
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (void)didRotateFromInterfaceOrientation:
|
||||||
|
(UIInterfaceOrientation)fromInterfaceOrientation
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidLoad {
|
||||||
|
[ super viewDidLoad ];
|
||||||
|
/* Add custom post-load code here */
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didReceiveMemoryWarning {
|
||||||
|
[ super didReceiveMemoryWarning ];
|
||||||
|
/* Add custom low-memory code here */
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
/* Here, the objects we've allocated are released */
|
||||||
|
//[ helloWorld release ];
|
||||||
|
// [ woahDizzy release ];
|
||||||
|
// [ glView release ];
|
||||||
|
[ super dealloc ];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -257,9 +257,9 @@ const int LOCAL_CONNECT_BLOCKING = EINPROGRESS;
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <netinet/in_systm.h>
|
//#include <netinet/in_systm.h>
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#include <netinet/ip.h>
|
//#include <netinet/ip.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
#define TARGET osxdisplay
|
#define TARGET osxdisplay
|
||||||
#define LOCAL_LIBS \
|
#define LOCAL_LIBS \
|
||||||
display putil glgsg
|
display putil glgsg
|
||||||
|
|
||||||
|
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
|
||||||
|
|
||||||
#define INSTALL_HEADERS \
|
#define INSTALL_HEADERS \
|
||||||
config_osxdisplay.h \
|
config_osxdisplay.h \
|
||||||
@ -22,6 +23,6 @@
|
|||||||
config_osxdisplay.cxx osxGraphicsPipe.cxx osxGraphicsWindow.mm osxGraphicsStateGuardian.cxx osxGraphicsBuffer.cxx
|
config_osxdisplay.cxx osxGraphicsPipe.cxx osxGraphicsWindow.mm osxGraphicsStateGuardian.cxx osxGraphicsBuffer.cxx
|
||||||
|
|
||||||
#define SOURCES \
|
#define SOURCES \
|
||||||
osxDisplay.xx $[INCLUDED_SOURCES] $[INSTALL_HEADERS]
|
$[INSTALL_HEADERS] osxGraphicsWindow.mm
|
||||||
|
|
||||||
#end lib_target
|
#end lib_target
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#include "osxdisplay_composite1.mm"
|
|
@ -2,4 +2,3 @@
|
|||||||
#include "osxGraphicsBuffer.cxx"
|
#include "osxGraphicsBuffer.cxx"
|
||||||
#include "osxGraphicsPipe.cxx"
|
#include "osxGraphicsPipe.cxx"
|
||||||
#include "osxGraphicsStateGuardian.cxx"
|
#include "osxGraphicsStateGuardian.cxx"
|
||||||
#include "osxGraphicsWindow.mm"
|
|
Loading…
x
Reference in New Issue
Block a user