bugGNUstep - Bugs: bug #22706, NSOpenGLView broken ?

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22706: NSOpenGLView broken ?

Submitted by:  Xavier Glattard <xgl>
Submitted on:  Sun 23 Mar 2008 07:42:01 PM UTC  
 
Category: Gui/AppKitSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Fred Kiefer <FredKiefer>
Open/Closed: In Test

Tue 01 Apr 2008 07:53:04 AM UTC, comment #5:

You're right : all examples of GLView use are different !

Two versions of BasicOpenGLView.m :
http://developer.apple.com/samplecode/CocoaGL/listing4.html
http://developer.apple.com/samplecode/Custom_Cocoa_OpenGL/listing2.html
And (with no prepareOpenGL) :
http://developer.apple.com/samplecode/BoingX/listing4.html
But :
http://developer.apple.com/samplecode/OpenGLFilterBasicsCocoa/listing1.html

In Cocoa drawing guide :
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/QuartzOpenGL/chapter_10_section_3.html#//apple_ref/doc/uid/TP40003290-CH211-DontLinkElementID_93
<< As with other views, you use your OpenGL views drawRect: method to draw the content of your view. When your drawRect: method is invoked, the environment is automatically configured for drawing using the OpenGL graphics context associated with your view. >>

I think most examples don't use NSOpenGLView properly : they use it as an ordinary View, which it is not.

In the page you cite Apple gives a sample OpenGLView implementation. It's not exactly like mine, but they use [lockFocus] and [prepareOpenGL].

About [prepareOpenGL] it is said :
<< This method is called only once after the OpenGL context is made the current context. >>
I think this should be done as soon as possible, ie when the context is set in [setOpenGLContext]. But it might be done later in [lockFocus] as it is not supposed to be used before. I dont know.
The sample implementation never sends [prepareOpenGL] but it is said : << after creating the NSOpenGLContext object >>

Really looks like they aren't sure :-)

Xavier Glattard <xgl>
Project Member
Mon 31 Mar 2008 11:44:59 PM UTC, comment #4:

I just found
http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_drawing/chapter_3_section_3.html#//apple_ref/doc/uid/TP40001987-CH404-DontLinkElementID_15

here they are using a NSOpenGLView subclass without makeCurrentContext in the drawRect: method. Maybe doing that call in lockFocus (or our replacement) might be correct.
But just in the next example on that page the call that method again. Looks like they aren't sure either :-(

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Mon 31 Mar 2008 10:41:06 PM UTC, comment #3:

I have some doubts about that two changes you just made.

Moving the attaching of the view to the context into
setOpenGLContext: looks wrong, as the specification says that you will have to call setView: after this call. Moving it into
openGLContext would seem correcter to me. In the later method you have created a memory leak, the allocated context never gets release.

As far as I can tell the move of the call to makeCurrentContext from the example code into the _lockFocusInContext:inRect: method is also wrong, but here I am not that sure. All the examples for using NSOpenGLView (or rather a subclass of it) that I have found up to now use as a first line in drawRect: the following:
[[self openGLContext] makeCurrentContext];

This does not prove that we should not call this method in lockFocus, but what reason do you have to think we should do so?

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Mon 31 Mar 2008 09:24:13 PM UTC, comment #2:

Thank you for the clue :-)

As you can read in the specs about [NSView display] :
<< Displays the receiver and all its subviews if possible, invoking each the NSView methods lockFocus, drawRect:, and unlockFocus as necessary. >>

So at least [lockFocus] must be send, if not [lockFocusInRect:]
Dont you think so ?

I've just tried with [_lockFocusInContext:inRect:] and all seems to run fine. But I think this is a not so better hack.

Anyway your right : NSOpenGLView had to be fixed to be closer to the specs. I've just made some changes, but these need some test. But IMHO [lockFocus] is THE place where the context is made current. This must be done before [drawRect:]

Thanks again

Xavier Glattard <xgl>
Project Member
Mon 31 Mar 2008 02:43:42 PM UTC, comment #1:

This should be fixed in SVN now.

Due to some changes I made over a year ago lockFocusInRect: is no longer called on subviews. I replaced this method on NSOpenGLView with canDraw, which still gets called. Over all it would be better not to rely on any such call and move the attaching of the view into openGLContext. This would also seem closer to the specification to me.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Sun 23 Mar 2008 07:42:01 PM UTC, original submission:

Hi

OpenGL is broken : neither examples/gui/MyGL nor gnustep-gears run properly. On X11/linux the GLX context complains about not to be bind to a window, and on winXP the programs fail silently.

[NSOpenGLView lockFocusInRect:] seems not to be send.

Any idea ?

Xavier

Xavier Glattard <xgl>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by FredKiefer (Posted a comment)
  • -unavailable- added by xgl (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 31 Mar 2008 02:43:42 PM UTCFredKieferStatusNone=>Fixed
      Assigned toNone=>FredKiefer
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1