├── jglfw ├── libs │ └── gdx-jnigen.jar ├── jni │ ├── al-libs │ │ └── libopenal.dylib │ ├── al-headers │ │ └── AL │ │ │ └── efx-creative.h │ ├── memcpy_wrap.c │ ├── glfw-3.0 │ │ ├── src │ │ │ ├── glfw3.pc.in │ │ │ ├── time.c │ │ │ ├── clipboard.c │ │ │ ├── nsgl_platform.h │ │ │ ├── win32_gamma.c │ │ │ ├── cocoa_time.c │ │ │ ├── cocoa_clipboard.m │ │ │ ├── x11_time.c │ │ │ ├── egl_platform.h │ │ │ ├── win32_time.c │ │ │ ├── gamma.c │ │ │ ├── CMakeLists.txt │ │ │ ├── config.h.in │ │ │ ├── joystick.c │ │ │ ├── wgl_platform.h │ │ │ ├── cocoa_gamma.c │ │ │ ├── win32_clipboard.c │ │ │ ├── glx_platform.h │ │ │ └── cocoa_platform.h │ │ ├── CMake │ │ │ ├── modules │ │ │ │ ├── FindEGL.cmake │ │ │ │ ├── FindGLESv2.cmake │ │ │ │ └── FindGLESv1.cmake │ │ │ ├── i586-mingw32msvc.cmake │ │ │ ├── amd64-mingw32msvc.cmake │ │ │ ├── i686-w64-mingw32.cmake │ │ │ ├── i686-pc-mingw32.cmake │ │ │ ├── x86_64-w64-mingw32.cmake │ │ │ └── README.txt │ │ ├── docs │ │ │ └── main.dox │ │ ├── COPYING.txt │ │ ├── .gitignore │ │ ├── cmake_uninstall.cmake.in │ │ ├── support │ │ │ └── getopt.h │ │ ├── examples │ │ │ └── CMakeLists.txt │ │ └── tests │ │ │ ├── title.c │ │ │ ├── windows.c │ │ │ ├── CMakeLists.txt │ │ │ ├── fsfocus.c │ │ │ ├── tearing.c │ │ │ ├── defaults.c │ │ │ ├── accuracy.c │ │ │ ├── threads.c │ │ │ ├── peter.c │ │ │ ├── clipboard.c │ │ │ ├── fsaa.c │ │ │ ├── gamma.c │ │ │ ├── reopen.c │ │ │ ├── iconify.c │ │ │ └── sharing.c │ ├── jni-headers │ │ ├── win32 │ │ │ ├── jni_md.h │ │ │ └── jawt_md.h │ │ ├── mac │ │ │ └── jni_md.h │ │ └── linux │ │ │ ├── jni_md.h │ │ │ └── jawt_md.h │ ├── build.xml │ ├── maven │ │ ├── desktop.xml │ │ └── pom.xml │ ├── com.badlogic.jglfw.utils.Memory.h │ ├── com.badlogic.jglfw.utils.Memory.cpp │ └── build.sh ├── .project ├── src │ └── com │ │ └── badlogic │ │ └── jglfw │ │ ├── GlfwVideoMode.java │ │ ├── generators │ │ ├── al_custom.txt │ │ └── gl_custom.txt │ │ ├── GlfwCallbackAdapter.java │ │ ├── utils │ │ └── Memory.java │ │ ├── GlfwCallbacks.java │ │ └── GlfwCallback.java ├── .classpath ├── .settings │ └── org.eclipse.jdt.core.prefs └── pom.xml ├── .gitignore ├── jglfw-tests ├── .classpath ├── src │ └── com │ │ └── badlogic │ │ └── jglfw │ │ └── tests │ │ ├── AlcTest.java │ │ ├── SimpleTest.java │ │ ├── GlDrawBufferTest.java │ │ ├── AwtTest.java │ │ ├── ShaderTest.java │ │ ├── MemoryTest.java │ │ ├── LongPointerTest.java │ │ ├── FullscreenTest.java │ │ └── GlfwTest.java ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs └── pom.xml ├── pom.xml └── README.md /jglfw/libs/gdx-jnigen.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badlogic/jglfw/HEAD/jglfw/libs/gdx-jnigen.jar -------------------------------------------------------------------------------- /jglfw/jni/al-libs/libopenal.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badlogic/jglfw/HEAD/jglfw/jni/al-libs/libopenal.dylib -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.o 3 | *.a 4 | *.so 5 | *.dll 6 | *.jar 7 | *.class 8 | libs/ 9 | target/ 10 | bin/ 11 | jglfw-*.zip 12 | -------------------------------------------------------------------------------- /jglfw/jni/al-headers/AL/efx-creative.h: -------------------------------------------------------------------------------- 1 | /* The tokens that would be defined here are already defined in efx.h. This 2 | * empty file is here to provide compatibility with Windows-based projects 3 | * that would include it. */ 4 | -------------------------------------------------------------------------------- /jglfw-tests/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/AlcTest.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw.tests; 2 | 3 | import com.badlogic.jglfw.al.ALC; 4 | import com.badlogic.jglfw.utils.SharedLibraryLoader; 5 | 6 | public class AlcTest { 7 | public static void main(String[] args) { 8 | new SharedLibraryLoader().load("openal"); 9 | new SharedLibraryLoader().load("jglfw"); 10 | ALC.alcOpenDevice(null); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jglfw/jni/memcpy_wrap.c: -------------------------------------------------------------------------------- 1 | #ifndef __ANDROID__ 2 | #ifdef __linux__ 3 | #ifdef __x86_64__ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | __asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); 10 | 11 | void *__wrap_memcpy(void * destination, const void * source, size_t num) 12 | { 13 | return memcpy(destination, source, num); 14 | } 15 | 16 | #endif 17 | #endif 18 | #endif -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/glfw3.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/lib 5 | 6 | Name: GLFW 7 | Description: A portable library for OpenGL, window and input 8 | Version: @GLFW_VERSION_FULL@ 9 | URL: http://www.glfw.org/ 10 | Requires.private: @GLFW_PKG_DEPS@ 11 | Libs: -L${libdir} -l@GLFW_LIB_NAME@ 12 | Libs.private: @GLFW_PKG_LIBS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/modules/FindEGL.cmake: -------------------------------------------------------------------------------- 1 | # Find EGL 2 | # 3 | # EGL_INCLUDE_DIR 4 | # EGL_LIBRARY 5 | # EGL_FOUND 6 | 7 | find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h) 8 | 9 | set(EGL_NAMES ${EGL_NAMES} egl EGL) 10 | find_library(EGL_LIBRARY NAMES ${EGL_NAMES}) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR) 14 | 15 | mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) 16 | 17 | -------------------------------------------------------------------------------- /jglfw/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | jglfw 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /jglfw-tests/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | jglfw-tests 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/GlfwVideoMode.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw; 2 | 3 | public class GlfwVideoMode { 4 | public int width; 5 | public int height; 6 | public int redBits; 7 | public int greenBits; 8 | public int blueBits; 9 | @Override 10 | public String toString() { 11 | return "GlfwVideoMode [width=" + width + ", height=" + height 12 | + ", redBits=" + redBits + ", greenBits=" + greenBits 13 | + ", blueBits=" + blueBits + "]"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/modules/FindGLESv2.cmake: -------------------------------------------------------------------------------- 1 | # Find GLESv2 2 | # 3 | # GLESv2_INCLUDE_DIR 4 | # GLESv2_LIBRARY 5 | # GLESv2_FOUND 6 | 7 | find_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h) 8 | 9 | set(GLESv2_NAMES ${GLESv2_NAMES} GLESv2) 10 | find_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES}) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_LIBRARY GLESv2_INCLUDE_DIR) 14 | 15 | mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY) 16 | 17 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/modules/FindGLESv1.cmake: -------------------------------------------------------------------------------- 1 | # Find GLESv1 2 | # 3 | # GLESv1_INCLUDE_DIR 4 | # GLESv1_LIBRARY 5 | # GLESv1_FOUND 6 | 7 | find_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h) 8 | 9 | set(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM) 10 | find_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES}) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | find_package_handle_standard_args(GLESv1 DEFAULT_MSG GLESv1_LIBRARY GLESv1_INCLUDE_DIR) 14 | 15 | mark_as_advanced(GLESv1_INCLUDE_DIR GLESv1_LIBRARY) 16 | 17 | -------------------------------------------------------------------------------- /jglfw/jni/jni-headers/win32/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * %W% %E% 3 | * 4 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT __declspec(dllexport) 12 | #define JNIIMPORT __declspec(dllimport) 13 | #define JNICALL __stdcall 14 | 15 | typedef long jint; 16 | typedef __int64 jlong; 17 | typedef signed char jbyte; 18 | 19 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 20 | -------------------------------------------------------------------------------- /jglfw/jni/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/docs/main.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @mainpage notitle 4 | 5 | @section main_intro Introduction 6 | 7 | GLFW is a free, Open Source, multi-platform library for opening a window, 8 | creating an OpenGL context and managing input. It is easy to integrate into 9 | existing applications and does not lay claim to the main loop. 10 | 11 | @link quick Quick introduction @endlink is a short tutorial for people new to GLFW. 12 | 13 | @link moving Moving from GLFW 2 to 3 @endlink explains what has changed and how 14 | to update existing code to use the GLFW 3 API. 15 | 16 | */ 17 | -------------------------------------------------------------------------------- /jglfw/jni/jni-headers/mac/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.19 05/11/17 3 | * 4 | * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 5 | * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT __attribute__((visibility("default"))) 12 | #define JNIIMPORT 13 | #define JNICALL 14 | 15 | #if __LP64__ 16 | typedef int jint; 17 | #else 18 | typedef long jint; 19 | #endif 20 | typedef long long jlong; 21 | typedef signed char jbyte; 22 | 23 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 24 | -------------------------------------------------------------------------------- /jglfw/jni/jni-headers/linux/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.20 10/03/23 3 | * 4 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JNI_MD_H_ 9 | #define _JAVASOFT_JNI_MD_H_ 10 | 11 | #define JNIEXPORT 12 | #define JNIIMPORT 13 | #define JNICALL 14 | 15 | typedef int jint; 16 | #ifdef _LP64 /* 64-bit Solaris */ 17 | typedef long jlong; 18 | #else 19 | typedef long long jlong; 20 | #endif 21 | 22 | typedef signed char jbyte; 23 | 24 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 25 | -------------------------------------------------------------------------------- /jglfw/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/i586-mingw32msvc.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i586-mingw32msvc-gcc") 5 | SET(CMAKE_CXX_COMPILER "i586-mingw32msvc-g++") 6 | SET(CMAKE_RC_COMPILER "i586-mingw32msvc-windres") 7 | SET(CMAKE_RANLIB "i586-mingw32msvc-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i586-mingw32msvc") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/amd64-mingw32msvc.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win64 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc") 5 | SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++") 6 | SET(CMAKE_RC_COMPILER "amd64-mingw32msvc-windres") 7 | SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /jglfw/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /jglfw-tests/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.6 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.6 12 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/i686-pc-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-pc-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "i686-pc-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "i686-pc-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-pc-mingw32-ranlib") 8 | 9 | #Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/opt/mingw/usr/i686-pc-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross compiling from Linux to Win32 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /jglfw/jni/maven/desktop.xml: -------------------------------------------------------------------------------- 1 | 4 | natives-desktop 5 | 6 | jar 7 | 8 | false 9 | 10 | 11 | ${project.build.directory}/desktop 12 | / 13 | 14 | ** 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/CMake/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains a collection of toolchain definitions for 2 | cross-compiling for Windows using MinGW on various other systems. 3 | 4 | To use these files you add a special parameter when configuring the source tree: 5 | 6 | cmake -DCMAKE_TOOLCHAIN_FILE= . 7 | 8 | The exact file to use depends on the prefix used by the MinGW binaries on your 9 | system. You can usually see this in the /usr directory, i.e. the Ubuntu 10 | MinGW-w64 packages have /usr/x86_64-w64-mingw32 for the 64-bit compilers, so the 11 | correct invocation would be: 12 | 13 | cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake . 14 | 15 | For more details see this article: 16 | 17 | http://www.paraview.org/Wiki/CMake_Cross_Compiling 18 | 19 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2010 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Makefile 3 | CMakeCache.txt 4 | CMakeFiles 5 | cmake_install.cmake 6 | cmake_uninstall.cmake 7 | docs/Doxyfile 8 | src/config.h 9 | src/glfw3.pc 10 | src/libglfw3.so 11 | src/libglfw3.a 12 | src/libglfw3.dylib 13 | src/glfw3.lib 14 | src/glfw3.dll 15 | src/glfw3dll.lib 16 | examples/*.app 17 | examples/*.exe 18 | examples/boing 19 | examples/gears 20 | examples/heightmap 21 | examples/splitview 22 | examples/triangle 23 | examples/wave 24 | src/config.h 25 | tests/*.app 26 | tests/*.exe 27 | tests/accuracy 28 | tests/clipboard 29 | tests/defaults 30 | tests/events 31 | tests/fsaa 32 | tests/fsfocus 33 | tests/gamma 34 | tests/glfwinfo 35 | tests/iconify 36 | tests/joysticks 37 | tests/modes 38 | tests/peter 39 | tests/reopen 40 | tests/sharing 41 | tests/tearing 42 | tests/threads 43 | tests/title 44 | tests/version 45 | tests/windows 46 | 47 | # Windows/VS ignores 48 | *.dir 49 | *.vcxproj* 50 | *.sln 51 | _ReSharper* 52 | Win32 53 | examples/Debug 54 | tests/Debug 55 | src/Debug 56 | *.opensdf 57 | *.sdf 58 | -------------------------------------------------------------------------------- /jglfw/jni/jni-headers/win32/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * %W% %E% 3 | * 4 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JAWT_MD_H_ 9 | #define _JAVASOFT_JAWT_MD_H_ 10 | 11 | #include 12 | #include "jawt.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /* 19 | * Win32-specific declarations for AWT native interface. 20 | * See notes in jawt.h for an example of use. 21 | */ 22 | typedef struct jawt_Win32DrawingSurfaceInfo { 23 | /* Native window, DDB, or DIB handle */ 24 | union { 25 | HWND hwnd; 26 | HBITMAP hbitmap; 27 | void* pbits; 28 | }; 29 | /* 30 | * This HDC should always be used instead of the HDC returned from 31 | * BeginPaint() or any calls to GetDC(). 32 | */ 33 | HDC hdc; 34 | HPALETTE hpalette; 35 | } JAWT_Win32DrawingSurfaceInfo; 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 42 | -------------------------------------------------------------------------------- /jglfw/jni/com.badlogic.jglfw.utils.Memory.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_badlogic_jglfw_utils_Memory */ 4 | 5 | #ifndef _Included_com_badlogic_jglfw_utils_Memory 6 | #define _Included_com_badlogic_jglfw_utils_Memory 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_badlogic_jglfw_utils_Memory 12 | * Method: mallocJni 13 | * Signature: (I)Ljava/nio/ByteBuffer; 14 | */ 15 | JNIEXPORT jobject JNICALL Java_com_badlogic_jglfw_utils_Memory_mallocJni 16 | (JNIEnv *, jclass, jint); 17 | 18 | /* 19 | * Class: com_badlogic_jglfw_utils_Memory 20 | * Method: free 21 | * Signature: (Ljava/nio/Buffer;)V 22 | */ 23 | JNIEXPORT void JNICALL Java_com_badlogic_jglfw_utils_Memory_free 24 | (JNIEnv *, jclass, jobject); 25 | 26 | /* 27 | * Class: com_badlogic_jglfw_utils_Memory 28 | * Method: getBufferAddress 29 | * Signature: (Ljava/nio/Buffer;)J 30 | */ 31 | JNIEXPORT jlong JNICALL Java_com_badlogic_jglfw_utils_Memory_getBufferAddress 32 | (JNIEnv *, jclass, jobject); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif 38 | -------------------------------------------------------------------------------- /jglfw/jni/jni-headers/linux/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jawt_md.h 1.13 10/03/23 3 | * 4 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 5 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 | */ 7 | 8 | #ifndef _JAVASOFT_JAWT_MD_H_ 9 | #define _JAVASOFT_JAWT_MD_H_ 10 | 11 | #include 12 | #include 13 | #include 14 | #include "jawt.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /* 21 | * X11-specific declarations for AWT native interface. 22 | * See notes in jawt.h for an example of use. 23 | */ 24 | typedef struct jawt_X11DrawingSurfaceInfo { 25 | Drawable drawable; 26 | Display* display; 27 | VisualID visualID; 28 | Colormap colormapID; 29 | int depth; 30 | /* 31 | * Since 1.4 32 | * Returns a pixel value from a set of RGB values. 33 | * This is useful for paletted color (256 color) modes. 34 | */ 35 | int (JNICALL *GetAWTColor)(JAWT_DrawingSurface* ds, 36 | int r, int g, int b); 37 | } JAWT_X11DrawingSurfaceInfo; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 44 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/SimpleTest.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlogic.jglfw.tests; 3 | 4 | import static com.badlogic.jglfw.Glfw.*; 5 | 6 | import com.badlogic.jglfw.GlfwCallback; 7 | 8 | import java.util.Arrays; 9 | 10 | import javax.swing.JFrame; 11 | 12 | import com.badlogic.jglfw.gl.GL; 13 | 14 | public class SimpleTest { 15 | public static void main (String[] args) throws Exception { 16 | if (!glfwInit()) { 17 | System.out.println("Couldn't initialize GLFW"); 18 | System.exit(-1); 19 | } 20 | glfwWindowHint(GLFW_DEPTH_BITS, 16); // this is needed on virtualbox... 21 | long window = glfwCreateWindow(800, 600, "Test", 0, 0); 22 | if (window == 0) { 23 | throw new RuntimeException("Couldn't create window"); 24 | } 25 | glfwMakeContextCurrent(window); 26 | while (!glfwWindowShouldClose(window)) { 27 | GL.glViewport(0, 0, 640, 480); 28 | GL.glClear(GL.GL_COLOR_BUFFER_BIT); 29 | GL.glRotatef(0.01f, 0, 0, 1); 30 | GL.glBegin(GL.GL_TRIANGLES); 31 | GL.glVertex2f(-0.5f, -0.5f); 32 | GL.glVertex2f(0.5f, -0.5f); 33 | GL.glVertex2f(0, 0.5f); 34 | GL.glEnd(); 35 | glfwPollEvents(); 36 | glfwSwapBuffers(window); 37 | } 38 | glfwDestroyWindow(window); 39 | glfwTerminate(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 4 | endif() 5 | 6 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 7 | string(REGEX REPLACE "\n" ";" files "${files}") 8 | 9 | foreach (file ${files}) 10 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 11 | if (EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 13 | OUTPUT_VARIABLE rm_out 14 | RETURN_VALUE rm_retval) 15 | if (NOT "${rm_retval}" STREQUAL 0) 16 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 17 | endif() 18 | elseif (IS_SYMLINK "$ENV{DESTDIR}${file}") 19 | EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 20 | OUTPUT_VARIABLE rm_out 21 | RETURN_VALUE rm_retval) 22 | if (NOT "${rm_retval}" STREQUAL 0) 23 | message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"") 24 | endif() 25 | else() 26 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 27 | endif() 28 | endforeach() 29 | 30 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/generators/al_custom.txt: -------------------------------------------------------------------------------- 1 | alcCreateContext 2 | public static native long alcCreateContext(long device, int[] attrlist); /* 3 | return (jlong)alcCreateContext((ALCdevice*)(device), (const ALCint*)(attrlist)); 4 | */ 5 | ----- 6 | alcGetCurrentContext 7 | public static native long alcGetCurrentContext(); /* 8 | return (jlong)alcGetCurrentContext(); 9 | */ 10 | ----- 11 | alcGetContextsDevice 12 | public static native long alcGetContextsDevice(long context); /* 13 | return (jlong)alcGetContextsDevice((ALCcontext*)context); 14 | */ 15 | ----- 16 | alcOpenDevice 17 | public static native long alcOpenDevice(String deviceName); /* 18 | return (long)alcOpenDevice((const ALCchar*)(deviceName)); 19 | */ 20 | ----- 21 | alcGetString 22 | public static native String alcGetString(long device, int name); /* 23 | return env->NewStringUTF((const char*)alcGetString((ALCdevice*)device, (ALCenum)name)); 24 | */ 25 | ----- 26 | alcCaptureOpenDevice 27 | public static native long alcCaptureOpenDevice(String deviceName, int frequency, int format, int buffersize); /* 28 | return (jlong)alcCaptureOpenDevice((const ALCchar*)deviceName, (ALCuint)frequency, (ALCenum)format, (ALCsizei)buffersize); 29 | */ 30 | ----- 31 | alGetString 32 | public static native Buffer alGetString(int param); /* 33 | return env->NewStringUTF((const char*)alGetString((ALenum)param)); 34 | */ 35 | ----- -------------------------------------------------------------------------------- /jglfw/jni/com.badlogic.jglfw.utils.Memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //@line:24 4 | 5 | #include 6 | #include 7 | #include 8 | JNIEXPORT jobject JNICALL Java_com_badlogic_jglfw_utils_Memory_mallocJni(JNIEnv* env, jclass clazz, jint numBytes) { 9 | 10 | 11 | //@line:44 12 | 13 | char* ptr = (char*)malloc(numBytes); 14 | if(ptr == 0) return 0; 15 | return env->NewDirectByteBuffer(ptr, numBytes); 16 | 17 | 18 | } 19 | 20 | JNIEXPORT void JNICALL Java_com_badlogic_jglfw_utils_Memory_free(JNIEnv* env, jclass clazz, jobject obj_buffer) { 21 | unsigned char* buffer = (unsigned char*)(obj_buffer?env->GetDirectBufferAddress(obj_buffer):0); 22 | 23 | 24 | //@line:53 25 | 26 | free(buffer); 27 | 28 | 29 | } 30 | 31 | static inline jlong wrapped_Java_com_badlogic_jglfw_utils_Memory_getBufferAddress 32 | (JNIEnv* env, jclass clazz, jobject obj_buffer, unsigned char* buffer) { 33 | 34 | //@line:64 35 | 36 | return (jlong) buffer; 37 | 38 | } 39 | 40 | JNIEXPORT jlong JNICALL Java_com_badlogic_jglfw_utils_Memory_getBufferAddress(JNIEnv* env, jclass clazz, jobject obj_buffer) { 41 | unsigned char* buffer = (unsigned char*)(obj_buffer?env->GetDirectBufferAddress(obj_buffer):0); 42 | 43 | jlong JNI_returnValue = wrapped_Java_com_badlogic_jglfw_utils_Memory_getBufferAddress(env, clazz, obj_buffer, buffer); 44 | 45 | 46 | return JNI_returnValue; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/GlfwCallbackAdapter.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw; 2 | 3 | public class GlfwCallbackAdapter implements GlfwCallback { 4 | @Override 5 | public void error (int error, String description) { 6 | } 7 | 8 | @Override 9 | public void monitor (long monitor, boolean connected) { 10 | } 11 | 12 | @Override 13 | public void windowPos (long window, int x, int y) { 14 | } 15 | 16 | @Override 17 | public void windowSize (long window, int width, int height) { 18 | } 19 | 20 | @Override 21 | public boolean windowClose (long window) { 22 | return true; 23 | } 24 | 25 | @Override 26 | public void windowRefresh (long window) { 27 | } 28 | 29 | @Override 30 | public void windowFocus (long window, boolean focused) { 31 | } 32 | 33 | @Override 34 | public void windowIconify (long window, boolean iconified) { 35 | } 36 | 37 | @Override 38 | public void key (long window, int key, int scanCode, int action, int mods) { 39 | } 40 | 41 | @Override 42 | public void character (long window, char character) { 43 | } 44 | 45 | @Override 46 | public void mouseButton (long window, int button, boolean pressed) { 47 | } 48 | 49 | @Override 50 | public void cursorPos (long window, int x, int y) { 51 | } 52 | 53 | @Override 54 | public void cursorEnter (long window, boolean entered) { 55 | } 56 | 57 | @Override 58 | public void scroll (long window, double scrollX, double scrollY) { 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/GlDrawBufferTest.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw.tests; 2 | 3 | import static com.badlogic.jglfw.Glfw.*; 4 | import static com.badlogic.jglfw.gl.GL.*; 5 | 6 | import java.nio.CharBuffer; 7 | import java.nio.FloatBuffer; 8 | 9 | import com.badlogic.jglfw.GlfwCallbackAdapter; 10 | import com.badlogic.jglfw.utils.Memory; 11 | 12 | public class GlDrawBufferTest { 13 | public static void main (String[] args) { 14 | glfwInit(); 15 | // glfwWindowHint(GLFW_DEPTH_BITS, 16); 16 | long window = glfwCreateWindow(800, 600, "GL Draw Buffer Test", glfwGetPrimaryMonitor(), 0); 17 | glfwMakeContextCurrent(window); 18 | glfwSetCallback(new GlfwCallbackAdapter() { 19 | @Override 20 | public void windowSize (long window, int width, int height) { 21 | glViewport(0, 0, width, height); 22 | } 23 | }); 24 | 25 | FloatBuffer vertices = Memory.malloc(9 * 4).asFloatBuffer(); 26 | vertices.put(new float[] {-0.5f, -0.5f, 0, 0.5f, -0.5f, 0, 0, 0.5f, 0 }); 27 | CharBuffer indices = Memory.malloc(3 * 2).asCharBuffer(); 28 | indices.put(new char[] { 0, 1, 2 }); 29 | 30 | while(!glfwWindowShouldClose(window) || glfwGetKey(window, GLFW_KEY_ESCAPE)) { 31 | glClearColor(1, 0, 0, 1); 32 | glClear(GL_COLOR_BUFFER_BIT); 33 | 34 | glRotatef(0.1f, 0, 0, 1); 35 | 36 | glEnableClientState(GL_VERTEX_ARRAY); 37 | glVertexPointer(3, GL_FLOAT, 3 * 4, vertices, 0); 38 | glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indices, 0); 39 | 40 | glfwPollEvents(); 41 | glfwSwapBuffers(window); 42 | } 43 | 44 | Memory.free(vertices); 45 | Memory.free(indices); 46 | glfwTerminate(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jglfw/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.badlogicgames.jglfw 6 | jglfw-parent 7 | 1.2-SNAPSHOT 8 | ../pom.xml 9 | 10 | 11 | jglfw 12 | jar 13 | JGLFW 14 | 15 | 16 | 17 | com.badlogicgames.gdx 18 | gdx-jnigen 19 | 2.3.0 20 | 21 | 22 | 23 | 24 | src 25 | 26 | 27 | libs/macos 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-source-plugin 34 | 2.2.1 35 | 36 | 37 | attach-sources 38 | generate-resources 39 | 40 | jar-no-fork 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/AwtTest.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlogic.jglfw.tests; 3 | 4 | import static com.badlogic.jglfw.Glfw.*; 5 | 6 | import com.badlogic.jglfw.GlfwCallback; 7 | 8 | import java.awt.EventQueue; 9 | import java.awt.Toolkit; 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import java.util.Arrays; 13 | 14 | import javax.swing.JButton; 15 | import javax.swing.JFrame; 16 | 17 | import com.badlogic.jglfw.gl.GL; 18 | 19 | public class AwtTest { 20 | public static void main (String[] args) throws Exception { 21 | EventQueue.invokeLater(new Runnable() { 22 | public void run () { 23 | Toolkit.getDefaultToolkit(); 24 | 25 | if (!glfwInit()) { 26 | System.out.println("Couldn't initialize GLFW"); 27 | System.exit(-1); 28 | } 29 | glfwWindowHint(GLFW_DEPTH_BITS, 16); // this is needed on virtualbox... 30 | final long window = glfwCreateWindow(800, 600, "Test", 0, 0); 31 | if (window == 0) { 32 | throw new RuntimeException("Couldn't create window"); 33 | } 34 | glfwMakeContextCurrent(window); 35 | glfwSwapInterval(1); 36 | 37 | new Runnable() { 38 | public void run () { 39 | if (glfwWindowShouldClose(window)) { 40 | glfwDestroyWindow(window); 41 | glfwTerminate(); 42 | return; 43 | } 44 | GL.glViewport(0, 0, 640, 480); 45 | GL.glClear(GL.GL_COLOR_BUFFER_BIT); 46 | GL.glRotatef(0.01f, 0, 0, 1); 47 | GL.glBegin(GL.GL_TRIANGLES); 48 | GL.glVertex2f(-0.5f, -0.5f); 49 | GL.glVertex2f(0.5f, -0.5f); 50 | GL.glVertex2f(0, 0.5f); 51 | GL.glEnd(); 52 | glfwPollEvents(); 53 | glfwSwapBuffers(window); 54 | EventQueue.invokeLater(this); 55 | } 56 | }.run(); 57 | } 58 | }); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/ShaderTest.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw.tests; 2 | 3 | import com.badlogic.jglfw.GlfwCallbackAdapter; 4 | import com.badlogic.jglfw.gl.GL; 5 | 6 | import static com.badlogic.jglfw.gl.GL.*; 7 | import static com.badlogic.jglfw.Glfw.*; 8 | 9 | 10 | public class ShaderTest { 11 | public static void main (String[] args) { 12 | glfwInit(); 13 | glfwWindowHint(GLFW_DEPTH_BITS, 16); 14 | long window = glfwCreateWindow(480, 320, "Shader Test", 0, 0); 15 | glfwMakeContextCurrent(window); 16 | glfwSetCallback(new GlfwCallbackAdapter() { 17 | @Override 18 | public void windowSize (long window, int width, int height) { 19 | glViewport(0, 0, width, height); 20 | } 21 | }); 22 | 23 | String vertexShader = "void main() { gl_Position = ftransform(); }"; 24 | String fragmentShader = "void main() { gl_FragColor = vec4(0.4,0.4,0.8,1.0); }"; 25 | 26 | int vShader = GL.glCreateShader(GL.GL_VERTEX_SHADER); 27 | GL.glShaderSource(vShader, vertexShader); 28 | GL.glCompileShader(vShader); 29 | int fShader = GL.glCreateShader(GL.GL_FRAGMENT_SHADER); 30 | GL.glShaderSource(fShader, fragmentShader); 31 | GL.glCompileShader(fShader); 32 | int program = GL.glCreateProgram(); 33 | GL.glAttachShader(program, vShader); 34 | GL.glAttachShader(program, fShader); 35 | GL.glLinkProgram(program); 36 | 37 | GL.glUseProgram(program); 38 | 39 | while(!glfwWindowShouldClose(window)) { 40 | glClearColor(1, 0, 0, 1); 41 | glClear(GL_COLOR_BUFFER_BIT); 42 | 43 | GL.glRotatef(0.01f, 0, 0, 1); 44 | GL.glBegin(GL.GL_TRIANGLES); 45 | GL.glVertex2f(-0.5f, -0.5f); 46 | GL.glVertex2f(0.5f, -0.5f); 47 | GL.glVertex2f(0, 0.5f); 48 | GL.glEnd(); 49 | 50 | glfwPollEvents(); 51 | glfwSwapBuffers(window); 52 | } 53 | 54 | glfwTerminate(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Any 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW public API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | GLFWAPI double glfwGetTime(void) 39 | { 40 | _GLFW_REQUIRE_INIT_OR_RETURN(0.0); 41 | return _glfwPlatformGetTime(); 42 | } 43 | 44 | GLFWAPI void glfwSetTime(double time) 45 | { 46 | _GLFW_REQUIRE_INIT(); 47 | _glfwPlatformSetTime(time); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Any 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | 35 | 36 | ////////////////////////////////////////////////////////////////////////// 37 | ////// GLFW public API ////// 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) 41 | { 42 | _GLFWwindow* window = (_GLFWwindow*) handle; 43 | _GLFW_REQUIRE_INIT(); 44 | _glfwPlatformSetClipboardString(window, string); 45 | } 46 | 47 | GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) 48 | { 49 | _GLFWwindow* window = (_GLFWwindow*) handle; 50 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 51 | return _glfwPlatformGetClipboardString(window); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/support/getopt.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * getopt.h - competent and free getopt library. 3 | * $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ 4 | * 5 | * Copyright (c)2002-2003 Mark K. Kim 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the original author of this software nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 31 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 34 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 35 | * DAMAGE. 36 | */ 37 | #ifndef GETOPT_H_ 38 | #define GETOPT_H_ 39 | 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | extern char* optarg; 47 | extern int optind; 48 | extern int opterr; 49 | extern int optopt; 50 | 51 | int getopt(int argc, char** argv, const char* optstr); 52 | 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | 59 | #endif /* GETOPT_H_ */ 60 | 61 | 62 | /* vim:ts=3 63 | */ 64 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw ${OPENGL_glu_LIBRARY}) 3 | 4 | if (BUILD_SHARED_LIBS) 5 | add_definitions(-DGLFW_DLL) 6 | link_libraries(${OPENGL_gl_LIBRARY} ${MATH_LIBRARY}) 7 | else() 8 | link_libraries(${glfw_LIBRARIES}) 9 | endif() 10 | 11 | include_directories(${GLFW_SOURCE_DIR}/include 12 | ${GLFW_SOURCE_DIR}/support) 13 | 14 | if (MSVC) 15 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 16 | endif() 17 | 18 | if (NOT APPLE) 19 | # HACK: This is NOTFOUND on OS X 10.8 20 | include_directories(${OPENGL_INCLUDE_DIR}) 21 | endif() 22 | 23 | set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h 24 | ${GLFW_SOURCE_DIR}/support/getopt.c) 25 | 26 | if (APPLE) 27 | # Set fancy names for bundles 28 | add_executable(Boing MACOSX_BUNDLE boing.c) 29 | add_executable(Gears MACOSX_BUNDLE gears.c) 30 | add_executable(Simple MACOSX_BUNDLE simple.c) 31 | add_executable(SplitView MACOSX_BUNDLE splitview.c) 32 | add_executable(Wave MACOSX_BUNDLE wave.c) 33 | 34 | set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing") 35 | set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears") 36 | set_target_properties(Simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") 37 | set_target_properties(SplitView PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") 38 | set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") 39 | else() 40 | # Set boring names for executables 41 | add_executable(boing WIN32 boing.c) 42 | add_executable(gears WIN32 gears.c) 43 | add_executable(heightmap WIN32 heightmap.c ${GETOPT}) 44 | add_executable(simple WIN32 simple.c) 45 | add_executable(splitview WIN32 splitview.c) 46 | add_executable(wave WIN32 wave.c) 47 | endif() 48 | 49 | if (MSVC) 50 | set(WINDOWS_BINARIES boing gears heightmap simple splitview wave) 51 | 52 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 53 | set_target_properties(${WINDOWS_BINARIES} PROPERTIES 54 | LINK_FLAGS "/ENTRY:mainCRTStartup") 55 | endif() 56 | 57 | if (APPLE) 58 | set(BUNDLE_BINARIES Boing Gears Simple SplitView Wave) 59 | 60 | set_target_properties(${BUNDLE_BINARIES} PROPERTIES 61 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 62 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) 63 | endif() 64 | 65 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/title.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // UTF-8 window title test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test sets a UTF-8 window title 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | static void error_callback(int error, const char* description) 36 | { 37 | fprintf(stderr, "Error: %s\n", description); 38 | } 39 | 40 | static void window_size_callback(GLFWwindow* window, int width, int height) 41 | { 42 | glViewport(0, 0, width, height); 43 | } 44 | 45 | int main(void) 46 | { 47 | GLFWwindow* window; 48 | 49 | glfwSetErrorCallback(error_callback); 50 | 51 | if (!glfwInit()) 52 | exit(EXIT_FAILURE); 53 | 54 | window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL); 55 | if (!window) 56 | { 57 | glfwTerminate(); 58 | exit(EXIT_FAILURE); 59 | } 60 | 61 | glfwMakeContextCurrent(window); 62 | glfwSwapInterval(1); 63 | 64 | glfwSetWindowSizeCallback(window, window_size_callback); 65 | 66 | while (!glfwWindowShouldClose(window)) 67 | { 68 | glClear(GL_COLOR_BUFFER_BIT); 69 | glfwSwapBuffers(window); 70 | glfwWaitEvents(); 71 | } 72 | 73 | glfwTerminate(); 74 | exit(EXIT_SUCCESS); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.sonatype.oss 6 | oss-parent 7 | 5 8 | 9 | 10 | com.badlogicgames.jglfw 11 | jglfw-parent 12 | pom 13 | 1.2-SNAPSHOT 14 | 15 | JGLFW- parent 16 | Java wrapper for GLFW 17 | http://github.com/badlogic/jglfw 18 | 19 | https://github.com/badlogic/jglfw/issues 20 | 21 | 22 | 23 | 24 | Apache Licence 2.0 25 | http://www.apache.org/licenses/LICENSE-2.0 26 | repo 27 | 28 | 29 | 30 | 31 | 32 | Developers 33 | https://github.com/badlogic/jglfw/graphs/contributors 34 | 35 | 36 | 37 | 38 | scm:git:https://github.com/badlogic/jglfw.git 39 | scm:git:https://github.com/badlogic/jglfw.git 40 | http://github.com/badlogic/jglfw 41 | 42 | 43 | 44 | 45 | gdx-nightlies 46 | https://oss.sonatype.org/content/repositories/snapshots/ 47 | 48 | 49 | 50 | 51 | 52 | 53 | org.apache.maven.plugins 54 | maven-source-plugin 55 | 56 | 57 | attach-sources 58 | generate-resources 59 | 60 | jar-no-fork 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-compiler-plugin 68 | 3.1 69 | 70 | 1.7 71 | 1.7 72 | true 73 | true 74 | 75 | 76 | 77 | 78 | 79 | 80 | jglfw 81 | jglfw-tests 82 | 83 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/nsgl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: NSOpenGL 4 | // API Version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2009-2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #ifndef _nsgl_platform_h_ 31 | #define _nsgl_platform_h_ 32 | 33 | 34 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 35 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL nsgl 36 | 37 | 38 | //======================================================================== 39 | // GLFW platform specific types 40 | //======================================================================== 41 | 42 | //------------------------------------------------------------------------ 43 | // Platform-specific OpenGL context structure 44 | //------------------------------------------------------------------------ 45 | typedef struct _GLFWcontextNSGL 46 | { 47 | id pixelFormat; 48 | id context; 49 | } _GLFWcontextNSGL; 50 | 51 | 52 | //------------------------------------------------------------------------ 53 | // Platform-specific library global data for NSGL 54 | //------------------------------------------------------------------------ 55 | typedef struct _GLFWlibraryNSGL 56 | { 57 | // dlopen handle for dynamically loading OpenGL extension entry points 58 | void* framework; 59 | } _GLFWlibraryNSGL; 60 | 61 | 62 | #endif // _nsgl_platform_h_ 63 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/win32_gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Win32 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 40 | { 41 | HDC dc; 42 | DISPLAY_DEVICE display; 43 | 44 | ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); 45 | display.cb = sizeof(DISPLAY_DEVICE); 46 | EnumDisplayDevices(monitor->win32.name, 0, &display, 0); 47 | 48 | dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); 49 | GetDeviceGammaRamp(dc, (WORD*) ramp); 50 | DeleteDC(dc); 51 | } 52 | 53 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 54 | { 55 | HDC dc; 56 | DISPLAY_DEVICE display; 57 | 58 | ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); 59 | display.cb = sizeof(DISPLAY_DEVICE); 60 | EnumDisplayDevices(monitor->win32.name, 0, &display, 0); 61 | 62 | dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); 63 | SetDeviceGammaRamp(dc, (WORD*) ramp); 64 | DeleteDC(dc); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/MemoryTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 3 | * "Kompetenzzentrum fuer wissensbasierte Anwendungen Forschungs- und EntwicklungsgmbH" 4 | * (Know-Center), Graz, Austria, office@know-center.at. 5 | * 6 | * Licensees holding valid Know-Center Commercial licenses may use this file in 7 | * accordance with the Know-Center Commercial License Agreement provided with 8 | * the Software or, alternatively, in accordance with the terms contained in 9 | * a written agreement between Licensees and Know-Center. 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Affero General Public License as 13 | * published by the Free Software Foundation, either version 3 of the 14 | * License, or (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Affero General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Affero General Public License 22 | * along with this program. If not, see . 23 | */ 24 | package com.badlogic.jglfw.tests; 25 | 26 | import java.nio.ByteBuffer; 27 | import java.nio.CharBuffer; 28 | import java.nio.DoubleBuffer; 29 | import java.nio.FloatBuffer; 30 | import java.nio.IntBuffer; 31 | import java.nio.LongBuffer; 32 | import java.nio.ShortBuffer; 33 | 34 | import com.badlogic.jglfw.utils.Memory; 35 | 36 | public class MemoryTest { 37 | public static void main(String[] args) { 38 | ByteBuffer buffer = ByteBuffer.allocate(20); 39 | buffer.position(1); 40 | System.out.println(Memory.getPosition(buffer)); 41 | 42 | ShortBuffer sBuffer = buffer.asShortBuffer(); 43 | sBuffer.position(1); 44 | System.out.println(Memory.getPosition(sBuffer)); 45 | 46 | CharBuffer cBuffer = buffer.asCharBuffer(); 47 | cBuffer.position(1); 48 | System.out.println(Memory.getPosition(cBuffer)); 49 | 50 | IntBuffer iBuffer = buffer.asIntBuffer(); 51 | iBuffer.position(1); 52 | System.out.println(Memory.getPosition(iBuffer)); 53 | 54 | FloatBuffer fBuffer = buffer.asFloatBuffer(); 55 | fBuffer.position(1); 56 | System.out.println(Memory.getPosition(fBuffer)); 57 | 58 | LongBuffer lBuffer = buffer.asLongBuffer(); 59 | lBuffer.position(1); 60 | System.out.println(Memory.getPosition(lBuffer)); 61 | 62 | DoubleBuffer dBuffer = buffer.asDoubleBuffer(); 63 | dBuffer.position(1); 64 | System.out.println(Memory.getPosition(dBuffer)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Cocoa 4 | // API Version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2009-2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | // Return raw time 36 | // 37 | static uint64_t getRawTime(void) 38 | { 39 | return mach_absolute_time(); 40 | } 41 | 42 | 43 | ////////////////////////////////////////////////////////////////////////// 44 | ////// GLFW internal API ////// 45 | ////////////////////////////////////////////////////////////////////////// 46 | 47 | // Initialise timer 48 | // 49 | void _glfwInitTimer(void) 50 | { 51 | mach_timebase_info_data_t info; 52 | mach_timebase_info(&info); 53 | 54 | _glfw.ns.timer.resolution = (double) info.numer / (info.denom * 1.0e9); 55 | _glfw.ns.timer.base = getRawTime(); 56 | } 57 | 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | ////// GLFW platform API ////// 61 | ////////////////////////////////////////////////////////////////////////// 62 | 63 | double _glfwPlatformGetTime(void) 64 | { 65 | return (double) (getRawTime() - _glfw.ns.timer.base) * 66 | _glfw.ns.timer.resolution; 67 | } 68 | 69 | void _glfwPlatformSetTime(double time) 70 | { 71 | _glfw.ns.timer.base = getRawTime() - 72 | (uint64_t) (time / _glfw.ns.timer.resolution); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /jglfw-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.badlogicgames.jglfw 6 | jglfw-parent 7 | 1.2-SNAPSHOT 8 | ../pom.xml 9 | 10 | 11 | jglfw-tests 12 | jar 13 | JGLFW Tests 14 | 15 | 16 | 17 | ${project.groupId} 18 | jglfw 19 | ${project.version} 20 | 21 | 22 | 23 | 24 | src 25 | 26 | 27 | org.apache.maven.plugins 28 | maven-source-plugin 29 | 2.2.1 30 | 31 | 32 | attach-sources 33 | generate-resources 34 | 35 | jar-no-fork 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-assembly-plugin 43 | 44 | 45 | package 46 | 47 | single 48 | 49 | 50 | 51 | 52 | 53 | com.badlogic.jglfw.tests.SimpleTest 54 | 55 | 56 | 57 | 58 | jar-with-dependencies 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/utils/Memory.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw.utils; 2 | 3 | import java.nio.Buffer; 4 | import java.nio.ByteBuffer; 5 | import java.nio.ByteOrder; 6 | import java.nio.CharBuffer; 7 | import java.nio.DoubleBuffer; 8 | import java.nio.FloatBuffer; 9 | import java.nio.IntBuffer; 10 | import java.nio.LongBuffer; 11 | import java.nio.ShortBuffer; 12 | 13 | /** 14 | * Methods to allocate memory on the heap and copy. Note that buffers 15 | * allocated with methods of this class need to be freed manually 16 | * via #free(Buffer). No bounds checking is performed, all buffers 17 | * are assumed to be direct buffers. 18 | * 19 | * @author mzechner 20 | * 21 | */ 22 | public class Memory { 23 | // @off 24 | /*JNI 25 | #include 26 | #include 27 | #include 28 | */ 29 | 30 | /** 31 | * Allocates numBytes bytes on the native heap. The 32 | * returned {@link ByteBuffer} needs to be free via {@link #free(Buffer)} 33 | * when no longer used. 34 | * @param numBytes the number of bytes to allocate 35 | * @return the direct Buffer pointing to the allocated heap memory or null 36 | */ 37 | public static ByteBuffer malloc(int numBytes) { 38 | ByteBuffer buffer = mallocJni(numBytes); 39 | if(buffer == null) return null; 40 | buffer.order(ByteOrder.nativeOrder()); 41 | return buffer; 42 | } 43 | 44 | private static native ByteBuffer mallocJni (int numBytes); /* 45 | char* ptr = (char*)malloc(numBytes); 46 | if(ptr == 0) return 0; 47 | return env->NewDirectByteBuffer(ptr, numBytes); 48 | */ 49 | 50 | /** 51 | * @param buffer the direct {@link Buffer} to free, previously allocated via {@link #malloc(int)} 52 | */ 53 | public static native void free (Buffer buffer); /* 54 | free(buffer); 55 | */ 56 | 57 | /** 58 | * The address of the heap memory block the direct buffer points to. Does not 59 | * take the position of the buffer into account. 60 | * 61 | * @param buffer 62 | * @return the address of the native heap area the buffer points to 63 | */ 64 | public static native long getBufferAddress (Buffer buffer); /* 65 | return (jlong) buffer; 66 | */ 67 | 68 | public static int getPosition(Buffer buffer) { 69 | if(buffer instanceof ByteBuffer) return buffer.position(); 70 | if(buffer instanceof CharBuffer) return buffer.position() << 1; 71 | if(buffer instanceof DoubleBuffer) return buffer.position() << 3; 72 | if(buffer instanceof FloatBuffer) return buffer.position() << 2; 73 | if(buffer instanceof IntBuffer) return buffer.position() << 2; 74 | if(buffer instanceof LongBuffer) return buffer.position() << 3; 75 | if(buffer instanceof ShortBuffer) return buffer.position() << 1; 76 | if(buffer == null) return 0; 77 | return buffer.position(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/LongPointerTest.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw.tests; 2 | 3 | import static com.badlogic.jglfw.Glfw.GLFW_DEPTH_BITS; 4 | import static com.badlogic.jglfw.Glfw.glfwCreateWindow; 5 | import static com.badlogic.jglfw.Glfw.glfwInit; 6 | import static com.badlogic.jglfw.Glfw.glfwMakeContextCurrent; 7 | import static com.badlogic.jglfw.Glfw.glfwPollEvents; 8 | import static com.badlogic.jglfw.Glfw.glfwSetCallback; 9 | import static com.badlogic.jglfw.Glfw.glfwSwapBuffers; 10 | import static com.badlogic.jglfw.Glfw.glfwTerminate; 11 | import static com.badlogic.jglfw.Glfw.glfwWindowHint; 12 | import static com.badlogic.jglfw.Glfw.glfwWindowShouldClose; 13 | import static com.badlogic.jglfw.gl.GL.GL_COLOR_BUFFER_BIT; 14 | import static com.badlogic.jglfw.gl.GL.GL_FLOAT; 15 | import static com.badlogic.jglfw.gl.GL.GL_TRIANGLES; 16 | import static com.badlogic.jglfw.gl.GL.GL_UNSIGNED_SHORT; 17 | import static com.badlogic.jglfw.gl.GL.GL_VERTEX_ARRAY; 18 | import static com.badlogic.jglfw.gl.GL.glClear; 19 | import static com.badlogic.jglfw.gl.GL.glClearColor; 20 | import static com.badlogic.jglfw.gl.GL.glDrawElements; 21 | import static com.badlogic.jglfw.gl.GL.glEnableClientState; 22 | import static com.badlogic.jglfw.gl.GL.glRotatef; 23 | import static com.badlogic.jglfw.gl.GL.glVertexPointer; 24 | import static com.badlogic.jglfw.gl.GL.glViewport; 25 | 26 | import java.nio.CharBuffer; 27 | import java.nio.FloatBuffer; 28 | 29 | import com.badlogic.jglfw.GlfwCallbackAdapter; 30 | import com.badlogic.jglfw.utils.Memory; 31 | 32 | public class LongPointerTest { 33 | public static void main (String[] args) { 34 | glfwInit(); 35 | glfwWindowHint(GLFW_DEPTH_BITS, 16); 36 | long window = glfwCreateWindow(480, 320, "Long Pointer Test", 0, 0); 37 | glfwMakeContextCurrent(window); 38 | glfwSetCallback(new GlfwCallbackAdapter() { 39 | @Override 40 | public void windowSize (long window, int width, int height) { 41 | glViewport(0, 0, width, height); 42 | } 43 | }); 44 | 45 | FloatBuffer vertices = Memory.malloc(9 * 4).asFloatBuffer(); 46 | vertices.put(new float[] {-0.5f, -0.5f, 0, 0.5f, -0.5f, 0, 0, 0.5f, 0 }); 47 | CharBuffer indices = Memory.malloc(3 * 2).asCharBuffer(); 48 | indices.put(new char[] { 0, 1, 2 }); 49 | 50 | while(!glfwWindowShouldClose(window)) { 51 | glClearColor(1, 0, 0, 1); 52 | glClear(GL_COLOR_BUFFER_BIT); 53 | 54 | glRotatef(0.1f, 0, 0, 1); 55 | 56 | glEnableClientState(GL_VERTEX_ARRAY); 57 | glVertexPointer(3, GL_FLOAT, 3 * 4, Memory.getBufferAddress(vertices)); 58 | glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, Memory.getBufferAddress(indices)); 59 | 60 | glfwPollEvents(); 61 | glfwSwapBuffers(window); 62 | } 63 | 64 | Memory.free(vertices); 65 | Memory.free(indices); 66 | glfwTerminate(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/cocoa_clipboard.m: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Cocoa 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | 35 | 36 | ////////////////////////////////////////////////////////////////////////// 37 | ////// GLFW platform API ////// 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) 41 | { 42 | NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; 43 | 44 | NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; 45 | [pasteboard declareTypes:types owner:nil]; 46 | [pasteboard setString:[NSString stringWithUTF8String:string] 47 | forType:NSStringPboardType]; 48 | } 49 | 50 | const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) 51 | { 52 | NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; 53 | 54 | if (![[pasteboard types] containsObject:NSStringPboardType]) 55 | { 56 | _glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL); 57 | return NULL; 58 | } 59 | 60 | NSString* object = [pasteboard stringForType:NSStringPboardType]; 61 | if (!object) 62 | { 63 | _glfwInputError(GLFW_PLATFORM_ERROR, 64 | "Cocoa: Failed to retrieve object from pasteboard"); 65 | return NULL; 66 | } 67 | 68 | free(_glfw.ns.clipboardString); 69 | _glfw.ns.clipboardString = strdup([object UTF8String]); 70 | 71 | return _glfw.ns.clipboardString; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/GlfwCallbacks.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlogic.jglfw; 3 | 4 | import java.util.ArrayList; 5 | 6 | public class GlfwCallbacks implements GlfwCallback { 7 | private ArrayList processors = new ArrayList(4); 8 | 9 | public void add (GlfwCallback callback) { 10 | processors.add(callback); 11 | } 12 | 13 | public void remove (GlfwCallback callback) { 14 | processors.remove(callback); 15 | } 16 | 17 | public void error (int error, String description) { 18 | for (int i = 0, n = processors.size(); i < n; i++) 19 | processors.get(i).error(error, description); 20 | } 21 | 22 | public void monitor (long monitor, boolean connected) { 23 | for (int i = 0, n = processors.size(); i < n; i++) 24 | processors.get(i).monitor(monitor, connected); 25 | } 26 | 27 | public void windowPos (long window, int x, int y) { 28 | for (int i = 0, n = processors.size(); i < n; i++) 29 | processors.get(i).windowPos(window, x, y); 30 | } 31 | 32 | public void windowSize (long window, int width, int height) { 33 | for (int i = 0, n = processors.size(); i < n; i++) 34 | processors.get(i).windowSize(window, width, height); 35 | } 36 | 37 | public boolean windowClose (long window) { 38 | for (int i = 0, n = processors.size(); i < n; i++) 39 | if (!processors.get(i).windowClose(window)) return false; 40 | return true; 41 | } 42 | 43 | public void windowRefresh (long window) { 44 | for (int i = 0, n = processors.size(); i < n; i++) 45 | processors.get(i).windowRefresh(window); 46 | } 47 | 48 | public void windowFocus (long window, boolean focused) { 49 | for (int i = 0, n = processors.size(); i < n; i++) 50 | processors.get(i).windowFocus(window, focused); 51 | } 52 | 53 | public void windowIconify (long window, boolean iconified) { 54 | for (int i = 0, n = processors.size(); i < n; i++) 55 | processors.get(i).windowIconify(window, iconified); 56 | } 57 | 58 | public void key (long window, int key, int scancode, int action, int mods) { 59 | for (int i = 0, n = processors.size(); i < n; i++) 60 | processors.get(i).key(window, key, scancode, action, mods); 61 | } 62 | 63 | public void character (long window, char character) { 64 | for (int i = 0, n = processors.size(); i < n; i++) 65 | processors.get(i).character(window, character); 66 | } 67 | 68 | public void mouseButton (long window, int button, boolean pressed) { 69 | for (int i = 0, n = processors.size(); i < n; i++) 70 | processors.get(i).mouseButton(window, button, pressed); 71 | } 72 | 73 | public void cursorPos (long window, int x, int y) { 74 | for (int i = 0, n = processors.size(); i < n; i++) 75 | processors.get(i).cursorPos(window, x, y); 76 | } 77 | 78 | public void cursorEnter (long window, boolean entered) { 79 | for (int i = 0, n = processors.size(); i < n; i++) 80 | processors.get(i).cursorEnter(window, entered); 81 | } 82 | 83 | public void scroll (long window, double scrollX, double scrollY) { 84 | for (int i = 0, n = processors.size(); i < n; i++) 85 | processors.get(i).scroll(window, scrollX, scrollY); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/windows.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Simple multi-window test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test creates four windows and clears each in a different color 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | static const char* titles[] = 36 | { 37 | "Foo", 38 | "Bar", 39 | "Baz", 40 | "Quux" 41 | }; 42 | 43 | static void error_callback(int error, const char* description) 44 | { 45 | fprintf(stderr, "Error: %s\n", description); 46 | } 47 | 48 | int main(void) 49 | { 50 | int i; 51 | GLboolean running = GL_TRUE; 52 | GLFWwindow* windows[4]; 53 | 54 | glfwSetErrorCallback(error_callback); 55 | 56 | if (!glfwInit()) 57 | exit(EXIT_FAILURE); 58 | 59 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 60 | 61 | for (i = 0; i < 4; i++) 62 | { 63 | windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); 64 | if (!windows[i]) 65 | { 66 | glfwTerminate(); 67 | exit(EXIT_FAILURE); 68 | } 69 | 70 | glfwMakeContextCurrent(windows[i]); 71 | glClearColor((GLclampf) (i & 1), 72 | (GLclampf) (i >> 1), 73 | i ? 0.f : 1.f, 74 | 0.f); 75 | 76 | glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); 77 | glfwShowWindow(windows[i]); 78 | } 79 | 80 | while (running) 81 | { 82 | for (i = 0; i < 4; i++) 83 | { 84 | glfwMakeContextCurrent(windows[i]); 85 | glClear(GL_COLOR_BUFFER_BIT); 86 | glfwSwapBuffers(windows[i]); 87 | 88 | if (glfwWindowShouldClose(windows[i])) 89 | running = GL_FALSE; 90 | } 91 | 92 | glfwPollEvents(); 93 | } 94 | 95 | glfwTerminate(); 96 | exit(EXIT_SUCCESS); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/x11_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: X11 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | #include 34 | #include 35 | 36 | 37 | // Return raw time 38 | // 39 | static uint64_t getRawTime(void) 40 | { 41 | #if defined(CLOCK_MONOTONIC) 42 | if (_glfw.x11.timer.monotonic) 43 | { 44 | struct timespec ts; 45 | 46 | clock_gettime(CLOCK_MONOTONIC, &ts); 47 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 48 | } 49 | else 50 | #endif 51 | { 52 | struct timeval tv; 53 | 54 | gettimeofday(&tv, NULL); 55 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 56 | } 57 | } 58 | 59 | // Initialise timer 60 | // 61 | void _glfwInitTimer(void) 62 | { 63 | #if defined(CLOCK_MONOTONIC) 64 | struct timespec ts; 65 | 66 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 67 | { 68 | _glfw.x11.timer.monotonic = GL_TRUE; 69 | _glfw.x11.timer.resolution = 1e-9; 70 | } 71 | else 72 | #endif 73 | { 74 | _glfw.x11.timer.resolution = 1e-6; 75 | } 76 | 77 | _glfw.x11.timer.base = getRawTime(); 78 | } 79 | 80 | 81 | ////////////////////////////////////////////////////////////////////////// 82 | ////// GLFW platform API ////// 83 | ////////////////////////////////////////////////////////////////////////// 84 | 85 | double _glfwPlatformGetTime(void) 86 | { 87 | return (double) (getRawTime() - _glfw.x11.timer.base) * 88 | _glfw.x11.timer.resolution; 89 | } 90 | 91 | void _glfwPlatformSetTime(double time) 92 | { 93 | _glfw.x11.timer.base = getRawTime() - 94 | (uint64_t) (time / _glfw.x11.timer.resolution); 95 | } 96 | 97 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/egl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: EGL 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #ifndef _egl_platform_h_ 32 | #define _egl_platform_h_ 33 | 34 | #include 35 | 36 | // This path may need to be changed if you build GLFW using your own setup 37 | // We ship and use our own copy of eglext.h since GLFW uses fairly new 38 | // extensions and not all operating systems come with an up-to-date version 39 | #include "../support/EGL/eglext.h" 40 | 41 | // Do we have support for dlopen/dlsym? 42 | #if defined(_GLFW_HAS_DLOPEN) 43 | #include 44 | #endif 45 | 46 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl 47 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL egl 48 | 49 | 50 | //======================================================================== 51 | // GLFW platform specific types 52 | //======================================================================== 53 | 54 | //------------------------------------------------------------------------ 55 | // Platform-specific OpenGL context structure 56 | //------------------------------------------------------------------------ 57 | typedef struct _GLFWcontextEGL 58 | { 59 | EGLConfig config; 60 | EGLContext context; 61 | EGLSurface surface; 62 | 63 | #if defined(_GLFW_X11) 64 | XVisualInfo* visual; 65 | #endif 66 | } _GLFWcontextEGL; 67 | 68 | 69 | //------------------------------------------------------------------------ 70 | // Platform-specific library global data for EGL 71 | //------------------------------------------------------------------------ 72 | typedef struct _GLFWlibraryEGL 73 | { 74 | EGLDisplay display; 75 | EGLint versionMajor, versionMinor; 76 | 77 | GLboolean KHR_create_context; 78 | 79 | } _GLFWlibraryEGL; 80 | 81 | 82 | #endif // _egl_platform_h_ 83 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | link_libraries(glfw ${OPENGL_glu_LIBRARY}) 3 | 4 | if (BUILD_SHARED_LIBS) 5 | add_definitions(-DGLFW_DLL) 6 | link_libraries(${OPENGL_gl_LIBRARY} ${MATH_LIBRARY}) 7 | else() 8 | link_libraries(${glfw_LIBRARIES}) 9 | endif() 10 | 11 | list(APPEND thread_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) 12 | if (UNIX AND NOT APPLE) 13 | list(APPEND thread_LIBRARIES ${RT_LIBRARY}) 14 | endif() 15 | 16 | include_directories(${GLFW_SOURCE_DIR}/include 17 | ${GLFW_SOURCE_DIR}/support) 18 | 19 | if (MSVC) 20 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 21 | endif() 22 | 23 | if (NOT APPLE) 24 | # HACK: This is NOTFOUND on OS X 10.8 25 | include_directories(${OPENGL_INCLUDE_DIR}) 26 | endif() 27 | 28 | set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h 29 | ${GLFW_SOURCE_DIR}/support/getopt.c) 30 | set(TINYCTHREAD ${GLFW_SOURCE_DIR}/support/tinycthread.h 31 | ${GLFW_SOURCE_DIR}/support/tinycthread.c) 32 | 33 | add_executable(clipboard clipboard.c ${GETOPT}) 34 | add_executable(defaults defaults.c) 35 | add_executable(events events.c) 36 | add_executable(fsaa fsaa.c ${GETOPT}) 37 | add_executable(fsfocus fsfocus.c) 38 | add_executable(gamma gamma.c ${GETOPT}) 39 | add_executable(glfwinfo glfwinfo.c ${GETOPT}) 40 | add_executable(iconify iconify.c ${GETOPT}) 41 | add_executable(joysticks joysticks.c) 42 | add_executable(modes modes.c ${GETOPT}) 43 | add_executable(peter peter.c) 44 | add_executable(reopen reopen.c) 45 | 46 | add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) 47 | set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy") 48 | 49 | add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c) 50 | set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") 51 | 52 | add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) 53 | set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") 54 | 55 | add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD}) 56 | set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") 57 | 58 | add_executable(title WIN32 MACOSX_BUNDLE title.c) 59 | set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") 60 | 61 | add_executable(windows WIN32 MACOSX_BUNDLE windows.c) 62 | set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") 63 | 64 | target_link_libraries(threads ${thread_LIBRARIES}) 65 | 66 | 67 | set(WINDOWS_BINARIES accuracy sharing tearing threads title windows) 68 | set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma glfwinfo 69 | iconify joysticks modes peter reopen) 70 | 71 | if (MSVC) 72 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 73 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 74 | LINK_FLAGS "/ENTRY:mainCRTStartup") 75 | endif() 76 | 77 | if (APPLE) 78 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 79 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 80 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) 81 | endif() 82 | 83 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Win32 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimer(void) 41 | { 42 | __int64 freq; 43 | 44 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &freq)) 45 | { 46 | _glfw.win32.timer.hasPC = GL_TRUE; 47 | _glfw.win32.timer.resolution = 1.0 / (double) freq; 48 | QueryPerformanceCounter((LARGE_INTEGER*) &_glfw.win32.timer.t0_64); 49 | } 50 | else 51 | { 52 | _glfw.win32.timer.hasPC = GL_FALSE; 53 | _glfw.win32.timer.resolution = 0.001; // winmm resolution is 1 ms 54 | _glfw.win32.timer.t0_32 = _glfw_timeGetTime(); 55 | } 56 | } 57 | 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | ////// GLFW platform API ////// 61 | ////////////////////////////////////////////////////////////////////////// 62 | 63 | double _glfwPlatformGetTime(void) 64 | { 65 | double t; 66 | __int64 t_64; 67 | 68 | if (_glfw.win32.timer.hasPC) 69 | { 70 | QueryPerformanceCounter((LARGE_INTEGER*) &t_64); 71 | t = (double)(t_64 - _glfw.win32.timer.t0_64); 72 | } 73 | else 74 | t = (double)(_glfw_timeGetTime() - _glfw.win32.timer.t0_32); 75 | 76 | return t * _glfw.win32.timer.resolution; 77 | } 78 | 79 | void _glfwPlatformSetTime(double t) 80 | { 81 | __int64 t_64; 82 | 83 | if (_glfw.win32.timer.hasPC) 84 | { 85 | QueryPerformanceCounter((LARGE_INTEGER*) &t_64); 86 | _glfw.win32.timer.t0_64 = t_64 - (__int64) (t / _glfw.win32.timer.resolution); 87 | } 88 | else 89 | _glfw.win32.timer.t0_32 = _glfw_timeGetTime() - (int)(t * 1000.0); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Any 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | 35 | 36 | ////////////////////////////////////////////////////////////////////////// 37 | ////// GLFW public API ////// 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) 41 | { 42 | int i, size = GLFW_GAMMA_RAMP_SIZE; 43 | GLFWgammaramp ramp; 44 | 45 | _GLFW_REQUIRE_INIT(); 46 | 47 | if (gamma <= 0.f) 48 | { 49 | _glfwInputError(GLFW_INVALID_VALUE, 50 | "Gamma value must be greater than zero"); 51 | return; 52 | } 53 | 54 | for (i = 0; i < size; i++) 55 | { 56 | float value; 57 | 58 | // Calculate intensity 59 | value = (float) i / (float) (size - 1); 60 | // Apply gamma curve 61 | value = (float) pow(value, 1.f / gamma) * 65535.f + 0.5f; 62 | 63 | // Clamp to value range 64 | if (value < 0.f) 65 | value = 0.f; 66 | else if (value > 65535.f) 67 | value = 65535.f; 68 | 69 | ramp.red[i] = (unsigned short) value; 70 | ramp.green[i] = (unsigned short) value; 71 | ramp.blue[i] = (unsigned short) value; 72 | } 73 | 74 | glfwSetGammaRamp(handle, &ramp); 75 | } 76 | 77 | GLFWAPI void glfwGetGammaRamp(GLFWmonitor* handle, GLFWgammaramp* ramp) 78 | { 79 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 80 | _GLFW_REQUIRE_INIT(); 81 | _glfwPlatformGetGammaRamp(monitor, ramp); 82 | } 83 | 84 | GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) 85 | { 86 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 87 | 88 | _GLFW_REQUIRE_INIT(); 89 | 90 | if (!monitor->rampChanged) 91 | { 92 | _glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp); 93 | monitor->rampChanged = GL_TRUE; 94 | } 95 | 96 | _glfwPlatformSetGammaRamp(monitor, ramp); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/fsfocus.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Fullscreen window (un)focus test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test is used to test window focusing and iconfication for 27 | // fullscreen windows with a video mode differing from the desktop mode 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | static void error_callback(int error, const char* description) 37 | { 38 | fprintf(stderr, "Error: %s\n", description); 39 | } 40 | 41 | static void window_focus_callback(GLFWwindow* window, int focused) 42 | { 43 | printf("%0.3f: Window %s\n", 44 | glfwGetTime(), 45 | focused ? "focused" : "defocused"); 46 | } 47 | 48 | static void window_key_callback(GLFWwindow* window, int key, int action) 49 | { 50 | if (action != GLFW_PRESS) 51 | return; 52 | 53 | switch (key) 54 | { 55 | case GLFW_KEY_ESCAPE: 56 | { 57 | printf("%0.3f: User pressed Escape\n", glfwGetTime()); 58 | glfwSetWindowShouldClose(window, GL_TRUE); 59 | break; 60 | } 61 | 62 | case GLFW_KEY_SPACE: 63 | { 64 | printf("%0.3f: User pressed Space\n", glfwGetTime()); 65 | glfwIconifyWindow(window); 66 | break; 67 | } 68 | } 69 | } 70 | 71 | int main(void) 72 | { 73 | GLFWwindow* window; 74 | 75 | glfwSetErrorCallback(error_callback); 76 | 77 | if (!glfwInit()) 78 | exit(EXIT_FAILURE); 79 | 80 | window = glfwCreateWindow(640, 480, "Fullscreen focus", glfwGetPrimaryMonitor(), NULL); 81 | if (!window) 82 | { 83 | glfwTerminate(); 84 | exit(EXIT_FAILURE); 85 | } 86 | 87 | glfwMakeContextCurrent(window); 88 | glfwSwapInterval(1); 89 | 90 | glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); 91 | 92 | glfwSetWindowFocusCallback(window, window_focus_callback); 93 | glfwSetKeyCallback(window, window_key_callback); 94 | 95 | while (!glfwWindowShouldClose(window)) 96 | { 97 | glClear(GL_COLOR_BUFFER_BIT); 98 | glfwSwapBuffers(window); 99 | glfwWaitEvents(); 100 | } 101 | 102 | glfwTerminate(); 103 | exit(EXIT_SUCCESS); 104 | } 105 | 106 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(${GLFW_SOURCE_DIR}/src 3 | ${GLFW_BINARY_DIR}/src 4 | ${glfw_INCLUDE_DIRS}) 5 | 6 | if (MSVC) 7 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 8 | endif() 9 | 10 | set(common_HEADERS ${GLFW_SOURCE_DIR}/include/GL/glfw3.h internal.h) 11 | set(common_SOURCES clipboard.c context.c gamma.c init.c input.c joystick.c 12 | monitor.c time.c window.c) 13 | 14 | if (_GLFW_COCOA) 15 | set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h) 16 | set(glfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_gamma.c 17 | cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_time.c 18 | cocoa_window.m) 19 | elseif (_GLFW_WIN32) 20 | set(glfw_HEADERS ${common_HEADERS} win32_platform.h) 21 | set(glfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_gamma.c 22 | win32_init.c win32_joystick.c win32_monitor.c win32_time.c 23 | win32_window.c) 24 | elseif (_GLFW_X11) 25 | set(glfw_HEADERS ${common_HEADERS} x11_platform.h) 26 | set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_gamma.c x11_init.c 27 | x11_joystick.c x11_monitor.c x11_time.c x11_window.c 28 | x11_unicode.c) 29 | endif() 30 | 31 | if (_GLFW_EGL) 32 | list(APPEND glfw_HEADERS ${common_HEADERS} egl_platform.h) 33 | list(APPEND glfw_SOURCES ${common_SOURCES} egl_context.c) 34 | elseif (_GLFW_NSGL) 35 | list(APPEND glfw_HEADERS ${common_HEADERS} nsgl_platform.h) 36 | list(APPEND glfw_SOURCES ${common_SOURCES} nsgl_context.m) 37 | elseif (_GLFW_WGL) 38 | list(APPEND glfw_HEADERS ${common_HEADERS} wgl_platform.h) 39 | list(APPEND glfw_SOURCES ${common_SOURCES} wgl_context.c) 40 | elseif (_GLFW_X11) 41 | list(APPEND glfw_HEADERS ${common_HEADERS} glx_platform.h) 42 | list(APPEND glfw_SOURCES ${common_SOURCES} glx_context.c) 43 | endif() 44 | 45 | if (APPLE) 46 | # For some reason, CMake doesn't know about .m 47 | set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) 48 | endif() 49 | 50 | add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) 51 | set_target_properties(glfw PROPERTIES OUTPUT_NAME "${GLFW_LIB_NAME}") 52 | 53 | if (BUILD_SHARED_LIBS) 54 | # Include version information in the output 55 | set_target_properties(glfw PROPERTIES VERSION ${GLFW_VERSION}) 56 | if (UNIX) 57 | set_target_properties(glfw PROPERTIES SOVERSION ${GLFW_VERSION_MAJOR}) 58 | endif() 59 | 60 | if (WIN32) 61 | # The GLFW DLL needs a special compile-time macro and import library name 62 | set_target_properties(glfw PROPERTIES PREFIX "" IMPORT_PREFIX "") 63 | 64 | if (MINGW) 65 | set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a") 66 | else() 67 | set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") 68 | endif() 69 | elseif (APPLE) 70 | # Append -fno-common to the compile flags to work around a bug in 71 | # Apple's GCC 72 | get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS) 73 | if (NOT glfw_CFLAGS) 74 | set(glfw_CFLAGS "") 75 | endif() 76 | set_target_properties(glfw PROPERTIES 77 | COMPILE_FLAGS "${glfw_CFLAGS} -fno-common") 78 | endif() 79 | 80 | target_link_libraries(glfw ${glfw_LIBRARIES}) 81 | target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) 82 | endif() 83 | 84 | install(TARGETS glfw DESTINATION lib${LIB_SUFFIX} ) 85 | 86 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/tearing.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Vsync enabling test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test renders a high contrast, horizontally moving bar, allowing for 27 | // visual verification of whether the set swap interval is indeed obeyed 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | static int swap_interval; 38 | 39 | static void set_swap_interval(GLFWwindow* window, int interval) 40 | { 41 | char title[256]; 42 | 43 | swap_interval = interval; 44 | glfwSwapInterval(swap_interval); 45 | 46 | sprintf(title, "Tearing detector (interval %i)", swap_interval); 47 | 48 | glfwSetWindowTitle(window, title); 49 | } 50 | 51 | static void error_callback(int error, const char* description) 52 | { 53 | fprintf(stderr, "Error: %s\n", description); 54 | } 55 | 56 | static void window_size_callback(GLFWwindow* window, int width, int height) 57 | { 58 | glViewport(0, 0, width, height); 59 | } 60 | 61 | static void key_callback(GLFWwindow* window, int key, int action) 62 | { 63 | if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) 64 | set_swap_interval(window, 1 - swap_interval); 65 | } 66 | 67 | int main(void) 68 | { 69 | float position; 70 | GLFWwindow* window; 71 | 72 | glfwSetErrorCallback(error_callback); 73 | 74 | if (!glfwInit()) 75 | exit(EXIT_FAILURE); 76 | 77 | window = glfwCreateWindow(640, 480, "", NULL, NULL); 78 | if (!window) 79 | { 80 | glfwTerminate(); 81 | exit(EXIT_FAILURE); 82 | } 83 | 84 | glfwMakeContextCurrent(window); 85 | set_swap_interval(window, swap_interval); 86 | 87 | glfwSetWindowSizeCallback(window, window_size_callback); 88 | glfwSetKeyCallback(window, key_callback); 89 | 90 | glMatrixMode(GL_PROJECTION); 91 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 92 | glMatrixMode(GL_MODELVIEW); 93 | 94 | while (!glfwWindowShouldClose(window)) 95 | { 96 | glClear(GL_COLOR_BUFFER_BIT); 97 | 98 | position = cosf(glfwGetTime() * 4.f) * 0.75f; 99 | glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); 100 | 101 | glfwSwapBuffers(window); 102 | glfwPollEvents(); 103 | } 104 | 105 | glfwTerminate(); 106 | exit(EXIT_SUCCESS); 107 | } 108 | 109 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Any 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | // As config.h.in, this file is used by CMake to produce the config.h shared 30 | // configuration header file. If you are adding a feature requiring 31 | // conditional compilation, this is the proper place to add the macros. 32 | //======================================================================== 33 | // As config.h, this file defines compile-time build options and macros for 34 | // all platforms supported by GLFW. As this is a generated file, don't modify 35 | // it. Instead, you should modify the config.h.in file. 36 | //======================================================================== 37 | 38 | // Define this to 1 if building GLFW for X11 39 | #cmakedefine _GLFW_X11 40 | // Define this to 1 if building GLFW for Win32 41 | #cmakedefine _GLFW_WIN32 42 | // Define this to 1 if building GLFW for Cocoa 43 | #cmakedefine _GLFW_COCOA 44 | 45 | // Define this to 1 if building GLFW for EGL 46 | #cmakedefine _GLFW_EGL 47 | // Define this to 1 if building GLFW for GLX 48 | #cmakedefine _GLFW_GLX 49 | // Define this to 1 if building GLFW for WGL 50 | #cmakedefine _GLFW_WGL 51 | // Define this to 1 if building GLFW for NSGL 52 | #cmakedefine _GLFW_NSGL 53 | 54 | // Define this to 1 if building as a shared library / dynamic library / DLL 55 | #cmakedefine _GLFW_BUILD_DLL 56 | 57 | // Define this to 1 to disable dynamic loading of winmm 58 | #cmakedefine _GLFW_NO_DLOAD_WINMM 59 | 60 | // Define this to 1 if glXGetProcAddress is available 61 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS 62 | // Define this to 1 if glXGetProcAddressARB is available 63 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSARB 64 | // Define this to 1 if glXGetProcAddressEXT is available 65 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT 66 | 67 | // Define this to 1 if glfwInit should change the current directory 68 | #cmakedefine _GLFW_USE_CHDIR 69 | // Define this to 1 if glfwCreateWindow should populate the menu bar 70 | #cmakedefine _GLFW_USE_MENUBAR 71 | 72 | // Define this to 1 if using OpenGL as the client library 73 | #cmakedefine _GLFW_USE_OPENGL 74 | // Define this to 1 if using OpenGL ES 1.1 as the client library 75 | #cmakedefine _GLFW_USE_GLESV1 76 | // Define this to 1 if using OpenGL ES 2.0 as the client library 77 | #cmakedefine _GLFW_USE_GLESV2 78 | 79 | // The GLFW version as used by glfwGetVersionString 80 | #define _GLFW_VERSION_FULL "@GLFW_VERSION_FULL@" 81 | 82 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Any 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #include "internal.h" 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW public API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | GLFWAPI int glfwGetJoystickParam(int joy, int param) 39 | { 40 | _GLFW_REQUIRE_INIT_OR_RETURN(0); 41 | 42 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 43 | { 44 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 45 | return 0; 46 | } 47 | 48 | return _glfwPlatformGetJoystickParam(joy, param); 49 | } 50 | 51 | GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes) 52 | { 53 | int i; 54 | 55 | _GLFW_REQUIRE_INIT_OR_RETURN(0); 56 | 57 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 58 | { 59 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 60 | return 0; 61 | } 62 | 63 | if (axes == NULL || numaxes < 0) 64 | { 65 | _glfwInputError(GLFW_INVALID_VALUE, NULL); 66 | return 0; 67 | } 68 | 69 | // Clear positions 70 | for (i = 0; i < numaxes; i++) 71 | axes[i] = 0.0f; 72 | 73 | return _glfwPlatformGetJoystickAxes(joy, axes, numaxes); 74 | } 75 | 76 | GLFWAPI int glfwGetJoystickButtons(int joy, 77 | unsigned char* buttons, 78 | int numbuttons) 79 | { 80 | int i; 81 | 82 | _GLFW_REQUIRE_INIT_OR_RETURN(0); 83 | 84 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 85 | { 86 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 87 | return 0; 88 | } 89 | 90 | if (buttons == NULL || numbuttons < 0) 91 | { 92 | _glfwInputError(GLFW_INVALID_VALUE, NULL); 93 | return 0; 94 | } 95 | 96 | // Clear button states 97 | for (i = 0; i < numbuttons; i++) 98 | buttons[i] = GLFW_RELEASE; 99 | 100 | return _glfwPlatformGetJoystickButtons(joy, buttons, numbuttons); 101 | } 102 | 103 | GLFWAPI const char* glfwGetJoystickName(int joy) 104 | { 105 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 106 | 107 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 108 | { 109 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 110 | return NULL; 111 | } 112 | 113 | return _glfwPlatformGetJoystickName(joy); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/wgl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: WGL 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #ifndef _wgl_platform_h_ 32 | #define _wgl_platform_h_ 33 | 34 | // This path may need to be changed if you build GLFW using your own setup 35 | // We ship and use our own copy of wglext.h since GLFW uses fairly new 36 | // extensions and not all operating systems come with an up-to-date version 37 | #include "../support/GL/wglext.h" 38 | 39 | 40 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl 41 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL wgl 42 | 43 | 44 | //======================================================================== 45 | // GLFW platform specific types 46 | //======================================================================== 47 | 48 | //------------------------------------------------------------------------ 49 | // Platform-specific OpenGL context structure 50 | //------------------------------------------------------------------------ 51 | typedef struct _GLFWcontextWGL 52 | { 53 | // Platform specific window resources 54 | HDC dc; // Private GDI device context 55 | HGLRC context; // Permanent rendering context 56 | 57 | // Platform specific extensions (context specific) 58 | PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; 59 | PFNWGLCHOOSEPIXELFORMATARBPROC ChoosePixelFormatARB; 60 | PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; 61 | PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; 62 | PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 63 | GLboolean EXT_swap_control; 64 | GLboolean ARB_multisample; 65 | GLboolean ARB_framebuffer_sRGB; 66 | GLboolean ARB_pixel_format; 67 | GLboolean ARB_create_context; 68 | GLboolean ARB_create_context_profile; 69 | GLboolean EXT_create_context_es2_profile; 70 | GLboolean ARB_create_context_robustness; 71 | } _GLFWcontextWGL; 72 | 73 | 74 | //------------------------------------------------------------------------ 75 | // Platform-specific library global data for WGL 76 | //------------------------------------------------------------------------ 77 | typedef struct _GLFWlibraryWGL 78 | { 79 | int dummy; 80 | 81 | } _GLFWlibraryWGL; 82 | 83 | 84 | #endif // _wgl_platform_h_ 85 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/cocoa_gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Cocoa 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | 38 | ////////////////////////////////////////////////////////////////////////// 39 | ////// GLFW platform API ////// 40 | ////////////////////////////////////////////////////////////////////////// 41 | 42 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 43 | { 44 | // TODO: Support ramp sizes other than 256 45 | 46 | uint32_t sampleCount; 47 | int i; 48 | CGGammaValue red[GLFW_GAMMA_RAMP_SIZE]; 49 | CGGammaValue green[GLFW_GAMMA_RAMP_SIZE]; 50 | CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE]; 51 | 52 | if (CGDisplayGammaTableCapacity(monitor->ns.displayID) != 53 | GLFW_GAMMA_RAMP_SIZE) 54 | { 55 | _glfwInputError(GLFW_PLATFORM_ERROR, 56 | "Cocoa: Only gamma ramps of size 256 supported"); 57 | return; 58 | } 59 | 60 | CGGetDisplayTransferByTable(monitor->ns.displayID, 61 | GLFW_GAMMA_RAMP_SIZE, 62 | red, green, blue, 63 | &sampleCount); 64 | 65 | for (i = 0; i < GLFW_GAMMA_RAMP_SIZE; i++) 66 | { 67 | ramp->red[i] = red[i] * 65535; 68 | ramp->green[i] = green[i] * 65535; 69 | ramp->blue[i] = blue[i] * 65535; 70 | } 71 | } 72 | 73 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 74 | { 75 | // TODO: Support ramp sizes other than 256 76 | 77 | int i; 78 | int size = GLFW_GAMMA_RAMP_SIZE; 79 | CGGammaValue red[GLFW_GAMMA_RAMP_SIZE]; 80 | CGGammaValue green[GLFW_GAMMA_RAMP_SIZE]; 81 | CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE]; 82 | 83 | if (CGDisplayGammaTableCapacity(monitor->ns.displayID) != 84 | GLFW_GAMMA_RAMP_SIZE) 85 | { 86 | _glfwInputError(GLFW_PLATFORM_ERROR, 87 | "Cocoa: Only gamma ramps of size 256 supported"); 88 | return; 89 | } 90 | 91 | // Convert to float & take the difference of the original gamma and 92 | // the linear function. 93 | for (i = 0; i < size; i++) 94 | { 95 | red[i] = ramp->red[i] / 65535.f; 96 | green[i] = ramp->green[i] / 65535.f; 97 | blue[i] = ramp->blue[i] / 65535.f; 98 | } 99 | 100 | CGSetDisplayTransferByTable(monitor->ns.displayID, 101 | GLFW_GAMMA_RAMP_SIZE, 102 | red, green, blue); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/defaults.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Default window/context test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test creates a windowed mode window with all parameters set to 27 | // default values and then reports the actual parameters of the created 28 | // window and context 29 | // 30 | //======================================================================== 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | typedef struct 39 | { 40 | int param; 41 | const char* ext; 42 | const char* name; 43 | } ParamGL; 44 | 45 | typedef struct 46 | { 47 | int param; 48 | const char* name; 49 | } ParamGLFW; 50 | 51 | static ParamGL gl_params[] = 52 | { 53 | { GL_RED_BITS, NULL, "red bits" }, 54 | { GL_GREEN_BITS, NULL, "green bits" }, 55 | { GL_BLUE_BITS, NULL, "blue bits" }, 56 | { GL_ALPHA_BITS, NULL, "alpha bits" }, 57 | { GL_DEPTH_BITS, NULL, "depth bits" }, 58 | { GL_STENCIL_BITS, NULL, "stencil bits" }, 59 | { GL_STEREO, NULL, "stereo" }, 60 | { GL_SAMPLES_ARB, "GL_ARB_multisample", "FSAA samples" }, 61 | { 0, NULL, NULL } 62 | }; 63 | 64 | static ParamGLFW glfw_params[] = 65 | { 66 | { GLFW_CONTEXT_VERSION_MAJOR, "Context version major" }, 67 | { GLFW_CONTEXT_VERSION_MINOR, "Context version minor" }, 68 | { GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" }, 69 | { GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" }, 70 | { GLFW_OPENGL_PROFILE, "OpenGL profile" }, 71 | { 0, NULL } 72 | }; 73 | 74 | static void error_callback(int error, const char* description) 75 | { 76 | fprintf(stderr, "Error: %s\n", description); 77 | } 78 | 79 | int main(void) 80 | { 81 | int i, width, height; 82 | GLFWwindow* window; 83 | 84 | glfwSetErrorCallback(error_callback); 85 | 86 | if (!glfwInit()) 87 | exit(EXIT_FAILURE); 88 | 89 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 90 | 91 | window = glfwCreateWindow(640, 480, "Defaults", NULL, NULL); 92 | if (!window) 93 | { 94 | glfwTerminate(); 95 | exit(EXIT_FAILURE); 96 | } 97 | 98 | glfwMakeContextCurrent(window); 99 | glfwGetWindowSize(window, &width, &height); 100 | 101 | printf("window size: %ix%i\n", width, height); 102 | 103 | for (i = 0; glfw_params[i].name; i++) 104 | { 105 | printf("%s: %i\n", 106 | glfw_params[i].name, 107 | glfwGetWindowParam(window, glfw_params[i].param)); 108 | } 109 | 110 | for (i = 0; gl_params[i].name; i++) 111 | { 112 | GLint value = 0; 113 | 114 | if (gl_params[i].ext) 115 | { 116 | if (!glfwExtensionSupported(gl_params[i].ext)) 117 | continue; 118 | } 119 | 120 | glGetIntegerv(gl_params[i].param, &value); 121 | 122 | printf("%s: %i\n", gl_params[i].name, value); 123 | } 124 | 125 | glfwDestroyWindow(window); 126 | window = NULL; 127 | 128 | glfwTerminate(); 129 | exit(EXIT_SUCCESS); 130 | } 131 | 132 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/GlfwCallback.java: -------------------------------------------------------------------------------- 1 | package com.badlogic.jglfw; 2 | 3 | /** 4 | * Registered with Glfw3#glfwSetCallback(), reacts to all 5 | * callback events of Glfw 6 | * @author mzechner 7 | * 8 | */ 9 | public interface GlfwCallback { 10 | /** 11 | * Called in case of an error, on the thread 12 | * the error was generated on. 13 | * @param error the error code 14 | * @param description the description of the error 15 | */ 16 | public void error(int error, String description); 17 | 18 | /** 19 | * Called when a monitor was connected/disconnected 20 | * @param monitor the monitor handle 21 | * @param connected whether the monitor was connected or disconnected 22 | */ 23 | public void monitor(long monitor, boolean connected); 24 | 25 | /** 26 | * Called when the position of a window changed 27 | * @param window the window handle 28 | * @param x the new x coordinate, in pixels, of the top left corner of the client area of the window 29 | * @param y the new y coordinate, in pixels, of the top left corner of the client area of the window 30 | */ 31 | public void windowPos(long window, int x, int y); 32 | 33 | /** 34 | * Called when the size of the window changed 35 | * @param window the window handle 36 | * @param width the new width in pixels 37 | * @param height the new height in pixels 38 | */ 39 | public void windowSize(long window, int width, int height); 40 | 41 | /** 42 | * Called when the window should be closed. 43 | * @param window the window handle 44 | * @return whether to allow closing the window 45 | */ 46 | public boolean windowClose(long window); 47 | 48 | /** 49 | * Called when the window content needs to be refreshed 50 | * @param window the window handle 51 | */ 52 | public void windowRefresh(long window); 53 | 54 | /** 55 | * Called when the focus of the window changed 56 | * @param window the window handle 57 | * @param focused whether the window is focused 58 | */ 59 | public void windowFocus(long window, boolean focused); 60 | 61 | /** 62 | * Called when the window is (de-)iconified 63 | * @param window the window handle 64 | * @param iconified whether the window is iconified 65 | */ 66 | public void windowIconify(long window, boolean iconified); 67 | 68 | /** 69 | * Called when a key was pressed or released 70 | * @param window the window handle 71 | * @param key the key code 72 | * @param scancode the scan code as reported by the OS 73 | * @param action whether the key was pressed (GLFW_PRESSED), released (GLFW_RELEASE) or repeated (GLFW_REPEAT) 74 | * @param mods the modifier flags 75 | */ 76 | public void key(long window, int key, int scancode, int action, int mods); 77 | 78 | /** 79 | * Called when a Unicode character was generated by the keyboard 80 | * @param window the window handle 81 | * @param character the Unicode character 82 | */ 83 | public void character(long window, char character); 84 | 85 | /** 86 | * Called when a mouse button was pressed or released 87 | * @param window the window handle 88 | * @param button the button id 89 | * @param pressed whether the button was pressed (true) or released (false) 90 | */ 91 | public void mouseButton(long window, int button, boolean pressed); 92 | 93 | /** 94 | * Called when the mouse cursor moved 95 | * @param window the window 96 | * @param x the x-coordinate in client area coordinates 97 | * @param y the y-coordinate in client area coordinates 98 | */ 99 | public void cursorPos(long window, int x, int y); 100 | 101 | /** 102 | * Called when the mouse entered the client area 103 | * @param window the window handle 104 | * @param entered whether the mouse cursor entered or left the window 105 | */ 106 | public void cursorEnter(long window, boolean entered); 107 | 108 | /** 109 | * Called when the mouse wheel was scrolled 110 | * @param window the window handle 111 | * @params scrollX The scroll offset along the x-axis. 112 | * @params scrollY The scroll offset along the y-axis. 113 | */ 114 | public void scroll(long window, double scrollX, double scrollY); 115 | } 116 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/accuracy.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Mouse cursor accuracy test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bug #1867804 27 | // 28 | // No sign of said bug has so far been detected 29 | // 30 | //======================================================================== 31 | 32 | #define GLFW_INCLUDE_GLU 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | static int cursor_x = 0, cursor_y = 0; 39 | static int window_width = 640, window_height = 480; 40 | static int swap_interval = 1; 41 | 42 | static void set_swap_interval(GLFWwindow* window, int interval) 43 | { 44 | char title[256]; 45 | 46 | swap_interval = interval; 47 | glfwSwapInterval(swap_interval); 48 | 49 | sprintf(title, "Cursor Inaccuracy Detector (interval %i)", swap_interval); 50 | 51 | glfwSetWindowTitle(window, title); 52 | } 53 | 54 | static void error_callback(int error, const char* description) 55 | { 56 | fprintf(stderr, "Error: %s\n", description); 57 | } 58 | 59 | static void window_size_callback(GLFWwindow* window, int width, int height) 60 | { 61 | window_width = width; 62 | window_height = height; 63 | 64 | glViewport(0, 0, window_width, window_height); 65 | 66 | glMatrixMode(GL_PROJECTION); 67 | glLoadIdentity(); 68 | gluOrtho2D(0.f, window_width, 0.f, window_height); 69 | } 70 | 71 | static void cursor_position_callback(GLFWwindow* window, int x, int y) 72 | { 73 | cursor_x = x; 74 | cursor_y = y; 75 | } 76 | 77 | static void key_callback(GLFWwindow* window, int key, int action) 78 | { 79 | if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) 80 | set_swap_interval(window, 1 - swap_interval); 81 | } 82 | 83 | int main(void) 84 | { 85 | GLFWwindow* window; 86 | int width, height; 87 | 88 | glfwSetErrorCallback(error_callback); 89 | 90 | if (!glfwInit()) 91 | exit(EXIT_FAILURE); 92 | 93 | window = glfwCreateWindow(window_width, window_height, "", NULL, NULL); 94 | if (!window) 95 | { 96 | glfwTerminate(); 97 | exit(EXIT_FAILURE); 98 | } 99 | 100 | glfwSetCursorPosCallback(window, cursor_position_callback); 101 | glfwSetWindowSizeCallback(window, window_size_callback); 102 | glfwSetKeyCallback(window, key_callback); 103 | 104 | glfwMakeContextCurrent(window); 105 | 106 | glfwGetWindowSize(window, &width, &height); 107 | window_size_callback(window, width, height); 108 | 109 | set_swap_interval(window, swap_interval); 110 | 111 | while (!glfwWindowShouldClose(window)) 112 | { 113 | glClear(GL_COLOR_BUFFER_BIT); 114 | 115 | glBegin(GL_LINES); 116 | glVertex2f(0.f, (GLfloat) window_height - cursor_y); 117 | glVertex2f((GLfloat) window_width, (GLfloat) window_height - cursor_y); 118 | glVertex2f((GLfloat) cursor_x, 0.f); 119 | glVertex2f((GLfloat) cursor_x, (GLfloat) window_height); 120 | glEnd(); 121 | 122 | glfwSwapBuffers(window); 123 | glfwPollEvents(); 124 | } 125 | 126 | glfwTerminate(); 127 | exit(EXIT_SUCCESS); 128 | } 129 | 130 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/threads.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Multithreading test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test is intended to verify whether the OpenGL context part of 27 | // the GLFW API is able to be used from multiple threads 28 | // 29 | //======================================================================== 30 | 31 | #include "tinycthread.h" 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | typedef struct 41 | { 42 | GLFWwindow* window; 43 | const char* title; 44 | float r, g, b; 45 | thrd_t id; 46 | } Thread; 47 | 48 | static volatile GLboolean running = GL_TRUE; 49 | 50 | static void error_callback(int error, const char* description) 51 | { 52 | fprintf(stderr, "Error: %s\n", description); 53 | } 54 | 55 | static int thread_main(void* data) 56 | { 57 | const Thread* thread = (const Thread*) data; 58 | 59 | glfwMakeContextCurrent(thread->window); 60 | assert(glfwGetCurrentContext() == thread->window); 61 | 62 | glfwSwapInterval(1); 63 | 64 | while (running) 65 | { 66 | const float v = (float) fabs(sin(glfwGetTime() * 2.f)); 67 | glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f); 68 | 69 | glClear(GL_COLOR_BUFFER_BIT); 70 | glfwSwapBuffers(thread->window); 71 | } 72 | 73 | glfwMakeContextCurrent(NULL); 74 | return 0; 75 | } 76 | 77 | int main(void) 78 | { 79 | int i, result; 80 | Thread threads[] = 81 | { 82 | { NULL, "Red", 1.f, 0.f, 0.f, 0 }, 83 | { NULL, "Green", 0.f, 1.f, 0.f, 0 }, 84 | { NULL, "Blue", 0.f, 0.f, 1.f, 0 } 85 | }; 86 | const int count = sizeof(threads) / sizeof(Thread); 87 | 88 | glfwSetErrorCallback(error_callback); 89 | 90 | if (!glfwInit()) 91 | exit(EXIT_FAILURE); 92 | 93 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 94 | 95 | for (i = 0; i < count; i++) 96 | { 97 | threads[i].window = glfwCreateWindow(200, 200, 98 | threads[i].title, 99 | NULL, NULL); 100 | if (!threads[i].window) 101 | { 102 | glfwTerminate(); 103 | exit(EXIT_FAILURE); 104 | } 105 | 106 | glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); 107 | glfwShowWindow(threads[i].window); 108 | 109 | if (thrd_create(&threads[i].id, thread_main, threads + i) != 110 | thrd_success) 111 | { 112 | fprintf(stderr, "Failed to create secondary thread\n"); 113 | 114 | glfwTerminate(); 115 | exit(EXIT_FAILURE); 116 | } 117 | } 118 | 119 | while (running) 120 | { 121 | assert(glfwGetCurrentContext() == NULL); 122 | 123 | glfwWaitEvents(); 124 | 125 | for (i = 0; i < count; i++) 126 | { 127 | if (glfwWindowShouldClose(threads[i].window)) 128 | running = GL_FALSE; 129 | } 130 | } 131 | 132 | for (i = 0; i < count; i++) 133 | thrd_join(threads[i].id, &result); 134 | 135 | exit(EXIT_SUCCESS); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/FullscreenTest.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlogic.jglfw.tests; 3 | 4 | import static com.badlogic.jglfw.Glfw.*; 5 | 6 | import com.badlogic.jglfw.GlfwCallback; 7 | 8 | import java.util.Arrays; 9 | 10 | import com.badlogic.jglfw.gl.GL; 11 | 12 | public class FullscreenTest { 13 | static long window; 14 | 15 | public static void main (String[] args) throws InterruptedException { 16 | if (!glfwInit()) { 17 | System.out.println("Couldn't initialize GLFW"); 18 | System.exit(-1); 19 | } 20 | glfwSetCallback(new GlfwCallback() { 21 | @Override 22 | public void error (int error, String description) { 23 | System.out.println("error: " + description); 24 | } 25 | 26 | @Override 27 | public void monitor (long monitor, boolean connected) { 28 | System.out.println("monitor " + monitor + " " + (connected ? "connected" : "disconnected")); 29 | } 30 | 31 | @Override 32 | public void windowPos (long window, int x, int y) { 33 | System.out.println("window position changed: " + x + ", " + y); 34 | } 35 | 36 | @Override 37 | public void windowSize (long window, int width, int height) { 38 | System.out.println("window size changed: " + width + ", " + height); 39 | } 40 | 41 | @Override 42 | public boolean windowClose (long window) { 43 | System.out.println("window closing"); 44 | return true; 45 | } 46 | 47 | @Override 48 | public void windowRefresh (long window) { 49 | System.out.println("window refresh needed"); 50 | } 51 | 52 | @Override 53 | public void windowFocus (long window, boolean focused) { 54 | System.out.println("window " + (focused ? "focused" : "lost focus")); 55 | } 56 | 57 | @Override 58 | public void windowIconify (long window, boolean iconified) { 59 | System.out.println("window " + (iconified ? "iconified" : "deiconified")); 60 | } 61 | 62 | @Override 63 | public void key (long w, int key, int scancode, int action, int modifiers) { 64 | String actionStr = "pressed"; 65 | if (action == GLFW_RELEASE) actionStr = "released"; 66 | if (action == GLFW_REPEAT) actionStr = "repeated"; 67 | System.out.println("key " + key + " " + actionStr); 68 | } 69 | 70 | @Override 71 | public void character (long window, char character) { 72 | System.out.println("character " + character); 73 | } 74 | 75 | @Override 76 | public void mouseButton (long w, int button, boolean pressed) { 77 | System.out.println("mouse button " + button + " " + (pressed ? "pressed" : "released")); 78 | 79 | if (pressed) { 80 | long newWindow; 81 | if (glfwGetWindowMonitor(window) != 0) { // Already fullscreen. 82 | newWindow = glfwCreateWindow(640, 480, "Test", 0, 0); 83 | } else { 84 | long monitor = glfwGetPrimaryMonitor(); 85 | newWindow = glfwCreateWindow(640, 480, "Test", monitor, 0); 86 | } 87 | if (newWindow == 0) { 88 | throw new RuntimeException("Couldn't create window"); 89 | } 90 | glfwMakeContextCurrent(newWindow); 91 | glfwDestroyWindow(window); 92 | window = newWindow; 93 | } 94 | } 95 | 96 | @Override 97 | public void cursorPos (long window, int x, int y) { 98 | System.out.println("cursor position " + x + ", " + y); 99 | } 100 | 101 | @Override 102 | public void cursorEnter (long window, boolean entered) { 103 | System.out.println("cursor " + (entered ? "entered" : "left")); 104 | } 105 | 106 | @Override 107 | public void scroll (long window, double scrollX, double scrollY) { 108 | System.out.println("scrolled " + scrollX + ", " + scrollY); 109 | } 110 | 111 | }); 112 | 113 | glfwWindowHint(GLFW_DEPTH_BITS, 16); // this is needed on virtualbox... 114 | window = glfwCreateWindow(800, 600, "Test", 0, 0); 115 | if (window == 0) { 116 | throw new RuntimeException("Couldn't create window"); 117 | } 118 | 119 | glfwMakeContextCurrent(window); 120 | while (!glfwWindowShouldClose(window)) { 121 | GL.glViewport(0, 0, 640, 480); 122 | GL.glClear(GL.GL_COLOR_BUFFER_BIT); 123 | GL.glRotatef(0.01f, 0, 0, 1); 124 | GL.glBegin(GL.GL_TRIANGLES); 125 | GL.glVertex2f(-0.5f, -0.5f); 126 | GL.glVertex2f(0.5f, -0.5f); 127 | GL.glVertex2f(0, 0.5f); 128 | GL.glEnd(); 129 | glfwPollEvents(); 130 | glfwSwapBuffers(window); 131 | } 132 | 133 | glfwDestroyWindow(window); 134 | glfwTerminate(); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/win32_clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Win32 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | ////////////////////////////////////////////////////////////////////////// 39 | ////// GLFW platform API ////// 40 | ////////////////////////////////////////////////////////////////////////// 41 | 42 | void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) 43 | { 44 | WCHAR* wideString; 45 | HANDLE stringHandle; 46 | size_t wideSize; 47 | 48 | wideString = _glfwCreateWideStringFromUTF8(string); 49 | if (!wideString) 50 | { 51 | _glfwInputError(GLFW_PLATFORM_ERROR, 52 | "Win32: Failed to convert clipboard string to " 53 | "wide string"); 54 | return; 55 | } 56 | 57 | wideSize = (wcslen(wideString) + 1) * sizeof(WCHAR); 58 | 59 | stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize); 60 | if (!stringHandle) 61 | { 62 | free(wideString); 63 | 64 | _glfwInputError(GLFW_PLATFORM_ERROR, 65 | "Win32: Failed to allocate global handle for clipboard"); 66 | return; 67 | } 68 | 69 | memcpy(GlobalLock(stringHandle), wideString, wideSize); 70 | GlobalUnlock(stringHandle); 71 | 72 | if (!OpenClipboard(window->win32.handle)) 73 | { 74 | GlobalFree(stringHandle); 75 | free(wideString); 76 | 77 | _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard"); 78 | return; 79 | } 80 | 81 | EmptyClipboard(); 82 | SetClipboardData(CF_UNICODETEXT, stringHandle); 83 | CloseClipboard(); 84 | 85 | free(wideString); 86 | } 87 | 88 | const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) 89 | { 90 | HANDLE stringHandle; 91 | 92 | if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) 93 | { 94 | _glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL); 95 | return NULL; 96 | } 97 | 98 | if (!OpenClipboard(window->win32.handle)) 99 | { 100 | _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard"); 101 | return NULL; 102 | } 103 | 104 | stringHandle = GetClipboardData(CF_UNICODETEXT); 105 | if (!stringHandle) 106 | { 107 | CloseClipboard(); 108 | 109 | _glfwInputError(GLFW_PLATFORM_ERROR, 110 | "Win32: Failed to retrieve clipboard data"); 111 | return NULL; 112 | } 113 | 114 | free(_glfw.win32.clipboardString); 115 | _glfw.win32.clipboardString = 116 | _glfwCreateUTF8FromWideString(GlobalLock(stringHandle)); 117 | 118 | GlobalUnlock(stringHandle); 119 | CloseClipboard(); 120 | 121 | if (!_glfw.win32.clipboardString) 122 | { 123 | _glfwInputError(GLFW_PLATFORM_ERROR, 124 | "Win32: Failed to convert wide string to UTF-8"); 125 | return NULL; 126 | } 127 | 128 | return _glfw.win32.clipboardString; 129 | } 130 | 131 | -------------------------------------------------------------------------------- /jglfw/jni/maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.badlogicgames.jglfw 6 | jglfw-parent 7 | 1.2-SNAPSHOT 8 | ../../../ 9 | 10 | 11 | jglfw-platform 12 | jar 13 | JGLWF Native Libraries 14 | 15 | 16 | http://libgdx.badlogicgames.com/jglfw/nightlies/dist 17 | 18 | 19 | 20 | 21 | ${project.groupId} 22 | jglfw 23 | ${project.version} 24 | 25 | 26 | 27 | 28 | src 29 | 30 | 31 | 32 | 33 | com.googlecode.maven-download-plugin 34 | maven-download-plugin 35 | 1.1.0 36 | 37 | 38 | desktop 39 | process-resources 40 | wget 41 | 42 | ${project.build.directory}/download-cache 43 | ${base.url}/jglfw-natives.jar 44 | true 45 | ${project.build.directory}/desktop 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | maven-resources-plugin 54 | 2.6 55 | 56 | 57 | copy-local-desktop 58 | prepare-package 59 | 60 | copy-resources 61 | 62 | 63 | 64 | ${basedir}/../../libs/linux32 65 | ${basedir}/../../libs/linux64 66 | ${basedir}/../../libs/macosx32 67 | ${basedir}/../../libs/macosx64 68 | ${basedir}/../../libs/windows32 69 | ${basedir}/../../libs/windows64 70 | 71 | ${basedir}/target/desktop 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | maven-assembly-plugin 81 | 2.4 82 | 83 | 84 | desktop.xml 85 | 86 | 87 | 88 | 89 | make-assembly 90 | package 91 | 92 | single 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/peter.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Cursor input bug test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bugs #1262764, #1726540 and 27 | // #1726592, all reported by the user peterpp, hence the name 28 | // 29 | // The utility of this test outside of these bugs is uncertain 30 | // 31 | //======================================================================== 32 | 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | static GLboolean reopen = GL_FALSE; 39 | static int cursor_x; 40 | static int cursor_y; 41 | 42 | static void toggle_cursor(GLFWwindow* window) 43 | { 44 | if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED) 45 | { 46 | printf("Released cursor\n"); 47 | glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); 48 | } 49 | else 50 | { 51 | printf("Captured cursor\n"); 52 | glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED); 53 | } 54 | } 55 | 56 | static void error_callback(int error, const char* description) 57 | { 58 | fprintf(stderr, "Error: %s\n", description); 59 | } 60 | 61 | static void cursor_position_callback(GLFWwindow* window, int x, int y) 62 | { 63 | printf("Cursor moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y); 64 | cursor_x = x; 65 | cursor_y = y; 66 | } 67 | 68 | static void key_callback(GLFWwindow* window, int key, int action) 69 | { 70 | switch (key) 71 | { 72 | case GLFW_KEY_SPACE: 73 | { 74 | if (action == GLFW_PRESS) 75 | toggle_cursor(window); 76 | 77 | break; 78 | } 79 | 80 | case GLFW_KEY_R: 81 | { 82 | if (action == GLFW_PRESS) 83 | reopen = GL_TRUE; 84 | 85 | break; 86 | } 87 | } 88 | } 89 | 90 | static void window_size_callback(GLFWwindow* window, int width, int height) 91 | { 92 | glViewport(0, 0, width, height); 93 | } 94 | 95 | static GLFWwindow* open_window(void) 96 | { 97 | GLFWwindow* window = glfwCreateWindow(640, 480, "Peter Detector", NULL, NULL); 98 | if (!window) 99 | return NULL; 100 | 101 | glfwMakeContextCurrent(window); 102 | glfwSwapInterval(1); 103 | 104 | glfwGetCursorPos(window, &cursor_x, &cursor_y); 105 | printf("Cursor position: %i %i\n", cursor_x, cursor_y); 106 | 107 | glfwSetWindowSizeCallback(window, window_size_callback); 108 | glfwSetCursorPosCallback(window, cursor_position_callback); 109 | glfwSetKeyCallback(window, key_callback); 110 | 111 | return window; 112 | } 113 | 114 | int main(void) 115 | { 116 | GLFWwindow* window; 117 | 118 | glfwSetErrorCallback(error_callback); 119 | 120 | if (!glfwInit()) 121 | exit(EXIT_FAILURE); 122 | 123 | window = open_window(); 124 | if (!window) 125 | { 126 | glfwTerminate(); 127 | exit(EXIT_FAILURE); 128 | } 129 | 130 | glClearColor(0.f, 0.f, 0.f, 0.f); 131 | 132 | while (!glfwWindowShouldClose(window)) 133 | { 134 | glClear(GL_COLOR_BUFFER_BIT); 135 | 136 | glfwSwapBuffers(window); 137 | glfwWaitEvents(); 138 | 139 | if (reopen) 140 | { 141 | glfwDestroyWindow(window); 142 | window = open_window(); 143 | if (!window) 144 | { 145 | glfwTerminate(); 146 | exit(EXIT_FAILURE); 147 | } 148 | 149 | reopen = GL_FALSE; 150 | } 151 | } 152 | 153 | glfwTerminate(); 154 | exit(EXIT_SUCCESS); 155 | } 156 | 157 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Clipboard test program 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the clipboard functionality. 27 | // 28 | //======================================================================== 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include "getopt.h" 36 | 37 | static void usage(void) 38 | { 39 | printf("Usage: clipboard [-h]\n"); 40 | } 41 | 42 | static GLboolean control_is_down(GLFWwindow* window) 43 | { 44 | return glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) || 45 | glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL); 46 | } 47 | 48 | static void error_callback(int error, const char* description) 49 | { 50 | fprintf(stderr, "Error: %s\n", description); 51 | } 52 | 53 | static void key_callback(GLFWwindow* window, int key, int action) 54 | { 55 | if (action != GLFW_PRESS) 56 | return; 57 | 58 | switch (key) 59 | { 60 | case GLFW_KEY_ESCAPE: 61 | glfwSetWindowShouldClose(window, GL_TRUE); 62 | break; 63 | 64 | case GLFW_KEY_V: 65 | if (control_is_down(window)) 66 | { 67 | const char* string; 68 | 69 | string = glfwGetClipboardString(window); 70 | if (string) 71 | printf("Clipboard contains \"%s\"\n", string); 72 | else 73 | printf("Clipboard does not contain a string\n"); 74 | } 75 | break; 76 | 77 | case GLFW_KEY_C: 78 | if (control_is_down(window)) 79 | { 80 | const char* string = "Hello GLFW World!"; 81 | glfwSetClipboardString(window, string); 82 | printf("Setting clipboard to \"%s\"\n", string); 83 | } 84 | break; 85 | } 86 | } 87 | 88 | static void window_size_callback(GLFWwindow* window, int width, int height) 89 | { 90 | glViewport(0, 0, width, height); 91 | } 92 | 93 | int main(int argc, char** argv) 94 | { 95 | int ch; 96 | GLFWwindow* window; 97 | 98 | while ((ch = getopt(argc, argv, "h")) != -1) 99 | { 100 | switch (ch) 101 | { 102 | case 'h': 103 | usage(); 104 | exit(EXIT_SUCCESS); 105 | 106 | default: 107 | usage(); 108 | exit(EXIT_FAILURE); 109 | } 110 | } 111 | 112 | glfwSetErrorCallback(error_callback); 113 | 114 | if (!glfwInit()) 115 | { 116 | fprintf(stderr, "Failed to initialize GLFW\n"); 117 | exit(EXIT_FAILURE); 118 | } 119 | 120 | window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL); 121 | if (!window) 122 | { 123 | glfwTerminate(); 124 | 125 | fprintf(stderr, "Failed to open GLFW window\n"); 126 | exit(EXIT_FAILURE); 127 | } 128 | 129 | glfwMakeContextCurrent(window); 130 | glfwSwapInterval(1); 131 | 132 | glfwSetKeyCallback(window, key_callback); 133 | glfwSetWindowSizeCallback(window, window_size_callback); 134 | 135 | glMatrixMode(GL_PROJECTION); 136 | glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); 137 | glMatrixMode(GL_MODELVIEW); 138 | 139 | glClearColor(0.5f, 0.5f, 0.5f, 0); 140 | 141 | while (!glfwWindowShouldClose(window)) 142 | { 143 | glClear(GL_COLOR_BUFFER_BIT); 144 | 145 | glColor3f(0.8f, 0.2f, 0.4f); 146 | glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 147 | 148 | glfwSwapBuffers(window); 149 | glfwWaitEvents(); 150 | } 151 | 152 | glfwTerminate(); 153 | exit(EXIT_SUCCESS); 154 | } 155 | 156 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/fsaa.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Fullscreen anti-aliasing test 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test renders two high contrast, slowly rotating quads, one aliased 27 | // and one (hopefully) anti-aliased, thus allowing for visual verification 28 | // of whether FSAA is indeed enabled 29 | // 30 | //======================================================================== 31 | 32 | #define GLFW_INCLUDE_GLU 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | #include "getopt.h" 40 | 41 | static void error_callback(int error, const char* description) 42 | { 43 | fprintf(stderr, "Error: %s\n", description); 44 | } 45 | 46 | static void window_size_callback(GLFWwindow* window, int width, int height) 47 | { 48 | glViewport(0, 0, width, height); 49 | } 50 | 51 | static void key_callback(GLFWwindow* window, int key, int action) 52 | { 53 | if (action != GLFW_PRESS) 54 | return; 55 | 56 | switch (key) 57 | { 58 | case GLFW_KEY_SPACE: 59 | glfwSetTime(0.0); 60 | break; 61 | } 62 | } 63 | 64 | static void usage(void) 65 | { 66 | printf("Usage: fsaa [-h] [-s SAMPLES]\n"); 67 | } 68 | 69 | int main(int argc, char** argv) 70 | { 71 | int ch, samples = 4; 72 | GLFWwindow* window; 73 | 74 | while ((ch = getopt(argc, argv, "hs:")) != -1) 75 | { 76 | switch (ch) 77 | { 78 | case 'h': 79 | usage(); 80 | exit(EXIT_SUCCESS); 81 | case 's': 82 | samples = atoi(optarg); 83 | break; 84 | default: 85 | usage(); 86 | exit(EXIT_FAILURE); 87 | } 88 | } 89 | 90 | glfwSetErrorCallback(error_callback); 91 | 92 | if (!glfwInit()) 93 | exit(EXIT_FAILURE); 94 | 95 | if (samples) 96 | printf("Requesting FSAA with %i samples\n", samples); 97 | else 98 | printf("Requesting that FSAA not be available\n"); 99 | 100 | glfwWindowHint(GLFW_SAMPLES, samples); 101 | 102 | window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL); 103 | if (!window) 104 | { 105 | glfwTerminate(); 106 | exit(EXIT_FAILURE); 107 | } 108 | 109 | glfwSetKeyCallback(window, key_callback); 110 | glfwSetWindowSizeCallback(window, window_size_callback); 111 | 112 | glfwMakeContextCurrent(window); 113 | glfwSwapInterval(1); 114 | 115 | if (!glfwExtensionSupported("GL_ARB_multisample")) 116 | { 117 | glfwTerminate(); 118 | exit(EXIT_FAILURE); 119 | } 120 | 121 | glGetIntegerv(GL_SAMPLES_ARB, &samples); 122 | if (samples) 123 | printf("Context reports FSAA is available with %i samples\n", samples); 124 | else 125 | printf("Context reports FSAA is unavailable\n"); 126 | 127 | glMatrixMode(GL_PROJECTION); 128 | gluOrtho2D(0.f, 1.f, 0.f, 0.5f); 129 | glMatrixMode(GL_MODELVIEW); 130 | 131 | while (!glfwWindowShouldClose(window)) 132 | { 133 | GLfloat time = (GLfloat) glfwGetTime(); 134 | 135 | glClear(GL_COLOR_BUFFER_BIT); 136 | 137 | glLoadIdentity(); 138 | glTranslatef(0.25f, 0.25f, 0.f); 139 | glRotatef(time, 0.f, 0.f, 1.f); 140 | 141 | glDisable(GL_MULTISAMPLE_ARB); 142 | glRectf(-0.15f, -0.15f, 0.15f, 0.15f); 143 | 144 | glLoadIdentity(); 145 | glTranslatef(0.75f, 0.25f, 0.f); 146 | glRotatef(time, 0.f, 0.f, 1.f); 147 | 148 | glEnable(GL_MULTISAMPLE_ARB); 149 | glRectf(-0.15f, -0.15f, 0.15f, 0.15f); 150 | 151 | glfwSwapBuffers(window); 152 | glfwPollEvents(); 153 | } 154 | 155 | glfwTerminate(); 156 | exit(EXIT_SUCCESS); 157 | } 158 | 159 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Gamma correction test program 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the gamma correction functionality for 27 | // both fullscreen and windowed mode windows 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "getopt.h" 37 | 38 | #define STEP_SIZE 0.1f 39 | 40 | static GLfloat gamma_value = 1.0f; 41 | 42 | static void usage(void) 43 | { 44 | printf("Usage: gamma [-h] [-f]\n"); 45 | } 46 | 47 | static void set_gamma(GLFWwindow* window, float value) 48 | { 49 | GLFWmonitor* monitor = glfwGetWindowMonitor(window); 50 | if (!monitor) 51 | monitor = glfwGetPrimaryMonitor(); 52 | 53 | gamma_value = value; 54 | printf("Gamma: %f\n", gamma_value); 55 | glfwSetGamma(monitor, gamma_value); 56 | } 57 | 58 | static void error_callback(int error, const char* description) 59 | { 60 | fprintf(stderr, "Error: %s\n", description); 61 | } 62 | 63 | static void key_callback(GLFWwindow* window, int key, int action) 64 | { 65 | if (action != GLFW_PRESS) 66 | return; 67 | 68 | switch (key) 69 | { 70 | case GLFW_KEY_ESCAPE: 71 | { 72 | glfwSetWindowShouldClose(window, GL_TRUE); 73 | break; 74 | } 75 | 76 | case GLFW_KEY_KP_ADD: 77 | case GLFW_KEY_Q: 78 | { 79 | set_gamma(window, gamma_value + STEP_SIZE); 80 | break; 81 | } 82 | 83 | case GLFW_KEY_KP_SUBTRACT: 84 | case GLFW_KEY_W: 85 | { 86 | if (gamma_value - STEP_SIZE > 0.f) 87 | set_gamma(window, gamma_value - STEP_SIZE); 88 | 89 | break; 90 | } 91 | } 92 | } 93 | 94 | static void size_callback(GLFWwindow* window, int width, int height) 95 | { 96 | glViewport(0, 0, width, height); 97 | } 98 | 99 | int main(int argc, char** argv) 100 | { 101 | int width, height, ch; 102 | GLFWmonitor* monitor = NULL; 103 | GLFWwindow* window; 104 | 105 | glfwSetErrorCallback(error_callback); 106 | 107 | if (!glfwInit()) 108 | exit(EXIT_FAILURE); 109 | 110 | while ((ch = getopt(argc, argv, "fh")) != -1) 111 | { 112 | switch (ch) 113 | { 114 | case 'h': 115 | usage(); 116 | exit(EXIT_SUCCESS); 117 | 118 | case 'f': 119 | monitor = glfwGetPrimaryMonitor(); 120 | break; 121 | 122 | default: 123 | usage(); 124 | exit(EXIT_FAILURE); 125 | } 126 | } 127 | 128 | if (monitor) 129 | { 130 | GLFWvidmode mode = glfwGetVideoMode(monitor); 131 | width = mode.width; 132 | height = mode.height; 133 | } 134 | else 135 | { 136 | width = 200; 137 | height = 200; 138 | } 139 | 140 | window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL); 141 | if (!window) 142 | { 143 | glfwTerminate(); 144 | exit(EXIT_FAILURE); 145 | } 146 | 147 | set_gamma(window, 1.f); 148 | 149 | glfwMakeContextCurrent(window); 150 | glfwSwapInterval(1); 151 | 152 | glfwSetKeyCallback(window, key_callback); 153 | glfwSetWindowSizeCallback(window, size_callback); 154 | 155 | glMatrixMode(GL_PROJECTION); 156 | glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); 157 | glMatrixMode(GL_MODELVIEW); 158 | 159 | glClearColor(0.5f, 0.5f, 0.5f, 0); 160 | 161 | while (!glfwWindowShouldClose(window)) 162 | { 163 | glClear(GL_COLOR_BUFFER_BIT); 164 | 165 | glColor3f(0.8f, 0.2f, 0.4f); 166 | glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 167 | 168 | glfwSwapBuffers(window); 169 | glfwWaitEvents(); 170 | } 171 | 172 | glfwTerminate(); 173 | exit(EXIT_SUCCESS); 174 | } 175 | 176 | -------------------------------------------------------------------------------- /jglfw/jni/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | BUILD=debug 5 | BUILD_DIR="target" 6 | 7 | JAR=$JAVA_HOME/bin/jar 8 | STRIP="strip -S -x " 9 | CC=clang 10 | CC_FLAGS="-c -m64 -Wfatal-errors -Wall -fPIC -mmacosx-version-min=10.7 -D_GLFW_COCOA -D_GLFW_NSGL -D_GLFW_USE_OPENGL -D_GLFW_USE_MENUBAR -DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable" 11 | CXX=clang 12 | CXX_FLAGS="-c -m64 -Wfatal-errors -Wall -std=c++11 -stdlib=libc++ -fPIC -mmacosx-version-min=10.7 -D_GLFW_COCOA -D_GLFW_NSGL -D_GLFW_USE_OPENGL -D_GLFW_USE_MENUBAR -DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable" 13 | 14 | HEADERS="-I./ -Iglfw-3.0/include -Iglfw-3.0/src -Igl-headers/ -Ijni-headers" 15 | CC_SOURCES=( 16 | "glfw-3.0/src/clipboard.c" 17 | "glfw-3.0/src/context.c" 18 | "glfw-3.0/src/gamma.c" 19 | "glfw-3.0/src/init.c" 20 | "glfw-3.0/src/input.c" 21 | "glfw-3.0/src/joystick.c" 22 | "glfw-3.0/src/monitor.c" 23 | "glfw-3.0/src/time.c" 24 | "glfw-3.0/src/window.c" 25 | "glfw-3.0/src/cocoa_clipboard.m" 26 | "glfw-3.0/src/cocoa_gamma.c" 27 | "glfw-3.0/src/cocoa_init.m" 28 | "glfw-3.0/src/cocoa_joystick.m" 29 | "glfw-3.0/src/cocoa_monitor.m" 30 | "glfw-3.0/src/cocoa_time.c" 31 | "glfw-3.0/src/cocoa_window.m" 32 | "glfw-3.0/src/nsgl_context.m" 33 | "memcpy_wrap.c" 34 | ) 35 | CXX_SOURCES=( 36 | "com.badlogic.jglfw.gl.GL.cpp" 37 | "com.badlogic.jglfw.Glfw.cpp" 38 | "com.badlogic.jglfw.utils.Memory.cpp" 39 | ) 40 | 41 | echo "${CC_SOURCES[@]}" 42 | 43 | LINKER_FLAGS="-shared -m64 -framework Cocoa -framework OpenGL -framework IOKit -lpthread -mmacosx-version-min=10.7" 44 | LIBRARIES="-L$BUILD_DIR -lm" 45 | 46 | JNI_MD="mac" 47 | 48 | OUTPUT_DIR="$BUILD_DIR" 49 | OUTPUT_PREFIX="lib" 50 | OUTPUT_NAME="jglfw" 51 | OUTPUT_SUFFIX=".dylib" 52 | 53 | function usage { 54 | cat < /dev/null; trace() { (PS4=; set -x; "$@";{ set +x; } 2> /dev/null); "$@";} 68 | 69 | while [ "${1:0:2}" = '--' ]; do 70 | NAME=${1%%=*} 71 | VALUE=${1#*=} 72 | case $NAME in 73 | '--target') TARGET="$VALUE" ;; 74 | '--build') BUILD="$VALUE" ;; 75 | '--help') 76 | usage 0 77 | ;; 78 | *) 79 | echo "Unrecognized option or syntax error in option '$1'" 80 | usage 1 81 | ;; 82 | esac 83 | shift 84 | done 85 | 86 | if [ "x$TARGET" = 'x' ]; then 87 | echo "Please specify a target with --target=: macosx, macosx-aarch64" 88 | exit 1 89 | fi 90 | 91 | if [ "x$TARGET" != 'x' ]; then 92 | OS=${TARGET%%-*} 93 | ARCH=${TARGET#*-} 94 | 95 | if [ "$ARCH" = "aarch64" ]; then 96 | OUTPUT_NAME="$OUTPUT_NAME""arm64" 97 | else 98 | OUTPUT_NAME="$OUTPUT_NAME""64" 99 | fi 100 | 101 | # CXX_FLAGS="$CXX_FLAGS -DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable -mmacosx-version-min=10.7" 102 | 103 | if [ "$ARCH" == "aarch64" ]; then 104 | CC_FLAGS="$CC_FLAGS -arch arm64" 105 | CXX_FLAGS="$CXX_FLAGS -arch arm64" 106 | LINKER_FLAGS="$LINKER_FLAGS -arch arm64" 107 | else 108 | CC_FLAGS="$CC_FLAGS -arch x86_64" 109 | CXX_FLAGS="$CXX_FLAGS -arch x86_64" 110 | LINKER_FLAGS="$LINKER_FLAGS -arch x86_64" 111 | fi 112 | 113 | if [ "$BUILD" = "debug" ]; then 114 | CXX_FLAGS="$CXX_FLAGS -g" 115 | else 116 | CC_FLAGS="$CC_FLAGS -O3" 117 | CXX_FLAGS="$CXX_FLAGS -O3" 118 | fi 119 | fi 120 | 121 | HEADERS="$HEADERS -Ijni-headers/${JNI_MD}" 122 | 123 | rm -rf $BUILD_DIR 124 | mkdir -p $BUILD_DIR 125 | mkdir -p $OUTPUT_DIR 126 | 127 | echo "--- Compiling for $TARGET, build type $BUILD" 128 | 129 | echo "------ Compiling C sources" 130 | for f in "${CC_SOURCES[@]}"; do 131 | OBJECT_FILE=$BUILD_DIR/`basename $f .c` 132 | trace $CC $CC_FLAGS $HEADERS "$f" -o $OBJECT_FILE.o 133 | done 134 | echo 135 | 136 | echo "------ Compiling C++ sources" 137 | for f in "${CXX_SOURCES[@]}"; do 138 | OBJECT_FILE=$BUILD_DIR/`basename $f .cpp` 139 | trace $CXX $CXX_FLAGS $HEADERS "$f" -o $OBJECT_FILE.o 140 | done 141 | echo 142 | 143 | echo "--- Linking & stripping" 144 | LINKER=$CXX 145 | OBJ_FILES=`find $BUILD_DIR -name "*.o"` 146 | OUTPUT_FILE="$OUTPUT_DIR/$OUTPUT_PREFIX$OUTPUT_NAME$OUTPUT_SUFFIX" 147 | trace $LINKER $OBJ_FILES $LIBRARIES $LINKER_FLAGS -o "$OUTPUT_FILE" 148 | trace $STRIP "$OUTPUT_FILE" 149 | echo 150 | 151 | echo "--- Updating spine-editor-natives.jar" 152 | mkdir -p ../libs/macos 153 | cp "$OUTPUT_FILE" ../libs/macos 154 | if test -f ../libs/jglfw-natives.jar; then 155 | trace $JAR uf ../libs/jglfw-natives.jar -C "$OUTPUT_DIR" "$OUTPUT_PREFIX$OUTPUT_NAME$OUTPUT_SUFFIX" 156 | else 157 | trace $JAR cf ../libs/jglfw-natives.jar -C "$OUTPUT_DIR" "$OUTPUT_PREFIX$OUTPUT_NAME$OUTPUT_SUFFIX" 158 | fi 159 | 160 | #trace rm -rf $BUILD_DIR -------------------------------------------------------------------------------- /jglfw-tests/src/com/badlogic/jglfw/tests/GlfwTest.java: -------------------------------------------------------------------------------- 1 | 2 | package com.badlogic.jglfw.tests; 3 | 4 | import static com.badlogic.jglfw.Glfw.*; 5 | 6 | import java.io.IOException; 7 | import java.util.Arrays; 8 | 9 | import com.badlogic.jglfw.GlfwCallback; 10 | import com.badlogic.jglfw.gl.GL; 11 | 12 | public class GlfwTest { 13 | public static void main (String[] args) throws InterruptedException, IOException { 14 | if (!glfwInit()) { 15 | System.out.println("Couldn't initialize GLFW"); 16 | System.exit(-1); 17 | } 18 | System.out.println(glfwGetVersion()); 19 | System.out.println(glfwGetVersionString()); 20 | System.out.println(Arrays.toString(glfwGetMonitors())); 21 | long monitor = glfwGetPrimaryMonitor(); 22 | System.out.println(monitor); 23 | System.out.println(glfwGetMonitorX(monitor) + ", " + glfwGetMonitorY(monitor)); 24 | System.out.println(glfwGetMonitorPhysicalWidth(monitor) + ", " + glfwGetMonitorPhysicalHeight(monitor)); 25 | System.out.println(glfwGetMonitorName(monitor)); 26 | System.out.println(glfwGetVideoModes(monitor)); 27 | System.out.println(glfwGetVideoMode(monitor)); 28 | 29 | System.out.println("ICC profile path: " + glfwGetMonitorIccProfilePath(monitor)); 30 | 31 | glfwSetCallback(new GlfwCallback() { 32 | @Override 33 | public void error (int error, String description) { 34 | System.out.println("error: " + description); 35 | } 36 | 37 | @Override 38 | public void monitor (long monitor, boolean connected) { 39 | System.out.println("monitor " + monitor + " " + (connected ? "connected" : "disconnected")); 40 | } 41 | 42 | @Override 43 | public void windowPos (long window, int x, int y) { 44 | System.out.println("window position changed: " + x + ", " + y); 45 | } 46 | 47 | @Override 48 | public void windowSize (long window, int width, int height) { 49 | System.out.println("window size changed: " + width + ", " + height); 50 | } 51 | 52 | @Override 53 | public boolean windowClose (long window) { 54 | System.out.println("window closing"); 55 | return true; 56 | } 57 | 58 | @Override 59 | public void windowRefresh (long window) { 60 | System.out.println("window refresh needed"); 61 | } 62 | 63 | @Override 64 | public void windowFocus (long window, boolean focused) { 65 | System.out.println("window " + (focused ? "focused" : "lost focus")); 66 | } 67 | 68 | @Override 69 | public void windowIconify (long window, boolean iconified) { 70 | System.out.println("window " + (iconified ? "iconified" : "deiconified")); 71 | } 72 | 73 | @Override 74 | public void key (long window, int key, int scancode, int action, int modifiers) { 75 | String actionStr = "pressed"; 76 | if (action == GLFW_RELEASE) actionStr = "released"; 77 | if (action == GLFW_REPEAT) actionStr = "repeated"; 78 | System.out.println("key " + key + " " + actionStr); 79 | } 80 | 81 | @Override 82 | public void character (long window, char character) { 83 | System.out.println("character " + character); 84 | } 85 | 86 | @Override 87 | public void mouseButton (long window, int button, boolean pressed) { 88 | System.out.println("mouse button " + button + " " + (pressed ? "pressed" : "released")); 89 | } 90 | 91 | @Override 92 | public void cursorPos (long window, int x, int y) { 93 | System.out.println("cursor position " + x + ", " + y); 94 | } 95 | 96 | @Override 97 | public void cursorEnter (long window, boolean entered) { 98 | System.out.println("cursor " + (entered ? "entered" : "left")); 99 | } 100 | 101 | @Override 102 | public void scroll (long window, double scrollX, double scrollY) { 103 | System.out.println("scrolled " + scrollX + ", " + scrollY); 104 | } 105 | 106 | }); 107 | 108 | glfwWindowHint(GLFW_DEPTH_BITS, 16); // this is needed on virtualbox... 109 | long window = glfwCreateWindow(800, 600, "Test", 0, 0); 110 | if (window == 0) { 111 | throw new RuntimeException("Couldn't create window"); 112 | } 113 | System.out.println(glfwGetWindowX(window) + ", " + glfwGetWindowY(window)); 114 | System.out.println(glfwGetWindowWidth(window) + ", " + glfwGetWindowHeight(window)); 115 | glfwSetWindowSize(window, 640, 480); 116 | glfwIconifyWindow(window); 117 | Thread.sleep(1000); 118 | glfwRestoreWindow(window); 119 | Thread.sleep(1000); 120 | glfwHideWindow(window); 121 | Thread.sleep(1000); 122 | glfwShowWindow(window); 123 | System.out.println(glfwGetWindowMonitor(window)); 124 | 125 | glfwMakeContextCurrent(window); 126 | glfwSwapInterval(1); 127 | 128 | while (!glfwWindowShouldClose(window)) { 129 | GL.glViewport(0, 0, 640, 480); 130 | GL.glClear(GL.GL_COLOR_BUFFER_BIT); 131 | GL.glRotatef(0.01f, 0, 0, 1); 132 | GL.glBegin(GL.GL_TRIANGLES); 133 | GL.glVertex2f(-0.5f, -0.5f); 134 | GL.glVertex2f(0.5f, -0.5f); 135 | GL.glVertex2f(0, 0.5f); 136 | GL.glEnd(); 137 | // glfwPollEvents(); 138 | glfwSwapBuffers(window); 139 | } 140 | 141 | glfwDestroyWindow(window); 142 | glfwTerminate(); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/glx_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: X11/GLX 4 | // API version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2002-2006 Marcus Geelnard 8 | // Copyright (c) 2006-2010 Camilla Berglund 9 | // 10 | // This software is provided 'as-is', without any express or implied 11 | // warranty. In no event will the authors be held liable for any damages 12 | // arising from the use of this software. 13 | // 14 | // Permission is granted to anyone to use this software for any purpose, 15 | // including commercial applications, and to alter it and redistribute it 16 | // freely, subject to the following restrictions: 17 | // 18 | // 1. The origin of this software must not be misrepresented; you must not 19 | // claim that you wrote the original software. If you use this software 20 | // in a product, an acknowledgment in the product documentation would 21 | // be appreciated but is not required. 22 | // 23 | // 2. Altered source versions must be plainly marked as such, and must not 24 | // be misrepresented as being the original software. 25 | // 26 | // 3. This notice may not be removed or altered from any source 27 | // distribution. 28 | // 29 | //======================================================================== 30 | 31 | #ifndef _glx_platform_h_ 32 | #define _glx_platform_h_ 33 | 34 | #define GLX_GLXEXT_LEGACY 35 | #include 36 | 37 | // This path may need to be changed if you build GLFW using your own setup 38 | // We ship and use our own copy of glxext.h since GLFW uses fairly new 39 | // extensions and not all operating systems come with an up-to-date version 40 | #include "../support/GL/glxext.h" 41 | 42 | // Do we have support for dlopen/dlsym? 43 | #if defined(_GLFW_HAS_DLOPEN) 44 | #include 45 | #endif 46 | 47 | // We support four different ways for getting addresses for GL/GLX 48 | // extension functions: glXGetProcAddress, glXGetProcAddressARB, 49 | // glXGetProcAddressEXT, and dlsym 50 | #if defined(_GLFW_HAS_GLXGETPROCADDRESSARB) 51 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressARB(x) 52 | #elif defined(_GLFW_HAS_GLXGETPROCADDRESS) 53 | #define _glfw_glXGetProcAddress(x) glXGetProcAddress(x) 54 | #elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT) 55 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x) 56 | #elif defined(_GLFW_HAS_DLOPEN) 57 | #define _glfw_glXGetProcAddress(x) dlsym(_glfw.glx.libGL, x) 58 | #define _GLFW_DLOPEN_LIBGL 59 | #else 60 | #error "No OpenGL entry point retrieval mechanism was enabled" 61 | #endif 62 | 63 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx 64 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX glx 65 | 66 | #ifndef GLX_MESA_swap_control 67 | typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int); 68 | #endif 69 | 70 | 71 | //======================================================================== 72 | // GLFW platform specific types 73 | //======================================================================== 74 | 75 | //------------------------------------------------------------------------ 76 | // Platform-specific OpenGL context structure 77 | //------------------------------------------------------------------------ 78 | typedef struct _GLFWcontextGLX 79 | { 80 | GLXContext context; // OpenGL rendering context 81 | XVisualInfo* visual; // Visual for selected GLXFBConfig 82 | 83 | } _GLFWcontextGLX; 84 | 85 | 86 | //------------------------------------------------------------------------ 87 | // Platform-specific library global data for GLX 88 | //------------------------------------------------------------------------ 89 | typedef struct _GLFWlibraryGLX 90 | { 91 | // Server-side GLX version 92 | int versionMajor, versionMinor; 93 | int eventBase; 94 | int errorBase; 95 | 96 | // GLX extensions 97 | PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; 98 | PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; 99 | PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; 100 | PFNGLXGETFBCONFIGATTRIBSGIXPROC GetFBConfigAttribSGIX; 101 | PFNGLXCHOOSEFBCONFIGSGIXPROC ChooseFBConfigSGIX; 102 | PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC CreateContextWithConfigSGIX; 103 | PFNGLXGETVISUALFROMFBCONFIGSGIXPROC GetVisualFromFBConfigSGIX; 104 | PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 105 | GLboolean SGIX_fbconfig; 106 | GLboolean SGI_swap_control; 107 | GLboolean EXT_swap_control; 108 | GLboolean MESA_swap_control; 109 | GLboolean ARB_multisample; 110 | GLboolean ARB_framebuffer_sRGB; 111 | GLboolean ARB_create_context; 112 | GLboolean ARB_create_context_profile; 113 | GLboolean ARB_create_context_robustness; 114 | GLboolean EXT_create_context_es2_profile; 115 | 116 | #if defined(_GLFW_DLOPEN_LIBGL) 117 | void* libGL; // dlopen handle for libGL.so 118 | #endif 119 | } _GLFWlibraryGLX; 120 | 121 | 122 | #endif // _glx_platform_h_ 123 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/reopen.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Window re-opener (open/close stress test) 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This test came about as the result of bug #1262773 27 | // 28 | // It closes and re-opens the GLFW window every five seconds, alternating 29 | // between windowed and fullscreen mode 30 | // 31 | // It also times and logs opening and closing actions and attempts to separate 32 | // user initiated window closing from its own 33 | // 34 | //======================================================================== 35 | 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | static void error_callback(int error, const char* description) 42 | { 43 | fprintf(stderr, "Error: %s\n", description); 44 | } 45 | 46 | static void window_size_callback(GLFWwindow* window, int width, int height) 47 | { 48 | glViewport(0, 0, width, height); 49 | } 50 | 51 | static int window_close_callback(GLFWwindow* window) 52 | { 53 | printf("Close callback triggered\n"); 54 | return GL_TRUE; 55 | } 56 | 57 | static void key_callback(GLFWwindow* window, int key, int action) 58 | { 59 | if (action != GLFW_PRESS) 60 | return; 61 | 62 | switch (key) 63 | { 64 | case GLFW_KEY_Q: 65 | case GLFW_KEY_ESCAPE: 66 | glfwSetWindowShouldClose(window, GL_TRUE); 67 | break; 68 | } 69 | } 70 | 71 | static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor) 72 | { 73 | double base; 74 | GLFWwindow* window; 75 | 76 | base = glfwGetTime(); 77 | 78 | window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); 79 | if (!window) 80 | return NULL; 81 | 82 | glfwMakeContextCurrent(window); 83 | glfwSwapInterval(1); 84 | 85 | glfwSetWindowSizeCallback(window, window_size_callback); 86 | glfwSetWindowCloseCallback(window, window_close_callback); 87 | glfwSetKeyCallback(window, key_callback); 88 | 89 | printf("Opening %s mode window took %0.3f seconds\n", 90 | monitor ? "fullscreen" : "windowed", 91 | glfwGetTime() - base); 92 | 93 | return window; 94 | } 95 | 96 | static void close_window(GLFWwindow* window) 97 | { 98 | double base = glfwGetTime(); 99 | glfwDestroyWindow(window); 100 | printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); 101 | } 102 | 103 | int main(int argc, char** argv) 104 | { 105 | int count = 0; 106 | GLFWwindow* window; 107 | 108 | glfwSetErrorCallback(error_callback); 109 | 110 | if (!glfwInit()) 111 | exit(EXIT_FAILURE); 112 | 113 | for (;;) 114 | { 115 | GLFWmonitor* monitor = NULL; 116 | 117 | if (count & 1) 118 | { 119 | int monitorCount; 120 | GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); 121 | monitor = monitors[rand() % monitorCount]; 122 | } 123 | 124 | window = open_window(640, 480, monitor); 125 | if (!window) 126 | { 127 | glfwTerminate(); 128 | exit(EXIT_FAILURE); 129 | } 130 | 131 | glMatrixMode(GL_PROJECTION); 132 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 133 | glMatrixMode(GL_MODELVIEW); 134 | 135 | glfwSetTime(0.0); 136 | 137 | while (glfwGetTime() < 5.0) 138 | { 139 | glClear(GL_COLOR_BUFFER_BIT); 140 | 141 | glPushMatrix(); 142 | glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f); 143 | glRectf(-0.5f, -0.5f, 1.f, 1.f); 144 | glPopMatrix(); 145 | 146 | glfwSwapBuffers(window); 147 | glfwPollEvents(); 148 | 149 | if (glfwWindowShouldClose(window)) 150 | { 151 | close_window(window); 152 | printf("User closed window\n"); 153 | 154 | glfwTerminate(); 155 | exit(EXIT_SUCCESS); 156 | } 157 | } 158 | 159 | printf("Closing window\n"); 160 | close_window(window); 161 | 162 | count++; 163 | } 164 | 165 | glfwTerminate(); 166 | } 167 | 168 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/iconify.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Iconify/restore test program 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test the iconify/restore functionality for 27 | // both fullscreen and windowed mode windows 28 | // 29 | //======================================================================== 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "getopt.h" 37 | 38 | static void usage(void) 39 | { 40 | printf("Usage: iconify [-h] [-f]\n"); 41 | } 42 | 43 | static void error_callback(int error, const char* description) 44 | { 45 | fprintf(stderr, "Error: %s\n", description); 46 | } 47 | 48 | static void key_callback(GLFWwindow* window, int key, int action) 49 | { 50 | printf("%0.2f Key %s\n", 51 | glfwGetTime(), 52 | action == GLFW_PRESS ? "pressed" : "released"); 53 | 54 | if (action != GLFW_PRESS) 55 | return; 56 | 57 | switch (key) 58 | { 59 | case GLFW_KEY_SPACE: 60 | glfwIconifyWindow(window); 61 | break; 62 | case GLFW_KEY_ESCAPE: 63 | glfwSetWindowShouldClose(window, GL_TRUE); 64 | break; 65 | } 66 | } 67 | 68 | static void window_size_callback(GLFWwindow* window, int width, int height) 69 | { 70 | printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height); 71 | 72 | glViewport(0, 0, width, height); 73 | } 74 | 75 | static void window_focus_callback(GLFWwindow* window, int focused) 76 | { 77 | printf("%0.2f Window %s\n", 78 | glfwGetTime(), 79 | focused ? "focused" : "defocused"); 80 | } 81 | 82 | static void window_iconify_callback(GLFWwindow* window, int iconified) 83 | { 84 | printf("%0.2f Window %s\n", 85 | glfwGetTime(), 86 | iconified ? "iconified" : "restored"); 87 | } 88 | 89 | int main(int argc, char** argv) 90 | { 91 | int width, height, ch; 92 | GLFWmonitor* monitor = NULL; 93 | GLFWwindow* window; 94 | 95 | glfwSetErrorCallback(error_callback); 96 | 97 | if (!glfwInit()) 98 | exit(EXIT_FAILURE); 99 | 100 | while ((ch = getopt(argc, argv, "fh")) != -1) 101 | { 102 | switch (ch) 103 | { 104 | case 'h': 105 | usage(); 106 | exit(EXIT_SUCCESS); 107 | 108 | case 'f': 109 | monitor = glfwGetPrimaryMonitor(); 110 | break; 111 | 112 | default: 113 | usage(); 114 | exit(EXIT_FAILURE); 115 | } 116 | } 117 | 118 | if (monitor) 119 | { 120 | GLFWvidmode mode = glfwGetVideoMode(monitor); 121 | width = mode.width; 122 | height = mode.height; 123 | } 124 | else 125 | { 126 | width = 640; 127 | height = 480; 128 | } 129 | 130 | window = glfwCreateWindow(width, height, "Iconify", monitor, NULL); 131 | if (!window) 132 | { 133 | glfwTerminate(); 134 | exit(EXIT_FAILURE); 135 | } 136 | 137 | glfwMakeContextCurrent(window); 138 | glfwSwapInterval(1); 139 | 140 | glfwSetKeyCallback(window, key_callback); 141 | glfwSetWindowSizeCallback(window, window_size_callback); 142 | glfwSetWindowFocusCallback(window, window_focus_callback); 143 | glfwSetWindowIconifyCallback(window, window_iconify_callback); 144 | 145 | printf("Window is %s and %s\n", 146 | glfwGetWindowParam(window, GLFW_ICONIFIED) ? "iconified" : "restored", 147 | glfwGetWindowParam(window, GLFW_FOCUSED) ? "focused" : "defocused"); 148 | 149 | glEnable(GL_SCISSOR_TEST); 150 | 151 | while (!glfwWindowShouldClose(window)) 152 | { 153 | glfwGetWindowSize(window, &width, &height); 154 | 155 | glScissor(0, 0, width, height); 156 | glClearColor(0, 0, 0, 0); 157 | glClear(GL_COLOR_BUFFER_BIT); 158 | 159 | glScissor(0, 0, 640, 480); 160 | glClearColor(1, 1, 1, 0); 161 | glClear(GL_COLOR_BUFFER_BIT); 162 | 163 | glfwSwapBuffers(window); 164 | glfwPollEvents(); 165 | } 166 | 167 | glfwTerminate(); 168 | exit(EXIT_SUCCESS); 169 | } 170 | 171 | -------------------------------------------------------------------------------- /jglfw/src/com/badlogic/jglfw/generators/gl_custom.txt: -------------------------------------------------------------------------------- 1 | glGetString 2 | public static native String glGetString(int name); /* 3 | return env->NewStringUTF((const char*)glGetString((GLenum)name)); 4 | */ 5 | ----- 6 | glGetStringi 7 | public static native String glGetString(int name, int index); /* 8 | return env->NewStringUTF((const char*)ext_glGetStringi((GLenum)name, (GLuint)index)); 9 | */ 10 | ----- 11 | glMapBuffer 12 | public static native Buffer glMapBuffer(int target, int access, long bufferSize); /* 13 | GLvoid* buffer = (GLvoid*)ext_glMapBuffer((GLenum)target, (GLenum)access); 14 | if(!buffer) return 0; 15 | return env->NewDirectByteBuffer(buffer, bufferSize); 16 | */ 17 | ----- 18 | glMapBufferARB 19 | public static native Buffer glMapBufferARB(int target, int access, long bufferSize); /* 20 | GLvoid* buffer = (GLvoid*)ext_glMapBufferARB((GLenum)target, (GLenum)access); 21 | if(!buffer) return 0; 22 | return env->NewDirectByteBuffer(buffer, bufferSize); 23 | */ 24 | ----- 25 | glMapBufferRange 26 | public static native Buffer glMapBufferRange(int target, int offset, int length, int access, long bufferSize); /* 27 | GLvoid* buffer = (GLvoid*)ext_glMapBufferRange((GLenum)target, (GLintptr)offset, (GLsizeiptr)length, (GLbitfield)access); 28 | if(!buffer) return 0; 29 | return env->NewDirectByteBuffer(buffer, bufferSize); 30 | */ 31 | ----- 32 | glMapObjectBufferATI 33 | public static native Buffer glMapObjectBufferATI(int buffer, long bufferSize); /* 34 | GLvoid* bufferPtr = (GLvoid*)ext_glMapObjectBufferATI((GLuint)buffer); 35 | if(!bufferPtr) return 0; 36 | return env->NewDirectByteBuffer(bufferPtr, bufferSize); 37 | */ 38 | ----- 39 | glMapNamedBufferEXT 40 | public static native Buffer glMapNamedBufferEXT(int buffer, int access, long bufferSize); /* 41 | GLvoid* bufferPtr = (GLvoid*)ext_glMapNamedBufferEXT((GLuint)buffer, (GLenum)access); 42 | if(!bufferPtr) return 0; 43 | return env->NewDirectByteBuffer(bufferPtr, bufferSize); 44 | */ 45 | ----- 46 | glMapNamedBufferRangeEXT 47 | public static native Buffer glMapNamedBufferRangeEXT(int buffer, int offset, int length, int access, int bufferSize); /* 48 | GLvoid* bufferPtr = (GLvoid*)ext_glMapNamedBufferRangeEXT((GLuint)buffer, (GLintptr)offset, (GLsizeiptr)length, (GLbitfield)access); 49 | if(!bufferPtr) return 0; 50 | return env->NewDirectByteBuffer(bufferPtr, bufferSize); 51 | */ 52 | ----- 53 | glMapTexture2DINTEL 54 | public static native Buffer glMapTexture2DINTEL(int texture, int level, int access, Buffer stride, int strideByteOffset, Buffer layout, int layoutByteOffset, long bufferSize); /* 55 | GLvoid* bufferPtr = (GLvoid*)ext_glMapTexture2DINTEL((GLuint)texture, (GLint)level, (GLbitfield)access, (const GLint*)(stride + strideByteOffset), (const GLenum*)(layout + layoutByteOffset)); 56 | if(!bufferPtr) return 0; 57 | return env->NewDirectByteBuffer(bufferPtr, bufferSize); 58 | */ 59 | ----- 60 | glShaderSource 61 | public static native void glShaderSource(int shader, String string); /* 62 | ext_glShaderSource((GLuint)shader, 1, &string, 0); 63 | */ 64 | ----- 65 | glShaderSourceARB 66 | public static native void glShaderSourceARB(int shader, String string); /* 67 | ext_glShaderSource((GLuint)shader, 1, &string, 0); 68 | */ 69 | ----- 70 | glBindAttribLocation 71 | public static native void glBindAttribLocation(int program, int index, String name); /* 72 | ext_glBindAttribLocation((GLuint)program, (GLuint)index, (const GLchar*)(name)); 73 | */ 74 | ----- 75 | glGetAttribLocation 76 | public static native int glGetAttribLocation(int program, String name); /* 77 | return (jint)ext_glGetAttribLocation((GLuint)program, (const GLchar*)(name)); 78 | */ 79 | ----- 80 | glGetUniformLocation 81 | public static native int glGetUniformLocation(int program, String name); /* 82 | return (jint)ext_glGetUniformLocation((GLuint)program, (const GLchar*)(name)); 83 | */ 84 | ----- 85 | glGetActiveAttrib 86 | public static native String glGetActiveAttrib(int program, int index, Buffer size, int sizeByteOffset, Buffer type, int typeByteOffset); /* 87 | // FIXME 2K limit for attrib names 88 | char cname[2048]; 89 | ext_glGetActiveAttrib((GLuint)program, (GLuint)index, (GLsizei)2048, 0, (GLint*)(size + sizeByteOffset), (GLenum*)(type + typeByteOffset), cname); 90 | return env->NewStringUTF( cname ); 91 | */ 92 | ----- 93 | glGetActiveUniform 94 | public static native String glGetActiveUniform(int program, int index, Buffer size, int sizeByteOffset, Buffer type, int typeByteOffset); /* 95 | // FIXME 2K limit for uniform names 96 | char cname[2048]; 97 | ext_glGetActiveUniform((GLuint)program, (GLuint)index, (GLsizei)2048, 0, (GLint*)(size + sizeByteOffset), (GLenum*)(type + typeByteOffset), cname); 98 | return env->NewStringUTF(cname); 99 | */ 100 | ----- 101 | glGetProgramInfoLog 102 | public static native String glGetProgramInfoLog(int program); /* 103 | // FIXME 10K limit 104 | char info[1024*10]; 105 | int length = 0; 106 | ext_glGetProgramInfoLog(program, 1024*10, &length, info); 107 | return env->NewStringUTF(info); 108 | */ 109 | ----- 110 | glGetShaderInfoLog 111 | public static native String glGetShaderInfoLog(int shader); /* 112 | // FIXME 10K limit 113 | char info[1024*10]; 114 | int length = 0; 115 | ext_glGetShaderInfoLog(shader, 1024*10, &length, info); 116 | return env->NewStringUTF(info); 117 | */ 118 | ----- -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/src/cocoa_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW - An OpenGL library 3 | // Platform: Cocoa 4 | // API Version: 3.0 5 | // WWW: http://www.glfw.org/ 6 | //------------------------------------------------------------------------ 7 | // Copyright (c) 2009-2010 Camilla Berglund 8 | // 9 | // This software is provided 'as-is', without any express or implied 10 | // warranty. In no event will the authors be held liable for any damages 11 | // arising from the use of this software. 12 | // 13 | // Permission is granted to anyone to use this software for any purpose, 14 | // including commercial applications, and to alter it and redistribute it 15 | // freely, subject to the following restrictions: 16 | // 17 | // 1. The origin of this software must not be misrepresented; you must not 18 | // claim that you wrote the original software. If you use this software 19 | // in a product, an acknowledgment in the product documentation would 20 | // be appreciated but is not required. 21 | // 22 | // 2. Altered source versions must be plainly marked as such, and must not 23 | // be misrepresented as being the original software. 24 | // 25 | // 3. This notice may not be removed or altered from any source 26 | // distribution. 27 | // 28 | //======================================================================== 29 | 30 | #ifndef _cocoa_platform_h_ 31 | #define _cocoa_platform_h_ 32 | 33 | 34 | #include 35 | 36 | #if defined(__OBJC__) 37 | #import 38 | #else 39 | #include 40 | typedef void* id; 41 | #endif 42 | 43 | #if defined(_GLFW_NSGL) 44 | #include "nsgl_platform.h" 45 | #else 46 | #error "No supported context creation API selected" 47 | #endif 48 | 49 | #include 50 | #include 51 | #include 52 | #include 53 | 54 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns 55 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns 56 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns 57 | 58 | 59 | //======================================================================== 60 | // GLFW platform specific types 61 | //======================================================================== 62 | 63 | //------------------------------------------------------------------------ 64 | // Pointer length integer 65 | //------------------------------------------------------------------------ 66 | typedef intptr_t GLFWintptr; 67 | 68 | 69 | //------------------------------------------------------------------------ 70 | // Platform-specific window structure 71 | //------------------------------------------------------------------------ 72 | typedef struct _GLFWwindowNS 73 | { 74 | id object; 75 | id delegate; 76 | id view; 77 | unsigned int modifierFlags; 78 | } _GLFWwindowNS; 79 | 80 | 81 | //------------------------------------------------------------------------ 82 | // Joystick information & state 83 | //------------------------------------------------------------------------ 84 | typedef struct 85 | { 86 | int present; 87 | char name[256]; 88 | 89 | IOHIDDeviceInterface** interface; 90 | 91 | int numAxes; 92 | int numButtons; 93 | int numHats; 94 | 95 | CFMutableArrayRef axes; 96 | CFMutableArrayRef buttons; 97 | CFMutableArrayRef hats; 98 | 99 | } _GLFWjoy; 100 | 101 | 102 | //------------------------------------------------------------------------ 103 | // Platform-specific library global data for Cocoa 104 | //------------------------------------------------------------------------ 105 | typedef struct _GLFWlibraryNS 106 | { 107 | struct { 108 | double base; 109 | double resolution; 110 | } timer; 111 | 112 | CGEventSourceRef eventSource; 113 | id delegate; 114 | id keyUpMonitor; 115 | 116 | char* clipboardString; 117 | 118 | short int keycodes[256]; 119 | short int scancodes[GLFW_KEY_LAST + 1]; 120 | 121 | _GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1]; 122 | } _GLFWlibraryNS; 123 | 124 | 125 | //------------------------------------------------------------------------ 126 | // Platform-specific monitor structure 127 | //------------------------------------------------------------------------ 128 | typedef struct _GLFWmonitorNS 129 | { 130 | CGDirectDisplayID displayID; 131 | CGDisplayModeRef previousMode; 132 | 133 | } _GLFWmonitorNS; 134 | 135 | 136 | //======================================================================== 137 | // Prototypes for platform specific internal functions 138 | //======================================================================== 139 | 140 | // Time 141 | void _glfwInitTimer(void); 142 | 143 | // Joystick input 144 | void _glfwInitJoysticks(void); 145 | void _glfwTerminateJoysticks(void); 146 | 147 | // Fullscreen 148 | GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, int* width, int* height, int* bpp); 149 | void _glfwRestoreVideoMode(_GLFWmonitor* monitor); 150 | 151 | // OpenGL support 152 | int _glfwInitContextAPI(void); 153 | void _glfwTerminateContextAPI(void); 154 | int _glfwCreateContext(_GLFWwindow* window, 155 | const _GLFWwndconfig* wndconfig, 156 | const _GLFWfbconfig* fbconfig); 157 | void _glfwDestroyContext(_GLFWwindow* window); 158 | 159 | float _glfwPlatformGetUnitsToPixelsRatio(_GLFWwindow* window); 160 | 161 | #endif // _cocoa_platform_h_ 162 | -------------------------------------------------------------------------------- /jglfw/jni/glfw-3.0/tests/sharing.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Context sharing test program 3 | // Copyright (c) Camilla Berglund 4 | // 5 | // This software is provided 'as-is', without any express or implied 6 | // warranty. In no event will the authors be held liable for any damages 7 | // arising from the use of this software. 8 | // 9 | // Permission is granted to anyone to use this software for any purpose, 10 | // including commercial applications, and to alter it and redistribute it 11 | // freely, subject to the following restrictions: 12 | // 13 | // 1. The origin of this software must not be misrepresented; you must not 14 | // claim that you wrote the original software. If you use this software 15 | // in a product, an acknowledgment in the product documentation would 16 | // be appreciated but is not required. 17 | // 18 | // 2. Altered source versions must be plainly marked as such, and must not 19 | // be misrepresented as being the original software. 20 | // 21 | // 3. This notice may not be removed or altered from any source 22 | // distribution. 23 | // 24 | //======================================================================== 25 | // 26 | // This program is used to test sharing of objects between contexts 27 | // 28 | //======================================================================== 29 | 30 | #define GLFW_INCLUDE_GLU 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #define WIDTH 400 37 | #define HEIGHT 400 38 | #define OFFSET 50 39 | 40 | static GLFWwindow* windows[2]; 41 | 42 | static void error_callback(int error, const char* description) 43 | { 44 | fprintf(stderr, "Error: %s\n", description); 45 | } 46 | 47 | static void key_callback(GLFWwindow* window, int key, int action) 48 | { 49 | if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) 50 | glfwSetWindowShouldClose(window, GL_TRUE); 51 | } 52 | 53 | static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY) 54 | { 55 | GLFWwindow* window; 56 | 57 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 58 | window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share); 59 | if (!window) 60 | return NULL; 61 | 62 | glfwMakeContextCurrent(window); 63 | glfwSwapInterval(1); 64 | glfwSetWindowPos(window, posX, posY); 65 | glfwShowWindow(window); 66 | 67 | glfwSetKeyCallback(window, key_callback); 68 | 69 | return window; 70 | } 71 | 72 | static GLuint create_texture(void) 73 | { 74 | int x, y; 75 | char pixels[256 * 256]; 76 | GLuint texture; 77 | 78 | glGenTextures(1, &texture); 79 | glBindTexture(GL_TEXTURE_2D, texture); 80 | 81 | for (y = 0; y < 256; y++) 82 | { 83 | for (x = 0; x < 256; x++) 84 | pixels[y * 256 + x] = rand() % 256; 85 | } 86 | 87 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels); 88 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 89 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 90 | 91 | return texture; 92 | } 93 | 94 | static void draw_quad(GLuint texture) 95 | { 96 | int width, height; 97 | glfwGetWindowSize(glfwGetCurrentContext(), &width, &height); 98 | 99 | glViewport(0, 0, width, height); 100 | 101 | glMatrixMode(GL_PROJECTION); 102 | glLoadIdentity(); 103 | gluOrtho2D(0.f, 1.f, 0.f, 1.f); 104 | 105 | glEnable(GL_TEXTURE_2D); 106 | glBindTexture(GL_TEXTURE_2D, texture); 107 | glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 108 | 109 | glBegin(GL_QUADS); 110 | 111 | glTexCoord2f(0.f, 0.f); 112 | glVertex2f(0.f, 0.f); 113 | 114 | glTexCoord2f(1.f, 0.f); 115 | glVertex2f(1.f, 0.f); 116 | 117 | glTexCoord2f(1.f, 1.f); 118 | glVertex2f(1.f, 1.f); 119 | 120 | glTexCoord2f(0.f, 1.f); 121 | glVertex2f(0.f, 1.f); 122 | 123 | glEnd(); 124 | } 125 | 126 | int main(int argc, char** argv) 127 | { 128 | int x, y, width; 129 | GLuint texture; 130 | 131 | glfwSetErrorCallback(error_callback); 132 | 133 | if (!glfwInit()) 134 | exit(EXIT_FAILURE); 135 | 136 | windows[0] = open_window("First", NULL, OFFSET, OFFSET); 137 | if (!windows[0]) 138 | { 139 | glfwTerminate(); 140 | exit(EXIT_FAILURE); 141 | } 142 | 143 | // This is the one and only time we create a texture 144 | // It is created inside the first context, created above 145 | // It will then be shared with the second context, created below 146 | texture = create_texture(); 147 | 148 | glfwGetWindowPos(windows[0], &x, &y); 149 | glfwGetWindowSize(windows[0], &width, NULL); 150 | 151 | // Put the second window to the right of the first one 152 | windows[1] = open_window("Second", windows[0], x + width + OFFSET, y); 153 | if (!windows[1]) 154 | { 155 | glfwTerminate(); 156 | exit(EXIT_FAILURE); 157 | } 158 | 159 | // Set drawing color for both contexts 160 | glfwMakeContextCurrent(windows[0]); 161 | glColor3f(0.6f, 0.f, 0.6f); 162 | glfwMakeContextCurrent(windows[1]); 163 | glColor3f(0.6f, 0.6f, 0.f); 164 | 165 | glfwMakeContextCurrent(windows[0]); 166 | 167 | while (!glfwWindowShouldClose(windows[0]) && 168 | !glfwWindowShouldClose(windows[1])) 169 | { 170 | glfwMakeContextCurrent(windows[0]); 171 | draw_quad(texture); 172 | 173 | glfwMakeContextCurrent(windows[1]); 174 | draw_quad(texture); 175 | 176 | glfwSwapBuffers(windows[0]); 177 | glfwSwapBuffers(windows[1]); 178 | 179 | glfwWaitEvents(); 180 | } 181 | 182 | glfwTerminate(); 183 | exit(EXIT_SUCCESS); 184 | } 185 | 186 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JGLFW 2 | ===== 3 | JGLFW is a crossplatform (Windows, Linux, Mac OS X) wrapper for 4 | * [GLFW 3.0](https://github.com/elmindreda/glfw), for window managment, OpenGL context creation and input handling 5 | * OpenGL, for graphics 6 | * OpenAL, for audio 7 | 8 | The GLFW bindings were created manually using [gdx-jnigen](https://github.com/libgdx/libgdx/wiki/jnigen). The bindings for OpenGL and OpenAL are automatically generated from the [GLEW](http://glew.sourceforge.net/) header and the standard [OpenAL Soft](http://kcat.strangesoft.net/openal.html) headers. 9 | 10 | Usage 11 | ----- 12 | Download the latest nightly build from http://libgdx.badlogicgames.com/jglfw/nightlies/ 13 | 14 | Create a Java project in your prefered way and add jglfw.jar and jglfw-natives.jar to your classpath. Check the [GLFW 3.0 documentation](https://github.com/elmindreda/glfw/blob/master/include/GL/glfw3.h). OpenGL 15 | and OpenAL should be straight forward to use. See the notes on GLFW, OpenGL and OpenAL below. 16 | 17 | Note: on Mac OS X you need to provide the -XstartOnFirstThread JVM argument, much 18 | like with SWT. 19 | 20 | Note: 32-bit Linux is currently not supported due to an issue with the build server. You can build the natives yourself, cd to jglfw/jni, then 21 | 22 | ant -f build-linux32.xml 23 | 24 | The endresult is in `jglfw/libs/linux32`, called `libjglfw.so`. Add that to the jglfw-natives.jar file with a ZIP program of your choice. 25 | 26 | Working from Source 27 | ------------------- 28 | Jglfw was developed with Eclipse, and you can find respective .classpath and .project files in the repository. Before you can work from source, it's recommended to fetch the latest nightlies from the build 29 | server. 30 | 31 | ant fetch 32 | 33 | This will download the jglfw-natives.jar into the jglfw/libs folder. You can now import the projects (jglfw, jglfw-tests) into Eclipse, or set up projects in an IDE you prefer. 34 | 35 | Building 36 | -------- 37 | The build system consists of an ant script located in the root folder. The simplest way to build jglfw is to invoke ant as follows 38 | 39 | ant clean package 40 | 41 | This will fetch the latest jglfw-natives.jar from the build server (http://libgdx.badlogicgames.com/jglfw), compile the Java sources and put everything into a versioned zip file. That way you do not need to worry about setting up all the cross-compilation toolchains. 42 | 43 | If you want to compile the native code yourself, you'll have a much more fun time. I only provide instructions to build on Linux and Mac OS X, on Windows you can try to use MinGW. 44 | 45 | #### Linux (to compile for Windows 32-/64-bit and Linux 32-/64-bit) 46 | Install dependencies and devel libs 47 | 48 | sudo apt-get install g++-mingw-w64-i686 g++-mingw-w64-x86-64 g++-multilib gcc-multilib libX11-dev libXrandr-dev libXxf86vm-dev libgl1-mesa-dev libgl1-mesa-glx 49 | 50 | Compile 51 | 52 | ant clean compile-natives package 53 | 54 | #### Mac 55 | Install the latest XCode from the Mac OS X App Store. To compile the Mac OS X natives (jglfw/libs/macosx32/libjglfw.dylib, a fat shared lib for 32-/64-bit): 56 | 57 | ant clean compile-mac-natives 58 | 59 | You can add the resulting .dylib to the `jglfw-natives.jar` generated on Linux as shown above. 60 | 61 | #### Modifying the Wrapper Code 62 | 63 | To modify the GLFW bindings, modify GLFW.java 64 | To modify the OpenGL bindings, modify GlParser.java and GlGenerator. Customizing works through the [custom.txt](https://github.com/badlogic/jglfw/blob/master/jglfw/src/com/badlogic/jglfw/gl/custom.txt) file. You can specify your own jnigen method in there. 65 | 66 | If you modified any of the bindings or wrapper generators, you'll need to run GlGenerator and GlfwBuild, in that order. This will regenerate all build scripts and C/C++ files. 67 | 68 | Notes on the GLFW bindings 69 | ---------------------- 70 | The GLFW wrapper is kept as close to the original C API as possible. The following deviations exist: 71 | 72 | * Instead of registering multiple callback procedures via `glfwSetErrorCallback` et. al, you can set a GlfwCallback (or GlfwCallbackAdapter) via Glfw#glfwSetCallback(). This interface contains all callback methods. 73 | * Gamma ramps can only be set via the simple method at the moment. 74 | * Instead `GLFWwindow*` and `GLFWmonitor*` pointers, you'll simply get a Java long. Not type-safe, but simple. 75 | * You should execute all window managment and rendering code on the main thread, that is, the thread within your `main()` method was started. 76 | * On Mac OS X you have to supply -XStartOnFirstThread as a JVM argument (SWT shares a similar issue). This is due to how Cocoa works (or doesn't, however you want to look at it...) 77 | 78 | Integration with Swing or AWT is not possible (so, no Applets either). You can however open Swing and AWT frames besides GLFW windows. 79 | 80 | Notes on the OpenGL bindings 81 | -------------------------------------------- 82 | OpenGL JNI methods are generated from the GLEW headers. A few notes: 83 | 84 | * Methods with pointer parameters, e.g. like in `glVertexPointer()`, have at least two Java method equivalents, one with the pointer converted to a Buffer and a byte offset, and another that only takes a long encoding a native heap memory address. If the concrete pointer parameter is known, e.g. `const float*`, a third method is generated that takes a Java array of equivalent type, plus an offset. 85 | * The position and limit of a direct Buffer are ignored! Supply a byte offset instead. 86 | * No bounds checking is performed, ever. 87 | * Extension methods are automatically loaded on startup, much like in the case of GLEW. 88 | 89 | Notes on the OpenAL bindings 90 | -------------------------------------------- 91 | To be defined... 92 | TODO 93 | ---- 94 | * [X] Build system 95 | * [X] Nightly builds, see http://libgdx.badlogicgames.com:8080, http://libgdx.badlogicgames.com/jglfw 96 | * [X] GLFW wrapper 97 | * [X] OpenGL generator 98 | * [ ] Add in the last few ignored methods 99 | * [ ] OpenAL generator 100 | --------------------------------------------------------------------------------