Search in sources :

Example 41 with LWJGLException

use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.

the class AWTGLCanvas method paint.

/**
	 * The default paint() operation makes the context current and calls paintGL() which should
	 * be overridden to do GL operations.
	 */
public final void paint(Graphics g) {
    LWJGLException exception = null;
    synchronized (SYNC_LOCK) {
        if (!isDisplayable())
            return;
        try {
            if (peer_info == null) {
                this.peer_info = implementation.createPeerInfo(this, pixel_format, attribs);
            }
            peer_info.lockAndGetHandle();
            try {
                if (context == null) {
                    this.context = new ContextGL(peer_info, attribs, drawable != null ? (ContextGL) ((DrawableLWJGL) drawable).getContext() : null);
                    first_run = true;
                }
                if (reentry_count == 0)
                    context.makeCurrent();
                reentry_count++;
                try {
                    if (update_context) {
                        context.update();
                        update_context = false;
                    }
                    if (first_run) {
                        first_run = false;
                        initGL();
                    }
                    paintGL();
                } finally {
                    reentry_count--;
                    if (reentry_count == 0)
                        context.releaseCurrent();
                }
            } finally {
                peer_info.unlock();
            }
        } catch (LWJGLException e) {
            exception = e;
        }
    }
    if (exception != null)
        exceptionOccurred(exception);
}
Also used : LWJGLException(org.lwjgl.LWJGLException)

Example 42 with LWJGLException

use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.

the class WindowCreationTest method handleInput.

/**
	 * Handles the input
	 */
private void handleInput() {
    while (Keyboard.next()) {
        // we only want key down events
        if (!Keyboard.getEventKeyState()) {
            continue;
        }
        // check for exit
        if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
            running = false;
        }
        // check for listing of modes
        if (Keyboard.getEventKey() == Keyboard.KEY_L) {
            for (int i = 0; i < fixed_modes.length; i++) {
                System.out.println("[" + i + "]: " + fixed_modes[i]);
            }
        }
        // ================================
        if (Keyboard.getEventKey() == Keyboard.KEY_0) {
            setMode(0);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_1) {
            setMode(1);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_2) {
            setMode(2);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_3) {
            setMode(3);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_4) {
            setMode(4);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_5) {
            setMode(5);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_6) {
            setMode(6);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_7) {
            setMode(7);
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_8) {
            setMode(8);
        }
        // ================================
        if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) {
            if (!Display.isFullscreen()) {
                Display.setLocation(window_x -= 10, window_y);
            }
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) {
            if (!Display.isFullscreen()) {
                Display.setLocation(window_x += 10, window_y);
            }
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_UP) {
            if (!Display.isFullscreen()) {
                Display.setLocation(window_x, window_y -= 10);
            }
        }
        if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) {
            if (!Display.isFullscreen()) {
                Display.setLocation(window_x, window_y += 10);
            }
        }
        // check for fullscreen
        if (Keyboard.getEventKey() == Keyboard.KEY_F) {
            try {
                if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
                    System.out.println("Performing Display.destroy()/create() cycle");
                    DisplayMode saved_mode = Display.getDisplayMode();
                    Display.destroy();
                    Display.setDisplayMode(saved_mode);
                    Display.setFullscreen(fullscreen = !fullscreen);
                    Display.create();
                } else
                    Display.setFullscreen(fullscreen = !fullscreen);
            } catch (LWJGLException lwjgle) {
                lwjgle.printStackTrace();
            }
        }
    }
}
Also used : DisplayMode(org.lwjgl.opengl.DisplayMode) LWJGLException(org.lwjgl.LWJGLException)

Example 43 with LWJGLException

use of org.lwjgl.LWJGLException in project lwjgl by LWJGL.

the class Gears method execute.

/**
	 *
	 */
private void execute() {
    try {
        init();
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.out.println("Failed to initialize Gears.");
        return;
    }
    System.out.println("\nGL RENDERER: " + glGetString(GL_RENDERER));
    System.out.println("GL VENDOR: " + glGetString(GL_VENDOR));
    System.out.println("GL VERSION: " + glGetString(GL_VERSION));
    System.out.println("GL_SHADING_LANGUAGE_VERSION: " + glGetString(GL_SHADING_LANGUAGE_VERSION));
    System.out.println("GL_EXTENSIONS = " + glGetString(GL_EXTENSIONS));
    ContextCapabilities caps = GLContext.getCapabilities();
    System.out.println();
    // Check extension support
    Field[] field = ContextCapabilities.class.getFields();
    for (Field f : field) {
        if (f.getName().startsWith("GL_")) {
            try {
                System.out.println(f.getName() + " - " + f.getBoolean(caps));
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }
    System.out.println();
    // Check for extensions that LWJGL does not support
    final String extensions = glGetString(GL_EXTENSIONS);
    final StringTokenizer tokenizer = new StringTokenizer(extensions);
    while (tokenizer.hasMoreTokens()) {
        final String ext = tokenizer.nextToken();
        try {
            if (!caps.getClass().getField(ext).getBoolean(caps))
                System.out.println("-- Extension exposed but functions are missing: " + ext);
        } catch (NoSuchFieldException e) {
            System.out.println("-- No LWJGL support for extension: " + ext);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    loop();
    destroy();
}
Also used : Field(java.lang.reflect.Field) StringTokenizer(java.util.StringTokenizer) LWJGLException(org.lwjgl.LWJGLException) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

LWJGLException (org.lwjgl.LWJGLException)43 ByteBuffer (java.nio.ByteBuffer)6 Pbuffer (org.lwjgl.opengl.Pbuffer)4 EnhancedRuntimeException (net.minecraftforge.fml.common.EnhancedRuntimeException)3 DisplayMode (org.lwjgl.opengl.DisplayMode)3 PixelFormat (org.lwjgl.opengl.PixelFormat)3 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 Method (java.lang.reflect.Method)2 FloatBuffer (java.nio.FloatBuffer)2 IntBuffer (java.nio.IntBuffer)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 GLCanvas (org.eclipse.swt.opengl.GLCanvas)2 GLData (org.eclipse.swt.opengl.GLData)2 Sphere (org.lwjgl.util.glu.Sphere)2 LifecycleListener (com.badlogic.gdx.LifecycleListener)1 LwjglApplication (com.badlogic.gdx.backends.lwjgl.LwjglApplication)1 LwjglApplicationConfiguration (com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration)1 JmeCursor (com.jme3.cursors.plugins.JmeCursor)1 DefaultPlatformChooser (com.jme3.opencl.DefaultPlatformChooser)1