use of org.eclipse.swt.opengl.GLCanvas in project lwjgl by LWJGL.
the class LWJGLInfoView method createPartControl.
/**
* {@inheritDoc}
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite i_parent) {
Text info = new Text(i_parent, SWT.READ_ONLY | SWT.LEFT | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
GLCanvas canvas = new GLCanvas(i_parent, SWT.NONE, new GLData());
canvas.setCurrent();
try {
GLContext.useContext(canvas);
} catch (LWJGLException ex) {
// TODO Implement catch block for LWJGLException
ex.printStackTrace();
}
String infoString = gatherInformation();
info.setText(infoString);
}
use of org.eclipse.swt.opengl.GLCanvas in project lwjgl by LWJGL.
the class LWJGLTestView method createPartControl.
/**
* {@inheritDoc}
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
String strVersion = getFeatureVersion("org.lwjgl");
this.setPartName("org.lwjgl " + strVersion);
IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager();
fpsstatuslineitem = new FpsStatusLineItem();
statusLine.add(fpsstatuslineitem);
GLData data = new GLData();
data.doubleBuffer = true;
canvas = new GLCanvas(parent, SWT.NONE, data);
canvas.setCurrent();
try {
GLContext.useContext(canvas);
} catch (LWJGLException e) {
e.printStackTrace();
}
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();
try {
GLContext.useContext(canvas);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, bounds.width, bounds.height);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
}
});
GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glColor3f(1.0f, 0.0f, 0.0f);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
GL11.glClearDepth(1.0);
GL11.glLineWidth(2);
GL11.glEnable(GL11.GL_DEPTH_TEST);
Display.getCurrent().asyncExec(initRunnable());
}
Aggregations