Search in sources :

Example 1 with GLCanvas

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);
}
Also used : GLCanvas(org.eclipse.swt.opengl.GLCanvas) GLData(org.eclipse.swt.opengl.GLData) Text(org.eclipse.swt.widgets.Text) LWJGLException(org.lwjgl.LWJGLException)

Example 2 with GLCanvas

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());
}
Also used : GLCanvas(org.eclipse.swt.opengl.GLCanvas) Listener(org.eclipse.swt.widgets.Listener) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) GLData(org.eclipse.swt.opengl.GLData) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

GLCanvas (org.eclipse.swt.opengl.GLCanvas)2 GLData (org.eclipse.swt.opengl.GLData)2 LWJGLException (org.lwjgl.LWJGLException)2 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 Text (org.eclipse.swt.widgets.Text)1