Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Trouble using swt GLCanvas on linux(Trouble using swt GLCanvas on linux)
Trouble using swt GLCanvas on linux [message #1022304] Thu, 21 March 2013 16:37 Go to next message
Steven Reynolds is currently offline Steven Reynolds
Messages: 2
Registered: March 2013
Junior Member
Hi

I am having trouble using the swt GLCanvas while on linux. If I use the provided Snippet209

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet209.java

I get 100% CPU utilization. The code is clearly structured to cause this high utilitzation. It does (from the main method)

display.asyncExec(new Runnable() {
int rot = 0;
public void run() {
// draw stuff
display.asyncExec(this);
}
});

Which means that it busy loops drawing as fast as it can.

When I try to convert the snippet to draw on PaintEvents, the opengl drawing that I do is immediatedly klobbered with something that draws plain black.

Does anyone have any luck using the swt GLCanvas on linux? Busy looping won't work for my application, most of the time, the display should be static and not consume CPU.


I've attached the PaintEvent version as DemoSWT2.

thanks
Steven

Re: Trouble using swt GLCanvas on linux [message #1022372 is a reply to message #1022304] Thu, 21 March 2013 19:10 Go to previous message
Steven Reynolds is currently offline Steven Reynolds
Messages: 2
Registered: March 2013
Junior Member
Oh, I have a solution. It looks like the swt GLCanvas is doing GTK double buffering. The associated gtk buffer swap hammered my drawing. With the following change, the code seems fine now

retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DemoSWT2.java 20 Mar 2013 22:13:41 -0000 1.7
+++ DemoSWT2.java 21 Mar 2013 18:49:58 -0000 1.8
@@ -9,6 +9,7 @@
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.internal.gtk.OS;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
@@ -83,7 +84,11 @@
GLData data = new GLData ();
data.doubleBuffer = true;
final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);
-
+ if (SWT.getPlatform().equals("gtk")) {
+ System.out.printf("Disabling GTK double buffering\n");
+ // TODO invoke reflectively?
+ OS.gtk_widget_set_double_buffered(canvas.handle,false);
+ }
canvas.setCurrent();
final GLContext context = GLDrawableFactory.getFactory().createExternalGLContext();

Previous Topic:Add Controls on Canvas at runtime
Next Topic:No Mouse-Events from an open Combo -Box
Goto Forum:
  


Current Time: Thu Oct 02 00:25:32 GMT 2014

Powered by FUDForum. Page generated in 0.02953 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software