Re: [Pyobjc-dev] PyObjC and NSOpenGLView
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2010-01-03 17:27:14
|
On 3 Jan, 2010, at 16:46, Tobias Wood wrote: > Hello, > First off, sorry if this is the wrong place to post this - I couldn't find a PyObjC users list. If there's a better place to post please let me know and I'll send it there. This list is fine, an other list where PyObjC and other mac users hang out is the pythonmac-sig list. > > I've been trying to rewrite a game of mine using PyObjC - it's currently a horrible mess of Objective-C and C++ and I think PyObjC will be a much better infrastructure. Unfortunately I'm failing at the first hurdle - implementing a subclass of NSOpenGLView working by reimplementing my Objective-C version line-by-line in PyObjC. I've got two problems with it: > 1) The NSOpenGLView seems to interfere with the drawing of the Window it's in. When I don't have the NSOpenGLView instantiated in Interface Builder, I'll get the standard grey/silver background in the window. Once I add the NSOpenGLView, the Window is suddenly filled in white (The OpenGLView is drawn correctly on top). > 2) If I try to use the GLU function gluPerspective I get the following unexpected error (My subclass is called WorldView, code is at the end of this message): > ValueError: NSInvalidArgumentException - Unlocking Focus on wrong view (<NSThemeFrame:0x2c11580>), expected <WorldView: 0x4e7850>) > Should I not be subclassing NSOpenGLView? Should I be subclassing something else? I've included my current sub-class below. I don't use NSOpenGLView myself, maybe someone else knows the answer. Does the OpenGL example work for you? <http://pyobjc.sourceforge.net/examples/pyobjc-framework-Cocoa/OpenGL/OpenGLDemo/index.html> > > On a different note, when I started this project I was intending to write the interface mainly in Objective-C and the game engine in Python. However the PyObjC examples all seem to be geared towards writing everything in Python. Is there a recommended way to call Python-implemented objects from Objective-C code? The only way I could find to do it is something along the lines of: > > id someObject; > Class PythonClass = NSClassFromString(@"PythonName"); > someObject = [PythonClass new]; > > but I was wondering if there was any other way? That's basicly the best way, you could also add an Objective-C class where the Python code can register objects or classes. Ronald |