Hallo, kann mir jemand ein einfaches LWJGL(3)-Beispiel /KSKB mit Kreis oder Kugel und Display, init(), loop(), usw. schreiben? Ich hab schon danach gesucht, aber nicht richtig gefunden. GL lib und alle native lib (damit meine ich DLL)hab ich korrekt eingebunden.
Bis jetzt hab ich das hier gefunden:
import static org.lwjgl.glfw.Callbacks.errorCallbackPrint;
import static org.lwjgl.glfw.Callbacks.glfwSetCallback;
import static org.lwjgl.glfw.GLFW.GLFWWindowSizeCallback;
import static org.lwjgl.glfw.GLFW.GLFW_RESIZABLE;
import static org.lwjgl.glfw.GLFW.GLFW_VISIBLE;
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
import static org.lwjgl.glfw.GLFW.glfwDefaultWindowHints;
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
import static org.lwjgl.glfw.GLFW.glfwGetVideoMode;
import static org.lwjgl.glfw.GLFW.glfwInit;
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
import static org.lwjgl.glfw.GLFW.glfwSetErrorCallback;
import static org.lwjgl.glfw.GLFW.glfwSetWindowPos;
import static org.lwjgl.glfw.GLFW.glfwShowWindow;
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
import static org.lwjgl.glfw.GLFW.glfwSwapInterval;
import static org.lwjgl.glfw.GLFW.glfwTerminate;
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
import org.lwjgl.glfw.GLFWWindowSizeCallback.SAM;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;
public class Display{
private GLFWErrorCallback errorCallback;
private long window;
boolean resized = false;
int WIDTH = 600;
int HEIGHT = 600;
public Display() {
try{
glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));
if ( glfwInit() != GL11.GL_TRUE )throw new IllegalStateException("Unable to initialize GLFW");
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay hidden after creation
glfwWindowHint(GLFW_RESIZABLE, GL11.GL_TRUE); // the window will be resizable
window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", MemoryUtil.NULL, MemoryUtil.NULL);
if ( window == MemoryUtil.NULL )
throw new RuntimeException("Failed to create the GLFW window");
// 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
);
glfwSetCallback(window, GLFWWindowSizeCallback(new SAM() {
@Override
public void invoke(long window, int width, int height) {
resized=true;
WIDTH=width;
HEIGHT=height;
}
}));
// Make the OpenGL context current
glfwMakeContextCurrent(window);
// Enable v-sync
glfwSwapInterval(1);
// Make the window visible
glfwShowWindow(window);
GLContext.createFromCurrent();
GL11.glClearColor(0.0f, 0.0f, 0.5f, 1.0f);
while ( glfwWindowShouldClose(window) == GL11.GL_FALSE ) {
if(resized){
GL11.glViewport(0, 0, WIDTH, HEIGHT);
resized=false;
}
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.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();
}
}
finally{
glfwTerminate();
errorCallback.release();
}
}
public static void main(String[] args) {
new Display();
}
}``` [Lwjgl 3.0 Tutorial: modern Opengl, part 1 - Tutorials - Forum - Static Void Games](http://forum.staticvoidgames.com/t/lwjgl-3-0-tutorial-modern-opengl-part-1/32)
Die Importe sind wirr und das mit der Exception auch. Danke für hilfe.