2016-06-12 8 views
2

LWJGL 3.0.0-SNAPSHOTがもう使用可能になったようですので、LWJGL 3.0.0に行ってください。しかし、私にとってはMacのバイナリが壊れているように見えます。3.0.0-SNAPSHOTからアップグレードした後にLWJGL 3.0.0でウィンドウが生成されない

私は過去に動作していた次のスクリプトを使用してネイティブをダウンロードしました。変更された唯一の行は次のようになります。

<lwjgl.version>3.0.0SNAPSHOT</lwjgl.version> -> <lwjgl.version>3.0.0</lwjgl.version> 

のpom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>Meltdown</groupId> 
<artifactId>Bitflip</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>Bitflip</name> 

<properties> 
    <lwjgl.version>3.0.0</lwjgl.version> 
    <!--<lwjgl.version>3.0.0-SNAPSHOT</lwjgl.version>--> 
    <swt.version>4.5.1</swt.version> 
    <joml.version>1.8.0</joml.version> 
    <class>game.SpaceGame</class> 
    <source>1.8</source> 
    <target>1.8</target> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 
<profiles> 
    <profile> 
     <id>mac</id> 
     <activation> 
      <os> 
       <family>Mac</family> 
      </os> 
     </activation> 
     <dependencies> 
      <dependency> 
       <groupId>org.lwjgl</groupId> 
       <artifactId>lwjgl-platform</artifactId> 
       <version>${lwjgl.version}</version> 
       <classifier>natives-osx</classifier> 
      </dependency> 
      <dependency> 
       <groupId>org.eclipse.swt</groupId> 
       <artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId> 
       <version>${swt.version}</version> 
      </dependency> 
     </dependencies> 
    </profile> 
</profiles> 
<build> 
    <sourceDirectory>src</sourceDirectory> 
    <resources> 
     <resource> 
      <directory>res</directory> 
     </resource> 
    </resources> 
    <plugins> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.5.1</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <version>2.4.3</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 
         <transformers> 
          <transformer 
            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
           <mainClass>org.lwjgl.demo.${class}</mainClass> 
          </transformer> 
         </transformers> 
         <finalName>lwjgl3-demos</finalName> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
<repositories> 
    <repository> 
     <id>oss.sonatype.org</id> 
     <url>https://oss.sonatype.org/content/repositories/snapshots/</url> 
     <snapshots> 
      <enabled>true</enabled> 
     </snapshots> 
    </repository> 
    <repository> 
     <id>swt-repo</id> 
     <url>http://maven-eclipse.github.io/maven</url> 
    </repository> 
</repositories> 
<dependencies> 
    <dependency> 
     <groupId>org.joml</groupId> 
     <artifactId>joml</artifactId> 
     <version>${joml.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.lwjgl</groupId> 
     <artifactId>lwjgl</artifactId> 
     <version>${lwjgl.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>RELEASE</version> 
    </dependency> 
</dependencies> 
</project> 

私はLWJGLのWebページからサンプルコードを実行するテストを行って確認するために:link to src

package org.gooeybits.meltdown.alt; 

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

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

public class Test { 

    // The window handle 
    private long window; 

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

     try { 
      init(); 
      loop(); 

      // Free the window callbacks and destroy the window 
      glfwFreeCallbacks(window); 
      glfwDestroyWindow(window); 
     } finally { 
      // Terminate GLFW and free the error callback 
      glfwTerminate(); 
      glfwSetErrorCallback(null).free(); 
     } 
    } 

    private void init() { 
     // Setup an error callback. The default implementation 
     // will print the error message in System.err. 
     GLFWErrorCallback.createPrint(System.err).set(); 

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

     // Configure our window 
     glfwDefaultWindowHints(); // optional, the current window hints are already the default 
     glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation 
     glfwWindowHint(GLFW_RESIZABLE, GLFW_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, (window, key, scancode, action, mods) -> { 
      if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) 
       glfwSetWindowShouldClose(window, true); // We will detect this in our rendering loop 
     }); 

     // Get the resolution of the primary monitor 
     GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); 
     // Center our window 
     glfwSetWindowPos(
       window, 
       (vidmode.width() - WIDTH)/2, 
       (vidmode.height() - 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 GLCapabilities instance and makes the OpenGL 
     // bindings available for use. 
     GL.createCapabilities(); 

     // 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)) { 
      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 Test().run(); 
    } 
} 

以下のVMオプションも設定しました:

-XstartOnFirstThread 
-Djava.awt.headless=true 

次のネイティブバイナリが(Mavenを)ダウンロードした:

libglfw.dylib 
libjemalloc.dylib 
liblwjgl.dylib 
libopenal.dylib 

プロジェクトをコンパイルし、実行している場合は、警告なし/エラーや例外を除いて正常に実行されます。欠けているのはウィンドウだけです。私はフルスクリーンとスタンドアロンの両方を試しました。しかし何も。

私の質問は、私がやっている何か変わったことを見ることができますか?

更新:この呼び出しは返されません。

window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", NULL, NULL); 

答えて

0

解決済み。

CUDAドライバとJDKをアンインストールしました。ビルド92ではなく、Java 8のビルド91を再起動してインストールしました。

しかし、私はCUDAのインストールに何か問題があったのか、それともJDKだったのかまだ分かりません。

だれでも同様の問題がある場合は、試してみてください。

java -cp .:./jar/*:./native -Djava.library.path=./native/ -Dorg.lwjgl.util.Debug=true -XstartOnFirstThread HelloWorld 
Hello LWJGL 3.0.0 build 90! 
[LWJGL] Version: 3.0.0 build 90 
[LWJGL]  OS: Mac OS X v10.11.5 
[LWJGL]  JRE: 1.8.0_91 x86_64 
[LWJGL]  JVM: Java HotSpot(TM) 64-Bit Server VM v25.91-b14 by Oracle Corporation 
[LWJGL] Loading library (system): lwjgl 
[LWJGL]  Loaded from java.library.path: ./native/liblwjgl.dylib 
[LWJGL] ThreadLocalUtil state: UnsafeState 
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe 
[LWJGL] Loading library: glfw 
[LWJGL]  Loaded from java.library.path: ./native/libglfw.dylib 
[LWJGL] Loading library: objc 
[LWJGL]  Loaded from java.library.path: ./native/libobjc.dylib 
[LWJGL] Loading library: /System/Library/Frameworks/OpenGL.framework 
[LWJGL]  Success 
関連する問題