Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 60138 Details for
Bug 176150
[OpenGL] org.eclipse.swt.opengl.*'s performance is poor on Windows platform
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
test program by JOGL
Snippet209.java (text/plain), 5.40 KB, created by
supertat
on 2007-03-02 04:09:10 EST
(
hide
)
Description:
test program by JOGL
Filename:
MIME Type:
Creator:
supertat
Created:
2007-03-02 04:09:10 EST
Size:
5.40 KB
patch
obsolete
>package org.eclipse.swt.snippets; > >import org.eclipse.swt.*; >import org.eclipse.swt.layout.*; >import org.eclipse.swt.widgets.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.opengl.GLCanvas; >import org.eclipse.swt.opengl.GLData; > >import javax.media.opengl.GL; >import javax.media.opengl.GLContext; >import javax.media.opengl.GLDrawableFactory; >import javax.media.opengl.glu.GLU; > >public class Snippet209 { > > static long startTime = System.currentTimeMillis() + 5000; > static long fps = 0; > > static void drawTorus(GL gl, float r, float R, int nsides, int rings) { > float ringDelta = 2.0f * (float) Math.PI / rings; > float sideDelta = 2.0f * (float) Math.PI / nsides; > float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f; > for (int i = rings - 1; i >= 0; i--) { > float theta1 = theta + ringDelta; > float cosTheta1 = (float) Math.cos(theta1); > float sinTheta1 = (float) Math.sin(theta1); > gl.glBegin(GL.GL_QUAD_STRIP); > float phi = 0.0f; > for (int j = nsides; j >= 0; j--) { > phi += sideDelta; > float cosPhi = (float) Math.cos(phi); > float sinPhi = (float) Math.sin(phi); > float dist = R + r * cosPhi; > gl.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); > gl.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); > gl.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); > gl.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); > } > gl.glEnd(); > theta = theta1; > cosTheta = cosTheta1; > sinTheta = sinTheta1; > } > } > > public static void main(String [] args) { > final Display display = new Display(); > Shell shell = new Shell(display); > shell.setLayout(new FillLayout()); > Composite comp = new Composite(shell, SWT.NONE); > comp.setLayout(new FillLayout()); > GLData data = new GLData (); > data.doubleBuffer = true; > final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); > > canvas.setCurrent(); > final GLContext context = GLDrawableFactory.getFactory().createExternalGLContext(); > > canvas.addListener(SWT.Resize, new Listener() { > public void handleEvent(Event event) { > Rectangle bounds = canvas.getBounds(); > float fAspect = (float) bounds.width / (float) bounds.height; > canvas.setCurrent(); > context.makeCurrent(); > GL gl = context.getGL (); > gl.glViewport(0, 0, bounds.width, bounds.height); > gl.glMatrixMode(GL.GL_PROJECTION); > gl.glLoadIdentity(); > GLU glu = new GLU(); > glu.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); > gl.glMatrixMode(GL.GL_MODELVIEW); > gl.glLoadIdentity(); > context.release(); > } > }); > > context.makeCurrent(); > GL gl = context.getGL (); > gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); > gl.glColor3f(1.0f, 0.0f, 0.0f); > gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); > gl.glClearDepth(1.0); > gl.glLineWidth(2); > gl.glEnable(GL.GL_DEPTH_TEST); > context.release(); > > shell.setText("SWT/JOGL Example"); > shell.setSize(640, 480); > shell.open(); > > display.asyncExec(new Runnable() { > int rot = 0; > public void run() { > if (!canvas.isDisposed()) { > canvas.setCurrent(); > context.makeCurrent(); > GL gl = context.getGL (); > gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); > gl.glClearColor(.3f, .5f, .8f, 1.0f); > gl.glLoadIdentity(); > gl.glTranslatef(0.0f, 0.0f, -10.0f); > float frot = rot; > gl.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); > gl.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); > rot++; > gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); > gl.glColor3f(0.9f, 0.9f, 0.9f); > drawTorus(gl, 1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); > canvas.swapBuffers(); > context.release(); > > if (startTime > System.currentTimeMillis()) { > fps++; > } else { > long timeUsed = 5000 + (startTime - System > .currentTimeMillis()); > startTime = System.currentTimeMillis() + 5000; > System.out.println(fps + " frames in " > + (float) (timeUsed / 1000f) + " seconds = " > + (fps / (timeUsed / 1000f))); > fps = 0; > } > > display.asyncExec(this); > } > } > }); > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 176150
:
60136
|
60137
|
60138
|
60302
|
60303
|
60304
|
60305
|
60522