├── .gitignore ├── CMakeLists.txt ├── HOWTOBUILD.txt ├── README.md ├── bin └── media │ └── !OBTAIN_THE_MEDIA_PACK_AND_PUT_IT_HERE.txt ├── build ├── !RUN CMAKE FROM HERE.txt └── templates │ └── vs2013.vcxproj.user.in ├── extern └── glfw-3.0.4 │ ├── .gitignore │ ├── CMake │ ├── amd64-mingw32msvc.cmake │ ├── i586-mingw32msvc.cmake │ ├── i686-pc-mingw32.cmake │ ├── i686-w64-mingw32.cmake │ ├── modules │ │ ├── FindEGL.cmake │ │ ├── FindGLESv1.cmake │ │ └── FindGLESv2.cmake │ └── x86_64-w64-mingw32.cmake │ ├── CMakeLists.txt │ ├── COPYING.txt │ ├── README.md │ ├── cmake_uninstall.cmake.in │ ├── deps │ ├── EGL │ │ └── eglext.h │ ├── GL │ │ ├── glext.h │ │ ├── glxext.h │ │ └── wglext.h │ ├── getopt.c │ ├── getopt.h │ ├── tinycthread.c │ └── tinycthread.h │ ├── docs │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── build.dox │ ├── compat.dox │ ├── compile.dox │ ├── context.dox │ ├── extra.css │ ├── footer.html │ ├── header.html │ ├── internal.dox │ ├── main.dox │ ├── monitor.dox │ ├── moving.dox │ ├── news.dox │ ├── quick.dox │ └── window.dox │ ├── examples │ ├── CMakeLists.txt │ ├── boing.c │ ├── gears.c │ ├── heightmap.c │ ├── simple.c │ ├── splitview.c │ └── wave.c │ ├── include │ └── GLFW │ │ ├── glfw3.h │ │ └── glfw3native.h │ ├── src │ ├── CMakeLists.txt │ ├── clipboard.c │ ├── cocoa_clipboard.m │ ├── cocoa_gamma.c │ ├── cocoa_init.m │ ├── cocoa_joystick.m │ ├── cocoa_monitor.m │ ├── cocoa_platform.h │ ├── cocoa_time.c │ ├── cocoa_window.m │ ├── context.c │ ├── egl_context.c │ ├── egl_platform.h │ ├── gamma.c │ ├── glfw3.pc.in │ ├── glfwConfig.cmake.in │ ├── glfwConfigVersion.cmake.in │ ├── glfw_config.h.in │ ├── glx_context.c │ ├── glx_platform.h │ ├── init.c │ ├── input.c │ ├── internal.h │ ├── joystick.c │ ├── monitor.c │ ├── nsgl_context.m │ ├── nsgl_platform.h │ ├── time.c │ ├── wgl_context.c │ ├── wgl_platform.h │ ├── win32_clipboard.c │ ├── win32_gamma.c │ ├── win32_init.c │ ├── win32_joystick.c │ ├── win32_monitor.c │ ├── win32_platform.h │ ├── win32_time.c │ ├── win32_window.c │ ├── window.c │ ├── x11_clipboard.c │ ├── x11_gamma.c │ ├── x11_init.c │ ├── x11_joystick.c │ ├── x11_monitor.c │ ├── x11_platform.h │ ├── x11_time.c │ ├── x11_unicode.c │ └── x11_window.c │ └── tests │ ├── CMakeLists.txt │ ├── accuracy.c │ ├── clipboard.c │ ├── defaults.c │ ├── events.c │ ├── fsaa.c │ ├── gamma.c │ ├── glfwinfo.c │ ├── iconify.c │ ├── joysticks.c │ ├── modes.c │ ├── peter.c │ ├── reopen.c │ ├── sharing.c │ ├── tearing.c │ ├── threads.c │ ├── title.c │ └── windows.c ├── include ├── GL │ ├── gl3w.h │ ├── glcorearb.h │ ├── glext.h │ ├── glxext.h │ └── wglext.h ├── object.h ├── sb6mfile.h ├── sb7.h ├── sb7color.h ├── sb7ext.h ├── sb7ktx.h ├── sb7textoverlay.h ├── shader.h └── vmath.h ├── lib └── !DO NOT DELETE THIS DIRECTORY └── src ├── alienrain └── alienrain.cpp ├── basicfbo └── basicfbo.cpp ├── bindlesstex └── bindlesstex.cpp ├── blendmatrix └── blendmatrix.cpp ├── blinnphong └── blinnphong.cpp ├── bumpmapping └── bumpmapping.cpp ├── clipdistance └── clipdistance.cpp ├── compressrgtc └── compressrgtc.cpp ├── csflocking └── csflocking.cpp ├── cubemapenv └── cubemapenv.cpp ├── cubicbezier └── cubicbezier.cpp ├── cullindirect └── cullindirect.cpp ├── deferredshading └── deferredshading.cpp ├── depthclamp └── depthclamp.cpp ├── dflandscape └── dflandscape.cpp ├── dispmap └── dispmap.cpp ├── dof └── dof.cpp ├── envmapsphere └── envmapsphere.cpp ├── equirectangular └── equirectangular.cpp ├── fontdemo └── fontdemo.cpp ├── fragcolorfrompos └── fragcolorfrompos.cpp ├── fragmentlist └── fragmentlist.cpp ├── grass └── grass.cpp ├── gsculling └── gsculling.cpp ├── gslayered └── gslayered.cpp ├── gsquads └── gsquads.cpp ├── gstessellate └── gstessellate.cpp ├── hdrbloom └── hdrbloom.cpp ├── hdrexposure └── hdrexposure.cpp ├── hdrtonemap └── hdrtonemap.cpp ├── hqfilter └── hqfilter.cpp ├── indexedcube └── indexedcube.cpp ├── indirectmaterial └── indirectmaterial.cpp ├── instancedattribs └── instancedattribs.cpp ├── julia └── julia.cpp ├── ktxview └── ktxview.cpp ├── linesmooth └── linesmooth.cpp ├── mirrorclampedge └── mirrorclampedge.cpp ├── movingtri └── movingtri.cpp ├── msaanative └── msaanative.cpp ├── multidrawindirect └── multidrawindirect.cpp ├── multimaterial └── multimaterial.cpp ├── multiscissor └── multiscissor.cpp ├── multiviewport └── multiviewport.cpp ├── noperspective └── noperspective.cpp ├── normalviewer └── normalviewer.cpp ├── objectexploder └── objectexploder.cpp ├── ompparticles └── ompparticles.cpp ├── packetbuffer └── packetbuffer.cpp ├── perpixelgloss └── perpixelgloss.cpp ├── phonglighting └── phonglighting.cpp ├── pmbfractal └── pmbfractal.cpp ├── pmbstreaming └── pmbstreaming.cpp ├── polygonsmooth └── polygonsmooth.cpp ├── prefixsum └── prefixsum.cpp ├── prefixsum2d └── prefixsum2d.cpp ├── programinfo └── programinfo.cpp ├── raytracer └── raytracer.cpp ├── rimlight └── rimlight.cpp ├── sampleshading └── sampleshading.cpp ├── sb6mrender └── sb6mrender.cpp ├── sb7 ├── gl3w.c ├── sb7.cpp ├── sb7color.cpp ├── sb7ktx.cpp ├── sb7object.cpp ├── sb7shader.cpp └── sb7textoverlay.cpp ├── sdfdemo └── sdfdemo.cpp ├── shadowmapping └── shadowmapping.cpp ├── shapedpoints └── shapedpoints.cpp ├── simpleclear └── simpleclear.cpp ├── simpletexcoords └── simpletexcoords.cpp ├── simpletexture └── simpletexture.cpp ├── singlepoint └── singlepoint.cpp ├── singletri └── singletri.cpp ├── sparsetexture └── sparsetexture.cpp ├── spinnycube └── spinnycube.cpp ├── springmass └── springmass.cpp ├── ssao └── ssao.cpp ├── starfield └── starfield.cpp ├── stereo └── stereo.cpp ├── subroutines └── subroutines.cpp ├── tessellatedcube └── tessellatedcube.cpp ├── tessellatedgstri └── tessellatedgstri.cpp ├── tessellatedtri └── tessellatedtri.cpp ├── tessmodes └── tessmodes.cpp ├── tesssubdivmodes └── tesssubdivmodes.cpp ├── toonshading └── toonshading.cpp ├── tunnel └── tunnel.cpp └── wrapmodes └── wrapmodes.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | build/ 3 | *.txt.user 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project (superbible7) 4 | 5 | LINK_DIRECTORIES( ${CMAKE_SOURCE_DIR}/lib ) 6 | 7 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 8 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 9 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) 10 | 11 | # Second, for multi-config builds (e.g. msvc) 12 | foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) 13 | string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) 14 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/bin ) 15 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/lib ) 16 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR}/lib ) 17 | endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) 18 | 19 | find_package(OpenGL) 20 | 21 | set (CMAKE_DEBUG_POSTFIX "_d") 22 | 23 | if(WIN32) 24 | set(COMMON_LIBS sb7 optimized glfw3 debug glfw3_d ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES}) 25 | elseif (UNIX) 26 | find_package(PkgConfig REQUIRED) 27 | pkg_check_modules(GLFW REQUIRED glfw3) 28 | set(COMMON_LIBS sb7 glfw3 X11 Xrandr Xinerama Xi Xxf86vm Xcursor GL rt dl) 29 | else() 30 | set(COMMON_LIBS sb7) 31 | endif() 32 | 33 | set(COMMON_LIBS ${COMMON_LIBS} ${EXTRA_LIBS}) 34 | 35 | add_library(sb7 36 | src/sb7/sb7.cpp 37 | src/sb7/sb7color.cpp 38 | src/sb7/sb7ktx.cpp 39 | src/sb7/sb7object.cpp 40 | src/sb7/sb7shader.cpp 41 | src/sb7/sb7textoverlay.cpp 42 | src/sb7/gl3w.c 43 | ) 44 | 45 | set(RUN_DIR ${PROJECT_SOURCE_DIR}/bin) 46 | 47 | set(EXAMPLES 48 | alienrain 49 | basicfbo 50 | bindlesstex 51 | blendmatrix 52 | blinnphong 53 | bumpmapping 54 | clipdistance 55 | csflocking 56 | compressrgtc 57 | cubemapenv 58 | cubicbezier 59 | cullindirect 60 | deferredshading 61 | depthclamp 62 | dflandscape 63 | dispmap 64 | dof 65 | envmapsphere 66 | equirectangular 67 | fontdemo 68 | fragcolorfrompos 69 | fragmentlist 70 | grass 71 | gsculling 72 | gslayered 73 | gsquads 74 | gstessellate 75 | hdrbloom 76 | hdrexposure 77 | hdrtonemap 78 | hqfilter 79 | indexedcube 80 | indirectmaterial 81 | instancedattribs 82 | julia 83 | ktxview 84 | linesmooth 85 | mirrorclampedge 86 | movingtri 87 | msaanative 88 | multidrawindirect 89 | multiscissor 90 | multiviewport 91 | noperspective 92 | normalviewer 93 | objectexploder 94 | ompparticles 95 | packetbuffer 96 | perpixelgloss 97 | phonglighting 98 | polygonsmooth 99 | prefixsum 100 | pmbfractal 101 | pmbstreaming 102 | prefixsum2d 103 | programinfo 104 | raytracer 105 | rimlight 106 | sampleshading 107 | # sb6mrender 108 | sdfdemo 109 | shadowmapping 110 | shapedpoints 111 | simpleclear 112 | simpletexcoords 113 | simpletexture 114 | singlepoint 115 | singletri 116 | sparsetexture 117 | spinnycube 118 | springmass 119 | ssao 120 | starfield 121 | stereo 122 | subroutines 123 | tessellatedcube 124 | tessellatedgstri 125 | tessellatedtri 126 | tessmodes 127 | tesssubdivmodes 128 | toonshading 129 | tunnel 130 | wrapmodes 131 | ) 132 | 133 | find_package(OpenMP) 134 | if (OPENMP_FOUND) 135 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 136 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 137 | endif() 138 | 139 | foreach(EXAMPLE ${EXAMPLES}) 140 | add_executable(${EXAMPLE} WIN32 src/${EXAMPLE}/${EXAMPLE}.cpp) 141 | set_property(TARGET ${EXAMPLE} PROPERTY DEBUG_POSTFIX _d) 142 | target_link_libraries(${EXAMPLE} ${COMMON_LIBS}) 143 | if(MSVC) 144 | configure_file(${PROJECT_SOURCE_DIR}/build/templates/vs2013.vcxproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.vcxproj.user @ONLY) 145 | endif(MSVC) 146 | endforeach(EXAMPLE) 147 | 148 | IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 149 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LINUX -std=c++0x") 150 | ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 151 | 152 | include_directories( include ) 153 | include_directories(extern/glfw-3.0.4/include) 154 | 155 | ADD_CUSTOM_TARGET(debug ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=Debug ${PROJECT_SOURCE_DIR}) 156 | ADD_CUSTOM_TARGET(release ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=Release ${PROJECT_SOURCE_DIR}) 157 | -------------------------------------------------------------------------------- /HOWTOBUILD.txt: -------------------------------------------------------------------------------- 1 | OpenGL SuperBible 7th Edition Examples - How to Build 2 | ===================================================== 3 | 4 | This source code archive uses CMake to build. The samples also use GLFW library, a 5 | snapshot of which is included in the `extern` folder. It's also possible to use a different 6 | copy of GLFW if desired, but that's an excercise for you. Instructions for each supported 7 | platform are as follows: 8 | 9 | Windows / Microsoft Visual Studio 2013 10 | -------------------------------------- 11 | 12 | Install CMake. Windows binaries are available from http://www.cmake.org/. 13 | Ensure that CMake is in your path. 14 | Open a command prompt and change to the directory where you've checked out the code. 15 | 16 | ### Build GLFW 17 | 18 | If you are going to use the copy of GLFW included in the archive, enter the 19 | GLFW directory in `extern/glfw-3.0.4`, and type: 20 | 21 | cmake -G "Visual Studio 12" . 22 | 23 | (Yes, that's not a mistake - Visual Studio 12 is 2013) 24 | 25 | Open the resulting GLFW.sln file in Visual Studio and build both the debug and release configurations. 26 | 27 | Copy and rename the resulting glfw3 libraries: 28 | 29 | * Copy `glfw-3.0.4/src/Debug/glfw3.lib` into the `lib` directory and **rename it to glfw3_d.lib**. 30 | * Copy `glf3-3.0.4/src/Release/glfw3.lib` into the `lib` directory but don't rename it. 31 | 32 | ### Build the samples 33 | 34 | Open a command prompt and change to the build directory in the source archive. 35 | Type: 36 | 37 | cmake -G "Visual Studio 12" .. 38 | 39 | Open the resulting superbible7.sln project in Visual Studio. 40 | 41 | The examples will build into the `bin` directory. 42 | 43 | Linux 44 | ----- 45 | 46 | As with Windows, the project uses CMake to create build files. You'll 47 | need to install it with the appropriate method for your distribution. On 48 | Debian-based distributions (such as Ubuntu and Mint): 49 | 50 | sudo apt-get install cmake 51 | 52 | You'll also need to satisfy dependencies. In particular, you'll need GL and 53 | GLX headers and libs (generally included in Mesa packages), and GLFW. You can use 54 | the a snapshot of GLFW included in the archive, if you wish, but pre-compiled 55 | packages should be available through package management on most distributions. 56 | 57 | Once you have everything, you should enter the "build" directory in the source 58 | arvhive and issue: 59 | 60 | cmake .. 61 | make 62 | 63 | The examples will build into the 'bin' directory. 64 | 65 | Other platforms 66 | --------------- 67 | 68 | The code will probably build for other platforms, especially if they are 69 | relatively non-obscure, but nothing besides Windows/Visual Studio and Linux 70 | has been tested. It's up to you to find a capable OpenGL 4.x driver for 71 | your platform of choice. CMake should also be able to build the appropriate 72 | project files for environments such as Code::Blocks and Eclipse, but again, 73 | this is untested. 74 | 75 | 76 | *Please note carefully: EVEN IF YOU CAN BUILD THE SOURCES FOR YOUR FAVORITE 77 | PLATFORM OF CHOICE, YOU NEED RECENT OpenGL 4.x DRIVERS TO RUN THEM. PLEASE 78 | DON'T PAN THE BOOK BECAUSE YOUR COMPUTER DOESN'T SUPPORT OpenGL 4.x. THANKS* 79 | 80 | Running the samples 81 | ------------------- 82 | 83 | *This part is really important. Please read it!* 84 | 85 | Most of the samples require some media files. The media files package is a 86 | separate download available from http://www.openglsuperbible.com and is 87 | rougly 100MB of textures, object files and shader code. Unpack the archive 88 | to the bin/media directory before trying to run these samples. 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OpenGL SuperBible 7th Edition Source Code 2 | ========================================= 3 | 4 | This is the repository for the example source code for the 7th edition of the 5 | OpenGL SuperBible. Please read HOWTOBUILD.txt. It tells you how to build and 6 | run the examples. 7 | 8 | *Note that to run these examples, you need the associated media files which 9 | are available from http://openglsuperbible.com/files/superbible7-media.zip*. 10 | -------------------------------------------------------------------------------- /bin/media/!OBTAIN_THE_MEDIA_PACK_AND_PUT_IT_HERE.txt: -------------------------------------------------------------------------------- 1 | Download the media pack from http://www.openglsuperbible.com and unpack it in this directory. 2 | -------------------------------------------------------------------------------- /build/!RUN CMAKE FROM HERE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/build/!RUN CMAKE FROM HERE.txt -------------------------------------------------------------------------------- /build/templates/vs2013.vcxproj.user.in: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir) 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir) 13 | WindowsLocalDebugger 14 | 15 | 16 | $(TargetDir) 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/.gitignore: -------------------------------------------------------------------------------- 1 | # External junk 2 | .DS_Store 3 | _ReSharper* 4 | *.opensdf 5 | *.sdf 6 | *.dir 7 | *.vcxproj* 8 | *.sln 9 | Win32 10 | Debug 11 | Release 12 | 13 | # CMake files 14 | Makefile 15 | CMakeCache.txt 16 | CMakeFiles 17 | cmake_install.cmake 18 | cmake_uninstall.cmake 19 | 20 | # Generated files 21 | docs/Doxyfile 22 | docs/html 23 | docs/warnings.txt 24 | src/glfw_config.h 25 | src/glfw3.pc 26 | src/glfwConfig.cmake 27 | src/glfwConfigVersion.cmake 28 | 29 | # Compiled binaries 30 | src/libglfw.so 31 | src/libglfw.so.3 32 | src/libglfw.so.3.0 33 | src/libglfw.dylib 34 | src/libglfw.dylib 35 | src/libglfw.3.dylib 36 | src/libglfw.3.0.dylib 37 | src/libglfw3.a 38 | src/glfw3.lib 39 | src/glfw3.dll 40 | src/glfw3dll.lib 41 | src/glfw3dll.a 42 | examples/*.app 43 | examples/*.exe 44 | examples/boing 45 | examples/gears 46 | examples/heightmap 47 | examples/splitview 48 | examples/simple 49 | examples/wave 50 | tests/*.app 51 | tests/*.exe 52 | tests/accuracy 53 | tests/clipboard 54 | tests/defaults 55 | tests/events 56 | tests/fsaa 57 | tests/gamma 58 | tests/glfwinfo 59 | tests/iconify 60 | tests/joysticks 61 | tests/modes 62 | tests/peter 63 | tests/reopen 64 | tests/sharing 65 | tests/tearing 66 | tests/threads 67 | tests/title 68 | tests/version 69 | tests/windows 70 | 71 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/deps/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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_custom_target(docs ALL ${DOXYGEN_EXECUTABLE} 3 | WORKING_DIRECTORY ${GLFW_BINARY_DIR}/docs 4 | COMMENT "Generating HTML documentation" VERBATIM) 5 | 6 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/docs/footer.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/docs/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $projectname: $title 8 | $title 9 | 10 | 11 | 12 | $treeview 13 | $search 14 | $mathjax 15 | 16 | $extrastylesheet 17 | 18 | 19 |
20 | 21 | 22 |
23 |
24 | GLFW 25 | 31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/docs/internal.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @page internals Internal structure 4 | 5 | @tableofcontents 6 | 7 | There are several interfaces inside GLFW. Each interface has its own area of 8 | responsibility and its own naming conventions. 9 | 10 | 11 | @section internals_public Public interface 12 | 13 | The most well-known is the public interface, described in the glfw3.h header 14 | file. This is implemented in source files shared by all platforms and these 15 | files contain no platform-specific code. This code usually ends up calling the 16 | platform and internal interfaces to do the actual work. 17 | 18 | The public interface uses the OpenGL naming conventions except with GLFW and 19 | glfw instead of GL and gl. For struct members, where OpenGL sets no precedent, 20 | it use headless camel case. 21 | 22 | Examples: @ref glfwCreateWindow, @ref GLFWwindow, @ref GLFWvidmode.redBits, 23 | `GLFW_RED_BITS` 24 | 25 | 26 | @section internals_native Native interface 27 | 28 | The [native interface](@ref native) is a small set of publicly available 29 | but platform-specific functions, described in the glfw3native.h header file and 30 | used to gain access to the underlying window, context and (on some platforms) 31 | display handles used by the platform interface. 32 | 33 | The function names of the native interface are similar to those of the public 34 | interface, but embeds the name of the interface that the returned handle is 35 | from. 36 | 37 | Examples: @ref glfwGetX11Window, @ref glfwGetWGLContext 38 | 39 | 40 | @section internals_internal Internal interface 41 | 42 | The internal interface consists of utility functions used by all other 43 | interfaces. It is shared code implemented in the same shared source files as 44 | the public and event interfaces. The internal interface is described in the 45 | internal.h header file. 46 | 47 | The internal interface is in charge of GLFW's global data, which it stores in 48 | a `_GLFWlibrary` struct named `_glfw`. 49 | 50 | The internal interface uses the same style as the public interface, except all 51 | global names have a leading underscore. 52 | 53 | Examples: @ref _glfwIsValidContextConfig, @ref _GLFWwindow, `_glfw.currentRamp` 54 | 55 | 56 | @section internals_platform Platform interface 57 | 58 | The platform interface implements all platform-specific operations as a service 59 | to the public interface. This includes event processing. The platform 60 | interface is never directly called by users of GLFW and never directly calls the 61 | user's code. It is also prohibited from modifying the platform-independent part 62 | of the internal structs. Instead, it calls the event interface when events 63 | interesting to GLFW are received. 64 | 65 | The platform interface mirrors those parts of the public interface that needs to 66 | perform platform-specific operations on some or all platforms. The are also 67 | named the same except that the glfw function prefix is replaced by 68 | _glfwPlatform. 69 | 70 | Examples: @ref _glfwPlatformCreateWindow 71 | 72 | The platform interface also defines structs that contain platform-specific 73 | global and per-object state. Their names mirror those of the internal 74 | interface, except that an interface-specific suffix is added. 75 | 76 | Examples: `_GLFWwindowX11`, `_GLFWcontextWGL` 77 | 78 | These structs are incorporated as members into the internal interface structs 79 | using special macros that name them after the specific interface used. This 80 | prevents shared code from accidentally using these members. 81 | 82 | Examples: `window.win32.handle`, `_glfw.x11.display` 83 | 84 | 85 | @section internals_event Event interface 86 | 87 | The event interface is implemented in the same shared source files as the public 88 | interface and is responsible for delivering the events it receives to the user, 89 | either via callbacks, via window state changes or both. 90 | 91 | The function names of the event interface use a `_glfwInput` prefix and the 92 | ObjectEvent pattern. 93 | 94 | Examples: @ref _glfwInputWindowFocus, @ref _glfwInputCursorMotion 95 | 96 | 97 | @section internals_static Static functions 98 | 99 | Static functions may be used by any interface and have no prefixes or suffixes. 100 | These use headless camel case. 101 | 102 | Examples: `clearScrollOffsets` 103 | 104 | 105 | @section internals_config Configuration macros 106 | 107 | GLFW uses a number of configuration macros to select at compile time which 108 | interfaces and code paths to use. They are defined in the glfw_config.h header file, 109 | which is generated from the `glfw_config.h.in` file by CMake. 110 | 111 | Configuration macros the same style as tokens in the public interface, except 112 | with a leading underscore. 113 | 114 | Examples: `_GLFW_HAS_GLXGETPROCADDRESS` 115 | 116 | */ 117 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | This is the documentation for version 3.0, which has [many new features](@ref news). 12 | 13 | There is a [quick tutorial](@ref quick) for people new to GLFW, which shows how 14 | to write a small but complete program, and guides for 15 | [compiling GLFW](@ref compile) and 16 | [building programs that use GLFW](@ref build). 17 | 18 | If you have used GLFW 2.x in the past, there is a 19 | [transition guide](@ref moving) that explains what has changed and how to update 20 | existing code to use the new API. 21 | 22 | */ 23 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/docs/monitor.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | @page monitor Multi-monitor guide 4 | 5 | @tableofcontents 6 | 7 | 8 | @section monitor_objects Monitor objects 9 | 10 | The @ref GLFWmonitor object represents a currently connected monitor. 11 | 12 | 13 | @section monitor_monitors Retrieving monitors 14 | 15 | The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is usually 16 | the user's preferred monitor and the one with global UI elements like task bar 17 | or menu bar. 18 | 19 | @code 20 | GLFWmonitor* primary = glfwGetPrimaryMonitor(); 21 | @endcode 22 | 23 | You can retrieve all currently connected monitors with @ref glfwGetMonitors. 24 | 25 | @code 26 | int count; 27 | GLFWmonitor** monitors = glfwGetMonitors(&count); 28 | @endcode 29 | 30 | 31 | @section monitor_modes Retrieving video modes 32 | 33 | Although GLFW generally does a good job at selecting a suitable video 34 | mode for you when you open a full screen window, it is sometimes useful to 35 | know exactly which modes are available on a certain system. For example, 36 | you may want to present the user with a list of video modes to select 37 | from. To get a list of available video modes, you can use the function 38 | @ref glfwGetVideoModes. 39 | 40 | @code 41 | int count; 42 | GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); 43 | @endcode 44 | 45 | To get the current video mode of a monitor call @ref glfwGetVideoMode. 46 | 47 | @code 48 | const GLFWvidmode* mode = glfwGetVideoMode(monitor); 49 | @endcode 50 | 51 | 52 | @section monitor_size Monitor physical size 53 | 54 | The physical size in millimetres of a monitor, or an approximation of it, can be 55 | retrieved with @ref glfwGetMonitorPhysicalSize. 56 | 57 | @code 58 | int widthMM, heightMM; 59 | glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); 60 | @endcode 61 | 62 | This can, for example, be used together with the current video mode to calculate 63 | the DPI of a monitor. 64 | 65 | @code 66 | const double dpi = mode->width / (widthMM / 25.4); 67 | @endcode 68 | 69 | 70 | @section monitor_name Monitor name 71 | 72 | The name of a monitor is returned by @ref glfwGetMonitorName. 73 | 74 | @code 75 | const char* name = glfwGetMonitorName(monitor); 76 | @endcode 77 | 78 | The monitor name is a regular C string using the UTF-8 encoding. Note that 79 | monitor names are not guaranteed to be unique. 80 | 81 | 82 | @section monitor_gamma Monitor gamma ramp 83 | 84 | The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts 85 | a monitor handle and a pointer to a @ref GLFWgammaramp structure. 86 | 87 | @code 88 | glfwSetGammaRamp(monitor, &ramp); 89 | @endcode 90 | 91 | The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. 92 | 93 | @code 94 | const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); 95 | @endcode 96 | 97 | If you wish to set a regular gamma ramp, you can have GLFW calculate it for you 98 | from the desired exponent with @ref glfwSetGamma, which in turn calls @ref 99 | glfwSetGammaRamp with the resulting ramp. 100 | 101 | @code 102 | glfwSetGamma(monitor, 1.0); 103 | @endcode 104 | 105 | */ 106 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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}/deps) 13 | 14 | if (NOT APPLE) 15 | # HACK: This is NOTFOUND on OS X 10.8 16 | include_directories(${OPENGL_INCLUDE_DIR}) 17 | endif() 18 | 19 | set(GETOPT ${GLFW_SOURCE_DIR}/deps/getopt.h 20 | ${GLFW_SOURCE_DIR}/deps/getopt.c) 21 | 22 | if (APPLE) 23 | # Set fancy names for bundles 24 | add_executable(Boing MACOSX_BUNDLE boing.c) 25 | add_executable(Gears MACOSX_BUNDLE gears.c) 26 | add_executable(Simple MACOSX_BUNDLE simple.c) 27 | add_executable("Split View" MACOSX_BUNDLE splitview.c) 28 | add_executable(Wave MACOSX_BUNDLE wave.c) 29 | 30 | set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing") 31 | set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears") 32 | set_target_properties(Simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") 33 | set_target_properties("Split View" PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View") 34 | set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") 35 | else() 36 | # Set boring names for executables 37 | add_executable(boing WIN32 boing.c) 38 | add_executable(gears WIN32 gears.c) 39 | add_executable(heightmap WIN32 heightmap.c ${GETOPT}) 40 | add_executable(simple WIN32 simple.c) 41 | add_executable(splitview WIN32 splitview.c) 42 | add_executable(wave WIN32 wave.c) 43 | endif() 44 | 45 | if (MSVC) 46 | set(WINDOWS_BINARIES boing gears heightmap simple splitview wave) 47 | 48 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 49 | set_target_properties(${WINDOWS_BINARIES} PROPERTIES 50 | LINK_FLAGS "/ENTRY:mainCRTStartup") 51 | endif() 52 | 53 | if (APPLE) 54 | set(BUNDLE_BINARIES Boing Gears Simple "Split View" Wave) 55 | 56 | set_target_properties(${BUNDLE_BINARIES} PROPERTIES 57 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 58 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) 59 | endif() 60 | 61 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/examples/simple.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // Simple GLFW example 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 | //! [code] 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | static void error_callback(int error, const char* description) 33 | { 34 | fputs(description, stderr); 35 | } 36 | 37 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 38 | { 39 | if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) 40 | glfwSetWindowShouldClose(window, GL_TRUE); 41 | } 42 | 43 | int main(void) 44 | { 45 | GLFWwindow* window; 46 | 47 | glfwSetErrorCallback(error_callback); 48 | 49 | if (!glfwInit()) 50 | exit(EXIT_FAILURE); 51 | 52 | window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); 53 | if (!window) 54 | { 55 | glfwTerminate(); 56 | exit(EXIT_FAILURE); 57 | } 58 | 59 | glfwMakeContextCurrent(window); 60 | 61 | glfwSetKeyCallback(window, key_callback); 62 | 63 | while (!glfwWindowShouldClose(window)) 64 | { 65 | float ratio; 66 | int width, height; 67 | 68 | glfwGetFramebufferSize(window, &width, &height); 69 | ratio = width / (float) height; 70 | 71 | glViewport(0, 0, width, height); 72 | glClear(GL_COLOR_BUFFER_BIT); 73 | 74 | glMatrixMode(GL_PROJECTION); 75 | glLoadIdentity(); 76 | glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); 77 | glMatrixMode(GL_MODELVIEW); 78 | 79 | glLoadIdentity(); 80 | glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f); 81 | 82 | glBegin(GL_TRIANGLES); 83 | glColor3f(1.f, 0.f, 0.f); 84 | glVertex3f(-0.6f, -0.4f, 0.f); 85 | glColor3f(0.f, 1.f, 0.f); 86 | glVertex3f(0.6f, -0.4f, 0.f); 87 | glColor3f(0.f, 0.f, 1.f); 88 | glVertex3f(0.f, 0.6f, 0.f); 89 | glEnd(); 90 | 91 | glfwSwapBuffers(window); 92 | glfwPollEvents(); 93 | } 94 | 95 | glfwDestroyWindow(window); 96 | 97 | glfwTerminate(); 98 | exit(EXIT_SUCCESS); 99 | } 100 | 101 | //! [code] 102 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(${GLFW_SOURCE_DIR}/src 3 | ${GLFW_BINARY_DIR}/src 4 | ${glfw_INCLUDE_DIRS}) 5 | 6 | add_definitions(-D_GLFW_USE_CONFIG_H) 7 | 8 | set(common_HEADERS ${GLFW_BINARY_DIR}/src/glfw_config.h internal.h 9 | ${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h 10 | ${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.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 | INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}") 79 | endif() 80 | 81 | target_link_libraries(glfw ${glfw_LIBRARIES}) 82 | target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) 83 | endif() 84 | 85 | if (GLFW_INSTALL) 86 | install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}) 87 | endif() 88 | 89 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW public API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string) 38 | { 39 | _GLFWwindow* window = (_GLFWwindow*) handle; 40 | _GLFW_REQUIRE_INIT(); 41 | _glfwPlatformSetClipboardString(window, string); 42 | } 43 | 44 | GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle) 45 | { 46 | _GLFWwindow* window = (_GLFWwindow*) handle; 47 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 48 | return _glfwPlatformGetClipboardString(window); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/cocoa_clipboard.m: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW platform API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) 38 | { 39 | NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; 40 | 41 | NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; 42 | [pasteboard declareTypes:types owner:nil]; 43 | [pasteboard setString:[NSString stringWithUTF8String:string] 44 | forType:NSStringPboardType]; 45 | } 46 | 47 | const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) 48 | { 49 | NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; 50 | 51 | if (![[pasteboard types] containsObject:NSStringPboardType]) 52 | { 53 | _glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL); 54 | return NULL; 55 | } 56 | 57 | NSString* object = [pasteboard stringForType:NSStringPboardType]; 58 | if (!object) 59 | { 60 | _glfwInputError(GLFW_PLATFORM_ERROR, 61 | "Cocoa: Failed to retrieve object from pasteboard"); 62 | return NULL; 63 | } 64 | 65 | free(_glfw.ns.clipboardString); 66 | _glfw.ns.clipboardString = strdup([object UTF8String]); 67 | 68 | return _glfw.ns.clipboardString; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/cocoa_gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | 36 | ////////////////////////////////////////////////////////////////////////// 37 | ////// GLFW platform API ////// 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 41 | { 42 | uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID); 43 | CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue)); 44 | 45 | CGGetDisplayTransferByTable(monitor->ns.displayID, 46 | size, 47 | values, 48 | values + size, 49 | values + size * 2, 50 | &size); 51 | 52 | _glfwAllocGammaArrays(ramp, size); 53 | 54 | for (i = 0; i < size; i++) 55 | { 56 | ramp->red[i] = (unsigned short) (values[i] * 65535); 57 | ramp->green[i] = (unsigned short) (values[i + size] * 65535); 58 | ramp->blue[i] = (unsigned short) (values[i + size * 2] * 65535); 59 | } 60 | 61 | free(values); 62 | } 63 | 64 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 65 | { 66 | int i; 67 | CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); 68 | 69 | for (i = 0; i < ramp->size; i++) 70 | { 71 | values[i] = ramp->red[i] / 65535.f; 72 | values[i + ramp->size] = ramp->green[i] / 65535.f; 73 | values[i + ramp->size * 2] = ramp->blue[i] / 65535.f; 74 | } 75 | 76 | CGSetDisplayTransferByTable(monitor->ns.displayID, 77 | ramp->size, 78 | values, 79 | values + ramp->size, 80 | values + ramp->size * 2); 81 | 82 | free(values); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/cocoa_init.m: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | #include // For MAXPATHLEN 29 | 30 | 31 | #if defined(_GLFW_USE_CHDIR) 32 | 33 | // Change to our application bundle's resources directory, if present 34 | // 35 | static void changeToResourcesDirectory(void) 36 | { 37 | char resourcesPath[MAXPATHLEN]; 38 | 39 | CFBundleRef bundle = CFBundleGetMainBundle(); 40 | if (!bundle) 41 | return; 42 | 43 | CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle); 44 | 45 | CFStringRef last = CFURLCopyLastPathComponent(resourcesURL); 46 | if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo) 47 | { 48 | CFRelease(last); 49 | CFRelease(resourcesURL); 50 | return; 51 | } 52 | 53 | CFRelease(last); 54 | 55 | if (!CFURLGetFileSystemRepresentation(resourcesURL, 56 | true, 57 | (UInt8*) resourcesPath, 58 | MAXPATHLEN)) 59 | { 60 | CFRelease(resourcesURL); 61 | return; 62 | } 63 | 64 | CFRelease(resourcesURL); 65 | 66 | chdir(resourcesPath); 67 | } 68 | 69 | #endif /* _GLFW_USE_CHDIR */ 70 | 71 | 72 | ////////////////////////////////////////////////////////////////////////// 73 | ////// GLFW platform API ////// 74 | ////////////////////////////////////////////////////////////////////////// 75 | 76 | int _glfwPlatformInit(void) 77 | { 78 | _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init]; 79 | 80 | #if defined(_GLFW_USE_CHDIR) 81 | changeToResourcesDirectory(); 82 | #endif 83 | 84 | _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); 85 | if (!_glfw.ns.eventSource) 86 | return GL_FALSE; 87 | 88 | CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0); 89 | 90 | if (!_glfwInitContextAPI()) 91 | return GL_FALSE; 92 | 93 | _glfwInitTimer(); 94 | _glfwInitJoysticks(); 95 | 96 | return GL_TRUE; 97 | } 98 | 99 | void _glfwPlatformTerminate(void) 100 | { 101 | if (_glfw.ns.eventSource) 102 | { 103 | CFRelease(_glfw.ns.eventSource); 104 | _glfw.ns.eventSource = NULL; 105 | } 106 | 107 | [NSApp setDelegate:nil]; 108 | [_glfw.ns.delegate release]; 109 | _glfw.ns.delegate = nil; 110 | 111 | [_glfw.ns.autoreleasePool release]; 112 | _glfw.ns.autoreleasePool = nil; 113 | 114 | [_glfw.ns.cursor release]; 115 | _glfw.ns.cursor = nil; 116 | 117 | free(_glfw.ns.clipboardString); 118 | 119 | _glfwTerminateJoysticks(); 120 | _glfwTerminateContextAPI(); 121 | } 122 | 123 | const char* _glfwPlatformGetVersionString(void) 124 | { 125 | const char* version = _GLFW_VERSION_NUMBER " Cocoa" 126 | #if defined(_GLFW_NSGL) 127 | " NSGL" 128 | #endif 129 | #if defined(_GLFW_USE_CHDIR) 130 | " chdir" 131 | #endif 132 | #if defined(_GLFW_USE_MENUBAR) 133 | " menubar" 134 | #endif 135 | #if defined(_GLFW_BUILD_DLL) 136 | " dynamic" 137 | #endif 138 | ; 139 | 140 | return version; 141 | } 142 | 143 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/cocoa_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _cocoa_platform_h_ 28 | #define _cocoa_platform_h_ 29 | 30 | 31 | #include 32 | 33 | #if defined(__OBJC__) 34 | #import 35 | #else 36 | #include 37 | typedef void* id; 38 | #endif 39 | 40 | #if defined(_GLFW_NSGL) 41 | #include "nsgl_platform.h" 42 | #else 43 | #error "No supported context creation API selected" 44 | #endif 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns 52 | #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns 53 | #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns 54 | 55 | 56 | //======================================================================== 57 | // GLFW platform specific types 58 | //======================================================================== 59 | 60 | 61 | //------------------------------------------------------------------------ 62 | // Platform-specific window structure 63 | //------------------------------------------------------------------------ 64 | typedef struct _GLFWwindowNS 65 | { 66 | id object; 67 | id delegate; 68 | id view; 69 | unsigned int modifierFlags; 70 | } _GLFWwindowNS; 71 | 72 | 73 | //------------------------------------------------------------------------ 74 | // Joystick information & state 75 | //------------------------------------------------------------------------ 76 | typedef struct 77 | { 78 | int present; 79 | char name[256]; 80 | 81 | IOHIDDeviceInterface** interface; 82 | 83 | CFMutableArrayRef axisElements; 84 | CFMutableArrayRef buttonElements; 85 | CFMutableArrayRef hatElements; 86 | 87 | float* axes; 88 | unsigned char* buttons; 89 | 90 | } _GLFWjoy; 91 | 92 | 93 | //------------------------------------------------------------------------ 94 | // Platform-specific library global data for Cocoa 95 | //------------------------------------------------------------------------ 96 | typedef struct _GLFWlibraryNS 97 | { 98 | struct { 99 | double base; 100 | double resolution; 101 | } timer; 102 | 103 | CGEventSourceRef eventSource; 104 | id delegate; 105 | id autoreleasePool; 106 | id cursor; 107 | 108 | char* clipboardString; 109 | 110 | _GLFWjoy joysticks[GLFW_JOYSTICK_LAST + 1]; 111 | } _GLFWlibraryNS; 112 | 113 | 114 | //------------------------------------------------------------------------ 115 | // Platform-specific monitor structure 116 | //------------------------------------------------------------------------ 117 | typedef struct _GLFWmonitorNS 118 | { 119 | CGDirectDisplayID displayID; 120 | CGDisplayModeRef previousMode; 121 | id screen; 122 | 123 | } _GLFWmonitorNS; 124 | 125 | 126 | //======================================================================== 127 | // Prototypes for platform specific internal functions 128 | //======================================================================== 129 | 130 | // Time 131 | void _glfwInitTimer(void); 132 | 133 | // Joystick input 134 | void _glfwInitJoysticks(void); 135 | void _glfwTerminateJoysticks(void); 136 | 137 | // Fullscreen 138 | GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired); 139 | void _glfwRestoreVideoMode(_GLFWmonitor* monitor); 140 | 141 | // OpenGL support 142 | int _glfwInitContextAPI(void); 143 | void _glfwTerminateContextAPI(void); 144 | int _glfwCreateContext(_GLFWwindow* window, 145 | const _GLFWwndconfig* wndconfig, 146 | const _GLFWfbconfig* fbconfig); 147 | void _glfwDestroyContext(_GLFWwindow* window); 148 | 149 | #endif // _cocoa_platform_h_ 150 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | // Return raw time 33 | // 34 | static uint64_t getRawTime(void) 35 | { 36 | return mach_absolute_time(); 37 | } 38 | 39 | 40 | ////////////////////////////////////////////////////////////////////////// 41 | ////// GLFW internal API ////// 42 | ////////////////////////////////////////////////////////////////////////// 43 | 44 | // Initialise timer 45 | // 46 | void _glfwInitTimer(void) 47 | { 48 | mach_timebase_info_data_t info; 49 | mach_timebase_info(&info); 50 | 51 | _glfw.ns.timer.resolution = (double) info.numer / (info.denom * 1.0e9); 52 | _glfw.ns.timer.base = getRawTime(); 53 | } 54 | 55 | 56 | ////////////////////////////////////////////////////////////////////////// 57 | ////// GLFW platform API ////// 58 | ////////////////////////////////////////////////////////////////////////// 59 | 60 | double _glfwPlatformGetTime(void) 61 | { 62 | return (double) (getRawTime() - _glfw.ns.timer.base) * 63 | _glfw.ns.timer.resolution; 64 | } 65 | 66 | void _glfwPlatformSetTime(double time) 67 | { 68 | _glfw.ns.timer.base = getRawTime() - 69 | (uint64_t) (time / _glfw.ns.timer.resolution); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/egl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 EGL - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _egl_platform_h_ 29 | #define _egl_platform_h_ 30 | 31 | #include 32 | 33 | // This path may need to be changed if you build GLFW using your own setup 34 | // We ship and use our own copy of eglext.h since GLFW uses fairly new 35 | // extensions and not all operating systems come with an up-to-date version 36 | #include "../deps/EGL/eglext.h" 37 | 38 | // Do we have support for dlopen/dlsym? 39 | #if defined(_GLFW_HAS_DLOPEN) 40 | #include 41 | #endif 42 | 43 | #define _GLFW_PLATFORM_FBCONFIG EGLConfig egl 44 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl 45 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL egl 46 | 47 | 48 | //======================================================================== 49 | // GLFW platform specific types 50 | //======================================================================== 51 | 52 | //------------------------------------------------------------------------ 53 | // Platform-specific OpenGL context structure 54 | //------------------------------------------------------------------------ 55 | typedef struct _GLFWcontextEGL 56 | { 57 | EGLConfig config; 58 | EGLContext context; 59 | EGLSurface surface; 60 | 61 | #if defined(_GLFW_X11) 62 | XVisualInfo* visual; 63 | #endif 64 | } _GLFWcontextEGL; 65 | 66 | 67 | //------------------------------------------------------------------------ 68 | // Platform-specific library global data for EGL 69 | //------------------------------------------------------------------------ 70 | typedef struct _GLFWlibraryEGL 71 | { 72 | EGLDisplay display; 73 | EGLint versionMajor, versionMinor; 74 | 75 | GLboolean KHR_create_context; 76 | 77 | } _GLFWlibraryEGL; 78 | 79 | 80 | #endif // _egl_platform_h_ 81 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #if defined(_MSC_VER) 34 | #include 35 | #endif 36 | 37 | 38 | ////////////////////////////////////////////////////////////////////////// 39 | ////// GLFW internal API ////// 40 | ////////////////////////////////////////////////////////////////////////// 41 | 42 | void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size) 43 | { 44 | ramp->red = calloc(size, sizeof(unsigned short)); 45 | ramp->green = calloc(size, sizeof(unsigned short)); 46 | ramp->blue = calloc(size, sizeof(unsigned short)); 47 | ramp->size = size; 48 | } 49 | 50 | void _glfwFreeGammaArrays(GLFWgammaramp* ramp) 51 | { 52 | free(ramp->red); 53 | free(ramp->green); 54 | free(ramp->blue); 55 | 56 | memset(ramp, 0, sizeof(GLFWgammaramp)); 57 | } 58 | 59 | 60 | ////////////////////////////////////////////////////////////////////////// 61 | ////// GLFW public API ////// 62 | ////////////////////////////////////////////////////////////////////////// 63 | 64 | GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) 65 | { 66 | int i; 67 | unsigned short values[256]; 68 | GLFWgammaramp ramp; 69 | 70 | _GLFW_REQUIRE_INIT(); 71 | 72 | if (gamma <= 0.f) 73 | { 74 | _glfwInputError(GLFW_INVALID_VALUE, 75 | "Gamma value must be greater than zero"); 76 | return; 77 | } 78 | 79 | for (i = 0; i < 256; i++) 80 | { 81 | double value; 82 | 83 | // Calculate intensity 84 | value = i / 255.0; 85 | // Apply gamma curve 86 | value = pow(value, 1.0 / gamma) * 65535.0 + 0.5; 87 | 88 | // Clamp to value range 89 | if (value > 65535.0) 90 | value = 65535.0; 91 | 92 | values[i] = (unsigned short) value; 93 | } 94 | 95 | ramp.red = values; 96 | ramp.green = values; 97 | ramp.blue = values; 98 | ramp.size = 256; 99 | 100 | glfwSetGammaRamp(handle, &ramp); 101 | } 102 | 103 | GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) 104 | { 105 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 106 | 107 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 108 | 109 | _glfwFreeGammaArrays(&monitor->currentRamp); 110 | _glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp); 111 | 112 | return &monitor->currentRamp; 113 | } 114 | 115 | GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) 116 | { 117 | _GLFWmonitor* monitor = (_GLFWmonitor*) handle; 118 | 119 | _GLFW_REQUIRE_INIT(); 120 | 121 | if (!monitor->originalRamp.size) 122 | _glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp); 123 | 124 | _glfwPlatformSetGammaRamp(monitor, ramp); 125 | } 126 | 127 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/glfw3.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/lib@LIB_SUFFIX@ 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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/glfwConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the glfw package 2 | # It defines the following variables 3 | # GLFW_INCLUDE_DIR, the path where GLFW headers are located 4 | # GLFW_LIBRARY_DIR, folder in which the GLFW library is located 5 | # GLFW_LIBRARY, library to link against to use GLFW 6 | 7 | set(GLFW_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include") 8 | set(GLFW_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@") 9 | 10 | find_library(GLFW_LIBRARY "@GLFW_LIB_NAME@" HINTS ${GLFW_LIBRARY_DIR}) 11 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/glfwConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION "@GLFW_VERSION_FULL@") 3 | 4 | if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@GLFW_VERSION_MAJOR@") 5 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 6 | if ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL @GLFW_VERSION_MINOR@) 7 | set(PACKAGE_VERSION_EXACT TRUE) 8 | endif() 9 | else() 10 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 11 | endif() 12 | 13 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/glfw_config.h.in: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // As glfw_config.h.in, this file is used by CMake to produce the 27 | // glfw_config.h configuration header file. If you are adding a feature 28 | // requiring conditional compilation, this is where to add the macro. 29 | //======================================================================== 30 | // As glfw_config.h, this file defines compile-time option macros for a 31 | // specific platform and development environment. If you are using the 32 | // GLFW CMake files, modify glfw_config.h.in instead of this file. If you 33 | // are using your own build system, make this file define the appropriate 34 | // macros in whatever way is suitable. 35 | //======================================================================== 36 | 37 | // Define this to 1 if building GLFW for X11 38 | #cmakedefine _GLFW_X11 39 | // Define this to 1 if building GLFW for Win32 40 | #cmakedefine _GLFW_WIN32 41 | // Define this to 1 if building GLFW for Cocoa 42 | #cmakedefine _GLFW_COCOA 43 | 44 | // Define this to 1 if building GLFW for EGL 45 | #cmakedefine _GLFW_EGL 46 | // Define this to 1 if building GLFW for GLX 47 | #cmakedefine _GLFW_GLX 48 | // Define this to 1 if building GLFW for WGL 49 | #cmakedefine _GLFW_WGL 50 | // Define this to 1 if building GLFW for NSGL 51 | #cmakedefine _GLFW_NSGL 52 | 53 | // Define this to 1 if building as a shared library / dynamic library / DLL 54 | #cmakedefine _GLFW_BUILD_DLL 55 | 56 | // Define this to 1 to disable dynamic loading of winmm 57 | #cmakedefine _GLFW_NO_DLOAD_WINMM 58 | // Define this to 1 if glfwSwapInterval should ignore DWM compositing status 59 | #cmakedefine _GLFW_USE_DWM_SWAP_INTERVAL 60 | // Define this to 1 to force use of high-performance GPU on Optimus systems 61 | #cmakedefine _GLFW_USE_OPTIMUS_HPG 62 | 63 | // Define this to 1 if glXGetProcAddress is available 64 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS 65 | // Define this to 1 if glXGetProcAddressARB is available 66 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSARB 67 | // Define this to 1 if glXGetProcAddressEXT is available 68 | #cmakedefine _GLFW_HAS_GLXGETPROCADDRESSEXT 69 | // Define this to 1 if dlopen is available 70 | #cmakedefine _GLFW_HAS_DLOPEN 71 | 72 | // Define this to 1 if glfwInit should change the current directory 73 | #cmakedefine _GLFW_USE_CHDIR 74 | // Define this to 1 if glfwCreateWindow should populate the menu bar 75 | #cmakedefine _GLFW_USE_MENUBAR 76 | 77 | // Define this to 1 if using OpenGL as the client library 78 | #cmakedefine _GLFW_USE_OPENGL 79 | // Define this to 1 if using OpenGL ES 1.1 as the client library 80 | #cmakedefine _GLFW_USE_GLESV1 81 | // Define this to 1 if using OpenGL ES 2.0 as the client library 82 | #cmakedefine _GLFW_USE_GLESV2 83 | 84 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/glx_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 GLX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _glx_platform_h_ 29 | #define _glx_platform_h_ 30 | 31 | #define GLX_GLXEXT_LEGACY 32 | #include 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 glxext.h since GLFW uses fairly new 36 | // extensions and not all operating systems come with an up-to-date version 37 | #include "../deps/GL/glxext.h" 38 | 39 | // Do we have support for dlopen/dlsym? 40 | #if defined(_GLFW_HAS_DLOPEN) 41 | #include 42 | #endif 43 | 44 | #include 45 | 46 | // We support four different ways for getting addresses for GL/GLX 47 | // extension functions: glXGetProcAddress, glXGetProcAddressARB, 48 | // glXGetProcAddressEXT, and dlsym 49 | #if defined(_GLFW_HAS_GLXGETPROCADDRESSARB) 50 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressARB(x) 51 | #elif defined(_GLFW_HAS_GLXGETPROCADDRESS) 52 | #define _glfw_glXGetProcAddress(x) glXGetProcAddress(x) 53 | #elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT) 54 | #define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x) 55 | #elif defined(_GLFW_HAS_DLOPEN) 56 | #define _glfw_glXGetProcAddress(x) dlsym(_glfw.glx.libGL, x) 57 | #define _GLFW_DLOPEN_LIBGL 58 | #else 59 | #error "No OpenGL entry point retrieval mechanism was enabled" 60 | #endif 61 | 62 | #define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx 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 | // TLS key for per-thread current context/window 97 | pthread_key_t current; 98 | 99 | // GLX extensions 100 | PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI; 101 | PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; 102 | PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; 103 | PFNGLXGETFBCONFIGATTRIBSGIXPROC GetFBConfigAttribSGIX; 104 | PFNGLXCHOOSEFBCONFIGSGIXPROC ChooseFBConfigSGIX; 105 | PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC CreateContextWithConfigSGIX; 106 | PFNGLXGETVISUALFROMFBCONFIGSGIXPROC GetVisualFromFBConfigSGIX; 107 | PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 108 | GLboolean SGIX_fbconfig; 109 | GLboolean SGI_swap_control; 110 | GLboolean EXT_swap_control; 111 | GLboolean MESA_swap_control; 112 | GLboolean ARB_multisample; 113 | GLboolean ARB_framebuffer_sRGB; 114 | GLboolean ARB_create_context; 115 | GLboolean ARB_create_context_profile; 116 | GLboolean ARB_create_context_robustness; 117 | GLboolean EXT_create_context_es2_profile; 118 | 119 | #if defined(_GLFW_DLOPEN_LIBGL) 120 | void* libGL; // dlopen handle for libGL.so 121 | #endif 122 | } _GLFWlibraryGLX; 123 | 124 | 125 | #endif // _glx_platform_h_ 126 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | // Global state shared between compilation units of GLFW 37 | // These are documented in internal.h 38 | // 39 | GLboolean _glfwInitialized = GL_FALSE; 40 | _GLFWlibrary _glfw; 41 | 42 | 43 | // The current error callback 44 | // This is outside of _glfw so it can be initialized and usable before 45 | // glfwInit is called, which lets that function report errors 46 | // 47 | static GLFWerrorfun _glfwErrorCallback = NULL; 48 | 49 | 50 | // Returns a generic string representation of the specified error 51 | // 52 | static const char* getErrorString(int error) 53 | { 54 | switch (error) 55 | { 56 | case GLFW_NOT_INITIALIZED: 57 | return "The GLFW library is not initialized"; 58 | case GLFW_NO_CURRENT_CONTEXT: 59 | return "There is no current context"; 60 | case GLFW_INVALID_ENUM: 61 | return "Invalid argument for enum parameter"; 62 | case GLFW_INVALID_VALUE: 63 | return "Invalid value for parameter"; 64 | case GLFW_OUT_OF_MEMORY: 65 | return "Out of memory"; 66 | case GLFW_API_UNAVAILABLE: 67 | return "The requested client API is unavailable"; 68 | case GLFW_VERSION_UNAVAILABLE: 69 | return "The requested client API version is unavailable"; 70 | case GLFW_PLATFORM_ERROR: 71 | return "A platform-specific error occurred"; 72 | case GLFW_FORMAT_UNAVAILABLE: 73 | return "The requested format is unavailable"; 74 | } 75 | 76 | return "ERROR: UNKNOWN ERROR TOKEN PASSED TO glfwErrorString"; 77 | } 78 | 79 | 80 | ////////////////////////////////////////////////////////////////////////// 81 | ////// GLFW event API ////// 82 | ////////////////////////////////////////////////////////////////////////// 83 | 84 | void _glfwInputError(int error, const char* format, ...) 85 | { 86 | if (_glfwErrorCallback) 87 | { 88 | char buffer[16384]; 89 | const char* description; 90 | 91 | if (format) 92 | { 93 | int count; 94 | va_list vl; 95 | 96 | va_start(vl, format); 97 | count = vsnprintf(buffer, sizeof(buffer), format, vl); 98 | va_end(vl); 99 | 100 | if (count < 0) 101 | buffer[sizeof(buffer) - 1] = '\0'; 102 | 103 | description = buffer; 104 | } 105 | else 106 | description = getErrorString(error); 107 | 108 | _glfwErrorCallback(error, description); 109 | } 110 | } 111 | 112 | 113 | ////////////////////////////////////////////////////////////////////////// 114 | ////// GLFW public API ////// 115 | ////////////////////////////////////////////////////////////////////////// 116 | 117 | GLFWAPI int glfwInit(void) 118 | { 119 | if (_glfwInitialized) 120 | return GL_TRUE; 121 | 122 | memset(&_glfw, 0, sizeof(_glfw)); 123 | 124 | if (!_glfwPlatformInit()) 125 | { 126 | _glfwPlatformTerminate(); 127 | return GL_FALSE; 128 | } 129 | 130 | _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount); 131 | if (_glfw.monitors == NULL) 132 | { 133 | _glfwInputError(GLFW_PLATFORM_ERROR, "No monitors found"); 134 | _glfwPlatformTerminate(); 135 | return GL_FALSE; 136 | } 137 | 138 | _glfwInitialized = GL_TRUE; 139 | 140 | // Not all window hints have zero as their default value 141 | glfwDefaultWindowHints(); 142 | 143 | return GL_TRUE; 144 | } 145 | 146 | GLFWAPI void glfwTerminate(void) 147 | { 148 | int i; 149 | 150 | if (!_glfwInitialized) 151 | return; 152 | 153 | memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks)); 154 | 155 | // Close all remaining windows 156 | while (_glfw.windowListHead) 157 | glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead); 158 | 159 | for (i = 0; i < _glfw.monitorCount; i++) 160 | { 161 | _GLFWmonitor* monitor = _glfw.monitors[i]; 162 | if (monitor->originalRamp.size) 163 | _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp); 164 | } 165 | 166 | _glfwDestroyMonitors(_glfw.monitors, _glfw.monitorCount); 167 | _glfw.monitors = NULL; 168 | _glfw.monitorCount = 0; 169 | 170 | _glfwPlatformTerminate(); 171 | 172 | _glfwInitialized = GL_FALSE; 173 | } 174 | 175 | GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev) 176 | { 177 | if (major != NULL) 178 | *major = GLFW_VERSION_MAJOR; 179 | 180 | if (minor != NULL) 181 | *minor = GLFW_VERSION_MINOR; 182 | 183 | if (rev != NULL) 184 | *rev = GLFW_VERSION_REVISION; 185 | } 186 | 187 | GLFWAPI const char* glfwGetVersionString(void) 188 | { 189 | return _glfwPlatformGetVersionString(); 190 | } 191 | 192 | GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun) 193 | { 194 | _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun); 195 | return cbfun; 196 | } 197 | 198 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW public API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | GLFWAPI int glfwJoystickPresent(int joy) 36 | { 37 | _GLFW_REQUIRE_INIT_OR_RETURN(0); 38 | 39 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 40 | { 41 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 42 | return 0; 43 | } 44 | 45 | return _glfwPlatformJoystickPresent(joy); 46 | } 47 | 48 | GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count) 49 | { 50 | *count = 0; 51 | 52 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 53 | 54 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 55 | { 56 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 57 | return NULL; 58 | } 59 | 60 | return _glfwPlatformGetJoystickAxes(joy, count); 61 | } 62 | 63 | GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count) 64 | { 65 | *count = 0; 66 | 67 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 68 | 69 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 70 | { 71 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 72 | return NULL; 73 | } 74 | 75 | return _glfwPlatformGetJoystickButtons(joy, count); 76 | } 77 | 78 | GLFWAPI const char* glfwGetJoystickName(int joy) 79 | { 80 | _GLFW_REQUIRE_INIT_OR_RETURN(NULL); 81 | 82 | if (joy < 0 || joy > GLFW_JOYSTICK_LAST) 83 | { 84 | _glfwInputError(GLFW_INVALID_ENUM, NULL); 85 | return NULL; 86 | } 87 | 88 | return _glfwPlatformGetJoystickName(joy); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/nsgl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 OS X - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #ifndef _nsgl_platform_h_ 28 | #define _nsgl_platform_h_ 29 | 30 | 31 | #define _GLFW_PLATFORM_FBCONFIG 32 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl 33 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL nsgl 34 | 35 | 36 | //======================================================================== 37 | // GLFW platform specific types 38 | //======================================================================== 39 | 40 | //------------------------------------------------------------------------ 41 | // Platform-specific OpenGL context structure 42 | //------------------------------------------------------------------------ 43 | typedef struct _GLFWcontextNSGL 44 | { 45 | id pixelFormat; 46 | id context; 47 | } _GLFWcontextNSGL; 48 | 49 | 50 | //------------------------------------------------------------------------ 51 | // Platform-specific library global data for NSGL 52 | //------------------------------------------------------------------------ 53 | typedef struct _GLFWlibraryNSGL 54 | { 55 | // dlopen handle for dynamically loading OpenGL extension entry points 56 | void* framework; 57 | 58 | // TLS key for per-thread current context/window 59 | pthread_key_t current; 60 | 61 | } _GLFWlibraryNSGL; 62 | 63 | 64 | #endif // _nsgl_platform_h_ 65 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | ////// GLFW public API ////// 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | GLFWAPI double glfwGetTime(void) 36 | { 37 | _GLFW_REQUIRE_INIT_OR_RETURN(0.0); 38 | return _glfwPlatformGetTime(); 39 | } 40 | 41 | GLFWAPI void glfwSetTime(double time) 42 | { 43 | _GLFW_REQUIRE_INIT(); 44 | _glfwPlatformSetTime(time); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/wgl_platform.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 WGL - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #ifndef _wgl_platform_h_ 29 | #define _wgl_platform_h_ 30 | 31 | // This path may need to be changed if you build GLFW using your own setup 32 | // We ship and use our own copy of wglext.h since GLFW uses fairly new 33 | // extensions and not all operating systems come with an up-to-date version 34 | #include "../deps/GL/wglext.h" 35 | 36 | 37 | #define _GLFW_PLATFORM_FBCONFIG int wgl 38 | #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl 39 | #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL wgl 40 | 41 | 42 | //======================================================================== 43 | // GLFW platform specific types 44 | //======================================================================== 45 | 46 | //------------------------------------------------------------------------ 47 | // Platform-specific OpenGL context structure 48 | //------------------------------------------------------------------------ 49 | typedef struct _GLFWcontextWGL 50 | { 51 | // Platform specific window resources 52 | HDC dc; // Private GDI device context 53 | HGLRC context; // Permanent rendering context 54 | 55 | // Platform specific extensions (context specific) 56 | PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT; 57 | PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB; 58 | PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; 59 | PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; 60 | PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; 61 | GLboolean EXT_swap_control; 62 | GLboolean ARB_multisample; 63 | GLboolean ARB_framebuffer_sRGB; 64 | GLboolean ARB_pixel_format; 65 | GLboolean ARB_create_context; 66 | GLboolean ARB_create_context_profile; 67 | GLboolean EXT_create_context_es2_profile; 68 | GLboolean ARB_create_context_robustness; 69 | } _GLFWcontextWGL; 70 | 71 | 72 | //------------------------------------------------------------------------ 73 | // Platform-specific library global data for WGL 74 | //------------------------------------------------------------------------ 75 | typedef struct _GLFWlibraryWGL 76 | { 77 | GLboolean hasTLS; 78 | DWORD current; 79 | 80 | // opengl32.dll 81 | struct { 82 | HINSTANCE instance; 83 | } opengl32; 84 | 85 | } _GLFWlibraryWGL; 86 | 87 | 88 | #endif // _wgl_platform_h_ 89 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/win32_clipboard.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) 40 | { 41 | WCHAR* wideString; 42 | HANDLE stringHandle; 43 | size_t wideSize; 44 | 45 | wideString = _glfwCreateWideStringFromUTF8(string); 46 | if (!wideString) 47 | { 48 | _glfwInputError(GLFW_PLATFORM_ERROR, 49 | "Win32: Failed to convert clipboard string to " 50 | "wide string"); 51 | return; 52 | } 53 | 54 | wideSize = (wcslen(wideString) + 1) * sizeof(WCHAR); 55 | 56 | stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize); 57 | if (!stringHandle) 58 | { 59 | free(wideString); 60 | 61 | _glfwInputError(GLFW_PLATFORM_ERROR, 62 | "Win32: Failed to allocate global handle for clipboard"); 63 | return; 64 | } 65 | 66 | memcpy(GlobalLock(stringHandle), wideString, wideSize); 67 | GlobalUnlock(stringHandle); 68 | 69 | if (!OpenClipboard(window->win32.handle)) 70 | { 71 | GlobalFree(stringHandle); 72 | free(wideString); 73 | 74 | _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard"); 75 | return; 76 | } 77 | 78 | EmptyClipboard(); 79 | SetClipboardData(CF_UNICODETEXT, stringHandle); 80 | CloseClipboard(); 81 | 82 | free(wideString); 83 | } 84 | 85 | const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) 86 | { 87 | HANDLE stringHandle; 88 | 89 | if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) 90 | { 91 | _glfwInputError(GLFW_FORMAT_UNAVAILABLE, NULL); 92 | return NULL; 93 | } 94 | 95 | if (!OpenClipboard(window->win32.handle)) 96 | { 97 | _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard"); 98 | return NULL; 99 | } 100 | 101 | stringHandle = GetClipboardData(CF_UNICODETEXT); 102 | if (!stringHandle) 103 | { 104 | CloseClipboard(); 105 | 106 | _glfwInputError(GLFW_PLATFORM_ERROR, 107 | "Win32: Failed to retrieve clipboard data"); 108 | return NULL; 109 | } 110 | 111 | free(_glfw.win32.clipboardString); 112 | _glfw.win32.clipboardString = 113 | _glfwCreateUTF8FromWideString(GlobalLock(stringHandle)); 114 | 115 | GlobalUnlock(stringHandle); 116 | CloseClipboard(); 117 | 118 | if (!_glfw.win32.clipboardString) 119 | { 120 | _glfwInputError(GLFW_PLATFORM_ERROR, 121 | "Win32: Failed to convert wide string to UTF-8"); 122 | return NULL; 123 | } 124 | 125 | return _glfw.win32.clipboardString; 126 | } 127 | 128 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/win32_gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 37 | { 38 | HDC dc; 39 | WORD values[768]; 40 | DISPLAY_DEVICE display; 41 | 42 | ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); 43 | display.cb = sizeof(DISPLAY_DEVICE); 44 | EnumDisplayDevices(monitor->win32.name, 0, &display, 0); 45 | 46 | dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); 47 | GetDeviceGammaRamp(dc, values); 48 | DeleteDC(dc); 49 | 50 | _glfwAllocGammaArrays(ramp, 256); 51 | 52 | memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short)); 53 | memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short)); 54 | memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short)); 55 | } 56 | 57 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 58 | { 59 | HDC dc; 60 | WORD values[768]; 61 | DISPLAY_DEVICE display; 62 | 63 | if (ramp->size != 256) 64 | { 65 | _glfwInputError(GLFW_PLATFORM_ERROR, 66 | "Win32: Gamma ramp size must be 256"); 67 | return; 68 | } 69 | 70 | memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short)); 71 | memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short)); 72 | memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short)); 73 | 74 | ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); 75 | display.cb = sizeof(DISPLAY_DEVICE); 76 | EnumDisplayDevices(monitor->win32.name, 0, &display, 0); 77 | 78 | dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); 79 | SetDeviceGammaRamp(dc, values); 80 | DeleteDC(dc); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/win32_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Calculate normalized joystick position 38 | // 39 | static float calcJoystickPos(DWORD pos, DWORD min, DWORD max) 40 | { 41 | float fpos = (float) pos; 42 | float fmin = (float) min; 43 | float fmax = (float) max; 44 | 45 | return (2.f * (fpos - fmin) / (fmax - fmin)) - 1.f; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW internal API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | // Initialize joystick interface 54 | // 55 | void _glfwInitJoysticks(void) 56 | { 57 | } 58 | 59 | // Close all opened joystick handles 60 | // 61 | void _glfwTerminateJoysticks(void) 62 | { 63 | int i; 64 | 65 | for (i = 0; i < GLFW_JOYSTICK_LAST; i++) 66 | free(_glfw.win32.joystick[i].name); 67 | } 68 | 69 | 70 | ////////////////////////////////////////////////////////////////////////// 71 | ////// GLFW platform API ////// 72 | ////////////////////////////////////////////////////////////////////////// 73 | 74 | int _glfwPlatformJoystickPresent(int joy) 75 | { 76 | JOYINFO ji; 77 | 78 | if (_glfw_joyGetPos(joy, &ji) != JOYERR_NOERROR) 79 | return GL_FALSE; 80 | 81 | return GL_TRUE; 82 | } 83 | 84 | const float* _glfwPlatformGetJoystickAxes(int joy, int* count) 85 | { 86 | JOYCAPS jc; 87 | JOYINFOEX ji; 88 | float* axes = _glfw.win32.joystick[joy].axes; 89 | 90 | if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) 91 | return NULL; 92 | 93 | ji.dwSize = sizeof(JOYINFOEX); 94 | ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | 95 | JOY_RETURNR | JOY_RETURNU | JOY_RETURNV; 96 | if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR) 97 | return NULL; 98 | 99 | axes[(*count)++] = calcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax); 100 | axes[(*count)++] = calcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax); 101 | 102 | if (jc.wCaps & JOYCAPS_HASZ) 103 | axes[(*count)++] = calcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax); 104 | 105 | if (jc.wCaps & JOYCAPS_HASR) 106 | axes[(*count)++] = calcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax); 107 | 108 | if (jc.wCaps & JOYCAPS_HASU) 109 | axes[(*count)++] = calcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax); 110 | 111 | if (jc.wCaps & JOYCAPS_HASV) 112 | axes[(*count)++] = calcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax); 113 | 114 | return axes; 115 | } 116 | 117 | const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) 118 | { 119 | JOYCAPS jc; 120 | JOYINFOEX ji; 121 | unsigned char* buttons = _glfw.win32.joystick[joy].buttons; 122 | 123 | if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) 124 | return NULL; 125 | 126 | ji.dwSize = sizeof(JOYINFOEX); 127 | ji.dwFlags = JOY_RETURNBUTTONS | JOY_RETURNPOV; 128 | if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR) 129 | return NULL; 130 | 131 | while (*count < (int) jc.wNumButtons) 132 | { 133 | buttons[*count] = (unsigned char) 134 | (ji.dwButtons & (1UL << *count) ? GLFW_PRESS : GLFW_RELEASE); 135 | (*count)++; 136 | } 137 | 138 | // Virtual buttons - Inject data from hats 139 | // Each hat is exposed as 4 buttons which exposes 8 directions with 140 | // concurrent button presses 141 | // NOTE: this API exposes only one hat 142 | 143 | if ((jc.wCaps & JOYCAPS_HASPOV) && (jc.wCaps & JOYCAPS_POV4DIR)) 144 | { 145 | int i, value = ji.dwPOV / 100 / 45; 146 | 147 | // Bit fields of button presses for each direction, including nil 148 | const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 }; 149 | 150 | if (value < 0 || value > 8) 151 | value = 8; 152 | 153 | for (i = 0; i < 4; i++) 154 | { 155 | if (directions[value] & (1 << i)) 156 | buttons[(*count)++] = GLFW_PRESS; 157 | else 158 | buttons[(*count)++] = GLFW_RELEASE; 159 | } 160 | } 161 | 162 | return buttons; 163 | } 164 | 165 | const char* _glfwPlatformGetJoystickName(int joy) 166 | { 167 | JOYCAPS jc; 168 | 169 | if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR) 170 | return NULL; 171 | 172 | free(_glfw.win32.joystick[joy].name); 173 | _glfw.win32.joystick[joy].name = _glfwCreateUTF8FromWideString(jc.szPname); 174 | 175 | return _glfw.win32.joystick[joy].name; 176 | } 177 | 178 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/win32_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | 31 | // Return raw time 32 | // 33 | static unsigned __int64 getRawTime(void) 34 | { 35 | if (_glfw.win32.timer.hasPC) 36 | { 37 | unsigned __int64 time; 38 | QueryPerformanceCounter((LARGE_INTEGER*) &time); 39 | return time; 40 | } 41 | else 42 | return (unsigned __int64) _glfw_timeGetTime(); 43 | } 44 | 45 | 46 | ////////////////////////////////////////////////////////////////////////// 47 | ////// GLFW internal API ////// 48 | ////////////////////////////////////////////////////////////////////////// 49 | 50 | // Initialise timer 51 | // 52 | void _glfwInitTimer(void) 53 | { 54 | unsigned __int64 frequency; 55 | 56 | if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency)) 57 | { 58 | _glfw.win32.timer.hasPC = GL_TRUE; 59 | _glfw.win32.timer.resolution = 1.0 / (double) frequency; 60 | } 61 | else 62 | { 63 | _glfw.win32.timer.hasPC = GL_FALSE; 64 | _glfw.win32.timer.resolution = 0.001; // winmm resolution is 1 ms 65 | } 66 | 67 | _glfw.win32.timer.base = getRawTime(); 68 | } 69 | 70 | 71 | ////////////////////////////////////////////////////////////////////////// 72 | ////// GLFW platform API ////// 73 | ////////////////////////////////////////////////////////////////////////// 74 | 75 | double _glfwPlatformGetTime(void) 76 | { 77 | return (double) (getRawTime() - _glfw.win32.timer.base) * 78 | _glfw.win32.timer.resolution; 79 | } 80 | 81 | void _glfwPlatformSetTime(double time) 82 | { 83 | _glfw.win32.timer.base = getRawTime() - 84 | (unsigned __int64) (time / _glfw.win32.timer.resolution); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/x11_gamma.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 X11 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2010 Camilla Berglund 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include "internal.h" 28 | 29 | #include 30 | #include 31 | 32 | 33 | ////////////////////////////////////////////////////////////////////////// 34 | ////// GLFW internal API ////// 35 | ////////////////////////////////////////////////////////////////////////// 36 | 37 | // Detect gamma ramp support 38 | // 39 | void _glfwInitGammaRamp(void) 40 | { 41 | // RandR gamma support is only available with version 1.2 and above 42 | if (_glfw.x11.randr.available && 43 | (_glfw.x11.randr.versionMajor > 1 || 44 | (_glfw.x11.randr.versionMajor == 1 && 45 | _glfw.x11.randr.versionMinor >= 2))) 46 | { 47 | // FIXME: Assumes that all monitors have the same size gamma tables 48 | // This is reasonable as I suspect the that if they did differ, it 49 | // would imply that setting the gamma size to an arbitary size is 50 | // possible as well. 51 | XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display, 52 | _glfw.x11.root); 53 | 54 | if (XRRGetCrtcGammaSize(_glfw.x11.display, rr->crtcs[0]) == 0) 55 | { 56 | // This is probably older Nvidia RandR with broken gamma support 57 | // Flag it as useless and try Xf86VidMode below, if available 58 | _glfw.x11.randr.gammaBroken = GL_TRUE; 59 | } 60 | 61 | XRRFreeScreenResources(rr); 62 | } 63 | } 64 | 65 | 66 | ////////////////////////////////////////////////////////////////////////// 67 | ////// GLFW platform API ////// 68 | ////////////////////////////////////////////////////////////////////////// 69 | 70 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 71 | { 72 | if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) 73 | { 74 | const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display, 75 | monitor->x11.crtc); 76 | XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display, 77 | monitor->x11.crtc); 78 | 79 | _glfwAllocGammaArrays(ramp, size); 80 | 81 | memcpy(ramp->red, gamma->red, size * sizeof(unsigned short)); 82 | memcpy(ramp->green, gamma->green, size * sizeof(unsigned short)); 83 | memcpy(ramp->blue, gamma->blue, size * sizeof(unsigned short)); 84 | 85 | XRRFreeGamma(gamma); 86 | } 87 | else if (_glfw.x11.vidmode.available) 88 | { 89 | int size; 90 | XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size); 91 | 92 | _glfwAllocGammaArrays(ramp, size); 93 | 94 | XF86VidModeGetGammaRamp(_glfw.x11.display, 95 | _glfw.x11.screen, 96 | ramp->size, ramp->red, ramp->green, ramp->blue); 97 | } 98 | } 99 | 100 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) 101 | { 102 | if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken) 103 | { 104 | XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size); 105 | 106 | memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short)); 107 | memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short)); 108 | memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short)); 109 | 110 | XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma); 111 | XRRFreeGamma(gamma); 112 | } 113 | else if (_glfw.x11.vidmode.available) 114 | { 115 | XF86VidModeSetGammaRamp(_glfw.x11.display, 116 | _glfw.x11.screen, 117 | ramp->size, 118 | (unsigned short*) ramp->red, 119 | (unsigned short*) ramp->green, 120 | (unsigned short*) ramp->blue); 121 | } 122 | } 123 | 124 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/src/x11_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.0 X11 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2010 Camilla Berglund 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include "internal.h" 29 | 30 | #include 31 | #include 32 | 33 | 34 | // Return raw time 35 | // 36 | static uint64_t getRawTime(void) 37 | { 38 | #if defined(CLOCK_MONOTONIC) 39 | if (_glfw.x11.timer.monotonic) 40 | { 41 | struct timespec ts; 42 | 43 | clock_gettime(CLOCK_MONOTONIC, &ts); 44 | return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec; 45 | } 46 | else 47 | #endif 48 | { 49 | struct timeval tv; 50 | 51 | gettimeofday(&tv, NULL); 52 | return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec; 53 | } 54 | } 55 | 56 | 57 | ////////////////////////////////////////////////////////////////////////// 58 | ////// GLFW internal API ////// 59 | ////////////////////////////////////////////////////////////////////////// 60 | 61 | // Initialise timer 62 | // 63 | void _glfwInitTimer(void) 64 | { 65 | #if defined(CLOCK_MONOTONIC) 66 | struct timespec ts; 67 | 68 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 69 | { 70 | _glfw.x11.timer.monotonic = GL_TRUE; 71 | _glfw.x11.timer.resolution = 1e-9; 72 | } 73 | else 74 | #endif 75 | { 76 | _glfw.x11.timer.resolution = 1e-6; 77 | } 78 | 79 | _glfw.x11.timer.base = getRawTime(); 80 | } 81 | 82 | 83 | ////////////////////////////////////////////////////////////////////////// 84 | ////// GLFW platform API ////// 85 | ////////////////////////////////////////////////////////////////////////// 86 | 87 | double _glfwPlatformGetTime(void) 88 | { 89 | return (double) (getRawTime() - _glfw.x11.timer.base) * 90 | _glfw.x11.timer.resolution; 91 | } 92 | 93 | void _glfwPlatformSetTime(double time) 94 | { 95 | _glfw.x11.timer.base = getRawTime() - 96 | (uint64_t) (time / _glfw.x11.timer.resolution); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | include_directories(${GLFW_SOURCE_DIR}/include 12 | ${GLFW_SOURCE_DIR}/deps) 13 | 14 | if (NOT APPLE) 15 | # HACK: This is NOTFOUND on OS X 10.8 16 | include_directories(${OPENGL_INCLUDE_DIR}) 17 | endif() 18 | 19 | set(GETOPT ${GLFW_SOURCE_DIR}/deps/getopt.h 20 | ${GLFW_SOURCE_DIR}/deps/getopt.c) 21 | set(TINYCTHREAD ${GLFW_SOURCE_DIR}/deps/tinycthread.h 22 | ${GLFW_SOURCE_DIR}/deps/tinycthread.c) 23 | 24 | add_executable(clipboard clipboard.c ${GETOPT}) 25 | add_executable(defaults defaults.c) 26 | add_executable(events events.c ${GETOPT}) 27 | add_executable(fsaa fsaa.c ${GETOPT}) 28 | add_executable(gamma gamma.c ${GETOPT}) 29 | add_executable(glfwinfo glfwinfo.c ${GETOPT}) 30 | add_executable(iconify iconify.c ${GETOPT}) 31 | add_executable(joysticks joysticks.c) 32 | add_executable(modes modes.c ${GETOPT}) 33 | add_executable(peter peter.c) 34 | add_executable(reopen reopen.c) 35 | 36 | add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) 37 | set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy") 38 | 39 | add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c) 40 | set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") 41 | 42 | add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) 43 | set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") 44 | 45 | add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD}) 46 | set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") 47 | 48 | add_executable(title WIN32 MACOSX_BUNDLE title.c) 49 | set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") 50 | 51 | add_executable(windows WIN32 MACOSX_BUNDLE windows.c) 52 | set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") 53 | 54 | target_link_libraries(threads ${CMAKE_THREAD_LIBS_INIT} ${RT_LIBRARY}) 55 | 56 | set(WINDOWS_BINARIES accuracy sharing tearing threads title windows) 57 | set(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo 58 | iconify joysticks modes peter reopen) 59 | 60 | if (MSVC) 61 | # Tell MSVC to use main instead of WinMain for Windows subsystem executables 62 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 63 | LINK_FLAGS "/ENTRY:mainCRTStartup") 64 | endif() 65 | 66 | if (APPLE) 67 | set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES 68 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} 69 | MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}) 70 | endif() 71 | 72 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 double cursor_x = 0.0, cursor_y = 0.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 framebuffer_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, double x, double y) 72 | { 73 | cursor_x = x; 74 | cursor_y = y; 75 | } 76 | 77 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 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 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 102 | glfwSetKeyCallback(window, key_callback); 103 | 104 | glfwMakeContextCurrent(window); 105 | 106 | glfwGetFramebufferSize(window, &width, &height); 107 | framebuffer_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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 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 scancode, int action, int mods) 48 | { 49 | if (action != GLFW_PRESS) 50 | return; 51 | 52 | switch (key) 53 | { 54 | case GLFW_KEY_ESCAPE: 55 | glfwSetWindowShouldClose(window, GL_TRUE); 56 | break; 57 | 58 | case GLFW_KEY_V: 59 | if (mods == GLFW_MOD_CONTROL) 60 | { 61 | const char* string; 62 | 63 | string = glfwGetClipboardString(window); 64 | if (string) 65 | printf("Clipboard contains \"%s\"\n", string); 66 | else 67 | printf("Clipboard does not contain a string\n"); 68 | } 69 | break; 70 | 71 | case GLFW_KEY_C: 72 | if (mods == GLFW_MOD_CONTROL) 73 | { 74 | const char* string = "Hello GLFW World!"; 75 | glfwSetClipboardString(window, string); 76 | printf("Setting clipboard to \"%s\"\n", string); 77 | } 78 | break; 79 | } 80 | } 81 | 82 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 83 | { 84 | glViewport(0, 0, width, height); 85 | } 86 | 87 | int main(int argc, char** argv) 88 | { 89 | int ch; 90 | GLFWwindow* window; 91 | 92 | while ((ch = getopt(argc, argv, "h")) != -1) 93 | { 94 | switch (ch) 95 | { 96 | case 'h': 97 | usage(); 98 | exit(EXIT_SUCCESS); 99 | 100 | default: 101 | usage(); 102 | exit(EXIT_FAILURE); 103 | } 104 | } 105 | 106 | glfwSetErrorCallback(error_callback); 107 | 108 | if (!glfwInit()) 109 | { 110 | fprintf(stderr, "Failed to initialize GLFW\n"); 111 | exit(EXIT_FAILURE); 112 | } 113 | 114 | window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL); 115 | if (!window) 116 | { 117 | glfwTerminate(); 118 | 119 | fprintf(stderr, "Failed to open GLFW window\n"); 120 | exit(EXIT_FAILURE); 121 | } 122 | 123 | glfwMakeContextCurrent(window); 124 | glfwSwapInterval(1); 125 | 126 | glfwSetKeyCallback(window, key_callback); 127 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 128 | 129 | glMatrixMode(GL_PROJECTION); 130 | glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f); 131 | glMatrixMode(GL_MODELVIEW); 132 | 133 | glClearColor(0.5f, 0.5f, 0.5f, 0); 134 | 135 | while (!glfwWindowShouldClose(window)) 136 | { 137 | glClear(GL_COLOR_BUFFER_BIT); 138 | 139 | glColor3f(0.8f, 0.2f, 0.4f); 140 | glRectf(-0.5f, -0.5f, 0.5f, 0.5f); 141 | 142 | glfwSwapBuffers(window); 143 | glfwWaitEvents(); 144 | } 145 | 146 | glfwTerminate(); 147 | exit(EXIT_SUCCESS); 148 | } 149 | 150 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 window hints set to 27 | // default values and then reports the actual attributes 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 attrib; 41 | const char* ext; 42 | const char* name; 43 | } AttribGL; 44 | 45 | typedef struct 46 | { 47 | int attrib; 48 | const char* name; 49 | } AttribGLFW; 50 | 51 | static AttribGL gl_attribs[] = 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 AttribGLFW glfw_attribs[] = 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 | glfwGetFramebufferSize(window, &width, &height); 100 | 101 | printf("framebuffer size: %ix%i\n", width, height); 102 | 103 | for (i = 0; glfw_attribs[i].name; i++) 104 | { 105 | printf("%s: %i\n", 106 | glfw_attribs[i].name, 107 | glfwGetWindowAttrib(window, glfw_attribs[i].attrib)); 108 | } 109 | 110 | for (i = 0; gl_attribs[i].name; i++) 111 | { 112 | GLint value = 0; 113 | 114 | if (gl_attribs[i].ext) 115 | { 116 | if (!glfwExtensionSupported(gl_attribs[i].ext)) 117 | continue; 118 | } 119 | 120 | glGetIntegerv(gl_attribs[i].attrib, &value); 121 | 122 | printf("%s: %i\n", gl_attribs[i].name, value); 123 | } 124 | 125 | glfwDestroyWindow(window); 126 | window = NULL; 127 | 128 | glfwTerminate(); 129 | exit(EXIT_SUCCESS); 130 | } 131 | 132 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 framebuffer_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 scancode, int action, int mods) 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 | glfwSetFramebufferSizeCallback(window, framebuffer_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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 scancode, int action, int mods) 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 framebuffer_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 | const 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 | glfwSetFramebufferSizeCallback(window, framebuffer_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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 scancode, int action, int mods) 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 | 73 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 74 | { 75 | printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height); 76 | 77 | glViewport(0, 0, width, height); 78 | } 79 | 80 | static void window_focus_callback(GLFWwindow* window, int focused) 81 | { 82 | printf("%0.2f Window %s\n", 83 | glfwGetTime(), 84 | focused ? "focused" : "defocused"); 85 | } 86 | 87 | static void window_iconify_callback(GLFWwindow* window, int iconified) 88 | { 89 | printf("%0.2f Window %s\n", 90 | glfwGetTime(), 91 | iconified ? "iconified" : "restored"); 92 | } 93 | 94 | int main(int argc, char** argv) 95 | { 96 | int width, height, ch; 97 | GLFWmonitor* monitor = NULL; 98 | GLFWwindow* window; 99 | 100 | glfwSetErrorCallback(error_callback); 101 | 102 | if (!glfwInit()) 103 | exit(EXIT_FAILURE); 104 | 105 | while ((ch = getopt(argc, argv, "fh")) != -1) 106 | { 107 | switch (ch) 108 | { 109 | case 'h': 110 | usage(); 111 | exit(EXIT_SUCCESS); 112 | 113 | case 'f': 114 | monitor = glfwGetPrimaryMonitor(); 115 | break; 116 | 117 | default: 118 | usage(); 119 | exit(EXIT_FAILURE); 120 | } 121 | } 122 | 123 | if (monitor) 124 | { 125 | const GLFWvidmode* mode = glfwGetVideoMode(monitor); 126 | width = mode->width; 127 | height = mode->height; 128 | } 129 | else 130 | { 131 | width = 640; 132 | height = 480; 133 | } 134 | 135 | window = glfwCreateWindow(width, height, "Iconify", monitor, NULL); 136 | if (!window) 137 | { 138 | glfwTerminate(); 139 | exit(EXIT_FAILURE); 140 | } 141 | 142 | glfwMakeContextCurrent(window); 143 | glfwSwapInterval(1); 144 | 145 | glfwSetKeyCallback(window, key_callback); 146 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 147 | glfwSetWindowSizeCallback(window, window_size_callback); 148 | glfwSetWindowFocusCallback(window, window_focus_callback); 149 | glfwSetWindowIconifyCallback(window, window_iconify_callback); 150 | 151 | printf("Window is %s and %s\n", 152 | glfwGetWindowAttrib(window, GLFW_ICONIFIED) ? "iconified" : "restored", 153 | glfwGetWindowAttrib(window, GLFW_FOCUSED) ? "focused" : "defocused"); 154 | 155 | glEnable(GL_SCISSOR_TEST); 156 | 157 | while (!glfwWindowShouldClose(window)) 158 | { 159 | glfwGetFramebufferSize(window, &width, &height); 160 | 161 | glScissor(0, 0, width, height); 162 | glClearColor(0, 0, 0, 0); 163 | glClear(GL_COLOR_BUFFER_BIT); 164 | 165 | glScissor(0, 0, 640, 480); 166 | glClearColor(1, 1, 1, 0); 167 | glClear(GL_COLOR_BUFFER_BIT); 168 | 169 | glfwSwapBuffers(window); 170 | glfwPollEvents(); 171 | } 172 | 173 | glfwTerminate(); 174 | exit(EXIT_SUCCESS); 175 | } 176 | 177 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 double cursor_x; 40 | static double cursor_y; 41 | 42 | static void toggle_cursor(GLFWwindow* window) 43 | { 44 | if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) 45 | { 46 | printf("Released cursor\n"); 47 | glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); 48 | } 49 | else 50 | { 51 | printf("Captured cursor\n"); 52 | glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); 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, double x, double y) 62 | { 63 | printf("Cursor moved to: %f %f (%f %f)\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 scancode, int action, int mods) 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 framebuffer_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: %f %f\n", cursor_x, cursor_y); 106 | 107 | glfwSetFramebufferSizeCallback(window, framebuffer_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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | #include 41 | 42 | static void error_callback(int error, const char* description) 43 | { 44 | fprintf(stderr, "Error: %s\n", description); 45 | } 46 | 47 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 48 | { 49 | glViewport(0, 0, width, height); 50 | } 51 | 52 | static void window_close_callback(GLFWwindow* window) 53 | { 54 | printf("Close callback triggered\n"); 55 | } 56 | 57 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 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 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 86 | glfwSetWindowCloseCallback(window, window_close_callback); 87 | glfwSetKeyCallback(window, key_callback); 88 | 89 | if (monitor) 90 | { 91 | printf("Opening full screen window on monitor %s took %0.3f seconds\n", 92 | glfwGetMonitorName(monitor), 93 | glfwGetTime() - base); 94 | } 95 | else 96 | { 97 | printf("Opening regular window took %0.3f seconds\n", 98 | glfwGetTime() - base); 99 | } 100 | 101 | return window; 102 | } 103 | 104 | static void close_window(GLFWwindow* window) 105 | { 106 | double base = glfwGetTime(); 107 | glfwDestroyWindow(window); 108 | printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); 109 | } 110 | 111 | int main(int argc, char** argv) 112 | { 113 | int count = 0; 114 | GLFWwindow* window; 115 | 116 | srand((unsigned int) time(NULL)); 117 | 118 | glfwSetErrorCallback(error_callback); 119 | 120 | if (!glfwInit()) 121 | exit(EXIT_FAILURE); 122 | 123 | for (;;) 124 | { 125 | GLFWmonitor* monitor = NULL; 126 | 127 | if (count & 1) 128 | { 129 | int monitorCount; 130 | GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); 131 | monitor = monitors[rand() % monitorCount]; 132 | } 133 | 134 | window = open_window(640, 480, monitor); 135 | if (!window) 136 | { 137 | glfwTerminate(); 138 | exit(EXIT_FAILURE); 139 | } 140 | 141 | glMatrixMode(GL_PROJECTION); 142 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 143 | glMatrixMode(GL_MODELVIEW); 144 | 145 | glfwSetTime(0.0); 146 | 147 | while (glfwGetTime() < 5.0) 148 | { 149 | glClear(GL_COLOR_BUFFER_BIT); 150 | 151 | glPushMatrix(); 152 | glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f); 153 | glRectf(-0.5f, -0.5f, 1.f, 1.f); 154 | glPopMatrix(); 155 | 156 | glfwSwapBuffers(window); 157 | glfwPollEvents(); 158 | 159 | if (glfwWindowShouldClose(window)) 160 | { 161 | close_window(window); 162 | printf("User closed window\n"); 163 | 164 | glfwTerminate(); 165 | exit(EXIT_SUCCESS); 166 | } 167 | } 168 | 169 | printf("Closing window\n"); 170 | close_window(window); 171 | 172 | count++; 173 | } 174 | 175 | glfwTerminate(); 176 | } 177 | 178 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 scancode, int action, int mods) 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 | glfwGetFramebufferSize(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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | static double frame_rate; 39 | 40 | static void update_window_title(GLFWwindow* window) 41 | { 42 | char title[256]; 43 | 44 | sprintf(title, "Tearing detector (interval %i, %0.1f Hz)", 45 | swap_interval, frame_rate); 46 | 47 | glfwSetWindowTitle(window, title); 48 | } 49 | 50 | static void set_swap_interval(GLFWwindow* window, int interval) 51 | { 52 | swap_interval = interval; 53 | glfwSwapInterval(swap_interval); 54 | update_window_title(window); 55 | } 56 | 57 | static void error_callback(int error, const char* description) 58 | { 59 | fprintf(stderr, "Error: %s\n", description); 60 | } 61 | 62 | static void framebuffer_size_callback(GLFWwindow* window, int width, int height) 63 | { 64 | glViewport(0, 0, width, height); 65 | } 66 | 67 | static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) 68 | { 69 | if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) 70 | set_swap_interval(window, 1 - swap_interval); 71 | } 72 | 73 | int main(void) 74 | { 75 | float position; 76 | unsigned long frame_count = 0; 77 | double last_time, current_time; 78 | GLFWwindow* window; 79 | 80 | glfwSetErrorCallback(error_callback); 81 | 82 | if (!glfwInit()) 83 | exit(EXIT_FAILURE); 84 | 85 | window = glfwCreateWindow(640, 480, "", NULL, NULL); 86 | if (!window) 87 | { 88 | glfwTerminate(); 89 | exit(EXIT_FAILURE); 90 | } 91 | 92 | glfwMakeContextCurrent(window); 93 | set_swap_interval(window, 0); 94 | 95 | last_time = glfwGetTime(); 96 | frame_rate = 0.0; 97 | 98 | glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); 99 | glfwSetKeyCallback(window, key_callback); 100 | 101 | glMatrixMode(GL_PROJECTION); 102 | glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); 103 | glMatrixMode(GL_MODELVIEW); 104 | 105 | while (!glfwWindowShouldClose(window)) 106 | { 107 | glClear(GL_COLOR_BUFFER_BIT); 108 | 109 | position = cosf((float) glfwGetTime() * 4.f) * 0.75f; 110 | glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); 111 | 112 | glfwSwapBuffers(window); 113 | glfwPollEvents(); 114 | 115 | frame_count++; 116 | 117 | current_time = glfwGetTime(); 118 | if (current_time - last_time > 1.0) 119 | { 120 | frame_rate = frame_count / (current_time - last_time); 121 | frame_count = 0; 122 | last_time = current_time; 123 | update_window_title(window); 124 | } 125 | } 126 | 127 | glfwTerminate(); 128 | exit(EXIT_SUCCESS); 129 | } 130 | 131 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | 39 | typedef struct 40 | { 41 | GLFWwindow* window; 42 | const char* title; 43 | float r, g, b; 44 | thrd_t id; 45 | } Thread; 46 | 47 | static volatile GLboolean running = GL_TRUE; 48 | 49 | static void error_callback(int error, const char* description) 50 | { 51 | fprintf(stderr, "Error: %s\n", description); 52 | } 53 | 54 | static int thread_main(void* data) 55 | { 56 | const Thread* thread = (const Thread*) data; 57 | 58 | glfwMakeContextCurrent(thread->window); 59 | glfwSwapInterval(1); 60 | 61 | while (running) 62 | { 63 | const float v = (float) fabs(sin(glfwGetTime() * 2.f)); 64 | glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f); 65 | 66 | glClear(GL_COLOR_BUFFER_BIT); 67 | glfwSwapBuffers(thread->window); 68 | } 69 | 70 | glfwMakeContextCurrent(NULL); 71 | return 0; 72 | } 73 | 74 | int main(void) 75 | { 76 | int i, result; 77 | Thread threads[] = 78 | { 79 | { NULL, "Red", 1.f, 0.f, 0.f, 0 }, 80 | { NULL, "Green", 0.f, 1.f, 0.f, 0 }, 81 | { NULL, "Blue", 0.f, 0.f, 1.f, 0 } 82 | }; 83 | const int count = sizeof(threads) / sizeof(Thread); 84 | 85 | glfwSetErrorCallback(error_callback); 86 | 87 | if (!glfwInit()) 88 | exit(EXIT_FAILURE); 89 | 90 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 91 | 92 | for (i = 0; i < count; i++) 93 | { 94 | threads[i].window = glfwCreateWindow(200, 200, 95 | threads[i].title, 96 | NULL, NULL); 97 | if (!threads[i].window) 98 | { 99 | glfwTerminate(); 100 | exit(EXIT_FAILURE); 101 | } 102 | 103 | glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); 104 | glfwShowWindow(threads[i].window); 105 | 106 | if (thrd_create(&threads[i].id, thread_main, threads + i) != 107 | thrd_success) 108 | { 109 | fprintf(stderr, "Failed to create secondary thread\n"); 110 | 111 | glfwTerminate(); 112 | exit(EXIT_FAILURE); 113 | } 114 | } 115 | 116 | while (running) 117 | { 118 | glfwWaitEvents(); 119 | 120 | for (i = 0; i < count; i++) 121 | { 122 | if (glfwWindowShouldClose(threads[i].window)) 123 | running = GL_FALSE; 124 | } 125 | } 126 | 127 | for (i = 0; i < count; i++) 128 | thrd_join(threads[i].id, &result); 129 | 130 | exit(EXIT_SUCCESS); 131 | } 132 | 133 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 framebuffer_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 | glfwSetFramebufferSizeCallback(window, framebuffer_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 | -------------------------------------------------------------------------------- /extern/glfw-3.0.4/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 | -------------------------------------------------------------------------------- /include/object.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/include/object.h -------------------------------------------------------------------------------- /include/sb6mfile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/include/sb6mfile.h -------------------------------------------------------------------------------- /include/sb7color.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/include/sb7color.h -------------------------------------------------------------------------------- /include/sb7ext.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/include/sb7ext.h -------------------------------------------------------------------------------- /include/sb7ktx.h: -------------------------------------------------------------------------------- 1 | #ifndef __SB6KTX_H__ 2 | #define __SB6KTX_H__ 3 | 4 | namespace sb7 5 | { 6 | 7 | namespace ktx 8 | { 9 | 10 | namespace file 11 | { 12 | 13 | struct header 14 | { 15 | unsigned char identifier[12]; 16 | unsigned int endianness; 17 | unsigned int gltype; 18 | unsigned int gltypesize; 19 | unsigned int glformat; 20 | unsigned int glinternalformat; 21 | unsigned int glbaseinternalformat; 22 | unsigned int pixelwidth; 23 | unsigned int pixelheight; 24 | unsigned int pixeldepth; 25 | unsigned int arrayelements; 26 | unsigned int faces; 27 | unsigned int miplevels; 28 | unsigned int keypairbytes; 29 | }; 30 | 31 | union keyvaluepair 32 | { 33 | unsigned int size; 34 | unsigned char rawbytes[4]; 35 | }; 36 | 37 | unsigned int load(const char * filename, unsigned int tex = 0); 38 | bool save(const char * filename, unsigned int target, unsigned int tex); 39 | 40 | } 41 | 42 | } 43 | 44 | } 45 | 46 | #endif /* __SB6KTX_H__ */ 47 | -------------------------------------------------------------------------------- /include/sb7textoverlay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012-2015 Graham Sellers 3 | * 4 | * This code is part of the OpenGL SuperBible, 7th Edition. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice (including the next 14 | * paragraph) shall be included in all copies or substantial portions of the 15 | * Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef __SB7TEXTOVERLAY_H__ 27 | #define __SB7TEXTOVERLAY_H__ 28 | 29 | #include 30 | 31 | namespace sb7 32 | { 33 | 34 | class text_overlay 35 | { 36 | public: 37 | text_overlay() 38 | : cursor_x(0), 39 | cursor_y(0) 40 | { 41 | 42 | } 43 | 44 | void init(int width, int height, const char* font = nullptr); 45 | void teardown(); 46 | void draw(); 47 | 48 | void drawText(const char* str, int x, int y); 49 | void print(const char* str); 50 | void scroll(int lines); 51 | void moveCursor(int x, int y); 52 | void clear(); 53 | 54 | private: 55 | GLuint text_buffer; 56 | GLuint font_texture; 57 | GLuint vao; 58 | 59 | GLuint text_program; 60 | char * screen_buffer; 61 | int buffer_width; 62 | int buffer_height; 63 | bool dirty; 64 | int cursor_x; 65 | int cursor_y; 66 | }; 67 | 68 | } // namespace sb7 69 | 70 | #endif /* __SB7TEXTOVERLAY_H__ */ 71 | -------------------------------------------------------------------------------- /include/shader.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHADER_H__ 2 | #define __SHADER_H__ 3 | 4 | namespace sb7 5 | { 6 | 7 | namespace shader 8 | { 9 | 10 | GLuint load(const char * filename, 11 | GLenum shader_type = GL_FRAGMENT_SHADER, 12 | #ifdef _DEBUG 13 | bool check_errors = true); 14 | #else 15 | bool check_errors = false); 16 | #endif 17 | 18 | GLuint from_string(const char * source, 19 | GLenum shader_type, 20 | #ifdef _DEBUG 21 | bool check_errors = true); 22 | #else 23 | bool check_errors = false); 24 | #endif 25 | 26 | } 27 | 28 | namespace program 29 | { 30 | 31 | GLuint link_from_shaders(const GLuint * shaders, 32 | int shader_count, 33 | bool delete_shaders, 34 | #ifdef _DEBUG 35 | bool check_errors = true); 36 | #else 37 | bool check_errors = false); 38 | #endif 39 | 40 | } 41 | 42 | } 43 | 44 | #endif /* __SHADER_H__ */ 45 | -------------------------------------------------------------------------------- /lib/!DO NOT DELETE THIS DIRECTORY: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/lib/!DO NOT DELETE THIS DIRECTORY -------------------------------------------------------------------------------- /src/alienrain/alienrain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/alienrain/alienrain.cpp -------------------------------------------------------------------------------- /src/basicfbo/basicfbo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/basicfbo/basicfbo.cpp -------------------------------------------------------------------------------- /src/bindlesstex/bindlesstex.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/bindlesstex/bindlesstex.cpp -------------------------------------------------------------------------------- /src/blendmatrix/blendmatrix.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/blendmatrix/blendmatrix.cpp -------------------------------------------------------------------------------- /src/blinnphong/blinnphong.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/blinnphong/blinnphong.cpp -------------------------------------------------------------------------------- /src/bumpmapping/bumpmapping.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/bumpmapping/bumpmapping.cpp -------------------------------------------------------------------------------- /src/clipdistance/clipdistance.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/clipdistance/clipdistance.cpp -------------------------------------------------------------------------------- /src/compressrgtc/compressrgtc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/compressrgtc/compressrgtc.cpp -------------------------------------------------------------------------------- /src/csflocking/csflocking.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/csflocking/csflocking.cpp -------------------------------------------------------------------------------- /src/cubemapenv/cubemapenv.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/cubemapenv/cubemapenv.cpp -------------------------------------------------------------------------------- /src/cubicbezier/cubicbezier.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/cubicbezier/cubicbezier.cpp -------------------------------------------------------------------------------- /src/cullindirect/cullindirect.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/cullindirect/cullindirect.cpp -------------------------------------------------------------------------------- /src/deferredshading/deferredshading.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/deferredshading/deferredshading.cpp -------------------------------------------------------------------------------- /src/depthclamp/depthclamp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/depthclamp/depthclamp.cpp -------------------------------------------------------------------------------- /src/dflandscape/dflandscape.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/dflandscape/dflandscape.cpp -------------------------------------------------------------------------------- /src/dispmap/dispmap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/dispmap/dispmap.cpp -------------------------------------------------------------------------------- /src/dof/dof.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/dof/dof.cpp -------------------------------------------------------------------------------- /src/envmapsphere/envmapsphere.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/envmapsphere/envmapsphere.cpp -------------------------------------------------------------------------------- /src/equirectangular/equirectangular.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/equirectangular/equirectangular.cpp -------------------------------------------------------------------------------- /src/fontdemo/fontdemo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/fontdemo/fontdemo.cpp -------------------------------------------------------------------------------- /src/fragcolorfrompos/fragcolorfrompos.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/fragcolorfrompos/fragcolorfrompos.cpp -------------------------------------------------------------------------------- /src/fragmentlist/fragmentlist.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/fragmentlist/fragmentlist.cpp -------------------------------------------------------------------------------- /src/grass/grass.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/grass/grass.cpp -------------------------------------------------------------------------------- /src/gsculling/gsculling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/gsculling/gsculling.cpp -------------------------------------------------------------------------------- /src/gslayered/gslayered.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/gslayered/gslayered.cpp -------------------------------------------------------------------------------- /src/gsquads/gsquads.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/gsquads/gsquads.cpp -------------------------------------------------------------------------------- /src/gstessellate/gstessellate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/gstessellate/gstessellate.cpp -------------------------------------------------------------------------------- /src/hdrbloom/hdrbloom.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/hdrbloom/hdrbloom.cpp -------------------------------------------------------------------------------- /src/hdrexposure/hdrexposure.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/hdrexposure/hdrexposure.cpp -------------------------------------------------------------------------------- /src/hdrtonemap/hdrtonemap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/hdrtonemap/hdrtonemap.cpp -------------------------------------------------------------------------------- /src/hqfilter/hqfilter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/hqfilter/hqfilter.cpp -------------------------------------------------------------------------------- /src/indexedcube/indexedcube.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/indexedcube/indexedcube.cpp -------------------------------------------------------------------------------- /src/indirectmaterial/indirectmaterial.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/indirectmaterial/indirectmaterial.cpp -------------------------------------------------------------------------------- /src/instancedattribs/instancedattribs.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/instancedattribs/instancedattribs.cpp -------------------------------------------------------------------------------- /src/julia/julia.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/julia/julia.cpp -------------------------------------------------------------------------------- /src/ktxview/ktxview.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/ktxview/ktxview.cpp -------------------------------------------------------------------------------- /src/linesmooth/linesmooth.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/linesmooth/linesmooth.cpp -------------------------------------------------------------------------------- /src/mirrorclampedge/mirrorclampedge.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/mirrorclampedge/mirrorclampedge.cpp -------------------------------------------------------------------------------- /src/movingtri/movingtri.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/movingtri/movingtri.cpp -------------------------------------------------------------------------------- /src/msaanative/msaanative.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/msaanative/msaanative.cpp -------------------------------------------------------------------------------- /src/multidrawindirect/multidrawindirect.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/multidrawindirect/multidrawindirect.cpp -------------------------------------------------------------------------------- /src/multimaterial/multimaterial.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/multimaterial/multimaterial.cpp -------------------------------------------------------------------------------- /src/multiscissor/multiscissor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/multiscissor/multiscissor.cpp -------------------------------------------------------------------------------- /src/multiviewport/multiviewport.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/multiviewport/multiviewport.cpp -------------------------------------------------------------------------------- /src/noperspective/noperspective.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/noperspective/noperspective.cpp -------------------------------------------------------------------------------- /src/normalviewer/normalviewer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/normalviewer/normalviewer.cpp -------------------------------------------------------------------------------- /src/objectexploder/objectexploder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/objectexploder/objectexploder.cpp -------------------------------------------------------------------------------- /src/ompparticles/ompparticles.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/ompparticles/ompparticles.cpp -------------------------------------------------------------------------------- /src/packetbuffer/packetbuffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/packetbuffer/packetbuffer.cpp -------------------------------------------------------------------------------- /src/perpixelgloss/perpixelgloss.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/perpixelgloss/perpixelgloss.cpp -------------------------------------------------------------------------------- /src/phonglighting/phonglighting.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/phonglighting/phonglighting.cpp -------------------------------------------------------------------------------- /src/pmbfractal/pmbfractal.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/pmbfractal/pmbfractal.cpp -------------------------------------------------------------------------------- /src/pmbstreaming/pmbstreaming.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/pmbstreaming/pmbstreaming.cpp -------------------------------------------------------------------------------- /src/polygonsmooth/polygonsmooth.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/polygonsmooth/polygonsmooth.cpp -------------------------------------------------------------------------------- /src/prefixsum/prefixsum.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/prefixsum/prefixsum.cpp -------------------------------------------------------------------------------- /src/prefixsum2d/prefixsum2d.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/prefixsum2d/prefixsum2d.cpp -------------------------------------------------------------------------------- /src/programinfo/programinfo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/programinfo/programinfo.cpp -------------------------------------------------------------------------------- /src/raytracer/raytracer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/raytracer/raytracer.cpp -------------------------------------------------------------------------------- /src/rimlight/rimlight.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/rimlight/rimlight.cpp -------------------------------------------------------------------------------- /src/sampleshading/sampleshading.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sampleshading/sampleshading.cpp -------------------------------------------------------------------------------- /src/sb6mrender/sb6mrender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sb6mrender/sb6mrender.cpp -------------------------------------------------------------------------------- /src/sb7/sb7.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright © 2012-2015 Graham Sellers 3 | * 4 | * This code is part of the OpenGL SuperBible, 6th Edition. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice (including the next 14 | * paragraph) shall be included in all copies or substantial portions of the 15 | * Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include 27 | 28 | sb7::application * sb7::application::app = 0; 29 | 30 | #include 31 | 32 | #include 33 | 34 | GL3WglProc sb6GetProcAddress(const char * funcname) 35 | { 36 | return gl3wGetProcAddress(funcname); 37 | } 38 | 39 | int sb6IsExtensionSupported(const char * extname) 40 | { 41 | GLint numExtensions; 42 | GLint i; 43 | 44 | glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); 45 | 46 | for (i = 0; i < numExtensions; i++) 47 | { 48 | const GLubyte * e = glGetStringi(GL_EXTENSIONS, i); 49 | if (!strcmp((const char *)e, extname)) 50 | { 51 | return 1; 52 | } 53 | } 54 | 55 | return 0; 56 | } 57 | void APIENTRY sb7::application::debug_callback(GLenum source, 58 | GLenum type, 59 | GLuint id, 60 | GLenum severity, 61 | GLsizei length, 62 | const GLchar* message, 63 | GLvoid* userParam) 64 | { 65 | reinterpret_cast(userParam)->onDebugMessage(source, type, id, severity, length, message); 66 | } -------------------------------------------------------------------------------- /src/sb7/sb7object.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sb7/sb7object.cpp -------------------------------------------------------------------------------- /src/sb7/sb7shader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sb7/sb7shader.cpp -------------------------------------------------------------------------------- /src/sb7/sb7textoverlay.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sb7/sb7textoverlay.cpp -------------------------------------------------------------------------------- /src/sdfdemo/sdfdemo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sdfdemo/sdfdemo.cpp -------------------------------------------------------------------------------- /src/shadowmapping/shadowmapping.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/shadowmapping/shadowmapping.cpp -------------------------------------------------------------------------------- /src/shapedpoints/shapedpoints.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/shapedpoints/shapedpoints.cpp -------------------------------------------------------------------------------- /src/simpleclear/simpleclear.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/simpleclear/simpleclear.cpp -------------------------------------------------------------------------------- /src/simpletexcoords/simpletexcoords.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/simpletexcoords/simpletexcoords.cpp -------------------------------------------------------------------------------- /src/simpletexture/simpletexture.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/simpletexture/simpletexture.cpp -------------------------------------------------------------------------------- /src/singlepoint/singlepoint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/singlepoint/singlepoint.cpp -------------------------------------------------------------------------------- /src/singletri/singletri.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/singletri/singletri.cpp -------------------------------------------------------------------------------- /src/sparsetexture/sparsetexture.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/sparsetexture/sparsetexture.cpp -------------------------------------------------------------------------------- /src/spinnycube/spinnycube.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/spinnycube/spinnycube.cpp -------------------------------------------------------------------------------- /src/springmass/springmass.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/springmass/springmass.cpp -------------------------------------------------------------------------------- /src/ssao/ssao.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/ssao/ssao.cpp -------------------------------------------------------------------------------- /src/starfield/starfield.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/starfield/starfield.cpp -------------------------------------------------------------------------------- /src/stereo/stereo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/stereo/stereo.cpp -------------------------------------------------------------------------------- /src/subroutines/subroutines.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/subroutines/subroutines.cpp -------------------------------------------------------------------------------- /src/tessellatedcube/tessellatedcube.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tessellatedcube/tessellatedcube.cpp -------------------------------------------------------------------------------- /src/tessellatedgstri/tessellatedgstri.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tessellatedgstri/tessellatedgstri.cpp -------------------------------------------------------------------------------- /src/tessellatedtri/tessellatedtri.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tessellatedtri/tessellatedtri.cpp -------------------------------------------------------------------------------- /src/tessmodes/tessmodes.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tessmodes/tessmodes.cpp -------------------------------------------------------------------------------- /src/tesssubdivmodes/tesssubdivmodes.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tesssubdivmodes/tesssubdivmodes.cpp -------------------------------------------------------------------------------- /src/toonshading/toonshading.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/toonshading/toonshading.cpp -------------------------------------------------------------------------------- /src/tunnel/tunnel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/tunnel/tunnel.cpp -------------------------------------------------------------------------------- /src/wrapmodes/wrapmodes.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openglsuperbible/sb7code/3f80b7a829442e2de9199a15e08ce7d09fd9260e/src/wrapmodes/wrapmodes.cpp --------------------------------------------------------------------------------