[cells-devel] Re: glutSwapBuffers bug?

Kenneth Tilton ktilton at nyc.rr.com
Sat Nov 13 18:53:55 UTC 2004


On Nov 13, 2004, at 12:52 PM, Geoff Stahl wrote:

> I woill have to inspect the code on this.  Top of my head there should 
> be no reason to do a flush then swap or a swap then flush as the swap 
> should implicitly flush (nothing that you will in the code as this 
> will happen in the engine) all pending commands.  I will have to 
> refresh my memory on how single buffered contexts are handled by GLUT 
> to know if a glutSwap should automatically be a glFlush.
>
> Feel free to write a bug with a short sample of the improper behavior 
> that you are seeing as the bottom line is we should be in line with 
> the latest official glut spec (not freeglut).

First of all, I understand completely that Freeglut is beside the 
point. I just mentioned that FWIW. Also FWIW, the Freeglut crowd is 
rather obsessive about being compatible right down to the bugs with the 
original Glut, and so they do study the original pretty closely. 
Anyway...

Write a bug? Uh, does Lisp count? <g> Here is the glutDisplayFunc, 
which sometimes works and sometimes does not, as described below:

(ccl::defcallback display-cb (:void)
   (let ((bounds #2a((0.0 0.0) (250.0 500.0) (500.0 0.0)))
	(point #(75.0 50.0)))
     (declare (ignorable bounds point))
     (#_glClearColor 0.0 1.0 0.0 1.0)
     (#_glClear #$GL_COLOR_BUFFER_BIT)

     ;; everything above always runs -------------
    ;; everything below was tried in diff combos, results below code

   ;; option "glBegin/glEnd"
     (progn
       (#_glBegin #$GL_POINTS)
       (dotimes (i 5000)
         (let ((j (random 3)))
           (setf (aref point 0) (/ (+ (aref point 0) (aref bounds j 0)) 
2.0)
                 (aref point 1) (/ (+ (aref point 1) (aref bounds j 1)) 
2.0))
           (#_glVertex2f (aref point 0) (aref point 1))))
       (#_glEnd))

    ;; option "glFlush"
     ;; (#_glFlush)

    ;; option "glutSwapBuffers"
     ;; (#_glutSwapBuffers)
     ))

Either of these next two are sufficient, but only one is necessary to 
produce something other than a blank screen:

     "glBegin/End" green screen with pretty picture
     "glFlush" green screen

Bug: option "glutSwapBuffers" alone will not produce the green 
background.

To be clear, if none of the options runs I also do not get the green 
background.

I was thrown for a bit while preparing this when the glFlush call 
proved unnecessary as long as the big vertex sequence was operational. 
Perhaps glEnd does a glFlush? ie, maybe if there were some small gl 
calls after the glEnd they would not take effect without the glFlush. 
Anyway, I left that in purely in the interest of full disclosure. You 
can chop that whole sequence and have a simpler report.

btw, if you are curious, i can steer you to a nice downloadable which 
neatly installs OpenMCL along with Emacs and nice interface from Emacs 
to OpenMCL. With that and about three instructions you could run 
working/nonworking code yourself.

cheers, kenny






More information about the cells-devel mailing list