From b824d786c4f7fe4db6263433dc2cec6407694bb8 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Thu, 6 Sep 2012 07:11:54 +0000 Subject: [PATCH] Made GLContext.getCapabilities throw a RuntimeException instead of returning null when there's no GL context current in the current thread. --- src/java/org/lwjgl/opengl/GLContext.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/java/org/lwjgl/opengl/GLContext.java b/src/java/org/lwjgl/opengl/GLContext.java index 5524993a..5a6c32cc 100644 --- a/src/java/org/lwjgl/opengl/GLContext.java +++ b/src/java/org/lwjgl/opengl/GLContext.java @@ -119,6 +119,14 @@ public final class GLContext { * @return The current capabilities instance. */ public static ContextCapabilities getCapabilities() { + ContextCapabilities caps = getCapabilitiesImpl(); + if ( caps == null ) + throw new RuntimeException("No OpenGL context found in the current thread."); + + return caps; + } + + private static ContextCapabilities getCapabilitiesImpl() { CapabilitiesCacheEntry recent_cache_entry = fast_path_cache; // Check owner of cache entry if ( recent_cache_entry.owner == Thread.currentThread() ) {