Re: [Pyobjc-dev] PyObjC, OpenGL & XCode
Brought to you by:
ronaldoussoren
|
From: Black <py...@bl...> - 2008-09-28 03:24:00
|
I answered my own question. I don't entirely know why this would make a difference, but declaring an awakeFromNib function (even with no body other than pass) for some reason made the reshape and prepareOpenGL functions start to work. On Sep 27, 2008, at 11:35 AM, Black wrote: > > > Hopefully someone can help me out here. I am, as the subject suggests, > trying to get OpenGL and PyObjC to play nice. > > I have been successful in the past using the general format of the > OpenGL example included in the PyObjC distribution, but I have found > that I was having some trouble with modifying it due to the new > Interface Builder. As a result, I decided to give the new XCode based > approach a go. I created a new document based python application and > then generally followed the path of the golden triangle demo in the > OpenGL programming guide from the Apple dev center. That worked fine > and I got a nice triangle displaying. > > The problem comes when I start to get a little more involved. My view > is a subclass of NSOpenGLView and I want to be able to override the > useful methods like prepareOpenGL and reshape. However, as soon as I > add one of those functions (even if they don't do anything), the > application breaks and this shows up in the console: > > 9/27/08 11:26:08 AM Analyzer[19022] *** Terminating app due to > uncaught exception 'NSInternalInconsistencyException', reason: '/ > Volumes/Valhalla/candrews/src/analyzer/Analyzer/main.m:44 main() > PyRun_SimpleFile failed with file '/Volumes/Valhalla/candrews/src/ > analyzer/Analyzer/build/Release/Analyzer.app/Contents/Resources/ > main.py'. See console for errors.' > > 9/27/08 11:26:08 AM Analyzer[19022] Stack: ( > 2505597259, > 2473656571, > 2505596715, > 2505596778 > ) > > Anyone have any ideas? The relevant class looks like this: > > from Foundation import * > from AppKit import * > import objc > from OpenGL.GL import * > from OpenGL.GLU import * > > > > class AnalyzerOpenGLView(NSOpenGLView): > > > def prepareOpenGL(self): > """ > This is called once after the OpenGL context is created. Put > OpenGL > initialization stuff in here. > """ > glClearColor(1.0,1.0,1.0,1.0) > > > def drawRect_(self, ((x, y), (w, h))): > """ > This function is where all of the drawing should take place. > """ > #glClearColor(0,0,0,1.0) > glClear(GL_COLOR_BUFFER_BIT) > glMatrixMode(GL_MODELVIEW) > glLoadIdentity() > glColor3ub(255, 0, 0) > glBegin(GL_TRIANGLES) > glVertex3f( 0.0, 0.6, 0.0) > glVertex3f( -0.2, -0.3, 0.0) > glVertex3f( 0.2, -0.3 ,0.0) > > glEnd() > > glFlush() > > > > Thanks, > Black > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |