Re: [PyOpenCL] Compiling on Windows 7 x64 and GL interoperability
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Il 20/07/2010 05:17, Andreas Kloeckner ha scritto: Mostly applied. Actually, I tried to piece together something platform-independent based on your and Paolo's comments--can you please test the version in git? I'm guessing I broke it, but I'd like to fix it back up as soon as possible. Thanks for your contribution! Andreas With this patch the example is working at least on linux :) iff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py index 29ee8a1..468564c 100644 - --- a/examples/gl_interop_demo.py +++ b/examples/gl_interop_demo.py @@ -1,17 +1,7 @@ from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.raw.GL.VERSION.GL_1_5 import glBufferData as rawGlBufferData - - - -from OpenGL import platform - - - -try: - -import OpenGL.WGL - -except: - -pass - -try: - -import OpenGL.GLX - -except: - -pass +from OpenGL import platform, GLX, WGL import pyopencl as cl @@ -42,11 +32,11 @@ def initialize(): if sys.platform == linux2: props.append( (ctx_props.GLX_DISPLAY_KHR, - -OpenGl.GLX.glXGetCurrentDisplay())) +GLX.glXGetCurrentDisplay())) elif sys.platform == nt: props.append( (ctx_props.WGL_HDC_KHR, - -OpenGL.WGL.wglGetCurrentDC())) +WGL.wglGetCurrentDC())) ctx = cl.Context(properties=props) glClearColor(1, 1, 1, 1) This evening I'll try this code on windows at home - -- Paolo Simone Gasparello -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxFeh0ACgkQir9NfUtfsb+o+gCgjb8IHjrTNO6HlmYHcLBoAXYA em4Anj7ySWB/O/CYwmzVNcC6y1eJluEE =9mHA -END PGP SIGNATURE- ___ PyOpenCL mailing list PyOpenCL@tiker.net http://lists.tiker.net/listinfo/pyopencl
Re: [PyOpenCL] Compiling on Windows 7 x64 and GL interoperability
Sorry for the indentation of the patch (thunderbird issue!?!?) I attach a copy of the patch :) -- Paolo Simone Gasparello diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py index 29ee8a1..468564c 100644 --- a/examples/gl_interop_demo.py +++ b/examples/gl_interop_demo.py @@ -1,17 +1,7 @@ from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.raw.GL.VERSION.GL_1_5 import glBufferData as rawGlBufferData - -from OpenGL import platform - -try: -import OpenGL.WGL -except: -pass -try: -import OpenGL.GLX -except: -pass +from OpenGL import platform, GLX, WGL import pyopencl as cl @@ -42,11 +32,11 @@ def initialize(): if sys.platform == linux2: props.append( (ctx_props.GLX_DISPLAY_KHR, -OpenGl.GLX.glXGetCurrentDisplay())) +GLX.glXGetCurrentDisplay())) elif sys.platform == nt: props.append( (ctx_props.WGL_HDC_KHR, -OpenGL.WGL.wglGetCurrentDC())) +WGL.wglGetCurrentDC())) ctx = cl.Context(properties=props) glClearColor(1, 1, 1, 1) signature.asc Description: OpenPGP digital signature ___ PyOpenCL mailing list PyOpenCL@tiker.net http://lists.tiker.net/listinfo/pyopencl
Re: [PyOpenCL] Compiling on Windows 7 x64 and GL interoperability
Am 20.07.2010 05:17, schrieb Andreas Kloeckner: 3) To test OpenGL interoperability I changed examples/gl_interop_demo.py: --- diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py index dd4bf3e..4495804 100644 --- a/examples/gl_interop_demo.py +++ b/examples/gl_interop_demo.py [snip] -- I didn't know how to make these changes platform independent. Mostly applied. Actually, I tried to piece together something platform-independent based on your and Paolo's comments--can you please test the version in git? I'm guessing I broke it, but I'd like to fix it back up as soon as possible. The recent git version of PyOpenCl with gl_interop_demo.py now works on my System (Win 7 64bit, Python 2.6, VS 2008, AMD 5870), tested with 32 and 64 bit versions Gregor ___ PyOpenCL mailing list PyOpenCL@tiker.net http://lists.tiker.net/listinfo/pyopencl
Re: [PyOpenCL] Compiling on Windows 7 x64 and GL interoperability
Hi Gregor, On Wed, 14 Jul 2010 14:40:00 +0200, Gregor Thalhammer gregor.thalham...@gmail.com wrote: To enable OpenGL interoperability I had to change wrap_cl.hpp: --- diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index b12286c..d9c46ff 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -20,6 +20,10 @@ +#ifdef _WIN32 +#define NOMINMAX +#include windows.h +#endif @@ -2874,8 +2878,8 @@ namespace pyopencl -typedef CL_API_ENTRY cl_int CL_API_CALL - (*func_ptr_type)(const cl_context_properties * /* properties */, +typedef CL_API_ENTRY cl_int (CL_API_CALL + *func_ptr_type)(const cl_context_properties * /* properties */, --- Compiling gave a couple of warnings since size_t and int or cl_uint are different. Applied, thanks! 3) To test OpenGL interoperability I changed examples/gl_interop_demo.py: --- diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py index dd4bf3e..4495804 100644 --- a/examples/gl_interop_demo.py +++ b/examples/gl_interop_demo.py [snip] -- I didn't know how to make these changes platform independent. Mostly applied. Actually, I tried to piece together something platform-independent based on your and Paolo's comments--can you please test the version in git? I'm guessing I broke it, but I'd like to fix it back up as soon as possible. Thanks for your contribution! Andreas pgpwenj6N4xeW.pgp Description: PGP signature ___ PyOpenCL mailing list PyOpenCL@tiker.net http://lists.tiker.net/listinfo/pyopencl
Re: [PyOpenCL] Compiling on Windows 7 x64 and GL interoperability
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Il 14/07/2010 14:40, Gregor Thalhammer ha scritto: @@ -31,8 +32,10 @@ __kernel void generate_sin(__global float2* a) def initialize(): plats = cl.get_platforms() ctx_props = cl.context_properties -props = [(ctx_props.PLATFORM, plats[0]), (ctx_props.GL_CONTEXT_KHR, -GetCurrentContext()), (ctx_props.GLX_DISPLAY_KHR, GetCurrentDisplay())] +props = [(ctx_props.PLATFORM, plats[0]), + (ctx_props.GL_CONTEXT_KHR, platform.GetCurrentContext()), + #(ctx_props.GLX_DISPLAY_KHR, platform.GetCurrentDisplay()), + ] ctx = cl.Context(properties=props) glClearColor(1, 1, 1, 1) glColor(0, 0, 1) -- I didn't know how to make these changes platform independent. As far as I know the display parameter is platform dependent. It means that on linux you have to use the tuple: (ctx_props.GLX_DISPLAY_KHR, OpenGL.GLX.glXGetCurrentContext()) while on windows that tuple must be: (ctx_props.WGL_HDC_KHR, OpenGL.WGL.wglGetCurrentDC()) On OSX that is different again, but I don't know how :) To get the platform independent requirement, one may think to write a function that does OS sniffing and that chooses the proper tuple automatically. - -- Paolo Simone Gasparello -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw+40UACgkQir9NfUtfsb9zOACfcl855rwdWyggOWI8klmKQUF1 Ti4AoJrpT3QmfX2ufsHAFxuG6PkOYVYJ =8iXE -END PGP SIGNATURE- ___ PyOpenCL mailing list PyOpenCL@tiker.net http://lists.tiker.net/listinfo/pyopencl