New topic: Cocoa and OpenGLSurface.Configure
<http://forums.realsoftware.com/viewtopic.php?t=46144> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message dbronson Post subject: Cocoa and OpenGLSurface.ConfigurePosted: Wed Dec 05, 2012 2:40 pm Joined: Mon Sep 21, 2009 9:33 am Posts: 24 I need to micromanage the details of the NSOpenGLPixelFormat used to create the NSOpenGLContext that I assume to be behind the Cocoa version of OpenGLSurface. I suspect this is what the "Configure" event is for. The documentation is a little thin, to say the least. Does anyone have a clue or an example of how to construct an appropriate memory block to return? Can I just create an appropriate NSOpenGLPixelFormat somehow and pass back a pointer to it or something? Top jranieri Post subject: Re: Cocoa and OpenGLSurface.ConfigurePosted: Wed Dec 05, 2012 2:55 pm Real Software Engineer Joined: Fri Jan 28, 2011 5:24 pm Posts: 124 dbronson wrote:I need to micromanage the details of the NSOpenGLPixelFormat used to create the NSOpenGLContext that I assume to be behind the Cocoa version of OpenGLSurface. I suspect this is what the "Configure" event is for. The documentation is a little thin, to say the least. Does anyone have a clue or an example of how to construct an appropriate memory block to return? Can I just create an appropriate NSOpenGLPixelFormat somehow and pass back a pointer to it or something? Great question and definitely something that could use more documentation. The MemoryBlock you pass back is treated as the value passed to -[NSOpenGLPixelFormat initWithAttributes:]. If you don't implement this event (or pass back nil), you get some default format attributes we create from the OpenGLSurface's properties. If we fail to create a valid NSOpenGLPixelFormat (or a valid NSOpenGLContext from that), we fire the error event. If you return true from that, we go back to the beginning of this whole process. _________________ Joe Ranieri Mac Frameworks & Compiler REAL Software, Inc. Top dbronson Post subject: Re: Cocoa and OpenGLSurface.ConfigurePosted: Wed Dec 05, 2012 3:45 pm Joined: Mon Sep 21, 2009 9:33 am Posts: 24 So, I can probably bang together an NSOpenGLPixelFormat* using declares, but then how do I return it as a memory block? Do I have to coerce it somehow, or can I just pass back the pointer? Top jranieri Post subject: Re: Cocoa and OpenGLSurface.ConfigurePosted: Wed Dec 05, 2012 3:52 pm Real Software Engineer Joined: Fri Jan 28, 2011 5:24 pm Posts: 124 dbronson wrote:So, I can probably bang together an NSOpenGLPixelFormat* using declares, but then how do I return it as a memory block? Do I have to coerce it somehow, or can I just pass back the pointer? Ah no, you don't need to create an NSOpenGLPixelFormat object. You need to create a MemoryBlock that contains an array (in the C sense) of NSOpenGLPixelFormatAttributes (Int32s). For example, to do something simple: dim attrs as new MemoryBlock( 28 ) attrs.Int32Value( 0 ) = 8 // NSOpenGLPFAColorSize attrs.Int32Value( 4 ) = 24 attrs.Int32Value( 8 ) = 12 // NSOpenGLPFADepthSize attrs.Int32Value( 12 ) = 24 attrs.Int32Value( 16 ) = 13 // NSOpenGLPFAStencilSize attrs.Int32Value( 20 ) = 8 attrs.Int32Value( 24 ) = 0 // terminates the array return attrs _________________ Joe Ranieri Mac Frameworks & Compiler REAL Software, Inc. Top dbronson Post subject: Re: Cocoa and OpenGLSurface.ConfigurePosted: Wed Dec 05, 2012 4:05 pm Joined: Mon Sep 21, 2009 9:33 am Posts: 24 Thanks! I'll give it a shot as soon as I have a spare moment. If I get it to work, I'll post it here, and voila - documentation/example for you. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
