diff --git a/.gitignor b/.gitignor new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignor @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..be4de24 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ff0be23 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..b5f0f5e --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,758 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1474554056995 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.8 + + + + + + + + lab + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lab.iml b/lab.iml new file mode 100644 index 0000000..1c63997 --- /dev/null +++ b/lab.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/jars/lwjgl.jar b/libs/jars/lwjgl.jar new file mode 100644 index 0000000..0431ddc Binary files /dev/null and b/libs/jars/lwjgl.jar differ diff --git a/libs/natives/OpenAL.dll b/libs/natives/OpenAL.dll new file mode 100644 index 0000000..f29c3ce Binary files /dev/null and b/libs/natives/OpenAL.dll differ diff --git a/libs/natives/OpenAL32.dll b/libs/natives/OpenAL32.dll new file mode 100644 index 0000000..31d639d Binary files /dev/null and b/libs/natives/OpenAL32.dll differ diff --git a/libs/natives/glfw.dll b/libs/natives/glfw.dll new file mode 100644 index 0000000..f8c3dc7 Binary files /dev/null and b/libs/natives/glfw.dll differ diff --git a/libs/natives/glfw32.dll b/libs/natives/glfw32.dll new file mode 100644 index 0000000..3291dce Binary files /dev/null and b/libs/natives/glfw32.dll differ diff --git a/libs/natives/jemalloc.dll b/libs/natives/jemalloc.dll new file mode 100644 index 0000000..c71efc1 Binary files /dev/null and b/libs/natives/jemalloc.dll differ diff --git a/libs/natives/jemalloc32.dll b/libs/natives/jemalloc32.dll new file mode 100644 index 0000000..6bea0b3 Binary files /dev/null and b/libs/natives/jemalloc32.dll differ diff --git a/libs/natives/libglfw.dylib b/libs/natives/libglfw.dylib new file mode 100644 index 0000000..905c1bd Binary files /dev/null and b/libs/natives/libglfw.dylib differ diff --git a/libs/natives/libglfw.so b/libs/natives/libglfw.so new file mode 100644 index 0000000..e97463b Binary files /dev/null and b/libs/natives/libglfw.so differ diff --git a/libs/natives/libjemalloc.dylib b/libs/natives/libjemalloc.dylib new file mode 100644 index 0000000..1d7cc79 Binary files /dev/null and b/libs/natives/libjemalloc.dylib differ diff --git a/libs/natives/libjemalloc.so b/libs/natives/libjemalloc.so new file mode 100644 index 0000000..dc95c65 Binary files /dev/null and b/libs/natives/libjemalloc.so differ diff --git a/libs/natives/liblwjgl.dylib b/libs/natives/liblwjgl.dylib new file mode 100644 index 0000000..ff88e7d Binary files /dev/null and b/libs/natives/liblwjgl.dylib differ diff --git a/libs/natives/liblwjgl.so b/libs/natives/liblwjgl.so new file mode 100644 index 0000000..e74b914 Binary files /dev/null and b/libs/natives/liblwjgl.so differ diff --git a/libs/natives/libopenal.dylib b/libs/natives/libopenal.dylib new file mode 100644 index 0000000..7f0047b Binary files /dev/null and b/libs/natives/libopenal.dylib differ diff --git a/libs/natives/libopenal.so b/libs/natives/libopenal.so new file mode 100644 index 0000000..0c8e888 Binary files /dev/null and b/libs/natives/libopenal.so differ diff --git a/libs/natives/lwjgl.dll b/libs/natives/lwjgl.dll new file mode 100644 index 0000000..f75e81e Binary files /dev/null and b/libs/natives/lwjgl.dll differ diff --git a/libs/natives/lwjgl32.dll b/libs/natives/lwjgl32.dll new file mode 100644 index 0000000..daa0541 Binary files /dev/null and b/libs/natives/lwjgl32.dll differ diff --git a/out/production/lab/Main.class b/out/production/lab/Main.class new file mode 100644 index 0000000..e0890fc Binary files /dev/null and b/out/production/lab/Main.class differ diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..3011cae --- /dev/null +++ b/src/Main.java @@ -0,0 +1,107 @@ +import org.lwjgl.*; +import org.lwjgl.glfw.*; +import org.lwjgl.opengl.*; + +import java.io.Console; + +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 Main { + + // 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 Main().run(); + } + +}