Git Product home page Git Product logo

lwjgl / lwjgl3 Goto Github PK

View Code? Open in Web Editor NEW
4.6K 161.0 619.0 92.98 MB

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.

Home Page: https://www.lwjgl.org

License: BSD 3-Clause "New" or "Revised" License

C 10.31% Java 69.50% C++ 1.68% Kotlin 18.48% Objective-C 0.02% Objective-C++ 0.01% GLSL 0.01% Assembly 0.01% Batchfile 0.01% Shell 0.01%
lwjgl kotlin opengl opencl openal vulkan bindings java glfw vr opengl-es fmod freetype harfbuzz openxr

lwjgl3's Introduction

Maven Central API Javadoc License

Size Build Status

LWJGL - Lightweight Java Game Library 3

LWJGL (https://www.lwjgl.org) is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL/Vulkan), audio (OpenAL) and parallel computing (OpenCL) applications. This access is direct and high-performance, yet also wrapped in a type-safe and user-friendly layer, appropriate for the Java ecosystem.

LWJGL is an enabling technology and provides low-level access. It is not a framework and does not provide higher-level utilities than what the native libraries expose. As such, novice programmers are encouraged to try one of the frameworks or game engines that make use of LWJGL, before working directly with the library.

LWJGL is open source software and freely available at no charge.

Useful links:

Contact:

If you'd like to contribute, see doc/README for a quick overview of the project structure, installation instructions and configuration options.

Getting Started

As of version 3.1.0, LWJGL is distributed as a set of modules. Only the core module is required and all bindings are optional (but some bindings depend on other bindings). The easiest way to download LWJGL is to use the build configurator on the website.

The build configurator generates Maven & Gradle declarations that can be added to existing projects. This is the easiest way to use LWJGL while developing.

LWJGL can also be downloaded as a simple set of JAR files. Each module consists of the following files:

  • lwjgl-<module>.jar
  • lwjgl-<module>-sources.jar
  • lwjgl-<module>-javadoc.jar
  • lwjgl-<module>-natives-<platform>.jar (for some bindings)

To compile and run an LWJGL application, the base and natives JAR files of the core module and each binding used should be added to the classpath. LWJGL extracts the natives to a temporary folder and loads them automatically, so no further configuration is necessary. If more customization is required (e.g. when creating a platform-specific installer) the natives may be extracted manually and loaded via java.library.path. See the Configuration class for more options.

LWJGL 3 requires Java 8 or later to build and run and currently supports the following platforms/architectures:

  • FreeBSD x64
  • Linux x64
  • Linux arm64 (ARMv8/AArch64)
  • Linux arm32 (ARMv7/armhf)
  • Linux ppc64le
  • Linux riscv64
  • macOS x64
  • macOS arm64
  • Windows x64
  • Windows x86
  • Windows arm64

Example code:

For migrating LWJGL 2 code to LWJGL 3, see the Migration Guide.

Troubleshooting

Most common issues faced by LWJGL users are trivially addressed with the following:

LWJGLX/debug is a Java Agent that will automatically detect a lot of these issues. It can also generate a trace log that's useful when reporting issues to LWJGL.

When asking for help or when you suspect a bug in LWJGL, preparing an MVCE (Minimal, Complete, and Verifiable example) that reproduces the issue will improve the chances of a quick and useful response.

List of Supported Bindings

Khronos APIs

Library Description
EGL An interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system.
KTX (Khronos Texture) A lightweight container for textures for OpenGL®, Vulkan® and other GPU APIs.
OpenCL An open, royalty-free standard for cross-platform, parallel programming of diverse processors found in personal computers, servers, mobile devices and embedded platforms.
OpenGL The most widely adopted 2D and 3D graphics API in the industry, bringing thousands of applications to a wide variety of computer platforms.
OpenGL ES A royalty-free, cross-platform API for full-function 2D and 3D graphics on embedded systems - including consoles, phones, appliances and vehicles.
OpenXR A royalty-free, open standard that provides high-performance access to Augmented Reality (AR) and Virtual Reality (VR)—collectively known as XR—platforms and devices.
Vulkan A new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs used in a wide variety of devices from PCs and consoles to mobile phones and embedded platforms.

Display and Input

Library Description
GLFW Create multiple windows, handle user input (keyboard, mouse, gaming peripherals) and manage contexts. Also features multi-monitor support, clipboard access, file drag-n-drop, and much more.
JAWT The AWT native interface.
Native File Dialog Extended A small C library that portably invokes native file open, folder select and file save dialogs.
tinyfd A native dialog library.

Audio

Library Description
FMOD An end-to-end solution for adding sound and music to any game.
OpenAL A cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.
OpenAL Soft An LGPL-licensed, cross-platform, software implementation of the OpenAL 3D audio API.
Opus A totally open, royalty-free, highly versatile audio codec.

Graphics

Library Description
Assimp A portable Open Source library to import various well-known 3D model formats in a uniform manner.
bgfx Cross-platform, graphics API agnostic, “Bring Your Own Engine/Framework” style rendering library, licensed under permissive BSD-2 clause open source license.
FreeType A freely available software library to render fonts.
HarfBuzz A text shaping library that allows programs to convert a sequence of Unicode input into properly formatted and positioned glyph output — for any writing system and language.
meshoptimizer A mesh optimization library that makes meshes smaller and faster to render.
NanoSVG A simple stupid SVG parser.
NanoVG A small antialiased vector graphics rendering library for OpenGL.
Nuklear A minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain.
par_octasphere Generates triangle meshes for spheres, rounded boxes, and capsules.
par_shapes Generate parametric surfaces and other simple shapes.
par_streamlines Triangulate wide lines and curves.
Shaderc A collection of libraries for shader compilation.
SPIRV-Cross A library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.
Tiny OpenEXR A small, single header-only library to load and save OpenEXR(.exr) images.
Tootle (AMD) A 3D triangle mesh optimization library that improves on existing mesh preprocessing techniques.
Vulkan Memory Allocator An easy to integrate Vulkan memory allocation library.
Yoga An open-source, cross-platform layout library that implements Flexbox.

AR/VR

Library Description
LibOVR The API of the Oculus SDK.
OpenVR An API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting.

stb - single-file public domain libraries for C/C++

Library Description
stb_easy_font Quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc.
stb_image Image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_image_resize Resize images larger/smaller with good quality.
stb_image_write Image writing to disk: PNG, TGA, BMP
stb_perlin Revised Perlin noise (3D input, 1D output).
stb_rect_pack Simple 2D rectangle packer with decent quality.
stb_truetype Parse, decode, and rasterize characters from truetype fonts.
stb_vorbis Decode ogg vorbis files from file/memory to float/16-bit signed output.

Other

Library Description
CUDA A parallel computing platform and programming model developed by NVIDIA for general computing on GPUs.
hwloc A portable abstraction of the hierarchical topology of modern architectures, including NUMA memory nodes, sockets, shared caches, cores and simultaneous multithreading.
jemalloc A general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support.
libffi A portable, high level programming interface to various calling conventions.
libdivide A library that replaces expensive integer divides with comparatively cheap multiplication and bitshifts.
LLVM A collection of modular and reusable compiler and toolchain technologies.
LMDB An extraordinarily fast, memory-efficient database. With memory-mapped files, it has the read performance of a pure in-memory database while retaining the persistence of standard disk-based databases.
LZ4 A lossless data compression algorithm that is focused on compression and decompression speed.
Meow hash An extremely fast non-cryptographic hash.
ODBC A C programming language interface that makes it possible for applications to access data from a variety of database management systems (DBMSs).
Remotery A realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser.
rpmalloc A public domain cross platform lock free thread caching 16-byte aligned memory allocator implemented in C.
xxHash An Extremely fast Hash algorithm, running at RAM speed limits.
Zstandard (zstd) A fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios.

Use of a binding is subject to the terms of the corresponding license.

Supporting this project

LWJGL exists thanks to all the people who contribute and donate to our collective.

lwjgl3's People

Contributors

apostolos avatar asood123 avatar bendem avatar blunderchips avatar code-disaster avatar gudenau avatar httpdigest avatar jordan4ibanez avatar kaiburjack avatar kappaone avatar kashike avatar kb-1000 avatar kitsunealex avatar knokko avatar marcono1234 avatar matzon avatar mflament avatar modmuss50 avatar mrmangohands avatar noviv avatar octylfractal avatar pokemmo avatar silvertiger avatar space928 avatar spasi avatar sriharshachilakapati avatar swinxy avatar teamworkguy2 avatar themrmilchmann avatar tomgillen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lwjgl3's Issues

Including LWJGL 3 in projects

Not really sure where to ask this, as I can't get an account in the LWJGL forums so that's out, but I need to include LWJGL 3 in my project for development. Since it's currently in a dev stage, is there any nightly/dev builds that I can use or do I need to just checkout the project and compile it along side my current project?

CLTest#testSubBuffer() failing in local Windows 7 environment

One of the LWJGL Core Tests, org.lwjgl.opencl.CLTest#testSubBuffer(), is failing in my local Windows environment.

The build succeeds, it is only the one aforementioned test that is failing.

Environment:

  • Commit: 313152a
  • Ant 1.94.
  • Java 1.8.0_20
  • Windows 7 64-bit
  • NVIDIA GeForce GTX 580 Driver version 347.52
ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 7 Ultimate
OS Version:                6.1.7601 Service Pack 1 Build 7601

Steps to Reproduce:

ant tests

Expected:

tests:
    [Tests] [LWJGL] Version 3.0.0a | Windows 7 | amd64
    [Tests] [LWJGL] MemoryUtil MemoryAccessor: MemoryAccessorUnsafe
    [Tests] [TestNG] Running:
    [Tests]   D:\git\lwjgl3\config\tests.xml
    [Tests]
    [Tests]
    [Tests] ===============================================
    [Tests] LWJGL Core Tests
    [Tests] Total tests run: 20, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests]
    [Tests] [TestNG] Running:
    [Tests]   D:\git\lwjgl3\config\tests_windows.xml
    [Tests]
    [Tests]
    [Tests] ===============================================
    [Tests] LWJGL Platform Tests
    [Tests] Total tests run: 12, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests]

Observed:

tests:
    [Tests] [LWJGL] Version 3.0.0a | Windows 7 | amd64
    [Tests] [LWJGL] MemoryUtil MemoryAccessor: MemoryAccessorUnsafe
    [Tests] [TestNG] Running:
    [Tests]   D:\git\lwjgl3\config\tests.xml
    [Tests]
    [Tests]
    [Tests] ===============================================
    [Tests] LWJGL Core Tests
    [Tests] Total tests run: 20, Failures: 1, Skips: 0
    [Tests] ===============================================
    [Tests]
    [Tests] [TestNG] Running:
    [Tests]   D:\git\lwjgl3\config\tests_windows.xml
    [Tests]
    [Tests]
    [Tests] ===============================================
    [Tests] LWJGL Platform Tests
    [Tests] Total tests run: 12, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests]
    [Tests] The tests failed.

Mac OS X: shader / core profile / pixel format

I've managed to run this with linux, but can't get it to work with os x.

As far as I can tell, I'm supposed to request the core profile when asking for the pixel format.

Is it something that LWJGL's supposed to take care of when creating the context (or maybe glfw when creating the window, or the video mode, I'm a bit fuzzy there)

The error messages
Failed to compile fragment shader:
ERROR: 0:1: '' : version '130' is not supported
ERROR: 0:3: 'smooth' : syntax error: syntax error
Linker failure: ERROR: One or more attached shaders not successfully compiled
Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL30.nglGenVertexArrays(GL30.java:3263)
at org.lwjgl.opengl.GL30.glGenVertexArrays(GL30.java:3292)

The shader

#version 130
in vec4 position;
void main() {
        gl_Position = position;
}

Here's the code I use to load the shaders: https://gist.github.com/Landolphia/139c90e753601b208cb6

Related: http://stackoverflow.com/questions/20264814/glsl-version-130-on-mac-os-x-causes-error

glfw causes program to hang

If you try to create a new Font object or call ImageIO.read() (only two I've discovered so far) after calling GLFW.glfwCreateWindow, the program will hang—as far as I can tell—indefinitely.

My source code is here if it helps. Main class is here

javax.script.ScriptException on Mac OS X

[update]
I created pull request which contains a fix for this issue.

Stack Trace:

devBox:lwjgl3 dev$ ant clean
Buildfile: /PATH_TO_DIRECTORY_HOLDING_REPO/lwjgl3/build.xml

BUILD FAILED
/PATH_TO_DIRECTORY_HOLDING_REPO/lwjgl3/build.xml:15: javax.script.ScriptException: ReferenceError: "println" is not defined in <eval> at line number 5
    at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:586)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:570)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:525)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:521)
    at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:192)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.util.ReflectUtil.invoke(ReflectUtil.java:108)
    at org.apache.tools.ant.util.ReflectWrapper.invoke(ReflectWrapper.java:81)
    at org.apache.tools.ant.util.optional.JavaxScriptRunner.evaluateScript(JavaxScriptRunner.java:103)
    at org.apache.tools.ant.util.optional.JavaxScriptRunner.executeScript(JavaxScriptRunner.java:67)
    at org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:52)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
    at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
    at org.apache.tools.ant.Main.runBuild(Main.java:826)
    at org.apache.tools.ant.Main.startAnt(Main.java:235)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: <eval>:5 ReferenceError: "println" is not defined
    at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:58)
    at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:320)
    at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:292)
    at jdk.nashorn.api.scripting.NashornScriptEngine.__noSuchProperty__(NashornScriptEngine.java:272)
    at jdk.nashorn.internal.scripts.Script$engine.L:35(nashorn:engine/resources/engine.js:37)
    at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:5)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:535)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:209)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:568)
    ... 33 more

Total time: 0 seconds

Environment Details:

devBox:lwjgl3 dev$ ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"

glfwCreateWindow never returns on Linux

I used the test code from http://www.lwjgl.org/guide and got no window.

I used this code with added println and no code after glfwCreateWindow is executed and no window is displayed.

No error is printed and the program keeps running but with no significant higher load.

I did some tests with glfw in c just to verify that the library works on my machine and could get a working window.

I have tested both the stable version and built my from source. When building from source it stops on the first test.

This is on ubuntu 14.10.

Forum Issue: Timeouts

For lack of communication alternatives, I will abuse GitHub to communicate this issue: There seems to be something wrong with the lwjgl support forum. I neither can:

  • create a new thread
  • answer to existing threads
  • preview my posts
  • send private messages to the moderators

In all these cases I simply get a forum timeout.

Since others seem to be able to make posts, this might be a problem with the activation of newly created accounts (my account is "bluenote", created and activated yesterday).

Add maven host

I work primarily with Gradle, and so would greatly appreciate the creation of a maven repository to host the new LWJGL 3.

Vulkan support.

So Khronos has made an official announcement for Vulkan https://www.khronos.org/vulkan

Khronos says the API will be available later this year (maybe for SIGGRAPH? Hopefully sooner). Apparently its a fairly compact API, although I'm not sure how the shader compiling process will work (part of the API? external tool? vendor provided? another library?) nor how LWJGL would fit in that.

I, for one, welcome our new low level API overlord with a big hug 😄

NullPointerException when trying to access unsupported OpenGL-methods

When trying to access a function that my graphic card doesn't support. Example:

glVertexAttribDivisor(0, 0);

causes a NPE:

Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL33.glVertexAttribDivisor(GL33.java:921)
    ...

The reason is that GL33.getInstance() returns null if GL33 is not supported.

Instead of throwing a NPE, an exception with a good description should be thrown. Maybe a good place to implement that would be the getInstance()-method of GLXX by checking for null – but that would introduce massive code duplication for every GLXX-class.

Function postfixes

Eh, I think this should be discussed with users here too:

http://forum.lwjgl.org/index.php?topic=5746.0

Personally I'm not entirely sold on the "No postfixes confuses users!" side of this. Then again, these days I'm using less and less typed calls, usually its more of fill a byte buffer and send it over the bus. So it wouldn't affect me too much, I dunno about other users.

Pixel unpack buffer exception. Bad check?

Hi, I recently ported my code from LWJGL 2 to LWJGL 3. I'm having this error while uploading compressed textures to the GPU:

Exception in thread "main" org.lwjgl.opengl.OpenGLException: Cannot use offsets when pixel unpack buffer object is disabled

The call i'm making is this one:

public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, ByteBuffer data) {
    if ( LWJGLUtil.CHECKS )
        GLChecks.ensureBufferObject(GL21.GL_PIXEL_UNPACK_BUFFER_BINDING, true);
    nglCompressedTexImage2D(target, level, internalformat, width, height, border, data == null ? 0 : data.remaining(), memAddressSafe(data));
}

As you can see, it checks if a PBO is bound before issuing the call. Thing is, I'm not using a PBO at all, just uploading mip maps of a DXT texture. (ie, proper target, level, format, and ByteBuffer with mip map data passed).

Essentially that overloaded version saves up the data.remaining() call, so if I explicitly pass data.remaining() as parameter with this version instead:

    public static void glCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, ByteBuffer data) {
    if ( LWJGLUtil.CHECKS ) {
        if ( data != null ) checkBuffer(data, imageSize);
        GLChecks.ensureBufferObject(GL21.GL_PIXEL_UNPACK_BUFFER_BINDING, false);
    }
    nglCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, memAddressSafe(data));
}

It works right, because its checking if a PBO isn't bound before issuing the call, unlike the first version.

Moreover, if I keep using the first version, while at the same time disabling LWJGL's checks, it works fine too.

Is all of this intended? I've never used PBOs before so I don't know why its checking for PBOs specifically.

Access violation exception

In attempting to test my library I stumbled onto a problem in that while I can debug java I haven't a clue as to how to read this and don't know what to make of it. Btw using code here.
Edit: while error appears similar to #9 my code isn't (as far as I'm aware) using OpenCL.

Support Logger for debug log messages

I love the support for debugging in GLContext. The setupDebugMessageCallback() method is super convenient.
While building up the debugging support in my own project I thought of something that would make the logging support even better.
Please consider adding a method that sends debug messages to a java.util.logging.Logger rather than a PrintStream. This would help lwjgl users easily tie GL debug messages in to application logs and enable the output during runtime.

To take this idea a bit further, the holy grail would be swapping in slf4j loggers for log output throughout the lwjgl library. That might take a bit more time to implement though so feel free to consider slf4j a low priority nice to have.
java.util Loggers are already on hand and slf4j can remap their output so that might be the best option if adding the slf4j dependency is undesirable.

Thanks again for all the great work! The new version is looking really good!

Can not use x86 libraries linux.

When I try to load the x86 instead of x64 libraries the program crashes:

OpenJDK 64-Bit Server VM warning: You have loaded library /home/shiro/NetBeansProjects/GameEngine/native/linux/x86/liblwjgl.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to load the native library: lwjgl
at org.lwjgl.LWJGLUtil.loadLibrarySystem(LWJGLUtil.java:329)
at org.lwjgl.Sys$1.run(Sys.java:36)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.(Sys.java:33)
at org.lwjgl.PointerBuffer.(PointerBuffer.java:16)
at org.lwjgl.BufferUtils.createPointerBuffer(BufferUtils.java:190)
at org.lwjgl.system.libffi.Closure.(Closure.java:45)
at org.lwjgl.glfw.Callbacks.errorCallbackPrint(Callbacks.java:127)

Loading x64 works.

Compiling warnings

On my Linux 3.7.0 (ant 1.8.2, gcc 4.7.2, openjdk 1.7.0_09) I'm getting a few compiling warnings:

sworddragon@ubuntu:~/.git/lwjgl3$ ant
Buildfile: /home/sworddragon/.git/lwjgl3/build.xml

all:

-initialize:
[Core] Created dir: /home/sworddragon/.git/lwjgl3/bin/Core
[Utilities] Created dir: /home/sworddragon/.git/lwjgl3/bin/Utilities
[Templates] Created dir: /home/sworddragon/.git/lwjgl3/bin/Templates
[Tests] Created dir: /home/sworddragon/.git/lwjgl3/bin/Tests
[bin] Created dir: /home/sworddragon/.git/lwjgl3/bin/lwjglamd64

compile-templates:
[Compiling Templates module] The corresponding parameter in the supertype 'FileFilter' is named 'p0'. This may cause problems when calling this function with named arguments.
[Compiling Templates module]
[Compiling Templates module] Unnecessary non-null assertion (!!) on a non-null receiver of type jet.String
[Compiling Templates module]
[Compiling Templates module] Unnecessary non-null assertion (!!) on a non-null receiver of type jet.String
[Compiling Templates module]
[Compiling Templates module] Unchecked cast: org.lwjgl.generator.FunctionTransform<out org.lwjgl.generator.QualifiedType>? to org.lwjgl.generator.AutoTypeTargetTransform
[Compiling Templates module]
[Compiling Templates module] Unchecked cast: org.lwjgl.generator.FunctionTransform<out org.lwjgl.generator.QualifiedType>? to org.lwjgl.generator.FunctionTransform<T>
[Compiling Templates module]
[Compiling Templates module] Unchecked cast: org.lwjgl.generator.FunctionTransform<out org.lwjgl.generator.QualifiedType>? to org.lwjgl.generator.FunctionTransform<T>
[Compiling Templates module]
[Compiling Templates module] The corresponding parameter in the supertype 'FileFilter' is named 'p0'. This may cause problems when calling this function with named arguments.
[Compiling Templates module]
[Compiling Templates module] The corresponding parameter in the supertype 'Comparator' is named 'p0'. This may cause problems when calling this function with named arguments.
[Compiling Templates module]
[Compiling Templates module] The corresponding parameter in the supertype 'Comparator' is named 'p1'. This may cause problems when calling this function with named arguments.
[Compiling Templates module]
[Compiling Templates module] The corresponding parameter in the supertype 'Comparator' is named 'p0'. This may cause problems when calling this function with named arguments.
[Compiling Templates module]
[Compiling Templates module]

-initialize:

generate:
[Java dependencies compilation] Compiling 1 source file to /home/sworddragon/.git/lwjgl3/bin/Templates
[Java dependencies compilation] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[Java dependencies compilation] 1 warning
[Generating code] GENERATING: org.lwjgl.opengl.WGLEXTExtensionsString
[Generating code] MKDIR: ./generated
[Generating code] MKDIR: ./generated/java
[Generating code] MKDIR: ./generated/java/org
[Generating code] MKDIR: ./generated/java/org/lwjgl
[Generating code] MKDIR: ./generated/java/org/lwjgl/opengl
[Generating code] WRITING: ./generated/java/org/lwjgl/opengl/WGLEXTExtensionsString.java
[Generating code] MKDIR: generated/native
[Generating code] MKDIR: generated/native/opengl
[Generating code] WRITING: generated/native/opengl/org_lwjgl_opengl_WGLEXTExtensionsString.c
[Generating code] GENERATING: org.lwjgl.opengl.ARBCopyBuffer
[Generating code] WRITING: ./generated/java/org/lwjgl/opengl/ARBCopyBuffer.java
[Generating code] WRITING: generated/native/opengl/org_lwjgl_opengl_ARBCopyBuffer.c
[Generating code] GENERATING: org.lwjgl.opengl.WGLARBExtensionsString
[Generating code] WRITING: ./generated/java/org/lwjgl/opengl/WGLARBExtensionsString.java
[Generating code] WRITING: generated/native/opengl/org_lwjgl_opengl_WGLARBExtensionsString.c
[Generating code] GENERATING: org.lwjgl.opengl.WGLARBPixelFormat
[Generating code] WRITING: ./generated/java/org/lwjgl/opengl/WGLARBPixelFormat.java
[Generating code] WRITING: generated/native/opengl/org_lwjgl_opengl_WGLARBPixelFormat.c
[Generating code] GENERATING: org.lwjgl.opengl.GL11
[Generating code] WRITING: ./generated/java/org/lwjgl/opengl/GL11.java
[Generating code] WRITING: generated/native/opengl/org_lwjgl_opengl_GL11.c
[Generating code] GENERATING: org.lwjgl.system.windows.WGL
[Generating code] MKDIR: ./generated/java/org/lwjgl/system
[Generating code] MKDIR: ./generated/java/org/lwjgl/system/windows
[Generating code] WRITING: ./generated/java/org/lwjgl/system/windows/WGL.java
[Generating code] MKDIR: generated/native/system
[Generating code] MKDIR: generated/native/system/windows
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_WGL.c
[Generating code] GENERATING: org.lwjgl.system.windows.WinBase
[Generating code] WRITING: ./generated/java/org/lwjgl/system/windows/WinBase.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_WinBase.c
[Generating code] GENERATING: org.lwjgl.system.windows.WinUser
[Generating code] WRITING: ./generated/java/org/lwjgl/system/windows/WinUser.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_WinUser.c
[Generating code] GENERATING: org.lwjgl.system.windows.WinGDI
[Generating code] WRITING: ./generated/java/org/lwjgl/system/windows/WinGDI.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_WinGDI.c
[Generating code] WRITING: generated/java/org/lwjgl/opengl/ContextCapabilities.java
[Generating code] GENERATING: org.lwjgl.system.windows.POINTFLOAT
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/POINTFLOAT.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_POINTFLOAT.c
[Generating code] GENERATING: org.lwjgl.system.windows.GLYPHMETRICSFLOAT
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/GLYPHMETRICSFLOAT.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_GLYPHMETRICSFLOAT.c
[Generating code] GENERATING: org.lwjgl.system.windows.PIXELFORMATDESCRIPTOR
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/PIXELFORMATDESCRIPTOR.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_PIXELFORMATDESCRIPTOR.c
[Generating code] GENERATING: org.lwjgl.system.windows.WNDCLASSEX
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/WNDCLASSEX.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_WNDCLASSEX.c
[Generating code] GENERATING: org.lwjgl.system.windows.OSVERSIONINFOEX
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/OSVERSIONINFOEX.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_OSVERSIONINFOEX.c
[Generating code] GENERATING: org.lwjgl.system.windows.POINT
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/POINT.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_POINT.c
[Generating code] GENERATING: org.lwjgl.system.windows.MSG
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/MSG.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_MSG.c
[Generating code] GENERATING: org.lwjgl.system.windows.POINTL
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/POINTL.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_POINTL.c
[Generating code] GENERATING: org.lwjgl.system.windows.DEVMODE
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/DEVMODE.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_DEVMODE.c
[Generating code] GENERATING: org.lwjgl.system.windows.DISPLAY_DEVICE
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/DISPLAY_DEVICE.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_DISPLAY_DEVICE.c
[Generating code] GENERATING: org.lwjgl.system.windows.EnumObjectsProc
[Generating code] WRITING: generated/java/org/lwjgl/system/windows/EnumObjectsProc.java
[Generating code] WRITING: generated/native/system/windows/org_lwjgl_system_windows_EnumObjectsProc.c

compile:
[Core java compilation] Compiling 45 source files to /home/sworddragon/.git/lwjgl3/bin/Core
[Core java compilation] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[Core java compilation] 1 warning

compile-native:

-compile_native_windows:

tests:
[Tests compilation] Compiling 8 source files to /home/sworddragon/.git/lwjgl3/bin/Tests
[Tests compilation] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[Tests compilation] 1 warning
[testng] [TestNG] Running:
[testng] /home/sworddragon/.git/lwjgl3/config/tests.xml
[testng]
[testng]
[testng] ===============================================
[testng] LWJGL Core Tests
[testng] Total tests run: 5, Failures: 0, Skips: 5
[testng] Configuration Failures: 1, Skips: 0
[testng] ===============================================
[testng]
[testng] [TestNG] Running:
[testng] /home/sworddragon/.git/lwjgl3/config/tests_linux.xml
[testng]
[testng]
[testng] ===============================================
[testng] LWJGL Platform Tests
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
[testng]
[testng] The tests failed.

BUILD SUCCESSFUL
Total time: 37 seconds

The building process is successfull but I can't find any usebale files for me like lwjgl.jar. Has something changed in LWJGL 3 in this way or am I missing something which is not described in README.md?

Taskbar Icon Support

As far as I have seen, there is no feature in LWJGL 3 for setting taskbar icons in Windows for an application (previously accomplished through Display.setIcons(ByteBuffer[])).

Linker warning on Mac OS X Mavericks 10.9.5

ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame

Has anyone else come across this?

The ant task completes with BUILD SUCCESSFUL. After reading your guidelines, I looked into the issue somewhat and saw two Google Groups discussions mentioned a couple times.

I was unable to determine the cause and if the warning can be safely ignored.

Steps to reproduce _(assumes successful $ ant compile-templates):_

$ ant compile-native

Observed output:
...
ommited some output for breviety
...

compile-native-macosx:
 [SDK Root] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk

-link-if-necessary:

-update-dependencies:

-link:
   [Linker] ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame

BUILD SUCCESSFUL
Total time: 19 seconds

Environmental Details

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
$ ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
#for sake of completion including some more relevant info output from Maven
$ mvn -v
...
Java version: 1.6.0_65, vendor: Apple Inc.
...
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"

glDrawPixels() changes ByteBuffer properties to where the buffer is unusable and crashes the JVM

This issue is specific to LWJGL 3. The below code works perfectly fine in LWJGL 2.

/* Inside of the initializer */
IntBuffer pixelBuffer = ByteBuffer.allocateDirect(400 * 240).asIntBuffer();
IntBuffer anotherBuffer = IntBuffer.allocate(400 * 240);

...

/* Inside of a render method */
glDrawPixels(400, 240, GL_BGRA, GL_UNSIGNED_BYTE, pixelBuffer);
pixelBuffer.rewind();
pixelBuffer.put(anotherBuffer); /* JVM crashes here, returns 0xC0000005 as error code */

Running the code without the glDrawPixels call works fine, so it isn't a problem with the Java implementation. This was tested on the JVM from both 7u71 and 8u25 on Window 8.1 64-bit, both with and without the glDrawPixels call. It also crashes with various non-indexed puts to 'pixelBuffer' (i.e. pixelBuffer.put(new int[10])), so I assume that this is the position, limit, or capacity of the buffer being messed up. Though I highly doubt that it's a driver problem, I tested this on an Nvidia GeForce GTX 650 Ti Boost with driver version 344.60.

native library lookup not OSGi compatible

In OSGi you can bundle native libraries within your jars. The OSGi classloader will take care of loading the native library for you.
This works only if System.loadLibrary('lwjgl') is used.
LWJGL.loadLibrarySystem() only uses System.load(new File('lwjgl.dll')), while the javadoc wrongly states it uses both System.load and System.loadLibrary

An easy fix for this issue is adding a System.loadLibrary(name) in the LWJGL.loadLibrarySystem() method before trying to find the lib file in the file system:

try {
  System.loadLibrary(name);
  return;
} catch(Throwable t) {}

GL12.GL_TEXTURE_BINDING_3D missing?

I'm converting my library to use LWJGL 3.0.0a, and GL_TEXTURE_BINDING_3D appears to be missing from org.lwjgl.opengl.GL12. It should have a value of 0x806A.

Also, how did you guys generate this code?

Mouse read

What is the way of reading the mouse position in LWJGL 3. The GLFW method requires a byte buffer or a float buffer so how would I read a value similar to that that I would get from the LWJGL 2 mouse class?
I'm probably just being tired but this isn't something I can find documentation on (The C implementation of GLFW uses integers).

No window opens Ubuntu

Using the basic sample on the website, I run LWJGL3 however no window opens, but the program does run.

I have tried running it using both unity and xfce2.12 but it didnt help and I also tried using stable and nightly both times it doesnt open a window.

Fixed by upgrading to ubuntu 15.04

Gradle build

Is this considered/going to be considered?

I think it's the fastest way of getting LWJGL3 to be used by other projects without the current LWJGL2 hassle of generating POMs separated from the main build. It can be used to compile without ant at all, or it can be mixed.

I started adding support and got the kotlin plugin to compile all the sources, but got confused about the Generator.kt

If you're not planning on adding this, please close as wont fix so I don't spend any more time on it :D

GLU perspective

My main perspective initialization in LWJGL 2 was GLU.gluPerspective
Is there an equivalent method in LWJGL 3?

ByteBuffer overloads for all calls

Hi, I propose this enhancement if it could be possible.

There are calls like GL20.glDrawBuffers that only take IntBuffer (or glUniform calls that only take FloatBuffers). For simplicity, all my buffer management its done through ByteBuffers and asking for views of other types only when needed (ie, big read/writes in with floats or ints which are a bit faster if done through FloatBuffer/IntBuffer respectively).

Thus, I often find myself needing an actual different type of buffer (say, FloatBuffer, IntBuffer) only when passing data to OpenGL.

Already many calls can receive ByteBuffers but there are a couple of cases in which you need a specific type of buffer.

It would be nice if all method calls could also take in ByteBuffers instead so I don't have to create very short lived views of my buffers. I understand it could exponentially increase the amount of function definitions in the library though.

Add support for C++ bindings

The bindings generator currently only supports pure C APIs. It would be useful to have the ability to create bindings to C++ APIs, e.g. Bullet and OpenEXR.

Windows: apply not working, returning weird error code

I was going to compile this for testing, but the build.xml failed on apply with weird error code:

compile-native-windows:
BUILD FAILED
lwjgl3\build.xml:187: The following error occurred while executing this line:
lwjgl3\config\windows\build.xml:33: apply returned: -1073741515

The full log is here.

compile-native error on osx

Using JDK 8 ea-b123 on OSX 10.9 Mavericks with LWJGL 3 commit 003e77b200ea215ebeb91515891a75c2e4770541

Buildfile: /Users/max96at/Dev/Java/lwjgl3/build.xml

-initialize:

-dependencies-uptodate:

check-dependencies:

-generated-uptodate:

generate:

compile:

compile-native:

compile-native-macosx:
 [SDK Root] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
 [Compiler] /Users/max96at/Dev/Java/lwjgl3/generated/native/opencl/org_lwjgl_opencl_CL20.c:10:96: fatal error: unknown type name 'cl_pipe_properties'; did you mean 'cl_context_properties'?
 [Compiler] typedef cl_mem (APIENTRY *clCreatePipePROC) (cl_context, cl_mem_flags, cl_uint, cl_uint, const cl_pipe_properties *, cl_int *);
 [Compiler]                                                                                                ^~~~~~~~~~~~~~~~~~
 [Compiler]                                                                                                cl_context_properties
 [Compiler] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenCL.framework/Headers/cl.h:62:29: note: 'cl_context_properties' declared here
 [Compiler] typedef intptr_t            cl_context_properties;
 [Compiler]                             ^
 [Compiler] 1 error generated.

BUILD FAILED
/Users/max96at/Dev/Java/lwjgl3/build.xml:187: The following error occurred while executing this line:
/Users/max96at/Dev/Java/lwjgl3/config/macosx/build.xml:111: apply returned: 1

Total time: 0 seconds

GLSL Version 330 fails to run?

When using a shader like the following:

#version 330
layout(location=0) in vec3 v_pos;
void main(void) {
    gl_Position = vec4(v_pos, 1.0);
}

I get this error:

java.lang.RuntimeException: Failed to create shader: ERROR: 0:1: '' :  version '330' is not supported

If the version number is removed, I get this error:

java.lang.RuntimeException: Failed to create shader: ERROR: 0:1: 'layout' : syntax error syntax error

Rectangle textures should be core in 2.1

https://github.com/LWJGL/lwjgl3/blob/master/src/templates/org/lwjgl/opengl/templates/GL31.kt

GL_TEXTURE_RECTANGLE is currently in GL31, but the OpenGL wiki says it was promoted to core in 2.1:

https://www.opengl.org/wiki/Rectangle_Texture

I'm not sure if this is an issue with LWJGL or the OpenGL wiki, or if there's something else going on (like lack of vendor support or something).

Wikipedia appears to contradict the OpenGL wiki: http://en.wikipedia.org/wiki/OpenGL#OpenGL_3.1
And the OpenGL wiki appears to contradict itself: https://www.opengl.org/wiki/History_of_OpenGL#OpenGL_3.1_.282009.29

Suggestion: Add FreeType Binding

My humble suggestion is to add bindings for FreeType. It is pretty much the industry standard library for font loading/rasterisation and I'd love to be able to use it with LWJGL. To be honest I have little experience with C++/JNI but I might be able to help implement it.

Thanks very much if you could consider this.

Null Pointer Exception When Binding Framebuffer to '0' (the window)

Hello, I'm porting my LWJGL 2 game to version 3 and I've came across this annoying issue.

Calling glBindFramebuffer(GL_FRAMEBUFFER, 0); will cause a null pointer exception like so:

Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.opengl.GL30.glBindFramebuffer(GL30.java:2308)
at test.TestFail.loop(TestFail.java:98)
at test.TestFail.run(TestFail.java:29)
at test.TestFail.main(TestFail.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

It's reproducible with the following test code copied and pasted from the getting started guide. (save for the one call to glBindFramebuffer):

package test;

import org.lwjgl.Sys;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;

import java.nio.ByteBuffer;

import static org.lwjgl.glfw.Callbacks.*;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.system.MemoryUtil.*;

public class TestFail {

                // We need to strongly reference callback instances.
                private GLFWErrorCallback errorCallback;
        private GLFWKeyCallback   keyCallback;

                // The window handle
                private long window;

                public void run() {
                System.out.println("Hello LWJGL " + Sys.getVersion() + "!");

                try {
                        init();
                        loop();

                        // Release window and window callbacks
                        glfwDestroyWindow(window);
                        keyCallback.release();
                    } finally {
                        // Terminate GLFW and release the GLFWerrorfun
                        glfwTerminate();
                        errorCallback.release();
                    }
            }

                private void init() {
                // Setup an error callback. The default implementation
                // will print the error message in System.err.
                glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

                // Initialize GLFW. Most GLFW functions will not work before doing this.
                if ( glfwInit() != GL11.GL_TRUE )
                    throw new IllegalStateException("Unable to initialize GLFW");

                // Configure our window
                glfwDefaultWindowHints(); // optional, the current window hints are already the default
                glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
                glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

                int WIDTH = 300;
                int HEIGHT = 300;

                // Create the window
                window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", NULL, NULL);
                if ( window == NULL )
                    throw new RuntimeException("Failed to create the GLFW window");

                // Setup a key callback. It will be called every time a key is pressed, repeated or released.
                glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
                        @Override
                        public void invoke(long window, int key, int scancode, int action, int mods) {
                                if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
                                    glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
                            }
                    });

                // Get the resolution of the primary monitor
                ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
                // Center our window
                glfwSetWindowPos(
                            window,
                            (GLFWvidmode.width(vidmode) - WIDTH) / 2,
                    (GLFWvidmode.height(vidmode) - HEIGHT) / 2
                );

                // Make the OpenGL context current
                glfwMakeContextCurrent(window);
                // Enable v-sync
                glfwSwapInterval(1);

                // Make the window visible
                glfwShowWindow(window);
            }

                private void loop() {
                // This line is critical for LWJGL's interoperation with GLFW's
                // OpenGL context, or any context that is managed externally.
                // LWJGL detects the context that is current in the current thread,
                // creates the ContextCapabilities instance and makes the OpenGL
        // bindings available for use.
        GLContext.createFromCurrent();

glBindFramebuffer(GL_FRAMEBUFFER, 0);

                // Set the clear color
                glClearColor(1.0f, 0.0f, 0.0f, 0.0f);

                // Run the rendering loop until the user has attempted to close
                // the window or has pressed the ESCAPE key.
                while ( glfwWindowShouldClose(window) == GL_FALSE ) {
                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer

                        glfwSwapBuffers(window); // swap the color buffers

                        // Poll for window events. The key callback above will only be
                        // invoked during this call.
                        glfwPollEvents();
                    }
            }

                public static void main(String[] args) {
                new TestFail().run();
            }

}

Thanks very much if you can help, or let me know if this is already a recognised issue.

Invalid X server connection specified. (Linux)

On Ubuntu 14.04 GLContext.createFromCurrent() throws a java.lang.IllegalStateException.
Output:
Exception in thread "main" java.lang.IllegalStateException: Invalid X server connection specified.
at org.lwjgl.system.linux.opengl.LinuxGLContext.createFromCurrent(LinuxGLContext.java:68)
at org.lwjgl.system.linux.opengl.LinuxGLContext.createFromCurrent(LinuxGLContext.java:63)
at org.lwjgl.opengl.GLContext.createFromCurrent(GLContext.java:41)

LibFFITest failing on local OS X Mavericks 10.9.5

One of the LWJGL Core Tests, LibFFITest, is failing in my local environment.

Environment:

Ant 1.94. , Java 1.8.0_25, Mac OS X 1.9.5

ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
sw_vers -productVersion 
10.9.5

Steps to reproduce:

ant tests

Expected Result:

tests:
    [Tests] [LWJGL] Version 3.0.0a | Mac OS X | x86_64
    [Tests] [LWJGL] MemoryUtil MemoryAccessor: MemoryAccessorUnsafe
    [Tests] [TestNG] Running:
    [Tests]   /Users/java/Documents/git/lwjgl3/config/tests.xml
    [Tests] 
    [Tests] 
    [Tests] ===============================================
    [Tests] LWJGL Core Tests
    [Tests] Total tests run: 20, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests] 
    [Tests] [TestNG] Running:
    [Tests]   /Users/java/Documents/git/lwjgl3/config/tests_macosx.xml
    [Tests] 
    [Tests] 
    [Tests] ===============================================
    [Tests] LWJGL Platform Tests
    [Tests] Total tests run: 0, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests]

Actual Result:

    [Tests] [LWJGL] Version 3.0.0a | Mac OS X | x86_64
    [Tests] [LWJGL] MemoryUtil MemoryAccessor: MemoryAccessorUnsafe
    [Tests] [TestNG] Running:
    [Tests]   /Users/java/Documents/git/lwjgl3/config/tests.xml
    [Tests] 
    [Tests] 
    [Tests] ===============================================
    [Tests] LWJGL Core Tests
    [Tests] Total tests run: 20, Failures: 1, Skips: 0
    [Tests] ===============================================
    [Tests] 
    [Tests] [TestNG] Running:
    [Tests]   /Users/java/Documents/git/lwjgl3/config/tests_macosx.xml
    [Tests] 
    [Tests] 
    [Tests] ===============================================
    [Tests] LWJGL Platform Tests
    [Tests] Total tests run: 0, Failures: 0, Skips: 0
    [Tests] ===============================================
    [Tests] 
    [Tests] The tests failed.

I looked into the name and cause of the one failed test:

org.lwjgl.system.libffi.LibFFITest
testLibFFI
java.lang.IllegalStateException: Please run the JVM with -XstartOnFirstThread.
    at org.lwjgl.system.macosx.EventLoop.checkFirstThread(EventLoop.java:20)
    at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:426)
    at org.lwjgl.system.libffi.LibFFITest.createGLFWWindow(LibFFITest.java:114)
    at org.lwjgl.system.libffi.LibFFITest.testLibFFI(LibFFITest.java:29)
... Removed 23 stack frames

Ensure correct initialization

The first LWJGL method called by client code varies, based on how the library is going to be used. We need to make sure that the library is correctly initialized under all circumstances.

Currently, there's a error if an external OpenGL context is used and the first method called is GLContext.createFromCurrent().

Making all key values in the Keyboard class into enums.

The key values in the Keyboard class are ints.

I'm creating an engine which the user needs to provide a key value, I would like the key values to be enums, so the user knows exactly that the engine wants a key value in the form of a enum, not a random int value.

If you don't have time for this and would like this to happen, I would happily create a PR. Just tell me what to think about when doing the conversion. For example names and stuff.

Theodor (Sorry for grammar, English not main language)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.