Esempio n. 1
0
#!/usr/bin/python
import os, sys, array, time, ctypes

if __name__ == '__main__':	# standalone from python2
	sys.path.append('../../rpythonic')
	import rpythonic
	rpythonic.set_pypy_root( '../../pypy' )
	import pypy.rpython.lltypesystem.rffi as rffi
	from pypy.rlib import streamio

else:	# from inside blender
	import rpythonic

################################
rpy = rpythonic.RPython( 'blender2ogre' )


class Mesh(object):

    def __init__(self, data):
        self.numVerts = N = len( data.vertices )
        self.numFaces = Nfaces = len(data.faces)

        self.vertex_positions = (ctypes.c_float * (N * 3))()
        data.vertices.foreach_get( 'co', self.vertex_positions )
        v = self.vertex_positions

        self.vertex_normals = (ctypes.c_float * (N * 3))()
        data.vertices.foreach_get( 'normal', self.vertex_normals )

        self.faces = (ctypes.c_uint * (Nfaces * 4))()
Esempio n. 2
0
#!/usr/bin/python
import os, sys
sys.path.append('..')
import rpythonic
#rpythonic.set_cache( '../cache' )
rpythonic.set_pypy_root('../../pypy')
################################

## requires Android SDK ##
SDK_ROOT = '../../android-sdk-linux_x86/'
assert os.path.isdir(SDK_ROOT)
SDK_TOOLS = os.path.join(SDK_ROOT, 'tools')
## requires Android NDK
NDK_PLATFORM_VERSION = 'android-9'  # change this to match your NDK version
NDK_ROOT = '../../android-ndk-r5b/'  # change this to point to your NDK installation
assert os.path.isdir(NDK_ROOT)
NDK_ROOT = os.path.abspath(NDK_ROOT)
NDK_PLATFORM = os.path.join(NDK_ROOT,
                            'platforms/%s/arch-arm/' % NDK_PLATFORM_VERSION)
assert os.path.isdir(NDK_PLATFORM)
NDK_LIBS = os.path.join(NDK_PLATFORM, 'usr/lib/')
assert os.path.isdir(NDK_LIBS)

USR = os.path.join(NDK_PLATFORM, 'usr')
USR_INC = os.path.join(USR, 'include')
USR_LIB = os.path.join(USR, 'lib')

#for name in 'android EGL GLES GLES2 SLES'.split():

## for stdarg.h
includes = [
Esempio n. 3
0
#!/usr/bin/python
import os, sys, time

if ".." not in sys.path:
    sys.path.append("..")
import rpythonic

rpythonic.set_pypy_root("../../pypy")
rpythonic.set_android_sdk_root("../../android-sdk-linux_x86/")
rpythonic.set_android_ndk_root("../../android-ndk-r5/")
rpy = rpythonic.RPython("android")

gl = rpy.rimport("GLES", namespace=globals())
e = rpy.rimport("EGL")
glue = rpy.rimport("android_native_app_glue")

## API ##
get_app_state = rffi.llexternal("rpythonic_get_app_state", [], lltype.Ptr(glue.android_app))
setup_glue = rffi.llexternal("rpythonic_setup_glue", [lltype.Ptr(glue.android_app)], rffi.VOIDP)
swap_buffers = rffi.llexternal("rpythonic_swap_buffers", [rffi.VOIDP], rffi.INT)
mainloop = rffi.llexternal("rpythonic_mainloop", [rffi.VOIDP], lltype.Void)

# /*
# * Send a simple string to the log.
# */
# int __android_log_write(int prio, const char *tag, const char *text);
log = rffi.llexternal("__android_log_write", [rffi.INT, rffi.CCHARP, rffi.CCHARP], rffi.INT)


def rprint(s, tag="rpythonic"):
    log(5, tag, s)  # 3 is debug level, 4 is info level, 5 is warn level