Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gfacciol committed May 27, 2015
1 parent 2aab1f9 commit f52766e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
11 changes: 8 additions & 3 deletions glfw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@
lib_basename = 'glfw-3.0.4.bin.WIN32/lib-mingw/glfw3'
elif sys.platform == 'darwin':
lib_ext = '.dylib'
lib_basename = 'libglfw'
else:
lib_basename = 'glfw-3.0.4.bin.MAC64/libglfw'
else: # linux?
lib_ext = '.so'
lib_basename = 'libglfw'
here = os.path.dirname(__file__)
libfile = os.path.join(here, lib_basename+lib_ext)

# if the precompiled libs are not valid reset lib filename and build
if not os.path.exists(libfile):
lib_basename = 'libglfw'
libfile = os.path.join(here, lib_basename+lib_ext)

if os.path.exists(libfile):
_glfw_file = libfile
else:
else:
print 'BUILDING GLFW...'
os.system('mkdir -p %s/build; cd %s/build; cmake -DBUILD_SHARED_LIBS=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF ../glfw_src; make; cp src/libglfw%s %s '%(here,here, lib_ext, here))
print 'CLEANING BUILD...'
Expand Down
Binary file added glfw/glfw-3.0.4.bin.MAC64/libglfw.dylib
Binary file not shown.
11 changes: 11 additions & 0 deletions piio/compile.mac64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#WITHOUT EXR STATICALLY LINKED
#gcc-4.8 -std=c99 -c iio.c -I/usr/local/Cellar/libpng/1.5.14/include/
#gcc-4.8 -std=c99 -c freemem.c
#gcc -dynamiclib -arch x86_64 -o MAC64/libiio.so iio.o freemem.o /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/local/Cellar/jpeg/8d/lib/libjpeg.a /usr/local/Cellar/libtiff/4.0.3/lib/libtiff.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a

#WITH EXR STATICALLY LINKED
gcc-4.8 -std=c99 -c iio.c -I/usr/local/Cellar/libpng/1.5.14/include/ -I/usr/local/include/OpenEXR -DI_CAN_HAS_LIBEXR -O3 -std=c99 -funroll-loops -Wno-unused -DNDEBUG
gcc-4.8 -std=c99 -c freemem.c -O3
gcc -dynamiclib -arch x86_64 -o MAC64/libiio.so iio.o freemem.o /usr/local/lib/libImath.a /usr/local/lib/libIlmImf.a /usr/local/lib/libIex.a /usr/local/lib/libHalf.a /usr/local/lib/libIlmThread.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a /usr/local/lib/libtiff.a /usr/local/lib/libjpeg.a /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/local/Cellar/zlib/1.2.8/lib/libz.a /usr/local/lib/libtiff.a /usr/local/lib/libjpeg.a /usr/local/Cellar/libpng/1.5.18/lib/libpng.a /usr/lib/libstdc++-static.a


8 changes: 7 additions & 1 deletion piio/iio.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,13 @@ static void inplace_flip_vertical(struct iio_image *x)

static void inplace_transpose(struct iio_image *x)
{
fail("inplace transpose not implemented");
int w = x->sizes[0];
int h = x->sizes[1];
if (w != h)
fail("rectangular inplace transpose not implemented");
for (int i = 0; i < w; i++)
for (int j = 0; j < i; j++)
inplace_swap_pixels(x, i, j, j, i);
}

static void inplace_reorient(struct iio_image *x, int orientation)
Expand Down
14 changes: 12 additions & 2 deletions piio/piio.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,22 @@
lib_basename = 'WIN64/iio'
else:
lib_basename = 'WIN32/iio'
else: # linux and osx
elif sys.platform.startswith('darwin'): # precompiled osx intel 64 bits
lib_basename = 'MAC64/libiio'
lib_ext = '.so'
else: # linux
lib_basename = 'libiio'
lib_ext = '.so'

libiiofile= os.path.join(here, lib_basename+lib_ext)

### fallback if precompiled libraries are not usable
try:
os.stat(libiiofile)
except OSError:
lib_basename = 'libiio'
lib_ext = '.so'
libiiofile= os.path.join(here, lib_basename+lib_ext)

### HACK TO BUILD libiio ON THE FLY
try:
Expand Down Expand Up @@ -162,7 +172,7 @@ def read_tiled_buffers(filename):
# generate the interlan memory to copy the tile
data = ctypes.ARRAY(ctypes.c_float, N)()
libiio.copy_tile(ptr, w, h, nch, data, x, y, ww, hh, out_nch) # only allow up to 4 channels
tiles.append( (data, x, y, ww,hh, out_nch) )
tiles.append( [data, x, y, ww,hh, out_nch, -1] ) # -1 (the last field is a placeholder for the textureID)


# free the memory
Expand Down
16 changes: 8 additions & 8 deletions v.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def keyboard_callback(window, key, scancode, action, mods):
glfw.glfwSetWindowShouldClose(window,1)
global x0,y0,w0,h0
print(x0,y0,w0,h0)
exit(0)
sys.exit(0)



Expand Down Expand Up @@ -774,8 +774,8 @@ def display( window ):
# ideally winx,winy should be equal to D.w,D.h BUT if the
# image is larger than the screen glutReshapeWindow(D.w,D.h)
# will fail and winx,winy will be truncated to the size of the screen
# winx, winy= glfw.glfwGetFramebufferSize(window)
winx, winy= glfw.glfwGetWindowSize(window)
winx, winy= glfw.glfwGetFramebufferSize(window)
# winx, winy= glfw.glfwGetWindowSize(window)
V.winx,V.winy=winx,winy

glViewport(0, 0, winx, winy);
Expand Down Expand Up @@ -998,7 +998,7 @@ def main():
from os import stat
stat(sys.argv[1])
except OSError:
exit(1)
sys.exit(1)
# otherwise use stdin as input (because it should be a pipe)
else:
sys.argv.append('-')
Expand All @@ -1017,8 +1017,8 @@ def main():
# as we must find out the image size before creating the window
D.imageBitmapTiles,D.w,D.h,D.nch,D.v_min,D.v_max = load_image(I1)
D.filename = I1
if I1 != '-':
from os import stat
from os import stat, path
if I1 != '-' and path.exists(I1):
D.mtime = (stat(I1).st_mtime)
V.data_min, V.data_max= D.v_min,D.v_max
V.reset_scale_bias()
Expand All @@ -1038,7 +1038,7 @@ def main():
from os import getcwd,chdir
savepath = getcwd()
if not glfw.glfwInit():
exit()
sys.exit(1)
chdir(savepath)


Expand All @@ -1053,7 +1053,7 @@ def main():

if not window:
glfw.glfwTerminate()
exit()
sys.exit(1)

# Make the window's context current
glfw.glfwMakeContextCurrent(window)
Expand Down

0 comments on commit f52766e

Please sign in to comment.