Lisp HUG Maillist Archive

OS X, LW 6.0, OpenGL artifacts while resizing

Dear list,

I managed to solve my layout issues by using IB for my UI and dealing directly
with the objc and cocoa interfaces - so far, so good. Now, I have a window with
an NSOpenGLView embedded, which autoresizes while resizing the window.

The real version (done with Xcode) works properly.
When running the LW version (which, to my humble opinion, does not differ)
reveals some artifacts within the GL view, while resizing.

Both versions have the same NIB file.

Does LW intercept window update events ? I am really confused, at the moment...


Here is the view code from the Xcode version:
;----------------------------------------------------
- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code here.
    }
    return self;
}

- (void)prepareOpenGL
{
    glClearColor(0.3, 0.5, 0.0, 1.0);
    glViewport(0,0,100,120); /* adjust later */
    
}
- (void)drawRect:(NSRect)dirtyRect {
    // Drawing code here.
    glClear(GL_COLOR_BUFFER_BIT);
    glSwapAPPLE();
}
;----------------------------------------------------

And my CL version:
;----------------------------------------------------
(objc:define-objc-class gl-view ()
  ()
  (:objc-class-name "GLView")
  (:objc-superclass-name "NSOpenGLView"))

(fli:define-foreign-function (gl-swap-apple "glSwapAPPLE")
    ())

(defun gl-reshape (obj)
  (let ((rect (make-array 4)))
    (objc:invoke-into rect (objc:objc-object-pointer obj) "frame")
    (gl:clear-color 0.3 0.5 0.0 1.0)
    (gl:viewport 0 0 (aref rect 2) (aref rect 3))
    (gl:matrix-mode :projection)
    (gl:load-identity)
    (gl:ortho 0.0 (aref rect 2) 0.0 (aref rect 3) 0.0 1.0)))

(objc:define-objc-method ("update" :void)
    ((this gl-view))
  (gl-reshape this))

(objc:define-objc-method ("reshape" :void)
    ((this gl-view))
  (gl-reshape this))

(objc:define-objc-method ("prepareOpenGL" :void)
    ((this gl-view))
  (gl-reshape this))

(objc:define-objc-method ("drawRect:" :void)
    ((this gl-view)
     (rect objc:objc-object-pointer))
  (declare (ignore rect))
  (gl:clear :color-buffer)
  (gl-swap-apple))
;----------------------------------------------------



Re: OS X, LW 6.0, OpenGL artifacts while resizing

Walantis Giosis <wg <at> freelance-giosis.com> writes:

> 
> 
> Dear list,
> 
> I managed to solve my layout issues by using IB for my UI and dealing directly
> with the objc and cocoa interfaces - so far, so good. Now, I have a window with
> an NSOpenGLView embedded, which autoresizes while resizing the window.
> 
> The real version (done with Xcode) works properly.
> When running the LW version (which, to my humble opinion, does not differ)
> reveals some artifacts within the GL view, while resizing.
> 
> Both versions have the same NIB file.
> 
> Does LW intercept window update events ? I am really confused, at the moment...
> 
> Here is the view code from the Xcode version:
> ;----------------------------------------------------

> ;----------------------------------------------------
> 
> 

UPDATE: I found the issue with the artifacts and solved it:

I have to send an 'update' message to my GL context whenever my GL view
resizes, it's also mentioned in the NSOpenGLContext class reference... oh my :)

Now I can use properly layouted views, done with IB, while writing all
the code in CL (and it's even deliverable!)

Best regards,
Walantis





Re: OS X, LW 6.0, OpenGL artifacts while resizing


On Dec 16, 2010, at 7:56 AM, Walantis Giosis wrote:

> Now I can use properly layouted views, done with IB, while writing all
> the code in CL (and it's even deliverable!)

Great news!

warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro@me.com






Updated at: 2020-12-10 08:38 UTC