Bug 38 - swapBuffers switch
Summary: swapBuffers switch
Status: VERIFIED DUPLICATE of bug 25
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 1
Hardware: All all
: P3 normal
Assignee: Sven Gothel
Depends on:
Reported: 2003-09-09 01:13 CEST by Sven Gothel
Modified: 2015-09-27 03:15 CEST (History)
0 users

See Also:
SCM Refs:
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2010-03-24 07:45:51 CET

---- Reported by greggpatton 2003-09-09 13:13:33 ----

I am writing a patch modeler.  I use a method of picking that renders each 
primitive in a unique color.  I use glReadPixels to check the color under the cursor 
when the mouse is clicked.  If the color matches the color of a primitive then I 
know I clicked on the primitive.

I perform the rendering and color check without swapping buffers so the primitives 
will never appear on the screen in their "pick" color.  The whole process is never 
seen by the user.

Currently, jogl always swaps buffers at the end of rendering.  For this picking 
technique to work I have to be able to keep swapBuffers from occuring during the 

I ended up modifying 3 classes.

I added two methods to glCanvas and two methods and a boolean to glContext.

glCanvas methods,

  public boolean getNoSwapBuffers() {
      return context.getNoSwapBuffers();

  public void setNoSwapBuffers(boolean b) {

glContext methods and boolean,

    protected boolean noSwapBuffers;

    public boolean getNoSwapBuffers() {
        return noSwapBuffers;

    public void setNoSwapBuffers(boolean b) {
        noSwapBuffers = b;

Then, in WindowsOnscreenGLContext, I modified the swapBuffers method to look 
like this,

    protected synchronized void swapBuffers() throws GLException {
        if (!noSwapBuffers) {

            if (!WGL.SwapBuffers(hdc)) {
                throw new GLException("Error swapping buffers");


This allows me, via glCanvas, to keep the buffers from being swapped.  

I've been using jogl like this for several days with no problems.

---- Additional Comments From kbr 2004-04-08 12:01:04 ----

Will be fixed under issue #25.

*** This issue has been marked as a duplicate of 25 ***

--- Bug imported by sgothel@jausoft.com 2010-03-24 07:45 EDT  ---

This bug was previously known as _bug_ 38 at https://jogl.dev.java.net/bugs/show_bug.cgi?id=38