@Override public void draw(final GL2 gl, final GLUgl2 glu, final Camera camera) { if (vendor == Vendor.ERROR) { return; } final int[] values = new int[] {NO_VALUE, NO_VALUE}; // try nvidia first if (vendor == Vendor.NVIDIA || vendor == Vendor.NONE) { try { gl.glGetIntegerv(GL_TOTAL_AVAILABLE_MEM, values, 0); gl.glGetIntegerv(GL_CURRENT_AVAILABLE_MEM, values, 1); if (values[1] >= 0) { vendor = Vendor.NVIDIA; } } catch (final GLException ex) { // failed to get values DebugUtil.clearGLErrors(gl); // error will be logged when values are not assigned values[0] = ERROR_VALUE; values[1] = ERROR_VALUE; } } // try amd/ati if (vendor == Vendor.AMD || vendor == Vendor.NONE) { try { if (vendor == Vendor.NONE) { if (gl instanceof WGLExt) { final WGLExt wgl = (WGLExt) gl; final int gpuCount = wgl.wglGetGPUIDsAMD(0, null); final int[] gpuIds = new int[gpuCount]; final IntBuffer totalMem = IntBuffer.allocate(1); for (int i = 0; i < gpuIds.length; i++) { wgl.wglGetGPUInfoAMD( gpuIds[i], WGLExt.WGL_GPU_RAM_AMD, GL2.GL_UNSIGNED_INT, 1, totalMem); values[0] = Math.max(values[0], totalMem.get(0)); } } } else { synchronized (this) { values[0] = totalAvailableMem; } } gl.glGetIntegerv(GL2.GL_TEXTURE_FREE_MEMORY_ATI, values, 1); if (values[1] >= 0) { vendor = Vendor.AMD; } } catch (final GLException ex) { // failed to get values DebugUtil.clearGLErrors(gl); // error will be logged when values are not assigned values[0] = ERROR_VALUE; values[1] = ERROR_VALUE; } } // catch errors if (vendor == Vendor.NONE && values[0] < 0 || values[1] < 0) { vendor = Vendor.ERROR; } synchronized (this) { totalAvailableMem = values[0]; currentAvailableMem = values[1]; } }