summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cowgill <jcowgill@debian.org>2016-08-09 15:20:03 +0000
committerJames Cowgill <jcowgill@debian.org>2016-08-09 15:20:03 +0000
commitdf93e238e30e97850d76ad5585b8ab9ad9c03e67 (patch)
tree2ae5f3305e1ee1882f563d2803f94aa6446dc367
parent301fd78b3ac87cf1fbce9d2c955db89094a304a5 (diff)
Imported Upstream version 2.4.0+dfsg
-rw-r--r--CMakeLists.txt50
-rw-r--r--changelog.txt124
-rw-r--r--cmake/Config.cmake20
-rw-r--r--cmake/Macros.cmake23
-rw-r--r--cmake/Modules/FindSFML.cmake8
-rw-r--r--cmake/toolchains/android.toolchain.cmake16
-rw-r--r--doc/doxyfile.in24
-rw-r--r--examples/android/AndroidManifest.xml2
-rw-r--r--examples/android/jni/Application.mk2
-rw-r--r--examples/android/jni/main.cpp102
-rw-r--r--examples/cocoa/CocoaAppDelegate.h2
-rw-r--r--examples/cocoa/CocoaAppDelegate.mm4
-rw-r--r--examples/cocoa/NSString+stdstring.h2
-rw-r--r--examples/cocoa/NSString+stdstring.mm2
-rw-r--r--examples/cocoa/main.m2
-rw-r--r--examples/cocoa/resources/Cocoa-Info.plist2
-rw-r--r--examples/opengl/OpenGL.cpp374
-rw-r--r--examples/pong/Pong.cpp2
-rw-r--r--examples/shader/Shader.cpp106
-rw-r--r--examples/shader/resources/billboard.frag11
-rw-r--r--examples/shader/resources/billboard.geom56
-rw-r--r--examples/shader/resources/billboard.vert5
-rw-r--r--examples/shader/resources/logo.pngbin0 -> 8849 bytes
-rw-r--r--examples/sound/Sound.cpp5
-rw-r--r--examples/sound_capture/SoundCapture.cpp3
-rw-r--r--examples/voip/Client.cpp20
-rw-r--r--include/SFML/Audio.hpp2
-rw-r--r--include/SFML/Audio/AlResource.hpp2
-rw-r--r--include/SFML/Audio/Export.hpp2
-rw-r--r--include/SFML/Audio/InputSoundFile.hpp14
-rw-r--r--include/SFML/Audio/Listener.hpp2
-rw-r--r--include/SFML/Audio/Music.hpp2
-rw-r--r--include/SFML/Audio/OutputSoundFile.hpp2
-rw-r--r--include/SFML/Audio/Sound.hpp2
-rw-r--r--include/SFML/Audio/SoundBuffer.hpp2
-rw-r--r--include/SFML/Audio/SoundBufferRecorder.hpp8
-rw-r--r--include/SFML/Audio/SoundFileFactory.hpp2
-rw-r--r--include/SFML/Audio/SoundFileFactory.inl2
-rw-r--r--include/SFML/Audio/SoundFileReader.hpp5
-rw-r--r--include/SFML/Audio/SoundFileWriter.hpp2
-rw-r--r--include/SFML/Audio/SoundRecorder.hpp46
-rw-r--r--include/SFML/Audio/SoundSource.hpp12
-rw-r--r--include/SFML/Audio/SoundStream.hpp2
-rw-r--r--include/SFML/Config.hpp44
-rw-r--r--include/SFML/Graphics.hpp2
-rw-r--r--include/SFML/Graphics/BlendMode.hpp9
-rw-r--r--include/SFML/Graphics/CircleShape.hpp2
-rw-r--r--include/SFML/Graphics/Color.hpp2
-rw-r--r--include/SFML/Graphics/ConvexShape.hpp2
-rw-r--r--include/SFML/Graphics/Drawable.hpp2
-rw-r--r--include/SFML/Graphics/Export.hpp2
-rw-r--r--include/SFML/Graphics/Font.hpp26
-rw-r--r--include/SFML/Graphics/Glsl.hpp227
-rw-r--r--include/SFML/Graphics/Glsl.inl155
-rw-r--r--include/SFML/Graphics/Glyph.hpp2
-rw-r--r--include/SFML/Graphics/Image.hpp2
-rw-r--r--include/SFML/Graphics/PrimitiveType.hpp21
-rw-r--r--include/SFML/Graphics/Rect.hpp2
-rw-r--r--include/SFML/Graphics/Rect.inl2
-rw-r--r--include/SFML/Graphics/RectangleShape.hpp2
-rw-r--r--include/SFML/Graphics/RenderStates.hpp2
-rw-r--r--include/SFML/Graphics/RenderTarget.hpp2
-rw-r--r--include/SFML/Graphics/RenderTexture.hpp20
-rw-r--r--include/SFML/Graphics/RenderWindow.hpp15
-rw-r--r--include/SFML/Graphics/Shader.hpp590
-rw-r--r--include/SFML/Graphics/Shape.hpp2
-rw-r--r--include/SFML/Graphics/Sprite.hpp2
-rw-r--r--include/SFML/Graphics/Text.hpp108
-rw-r--r--include/SFML/Graphics/Texture.hpp76
-rw-r--r--include/SFML/Graphics/Transform.hpp2
-rw-r--r--include/SFML/Graphics/Transformable.hpp2
-rw-r--r--include/SFML/Graphics/Vertex.hpp2
-rw-r--r--include/SFML/Graphics/VertexArray.hpp4
-rw-r--r--include/SFML/Graphics/View.hpp6
-rw-r--r--include/SFML/Main.hpp2
-rw-r--r--include/SFML/Network.hpp2
-rw-r--r--include/SFML/Network/Export.hpp2
-rw-r--r--include/SFML/Network/Ftp.hpp5
-rw-r--r--include/SFML/Network/Http.hpp2
-rw-r--r--include/SFML/Network/IpAddress.hpp16
-rw-r--r--include/SFML/Network/Packet.hpp2
-rw-r--r--include/SFML/Network/Socket.hpp2
-rw-r--r--include/SFML/Network/SocketHandle.hpp2
-rw-r--r--include/SFML/Network/SocketSelector.hpp2
-rw-r--r--include/SFML/Network/TcpListener.hpp8
-rw-r--r--include/SFML/Network/TcpSocket.hpp2
-rw-r--r--include/SFML/Network/UdpSocket.hpp9
-rw-r--r--include/SFML/OpenGL.hpp5
-rw-r--r--include/SFML/System.hpp2
-rw-r--r--include/SFML/System/Clock.hpp2
-rw-r--r--include/SFML/System/Err.hpp2
-rw-r--r--include/SFML/System/Export.hpp2
-rw-r--r--include/SFML/System/FileInputStream.hpp10
-rw-r--r--include/SFML/System/InputStream.hpp2
-rw-r--r--include/SFML/System/Lock.hpp2
-rw-r--r--include/SFML/System/MemoryInputStream.hpp10
-rw-r--r--include/SFML/System/Mutex.hpp2
-rw-r--r--include/SFML/System/NativeActivity.hpp62
-rw-r--r--include/SFML/System/NonCopyable.hpp2
-rw-r--r--include/SFML/System/Sleep.hpp2
-rw-r--r--include/SFML/System/String.hpp3
-rw-r--r--include/SFML/System/String.inl2
-rw-r--r--include/SFML/System/Thread.hpp2
-rw-r--r--include/SFML/System/Thread.inl2
-rw-r--r--include/SFML/System/ThreadLocal.hpp2
-rw-r--r--include/SFML/System/ThreadLocalPtr.hpp2
-rw-r--r--include/SFML/System/ThreadLocalPtr.inl2
-rw-r--r--include/SFML/System/Time.hpp2
-rw-r--r--include/SFML/System/Utf.hpp2
-rw-r--r--include/SFML/System/Utf.inl4
-rw-r--r--include/SFML/System/Vector2.hpp2
-rw-r--r--include/SFML/System/Vector2.inl2
-rw-r--r--include/SFML/System/Vector3.hpp2
-rw-r--r--include/SFML/System/Vector3.inl2
-rw-r--r--include/SFML/Window.hpp2
-rw-r--r--include/SFML/Window/Context.hpp33
-rw-r--r--include/SFML/Window/ContextSettings.hpp9
-rw-r--r--include/SFML/Window/Event.hpp2
-rw-r--r--include/SFML/Window/Export.hpp2
-rw-r--r--include/SFML/Window/GlResource.hpp2
-rw-r--r--include/SFML/Window/Joystick.hpp2
-rw-r--r--include/SFML/Window/Keyboard.hpp2
-rw-r--r--include/SFML/Window/Mouse.hpp2
-rw-r--r--include/SFML/Window/Sensor.hpp2
-rw-r--r--include/SFML/Window/Touch.hpp4
-rw-r--r--include/SFML/Window/VideoMode.hpp2
-rw-r--r--include/SFML/Window/Window.hpp25
-rw-r--r--include/SFML/Window/WindowHandle.hpp41
-rw-r--r--include/SFML/Window/WindowStyle.hpp2
-rw-r--r--license.txt2
-rw-r--r--src/SFML/Audio/ALCheck.cpp2
-rw-r--r--src/SFML/Audio/ALCheck.hpp2
-rw-r--r--src/SFML/Audio/AlResource.cpp2
-rw-r--r--src/SFML/Audio/AudioDevice.cpp2
-rw-r--r--src/SFML/Audio/AudioDevice.hpp2
-rw-r--r--src/SFML/Audio/InputSoundFile.cpp2
-rw-r--r--src/SFML/Audio/Listener.cpp2
-rw-r--r--src/SFML/Audio/Music.cpp2
-rw-r--r--src/SFML/Audio/OutputSoundFile.cpp2
-rw-r--r--src/SFML/Audio/Sound.cpp16
-rw-r--r--src/SFML/Audio/SoundBuffer.cpp2
-rw-r--r--src/SFML/Audio/SoundBufferRecorder.cpp12
-rw-r--r--src/SFML/Audio/SoundFileFactory.cpp2
-rw-r--r--src/SFML/Audio/SoundFileReaderFlac.cpp12
-rw-r--r--src/SFML/Audio/SoundFileReaderFlac.hpp10
-rw-r--r--src/SFML/Audio/SoundFileReaderOgg.cpp2
-rw-r--r--src/SFML/Audio/SoundFileReaderOgg.hpp5
-rw-r--r--src/SFML/Audio/SoundFileReaderWav.cpp39
-rw-r--r--src/SFML/Audio/SoundFileReaderWav.hpp6
-rw-r--r--src/SFML/Audio/SoundFileWriterFlac.cpp2
-rw-r--r--src/SFML/Audio/SoundFileWriterFlac.hpp2
-rw-r--r--src/SFML/Audio/SoundFileWriterOgg.cpp34
-rw-r--r--src/SFML/Audio/SoundFileWriterOgg.hpp2
-rw-r--r--src/SFML/Audio/SoundFileWriterWav.cpp2
-rw-r--r--src/SFML/Audio/SoundFileWriterWav.hpp2
-rw-r--r--src/SFML/Audio/SoundRecorder.cpp72
-rw-r--r--src/SFML/Audio/SoundSource.cpp21
-rw-r--r--src/SFML/Audio/SoundStream.cpp6
-rw-r--r--src/SFML/CMakeLists.txt16
-rw-r--r--src/SFML/Graphics/BlendMode.cpp2
-rw-r--r--src/SFML/Graphics/CMakeLists.txt3
-rw-r--r--src/SFML/Graphics/CircleShape.cpp2
-rw-r--r--src/SFML/Graphics/Color.cpp2
-rw-r--r--src/SFML/Graphics/ConvexShape.cpp2
-rw-r--r--src/SFML/Graphics/Font.cpp92
-rw-r--r--src/SFML/Graphics/GLCheck.cpp2
-rw-r--r--src/SFML/Graphics/GLCheck.hpp2
-rw-r--r--src/SFML/Graphics/GLExtensions.cpp12
-rw-r--r--src/SFML/Graphics/GLExtensions.hpp32
-rw-r--r--src/SFML/Graphics/GLExtensions.txt8
-rw-r--r--src/SFML/Graphics/GLLoader.cpp1146
-rw-r--r--src/SFML/Graphics/GLLoader.hpp858
-rw-r--r--src/SFML/Graphics/Glsl.cpp86
-rw-r--r--src/SFML/Graphics/Image.cpp2
-rw-r--r--src/SFML/Graphics/ImageLoader.cpp47
-rw-r--r--src/SFML/Graphics/ImageLoader.hpp2
-rw-r--r--src/SFML/Graphics/RectangleShape.cpp2
-rw-r--r--src/SFML/Graphics/RenderStates.cpp2
-rw-r--r--src/SFML/Graphics/RenderTarget.cpp3
-rw-r--r--src/SFML/Graphics/RenderTexture.cpp10
-rw-r--r--src/SFML/Graphics/RenderTextureImpl.cpp2
-rw-r--r--src/SFML/Graphics/RenderTextureImpl.hpp2
-rw-r--r--src/SFML/Graphics/RenderTextureImplDefault.cpp2
-rw-r--r--src/SFML/Graphics/RenderTextureImplDefault.hpp2
-rw-r--r--src/SFML/Graphics/RenderTextureImplFBO.cpp3
-rw-r--r--src/SFML/Graphics/RenderTextureImplFBO.hpp2
-rw-r--r--src/SFML/Graphics/RenderWindow.cpp29
-rw-r--r--src/SFML/Graphics/Shader.cpp751
-rw-r--r--src/SFML/Graphics/Shape.cpp6
-rw-r--r--src/SFML/Graphics/Sprite.cpp4
-rw-r--r--src/SFML/Graphics/Text.cpp246
-rw-r--r--src/SFML/Graphics/Texture.cpp118
-rw-r--r--src/SFML/Graphics/TextureSaver.cpp2
-rw-r--r--src/SFML/Graphics/TextureSaver.hpp2
-rw-r--r--src/SFML/Graphics/Transform.cpp2
-rw-r--r--src/SFML/Graphics/Transformable.cpp2
-rw-r--r--src/SFML/Graphics/Vertex.cpp2
-rw-r--r--src/SFML/Graphics/VertexArray.cpp2
-rw-r--r--src/SFML/Graphics/View.cpp2
-rw-r--r--src/SFML/Main/MainAndroid.cpp2
-rw-r--r--src/SFML/Main/MainWin32.cpp9
-rw-r--r--src/SFML/Main/MainiOS.mm2
-rw-r--r--src/SFML/Network/Ftp.cpp19
-rw-r--r--src/SFML/Network/Http.cpp5
-rw-r--r--src/SFML/Network/IpAddress.cpp116
-rw-r--r--src/SFML/Network/Packet.cpp2
-rw-r--r--src/SFML/Network/Socket.cpp9
-rw-r--r--src/SFML/Network/SocketImpl.hpp2
-rw-r--r--src/SFML/Network/SocketSelector.cpp2
-rw-r--r--src/SFML/Network/TcpListener.cpp12
-rw-r--r--src/SFML/Network/TcpSocket.cpp2
-rw-r--r--src/SFML/Network/UdpSocket.cpp12
-rw-r--r--src/SFML/Network/Unix/SocketImpl.cpp14
-rw-r--r--src/SFML/Network/Unix/SocketImpl.hpp2
-rw-r--r--src/SFML/Network/Win32/SocketImpl.cpp2
-rw-r--r--src/SFML/Network/Win32/SocketImpl.hpp2
-rw-r--r--src/SFML/System/Android/Activity.cpp2
-rw-r--r--src/SFML/System/Android/NativeActivity.cpp39
-rw-r--r--src/SFML/System/Android/ResourceStream.cpp41
-rw-r--r--src/SFML/System/CMakeLists.txt2
-rw-r--r--src/SFML/System/Clock.cpp2
-rw-r--r--src/SFML/System/Err.cpp2
-rw-r--r--src/SFML/System/FileInputStream.cpp6
-rw-r--r--src/SFML/System/Lock.cpp2
-rw-r--r--src/SFML/System/MemoryInputStream.cpp2
-rw-r--r--src/SFML/System/Mutex.cpp2
-rw-r--r--src/SFML/System/Sleep.cpp2
-rw-r--r--src/SFML/System/String.cpp2
-rw-r--r--src/SFML/System/Thread.cpp2
-rw-r--r--src/SFML/System/ThreadLocal.cpp2
-rw-r--r--src/SFML/System/Time.cpp2
-rw-r--r--src/SFML/System/Unix/ClockImpl.cpp2
-rw-r--r--src/SFML/System/Unix/ClockImpl.hpp2
-rw-r--r--src/SFML/System/Unix/MutexImpl.cpp2
-rw-r--r--src/SFML/System/Unix/MutexImpl.hpp2
-rw-r--r--src/SFML/System/Unix/SleepImpl.cpp2
-rw-r--r--src/SFML/System/Unix/SleepImpl.hpp2
-rw-r--r--src/SFML/System/Unix/ThreadImpl.cpp2
-rw-r--r--src/SFML/System/Unix/ThreadImpl.hpp2
-rw-r--r--src/SFML/System/Unix/ThreadLocalImpl.cpp5
-rw-r--r--src/SFML/System/Unix/ThreadLocalImpl.hpp2
-rw-r--r--src/SFML/System/Win32/ClockImpl.cpp2
-rw-r--r--src/SFML/System/Win32/ClockImpl.hpp2
-rw-r--r--src/SFML/System/Win32/MutexImpl.cpp2
-rw-r--r--src/SFML/System/Win32/MutexImpl.hpp2
-rw-r--r--src/SFML/System/Win32/SleepImpl.cpp2
-rw-r--r--src/SFML/System/Win32/SleepImpl.hpp2
-rw-r--r--src/SFML/System/Win32/ThreadImpl.cpp2
-rw-r--r--src/SFML/System/Win32/ThreadImpl.hpp2
-rw-r--r--src/SFML/System/Win32/ThreadLocalImpl.cpp2
-rw-r--r--src/SFML/System/Win32/ThreadLocalImpl.hpp2
-rw-r--r--src/SFML/Window/Android/InputImpl.cpp1
-rw-r--r--src/SFML/Window/Android/SensorImpl.cpp2
-rw-r--r--src/SFML/Window/Android/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/Android/WindowImplAndroid.cpp15
-rw-r--r--src/SFML/Window/Android/WindowImplAndroid.hpp8
-rw-r--r--src/SFML/Window/CMakeLists.txt9
-rw-r--r--src/SFML/Window/Context.cpp110
-rw-r--r--src/SFML/Window/EglContext.cpp25
-rw-r--r--src/SFML/Window/EglContext.hpp5
-rw-r--r--src/SFML/Window/FreeBSD/JoystickImpl.cpp2
-rw-r--r--src/SFML/Window/FreeBSD/JoystickImpl.hpp2
-rw-r--r--src/SFML/Window/GlContext.cpp72
-rw-r--r--src/SFML/Window/GlContext.hpp8
-rw-r--r--src/SFML/Window/GlResource.cpp2
-rw-r--r--src/SFML/Window/InputImpl.hpp2
-rw-r--r--src/SFML/Window/Joystick.cpp2
-rw-r--r--src/SFML/Window/JoystickImpl.hpp2
-rw-r--r--src/SFML/Window/JoystickManager.cpp2
-rw-r--r--src/SFML/Window/JoystickManager.hpp2
-rw-r--r--src/SFML/Window/Keyboard.cpp2
-rw-r--r--src/SFML/Window/Mouse.cpp2
-rw-r--r--src/SFML/Window/OSX/AutoreleasePoolWrapper.h22
-rw-r--r--src/SFML/Window/OSX/AutoreleasePoolWrapper.mm168
-rw-r--r--src/SFML/Window/OSX/HIDInputManager.hpp2
-rw-r--r--src/SFML/Window/OSX/HIDInputManager.mm6
-rw-r--r--src/SFML/Window/OSX/HIDJoystickManager.cpp6
-rw-r--r--src/SFML/Window/OSX/HIDJoystickManager.hpp2
-rw-r--r--src/SFML/Window/OSX/InputImpl.hpp2
-rw-r--r--src/SFML/Window/OSX/InputImpl.mm4
-rw-r--r--src/SFML/Window/OSX/JoystickImpl.cpp2
-rw-r--r--src/SFML/Window/OSX/JoystickImpl.hpp2
-rw-r--r--src/SFML/Window/OSX/NSImage+raw.h52
-rw-r--r--src/SFML/Window/OSX/NSImage+raw.mm68
-rw-r--r--src/SFML/Window/OSX/SFApplication.h2
-rw-r--r--src/SFML/Window/OSX/SFApplication.m2
-rw-r--r--src/SFML/Window/OSX/SFApplicationDelegate.h2
-rw-r--r--src/SFML/Window/OSX/SFApplicationDelegate.m2
-rw-r--r--src/SFML/Window/OSX/SFContext.hpp2
-rw-r--r--src/SFML/Window/OSX/SFContext.mm13
-rw-r--r--src/SFML/Window/OSX/SFKeyboardModifiersHelper.h2
-rw-r--r--src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm2
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView+keyboard.mm220
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView+keyboard_priv.h68
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView+mouse.mm402
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView+mouse_priv.h110
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView.h65
-rw-r--r--src/SFML/Window/OSX/SFOpenGLView.mm507
-rw-r--r--src/SFML/Window/OSX/SFSilentResponder.h2
-rw-r--r--src/SFML/Window/OSX/SFSilentResponder.m2
-rw-r--r--src/SFML/Window/OSX/SFViewController.h2
-rw-r--r--src/SFML/Window/OSX/SFViewController.mm9
-rw-r--r--src/SFML/Window/OSX/SFWindow.h2
-rw-r--r--src/SFML/Window/OSX/SFWindow.m2
-rw-r--r--src/SFML/Window/OSX/SFWindowController.h9
-rw-r--r--src/SFML/Window/OSX/SFWindowController.mm181
-rw-r--r--src/SFML/Window/OSX/Scaling.h103
-rw-r--r--src/SFML/Window/OSX/SensorImpl.cpp2
-rw-r--r--src/SFML/Window/OSX/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/OSX/VideoModeImpl.cpp25
-rw-r--r--src/SFML/Window/OSX/WindowImplCocoa.hpp10
-rw-r--r--src/SFML/Window/OSX/WindowImplCocoa.mm92
-rw-r--r--src/SFML/Window/OSX/WindowImplDelegateProtocol.h10
-rw-r--r--src/SFML/Window/OSX/cg_sf_conversion.hpp2
-rw-r--r--src/SFML/Window/OSX/cg_sf_conversion.mm (renamed from src/SFML/Window/OSX/cg_sf_conversion.cpp)63
-rw-r--r--src/SFML/Window/OSX/cpp_objc_conversion.h2
-rw-r--r--src/SFML/Window/OSX/cpp_objc_conversion.mm2
-rw-r--r--src/SFML/Window/Sensor.cpp2
-rw-r--r--src/SFML/Window/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/SensorManager.cpp2
-rw-r--r--src/SFML/Window/SensorManager.hpp2
-rw-r--r--src/SFML/Window/Touch.cpp2
-rw-r--r--src/SFML/Window/Unix/Display.cpp2
-rw-r--r--src/SFML/Window/Unix/Display.hpp2
-rw-r--r--src/SFML/Window/Unix/GlxContext.cpp451
-rw-r--r--src/SFML/Window/Unix/GlxContext.hpp40
-rw-r--r--src/SFML/Window/Unix/GlxExtensions.cpp135
-rw-r--r--src/SFML/Window/Unix/GlxExtensions.hpp89
-rw-r--r--src/SFML/Window/Unix/GlxExtensions.txt9
-rw-r--r--src/SFML/Window/Unix/InputImpl.cpp2
-rw-r--r--src/SFML/Window/Unix/InputImpl.hpp2
-rw-r--r--src/SFML/Window/Unix/JoystickImpl.cpp38
-rw-r--r--src/SFML/Window/Unix/JoystickImpl.hpp8
-rw-r--r--src/SFML/Window/Unix/ScopedXcbPtr.hpp2
-rw-r--r--src/SFML/Window/Unix/ScopedXcbPtr.inl2
-rw-r--r--src/SFML/Window/Unix/SensorImpl.cpp2
-rw-r--r--src/SFML/Window/Unix/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/Unix/VideoModeImpl.cpp2
-rw-r--r--src/SFML/Window/Unix/WindowImplX11.cpp224
-rw-r--r--src/SFML/Window/Unix/WindowImplX11.hpp16
-rw-r--r--src/SFML/Window/VideoMode.cpp2
-rw-r--r--src/SFML/Window/VideoModeImpl.hpp2
-rw-r--r--src/SFML/Window/Win32/InputImpl.cpp2
-rw-r--r--src/SFML/Window/Win32/InputImpl.hpp2
-rw-r--r--src/SFML/Window/Win32/JoystickImpl.cpp2
-rw-r--r--src/SFML/Window/Win32/JoystickImpl.hpp2
-rw-r--r--src/SFML/Window/Win32/SensorImpl.cpp2
-rw-r--r--src/SFML/Window/Win32/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/Win32/VideoModeImpl.cpp2
-rw-r--r--src/SFML/Window/Win32/WglContext.cpp290
-rw-r--r--src/SFML/Window/Win32/WglContext.hpp57
-rw-r--r--src/SFML/Window/Win32/WglExtensions.cpp153
-rw-r--r--src/SFML/Window/Win32/WglExtensions.hpp58
-rw-r--r--src/SFML/Window/Win32/WglExtensions.txt7
-rw-r--r--src/SFML/Window/Win32/WindowImplWin32.cpp56
-rw-r--r--src/SFML/Window/Win32/WindowImplWin32.hpp25
-rw-r--r--src/SFML/Window/Window.cpp10
-rw-r--r--src/SFML/Window/WindowImpl.cpp2
-rw-r--r--src/SFML/Window/WindowImpl.hpp10
-rw-r--r--src/SFML/Window/iOS/EaglContext.hpp2
-rw-r--r--src/SFML/Window/iOS/EaglContext.mm2
-rw-r--r--src/SFML/Window/iOS/InputImpl.hpp2
-rw-r--r--src/SFML/Window/iOS/InputImpl.mm2
-rw-r--r--src/SFML/Window/iOS/JoystickImpl.hpp2
-rw-r--r--src/SFML/Window/iOS/JoystickImpl.mm2
-rw-r--r--src/SFML/Window/iOS/ObjCType.hpp2
-rw-r--r--src/SFML/Window/iOS/SFAppDelegate.hpp2
-rw-r--r--src/SFML/Window/iOS/SFAppDelegate.mm2
-rw-r--r--src/SFML/Window/iOS/SFMain.hpp2
-rw-r--r--src/SFML/Window/iOS/SFMain.mm2
-rw-r--r--src/SFML/Window/iOS/SFView.hpp2
-rw-r--r--src/SFML/Window/iOS/SFView.mm2
-rw-r--r--src/SFML/Window/iOS/SFViewController.hpp2
-rw-r--r--src/SFML/Window/iOS/SFViewController.mm2
-rw-r--r--src/SFML/Window/iOS/SensorImpl.hpp2
-rw-r--r--src/SFML/Window/iOS/SensorImpl.mm2
-rw-r--r--src/SFML/Window/iOS/VideoModeImpl.mm2
-rw-r--r--src/SFML/Window/iOS/WindowImplUIKit.hpp10
-rw-r--r--src/SFML/Window/iOS/WindowImplUIKit.mm9
379 files changed, 8159 insertions, 3041 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c852100..aeed46a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,8 +39,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake)
# setup version numbers
set(VERSION_MAJOR 2)
-set(VERSION_MINOR 3)
-set(VERSION_PATCH 2)
+set(VERSION_MINOR 4)
+set(VERSION_PATCH 0)
# add the SFML header path
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -125,9 +125,19 @@ if(NOT BUILD_SHARED_LIBS)
add_definitions(-DSFML_STATIC)
endif()
-# remove SL security warnings with Visual C++
+# Visual C++: remove warnings regarding SL security and algorithms on pointers
if(SFML_COMPILER_MSVC)
- add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
+ # add an option to choose whether PDB debug symbols should be generated (defaults to true when possible)
+ if(CMAKE_VERSION VERSION_LESS 3.1)
+ sfml_set_option(SFML_GENERATE_PDB FALSE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1.")
+ if(SFML_GENERATE_PDB)
+ message(FATAL_ERROR "Generation of PDB files (SFML_GENERATE_PDB) requires at least CMake 3.1.0")
+ endif()
+ else()
+ sfml_set_option(SFML_GENERATE_PDB TRUE BOOL "True to generate PDB debug symbols, FALSE otherwise. Requires CMake 3.1.")
+ endif()
+
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
endif()
# define SFML_OPENGL_ES if needed
@@ -177,15 +187,14 @@ if(SFML_OS_MACOSX)
endif()
endif()
- # configure Xcode templates
- if(CMAKE_OSX_ARCHITECTURES)
- # maybe multiple arches are present in CMAKE_OSX_ARCHITECTURES
- # we simply need to replace ';' by ' ' (space) and store the result in XCODE_TEMPLATES_ARCH
- string(REPLACE ";" " " XCODE_TEMPLATES_ARCH "${CMAKE_OSX_ARCHITECTURES}")
- else()
- # no arch was provided to cmake, so we use the default one
- set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)")
+ # only the default architecture (i.e. 64-bit) is supported
+ if(CMAKE_OSX_ARCHITECTURES AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
+ message(FATAL_ERROR "Only 64-bit architecture is supported")
+ return()
endif()
+
+ # configure Xcode templates
+ set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)")
endif()
if(SFML_OS_LINUX OR SFML_OS_FREEBSD)
@@ -231,6 +240,13 @@ if(NOT SFML_BUILD_FRAMEWORKS)
DESTINATION .
COMPONENT devel
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
+
+ if(SFML_GENERATE_PDB)
+ install(DIRECTORY ${PROJECT_BINARY_DIR}/lib
+ DESTINATION .
+ COMPONENT devel
+ FILES_MATCHING PATTERN "*.pdb")
+ endif()
else()
# find only "root" headers
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")
@@ -264,7 +280,7 @@ else()
COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* $<TARGET_FILE_DIR:SFML>/Headers)
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
- # NOTE: it's not required to link agains SFML.framework
+ # NOTE: it's not required to link against SFML.framework
set_target_properties(SFML PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
@@ -287,15 +303,19 @@ if(SFML_OS_WINDOWS)
# install the binaries of SFML dependencies
if(ARCH_32BITS)
install(DIRECTORY extlibs/bin/x86/ DESTINATION bin)
- if(SFML_COMPILER_MSVC)
+ if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION lib)
+ elseif(SFML_COMPILER_MSVC)
+ install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION lib)
else()
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION lib)
endif()
elseif(ARCH_64BITS)
install(DIRECTORY extlibs/bin/x64/ DESTINATION bin)
- if(SFML_COMPILER_MSVC)
+ if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION lib)
+ elseif(SFML_COMPILER_MSVC)
+ install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION lib)
else()
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION lib)
endif()
diff --git a/changelog.txt b/changelog.txt
index 80ded9c..ff61a53 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,122 @@
+SFML 2.4.0
+==========
+
+Also available on the website: http://www.sfml-dev.org/changelog.php#sfml-2.4.0
+
+General
+=======
+
+* Added deprecation macro (#969)
+* Fixed issues reported by Coverity Scan static analysis (#1064)
+* Fixed some initialization issues reported by Cppcheck (#1008)
+* Changed comment chars in FindSFML.cmake to # (#1090)
+* Fixed some typos (#1098, #993, #1099, #956, #963, #979)
+* Updated/fixed string comparisons in Config.cmake (#1102)
+* Added the missing -s postfix for the RelWithDebInfo config (#1014)
+* [Android] Fixed current Android compilation issues (#1116, #1111, #1079)
+* [OS X] Update Xcode template material (#976, #968)
+* [Windows] Added support for VS 2015 (#972)
+* [Windows] Create and install PDB debug symbols alongside binaries (#1037)
+
+Deprecated API
+==============
+
+* sf::RenderWindow::capture(): Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
+* sf::Shader::setParameter(): Use setUniform() instead.
+* sf::Text::getColor(): There is now fill and outline colors instead of a single global color. Use getFillColor() or getOutlineColor() instead.
+* sf::Text::setColor(): There is now fill and outline colors instead of a single global color. Use setFillColor() or setOutlineColor() instead.
+* sf::LinesStrip: Use LineStrip instead.
+* sf::TrianglesFan: Use TriangleFan instead.
+* sf::TrianglesStrip: Use TriangleStrip instead.
+
+System
+======
+
+Features
+--------
+* [Android] Added sf::getNativeActivity() (#1005, #680)
+
+Bugfixes
+--------
+* Added missing <iterator> include in String.hpp (#1069, #1068)
+* Fixed encoding of UTF-16 (#997)
+* [Android] Fixed crash when trying to load a non-existing font file (#1058)
+
+
+Window
+======
+
+Features
+--------
+* Added ability to grab cursor (#614, #394, #1107)
+* Added Multi-GPU preference (#869, #867)
+* Added support for sRGB capable framebuffers (#981, #175)
+* [Linux, Windows] Improved OpenGL context creation (#884)
+* [Linux, Windows] Added support for pbuffers on Windows and Unix (#885, #434)
+
+Bugfixes
+--------
+* Updated platform-specific handle documentation (#961)
+* [Android] Accept touch events from "multiple" devices (#954, #953)
+* [Android] Copy the selected EGL context's settings to SFML (#1039)
+* [Linux] Fixed modifiers causing sf::Keyboard::Unknown being returned (#1022, #1012)
+* [OS X] Improved memory management on OS X (#962, #790)
+* [OS X] Fixed crash when resizing a window to a zero-height/width size (#986, #984)
+* [OS X] Use the mouse button constant instead of 0 to avoid a compiler error on OSX (#1035)
+* [OS X] OS X improvement: warnings + bugfix + refactoring, the lot! (#1042)
+
+
+Graphics
+========
+
+Features
+--------
+* Added support for outlined text (#840)
+* Add support for geometry shaders (#886, #428)
+* Feature/blend mode reverse subtract (#945, #944)
+* Implemented support for mipmap generation (#973, #498, #123)
+* Added new API to set shader uniforms (#983, #538)
+* Rewrite RenderWindow::capture (#1001)
+
+Bugfixes
+--------
+* Exporting some Glsl utility functions due to linking issues (#1044, #1046)
+* Fixed missing initialisation of Font::m_stroker (#1059)
+* Changed primitive types to be grammatically correct (#1095, #939)
+
+
+Audio
+=====
+
+Features
+--------
+* Implemented stereo audio recording (#1010)
+
+Bugfixes
+--------
+* Added an assignment operator to SoundSource (#864)
+* [OS X] Updates OpenAL-soft for OS X to version 1.17.2 (#1057, #900, #1000)
+* Fixed a bug where vorbis can't handle large buffers (#1067)
+* Added support for 24-bit .wav files (#958, #955)
+* Fixed threading issue in sf::SoundRecorder (#1011)
+* Made WAV file reader no longer assume that data chunk goes till end of file to prevent reading trailing metadata as samples (#1018)
+* Fixed seeking in multi channel FLAC files (#1041, #1040)
+
+Network
+=======
+
+Features
+--------
+* Added optional argument on which address to bind (socket). (#850, #678)
+
+Bugfixes
+--------
+* Fixed FTP directory listing blocking forever (#1086, #1025)
+
+
+
+
+
SFML 2.3.2
==========
@@ -91,6 +210,11 @@ General
* [Linux] Fixed missing pthread dependency (#794)
* [OS X] Relaxed CMake installation rules regarding framework dependencies (#767)
+Deprecated API
+==============
+
+* sf::Event::MouseWheelEvent: This event is deprecated and potentially inaccurate. Use MouseWheelScrollEvent instead.
+
Window
======
diff --git a/cmake/Config.cmake b/cmake/Config.cmake
index 08c83ef..6506ac0 100644
--- a/cmake/Config.cmake
+++ b/cmake/Config.cmake
@@ -1,5 +1,5 @@
# detect the OS
-if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(SFML_OS_WINDOWS 1)
# don't use the OpenGL ES implementation on Windows
@@ -8,15 +8,15 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# detect the architecture (note: this test won't work for cross-compilation)
include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
- if("${SIZEOF_VOID_PTR}" STREQUAL "4")
+ if(${SIZEOF_VOID_PTR} STREQUAL "4")
set(ARCH_32BITS 1)
- elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
+ elseif(${SIZEOF_VOID_PTR} STREQUAL "8")
set(ARCH_64BITS 1)
else()
message(FATAL_ERROR "Unsupported architecture")
return()
endif()
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(SFML_OS_UNIX 1)
if(ANDROID)
set(SFML_OS_ANDROID 1)
@@ -27,11 +27,11 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# don't use the OpenGL ES implementation on Linux
set(OPENGL_ES 0)
endif()
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(SFML_OS_FREEBSD 1)
# don't use the OpenGL ES implementation on FreeBSD
set(OPENGL_ES 0)
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(IOS)
set(SFML_OS_IOS 1)
@@ -59,13 +59,13 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
return()
endif()
endif()
-elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(SFML_OS_ANDROID 1)
# use the OpenGL ES implementation on Android
set(OPENGL_ES 1)
else()
- message(FATAL_ERROR "Unsupported operating system")
+ message(FATAL_ERROR "Unsupported operating system or environment")
return()
endif()
@@ -86,7 +86,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
- if(${GCC_MACHINE} MATCHES ".*w64.*")
+ if(GCC_MACHINE MATCHES ".*w64.*")
set(SFML_COMPILER_GCC_W64 1)
endif()
elseif(MSVC)
@@ -101,6 +101,8 @@ elseif(MSVC)
set(SFML_MSVC_VERSION 11)
elseif(MSVC_VERSION EQUAL 1800)
set(SFML_MSVC_VERSION 12)
+ elseif(MSVC_VERSION EQUAL 1900)
+ set(SFML_MSVC_VERSION 14)
endif()
else()
message(FATAL_ERROR "Unsupported compiler")
diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake
index 0cf8826..cd2ca8f 100644
--- a/cmake/Macros.cmake
+++ b/cmake/Macros.cmake
@@ -37,6 +37,7 @@ macro(sfml_add_library target)
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
+ set_target_properties(${target} PROPERTIES RELWITHDEBINFO_POSTFIX -s)
endif()
# set the version and soversion of the target (for compatible systems -- mostly Linuxes)
@@ -58,6 +59,28 @@ macro(sfml_add_library target)
endif()
endif()
+ # For Visual Studio on Windows, export debug symbols (PDB files) to lib directory
+ if(SFML_GENERATE_PDB)
+ # PDB files are only generated in Debug and RelWithDebInfo configurations, find out which one
+ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+ set(SFML_PDB_POSTFIX "-d")
+ else()
+ set(SFML_PDB_POSTFIX "")
+ endif()
+
+ if(BUILD_SHARED_LIBS)
+ # DLLs export debug symbols in the linker PDB (the compiler PDB is an intermediate file)
+ set_target_properties(${target} PROPERTIES
+ PDB_NAME "${target}${SFML_PDB_POSTFIX}"
+ PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
+ else()
+ # Static libraries have no linker PDBs, thus the compiler PDBs are relevant
+ set_target_properties(${target} PROPERTIES
+ COMPILE_PDB_NAME "${target}-s${SFML_PDB_POSTFIX}"
+ COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
+ endif()
+ endif()
+
# if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
# (exported ones are explicitly marked)
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
diff --git a/cmake/Modules/FindSFML.cmake b/cmake/Modules/FindSFML.cmake
index 871f866..fdea1eb 100644
--- a/cmake/Modules/FindSFML.cmake
+++ b/cmake/Modules/FindSFML.cmake
@@ -7,14 +7,14 @@
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
# example:
-# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
+# find_package(SFML COMPONENTS graphics window system) # find the graphics, window and system modules
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
# example:
-# find_package(SFML COMPONENTS ...) // no specific version required
-# find_package(SFML 2 COMPONENTS ...) // any 2.x version
-# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
+# find_package(SFML COMPONENTS ...) # no specific version required
+# find_package(SFML 2 COMPONENTS ...) # any 2.x version
+# find_package(SFML 2.4 COMPONENTS ...) # version 2.4 or greater
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
diff --git a/cmake/toolchains/android.toolchain.cmake b/cmake/toolchains/android.toolchain.cmake
index 1eeebe5..d0fdf00 100644
--- a/cmake/toolchains/android.toolchain.cmake
+++ b/cmake/toolchains/android.toolchain.cmake
@@ -600,7 +600,7 @@ if( BUILD_WITH_ANDROID_NDK )
endif()
if( NOT __availableToolchains )
file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" )
- if( __availableToolchains )
+ if( __availableToolchainsLst )
list(SORT __availableToolchainsLst) # we need clang to go after gcc
endif()
__LIST_FILTER( __availableToolchainsLst "^[.]" )
@@ -847,8 +847,8 @@ The possible values are:
stlport_shared -> Use the STLport runtime as a shared library.
gnustl_static -> (default) Use the GNU STL as a static library.
gnustl_shared -> Use the GNU STL as a shared library.
- c++_static -> Use libc++ as a static library.
- c++_shared -> Use libc++ as a shared library.
+ c++_static -> Use libc++ as a static library.
+ c++_shared -> Use libc++ as a shared library.
" )
endif()
elseif( BUILD_WITH_STANDALONE_TOOLCHAIN )
@@ -973,6 +973,7 @@ if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFF
set( _clang_name "clang" )
endif()
+
# setup paths and STL for NDK
if( BUILD_WITH_ANDROID_NDK )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
@@ -990,7 +991,7 @@ if( BUILD_WITH_ANDROID_NDK )
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
elseif( ANDROID_STL MATCHES "gabi" )
if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
- message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
+ message( FATAL_ERROR "gabi++ is not available in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
endif()
set( ANDROID_RTTI ON )
set( ANDROID_EXCEPTIONS OFF )
@@ -1122,7 +1123,12 @@ if( NOT CMAKE_C_COMPILER )
endif()
set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" )
set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
- set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
+ if( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" )
+ # Use gcc-ar if we have it for better LTO support.
+ set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
+ else()
+ set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
+ endif()
set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" )
set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
diff --git a/doc/doxyfile.in b/doc/doxyfile.in
index 47622e6..9a44a6a 100644
--- a/doc/doxyfile.in
+++ b/doc/doxyfile.in
@@ -301,7 +301,7 @@ EXTENSION_MAPPING =
# case of backward compatibilities issues.
# The default value is: YES.
-MARKDOWN_SUPPORT = NO
+MARKDOWN_SUPPORT = YES
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
@@ -2000,7 +2000,9 @@ PREDEFINED = SFML_SYSTEM_API \
SFML_NETWORK_API \
SFML_WINDOW_API \
SFML_AUDIO_API \
- SFML_GRAPHICS_API
+ SFML_GRAPHICS_API \
+ SFML_DEPRECATED \
+ SFML_DOXYGEN
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
@@ -2375,3 +2377,21 @@ GENERATE_LEGEND = YES
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_CLEANUP = YES
+
+#---------------------------------------------------------------------------
+# SFML specific aliases
+#---------------------------------------------------------------------------
+
+# sfplatform{platform(s)}
+# sfplatform{platform(s), header}
+#
+# Warns the user that some specific class or function is only available on
+# specific platforms.
+#
+# This shouldn't be used for incomplete implementations. It's meant for things
+# that will never appear on another platform, e.g. Android's native activity.
+#
+# If a header is given, the user is informed, that this header must be included
+# for the mentioned element to be defined.
+ALIASES += sfplatform{1}="<dl class=\"attention\"><dt>Platform Limitation</dt><dd><b>This is only available on \1.</b></dd></dl>"
+ALIASES += sfplatform{2}="<dl class=\"attention\"><dt>Platform Limitation</dt><dd><b>This is only available on \1</b> and to use it, you'll have to specifically include \2 in your code.</dd></dl>"
diff --git a/examples/android/AndroidManifest.xml b/examples/android/AndroidManifest.xml
index beb3538..edee84f 100644
--- a/examples/android/AndroidManifest.xml
+++ b/examples/android/AndroidManifest.xml
@@ -10,6 +10,8 @@
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19" />
+ <uses-permission android:name="android.permission.VIBRATE" />
+
<application android:label="@string/app_name"
android:icon="@drawable/sfml_logo"
android:hasCode="false"
diff --git a/examples/android/jni/Application.mk b/examples/android/jni/Application.mk
index a18107b..71828c8 100644
--- a/examples/android/jni/Application.mk
+++ b/examples/android/jni/Application.mk
@@ -1,4 +1,4 @@
-NDK_TOOLCHAIN_VERSION := 4.8
+NDK_TOOLCHAIN_VERSION := 4.9
APP_PLATFORM := android-9
APP_STL := c++_shared
APP_ABI := armeabi-v7a
diff --git a/examples/android/jni/main.cpp b/examples/android/jni/main.cpp
index a8e75de..56b6741 100644
--- a/examples/android/jni/main.cpp
+++ b/examples/android/jni/main.cpp
@@ -4,7 +4,76 @@
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
+// Do we want to showcase direct JNI/NDK interaction?
+// Undefine this to get real cross-platform code.
+#define USE_JNI
+#if defined(USE_JNI)
+// These headers are only needed for direct NDK/JDK interaction
+#include <jni.h>
+#include <android/native_activity.h>
+
+// Since we want to get the native activity from SFML, we'll have to use an
+// extra header here:
+#include <SFML/System/NativeActivity.hpp>
+
+// NDK/JNI sub example - call Java code from native code
+int vibrate(sf::Time duration)
+{
+ // First we'll need the native activity handle
+ ANativeActivity *activity = sf::getNativeActivity();
+
+ // Retrieve the JVM and JNI environment
+ JavaVM* vm = activity->vm;
+ JNIEnv* env = activity->env;
+
+ // First, attach this thread to the main thread
+ JavaVMAttachArgs attachargs;
+ attachargs.version = JNI_VERSION_1_6;
+ attachargs.name = "NativeThread";
+ attachargs.group = NULL;
+ jint res = vm->AttachCurrentThread(&env, &attachargs);
+
+ if (res == JNI_ERR)
+ return EXIT_FAILURE;
+
+ // Retrieve class information
+ jclass natact = env->FindClass("android/app/NativeActivity");
+ jclass context = env->FindClass("android/content/Context");
+
+ // Get the value of a constant
+ jfieldID fid = env->GetStaticFieldID(context, "VIBRATOR_SERVICE", "Ljava/lang/String;");
+ jobject svcstr = env->GetStaticObjectField(context, fid);
+
+ // Get the method 'getSystemService' and call it
+ jmethodID getss = env->GetMethodID(natact, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
+ jobject vib_obj = env->CallObjectMethod(activity->clazz, getss, svcstr);
+
+ // Get the object's class and retrieve the member name
+ jclass vib_cls = env->GetObjectClass(vib_obj);
+ jmethodID vibrate = env->GetMethodID(vib_cls, "vibrate", "(J)V");
+
+ // Determine the timeframe
+ jlong length = duration.asMilliseconds();
+
+ // Bzzz!
+ env->CallVoidMethod(vib_obj, vibrate, length);
+
+ // Free references
+ env->DeleteLocalRef(vib_obj);
+ env->DeleteLocalRef(vib_cls);
+ env->DeleteLocalRef(svcstr);
+ env->DeleteLocalRef(context);
+ env->DeleteLocalRef(natact);
+
+ // Detach thread again
+ vm->DetachCurrentThread();
+}
+#endif
+
+// This is the actual Android example. You don't have to write any platform
+// specific code, unless you want to use things not directly exposed.
+// ('vibrate()' in this example; undefine 'USE_JNI' above to disable it)
int main(int argc, char *argv[])
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
@@ -31,25 +100,28 @@ int main(int argc, char *argv[])
while (window.pollEvent(event))
{
- if (event.type == sf::Event::Closed)
- {
- window.close();
- }
-
- if (event.type == sf::Event::Resized)
+ switch (event.type)
{
- view.setSize(event.size.width, event.size.height);
- view.setCenter(event.size.width/2, event.size.height/2);
- window.setView(view);
+ case sf::Event::Closed:
+ window.close();
+ break;
+ case sf::Event::Resized:
+ view.setSize(event.size.width, event.size.height);
+ view.setCenter(event.size.width/2, event.size.height/2);
+ window.setView(view);
+ break;
+ case sf::Event::TouchBegan:
+ if (event.touch.finger == 0)
+ {
+ image.setPosition(event.touch.x, event.touch.y);
+#if defined(USE_JNI)
+ vibrate(sf::milliseconds(10));
+#endif
+ }
+ break;
}
}
- if (sf::Touch::isDown(0))
- {
- sf::Vector2i position = sf::Touch::getPosition(0);
- image.setPosition(position.x, position.y);
- }
-
window.clear(sf::Color::White);
window.draw(image);
window.display();
diff --git a/examples/cocoa/CocoaAppDelegate.h b/examples/cocoa/CocoaAppDelegate.h
index b3fe9ca..23f6a4a 100644
--- a/examples/cocoa/CocoaAppDelegate.h
+++ b/examples/cocoa/CocoaAppDelegate.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/examples/cocoa/CocoaAppDelegate.mm b/examples/cocoa/CocoaAppDelegate.mm
index 3afadf6..3d6bc60 100644
--- a/examples/cocoa/CocoaAppDelegate.mm
+++ b/examples/cocoa/CocoaAppDelegate.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -57,7 +57,7 @@ struct SFMLmainWindow
if (!font.loadFromFile(resPath + "/sansation.ttf"))
NSLog(@"Couldn't load the font");
- text.setColor(sf::Color::White);
+ text.setFillColor(sf::Color::White);
text.setFont(font);
}
diff --git a/examples/cocoa/NSString+stdstring.h b/examples/cocoa/NSString+stdstring.h
index 0e4195a..eeee189 100644
--- a/examples/cocoa/NSString+stdstring.h
+++ b/examples/cocoa/NSString+stdstring.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/examples/cocoa/NSString+stdstring.mm b/examples/cocoa/NSString+stdstring.mm
index 5581f5e..fd1a743 100644
--- a/examples/cocoa/NSString+stdstring.mm
+++ b/examples/cocoa/NSString+stdstring.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/examples/cocoa/main.m b/examples/cocoa/main.m
index 2609d64..acd83f2 100644
--- a/examples/cocoa/main.m
+++ b/examples/cocoa/main.m
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/examples/cocoa/resources/Cocoa-Info.plist b/examples/cocoa/resources/Cocoa-Info.plist
index 0e730f2..5ec9e54 100644
--- a/examples/cocoa/resources/Cocoa-Info.plist
+++ b/examples/cocoa/resources/Cocoa-Info.plist
@@ -25,7 +25,7 @@
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSHumanReadableCopyright</key>
- <string>Copyright © 2007-2015 Marco Antognini and Laurent Gomila. Shared under zlib/libpng License.</string>
+ <string>Copyright © 2007-2016 Marco Antognini and Laurent Gomila. Shared under zlib/libpng License.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
diff --git a/examples/opengl/OpenGL.cpp b/examples/opengl/OpenGL.cpp
index c2d1697..20af113 100644
--- a/examples/opengl/OpenGL.cpp
+++ b/examples/opengl/OpenGL.cpp
@@ -5,6 +5,10 @@
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
+#ifndef GL_SRGB8_ALPHA8
+#define GL_SRGB8_ALPHA8 0x8C43
+#endif
+
////////////////////////////////////////////////////////////
/// Entry point of application
@@ -14,185 +18,221 @@
////////////////////////////////////////////////////////////
int main()
{
- // Request a 24-bits depth buffer when creating the window
- sf::ContextSettings contextSettings;
- contextSettings.depthBits = 24;
-
- // Create the main window
- sf::RenderWindow window(sf::VideoMode(800, 600), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
- window.setVerticalSyncEnabled(true);
-
- // Create a sprite for the background
- sf::Texture backgroundTexture;
- if (!backgroundTexture.loadFromFile("resources/background.jpg"))
- return EXIT_FAILURE;
- sf::Sprite background(backgroundTexture);
-
- // Create some text to draw on top of our OpenGL object
- sf::Font font;
- if (!font.loadFromFile("resources/sansation.ttf"))
- return EXIT_FAILURE;
- sf::Text text("SFML / OpenGL demo", font);
- text.setColor(sf::Color(255, 255, 255, 170));
- text.setPosition(250.f, 450.f);
-
- // Make the window the active target for OpenGL calls
- // Note: If using sf::Texture or sf::Shader with OpenGL,
- // be sure to call sf::Texture::getMaximumSize() and/or
- // sf::Shader::isAvailable() at least once before calling
- // setActive(), as those functions will cause a context switch
- window.setActive();
-
- // Load an OpenGL texture.
- // We could directly use a sf::Texture as an OpenGL texture (with its Bind() member function),
- // but here we want more control on it (generate mipmaps, ...) so we create a new one from an image
- GLuint texture = 0;
- {
- sf::Image image;
- if (!image.loadFromFile("resources/texture.jpg"))
- return EXIT_FAILURE;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.getSize().x, image.getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsPtr());
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- }
-
- // Enable Z-buffer read and write
- glEnable(GL_DEPTH_TEST);
- glDepthMask(GL_TRUE);
- glClearDepth(1.f);
+ bool exit = false;
+ bool sRgb = false;
- // Disable lighting
- glDisable(GL_LIGHTING);
-
- // Configure the viewport (the same size as the window)
- glViewport(0, 0, window.getSize().x, window.getSize().y);
-
- // Setup a perspective projection
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
- glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
-
- // Bind the texture
- glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, texture);
-
- // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
- static const GLfloat cube[] =
- {
- // positions // texture coordinates
- -20, -20, -20, 0, 0,
- -20, 20, -20, 1, 0,
- -20, -20, 20, 0, 1,
- -20, -20, 20, 0, 1,
- -20, 20, -20, 1, 0,
- -20, 20, 20, 1, 1,
-
- 20, -20, -20, 0, 0,
- 20, 20, -20, 1, 0,
- 20, -20, 20, 0, 1,
- 20, -20, 20, 0, 1,
- 20, 20, -20, 1, 0,
- 20, 20, 20, 1, 1,
-
- -20, -20, -20, 0, 0,
- 20, -20, -20, 1, 0,
- -20, -20, 20, 0, 1,
- -20, -20, 20, 0, 1,
- 20, -20, -20, 1, 0,
- 20, -20, 20, 1, 1,
-
- -20, 20, -20, 0, 0,
- 20, 20, -20, 1, 0,
- -20, 20, 20, 0, 1,
- -20, 20, 20, 0, 1,
- 20, 20, -20, 1, 0,
- 20, 20, 20, 1, 1,
-
- -20, -20, -20, 0, 0,
- 20, -20, -20, 1, 0,
- -20, 20, -20, 0, 1,
- -20, 20, -20, 0, 1,
- 20, -20, -20, 1, 0,
- 20, 20, -20, 1, 1,
-
- -20, -20, 20, 0, 0,
- 20, -20, 20, 1, 0,
- -20, 20, 20, 0, 1,
- -20, 20, 20, 0, 1,
- 20, -20, 20, 1, 0,
- 20, 20, 20, 1, 1
- };
-
- // Enable position and texture coordinates vertex components
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), cube);
- glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), cube + 3);
-
- // Disable normal and color vertex components
- glDisableClientState(GL_NORMAL_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-
- // Create a clock for measuring the time elapsed
- sf::Clock clock;
-
- // Start game loop
- while (window.isOpen())
+ while (!exit)
{
- // Process events
- sf::Event event;
- while (window.pollEvent(event))
- {
- // Close window: exit
- if (event.type == sf::Event::Closed)
- window.close();
+ // Request a 24-bits depth buffer when creating the window
+ sf::ContextSettings contextSettings;
+ contextSettings.depthBits = 24;
+ contextSettings.sRgbCapable = sRgb;
+
+ // Create the main window
+ sf::RenderWindow window(sf::VideoMode(800, 600), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
+ window.setVerticalSyncEnabled(true);
+
+ // Create a sprite for the background
+ sf::Texture backgroundTexture;
+ backgroundTexture.setSrgb(sRgb);
+ if (!backgroundTexture.loadFromFile("resources/background.jpg"))
+ return EXIT_FAILURE;
+ sf::Sprite background(backgroundTexture);
- // Escape key: exit
- if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
- window.close();
+ // Create some text to draw on top of our OpenGL object
+ sf::Font font;
+ if (!font.loadFromFile("resources/sansation.ttf"))
+ return EXIT_FAILURE;
+ sf::Text text("SFML / OpenGL demo", font);
+ sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
+ sf::Text mipmapInstructions("Press return to toggle mipmapping", font);
+ text.setFillColor(sf::Color(255, 255, 255, 170));
+ sRgbInstructions.setFillColor(sf::Color(255, 255, 255, 170));
+ mipmapInstructions.setFillColor(sf::Color(255, 255, 255, 170));
+ text.setPosition(250.f, 450.f);
+ sRgbInstructions.setPosition(150.f, 500.f);
+ mipmapInstructions.setPosition(180.f, 550.f);
+
+ // Load a texture to apply to our 3D cube
+ sf::Texture texture;
+ if (!texture.loadFromFile("resources/texture.jpg"))
+ return EXIT_FAILURE;
- // Adjust the viewport when the window is resized
- if (event.type == sf::Event::Resized)
- glViewport(0, 0, event.size.width, event.size.height);
- }
+ // Attempt to generate a mipmap for our cube texture
+ // We don't check the return value here since
+ // mipmapping is purely optional in this example
+ texture.generateMipmap();
- // Draw the background
- window.pushGLStates();
- window.draw(background);
- window.popGLStates();
+ // Enable Z-buffer read and write
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(GL_TRUE);
+ glClearDepth(1.f);
- // Clear the depth buffer
- glClear(GL_DEPTH_BUFFER_BIT);
+ // Disable lighting
+ glDisable(GL_LIGHTING);
- // We get the position of the mouse cursor, so that we can move the box accordingly
- float x = sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
- float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
+ // Configure the viewport (the same size as the window)
+ glViewport(0, 0, window.getSize().x, window.getSize().y);
- // Apply some transformations
- glMatrixMode(GL_MODELVIEW);
+ // Setup a perspective projection
+ glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glTranslatef(x, y, -100.f);
- glRotatef(clock.getElapsedTime().asSeconds() * 50.f, 1.f, 0.f, 0.f);
- glRotatef(clock.getElapsedTime().asSeconds() * 30.f, 0.f, 1.f, 0.f);
- glRotatef(clock.getElapsedTime().asSeconds() * 90.f, 0.f, 0.f, 1.f);
+ GLfloat ratio = static_cast<float>(window.getSize().x) / window.getSize().y;
+ glFrustum(-ratio, ratio, -1.f, 1.f, 1.f, 500.f);
- // Draw the cube
- glDrawArrays(GL_TRIANGLES, 0, 36);
+ // Bind the texture
+ glEnable(GL_TEXTURE_2D);
+ sf::Texture::bind(&texture);
- // Draw some text on top of our OpenGL object
- window.pushGLStates();
- window.draw(text);
- window.popGLStates();
-
- // Finally, display the rendered frame on screen
- window.display();
+ // Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
+ static const GLfloat cube[] =
+ {
+ // positions // texture coordinates
+ -20, -20, -20, 0, 0,
+ -20, 20, -20, 1, 0,
+ -20, -20, 20, 0, 1,
+ -20, -20, 20, 0, 1,
+ -20, 20, -20, 1, 0,
+ -20, 20, 20, 1, 1,
+
+ 20, -20, -20, 0, 0,
+ 20, 20, -20, 1, 0,
+ 20, -20, 20, 0, 1,
+ 20, -20, 20, 0, 1,
+ 20, 20, -20, 1, 0,
+ 20, 20, 20, 1, 1,
+
+ -20, -20, -20, 0, 0,
+ 20, -20, -20, 1, 0,
+ -20, -20, 20, 0, 1,
+ -20, -20, 20, 0, 1,
+ 20, -20, -20, 1, 0,
+ 20, -20, 20, 1, 1,
+
+ -20, 20, -20, 0, 0,
+ 20, 20, -20, 1, 0,
+ -20, 20, 20, 0, 1,
+ -20, 20, 20, 0, 1,
+ 20, 20, -20, 1, 0,
+ 20, 20, 20, 1, 1,
+
+ -20, -20, -20, 0, 0,
+ 20, -20, -20, 1, 0,
+ -20, 20, -20, 0, 1,
+ -20, 20, -20, 0, 1,
+ 20, -20, -20, 1, 0,
+ 20, 20, -20, 1, 1,
+
+ -20, -20, 20, 0, 0,
+ 20, -20, 20, 1, 0,
+ -20, 20, 20, 0, 1,
+ -20, 20, 20, 0, 1,
+ 20, -20, 20, 1, 0,
+ 20, 20, 20, 1, 1
+ };
+
+ // Enable position and texture coordinates vertex components
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), cube);
+ glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), cube + 3);
+
+ // Disable normal and color vertex components
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+
+ // Create a clock for measuring the time elapsed
+ sf::Clock clock;
+
+ // Flag to track whether mipmapping is currently enabled
+ bool mipmapEnabled = true;
+
+ // Start game loop
+ while (window.isOpen())
+ {
+ // Process events
+ sf::Event event;
+ while (window.pollEvent(event))
+ {
+ // Close window: exit
+ if (event.type == sf::Event::Closed)
+ {
+ exit = true;
+ window.close();
+ }
+
+ // Escape key: exit
+ if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
+ {
+ exit = true;
+ window.close();
+ }
+
+ // Return key: toggle mipmapping
+ if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return))
+ {
+ if (mipmapEnabled)
+ {
+ // We simply reload the texture to disable mipmapping
+ if (!texture.loadFromFile("resources/texture.jpg"))
+ return EXIT_FAILURE;
+
+ mipmapEnabled = false;
+ }
+ else
+ {
+ texture.generateMipmap();
+
+ mipmapEnabled = true;
+ }
+ }
+
+ // Space key: toggle sRGB conversion
+ if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
+ {
+ sRgb = !sRgb;
+ window.close();
+ }
+
+ // Adjust the viewport when the window is resized
+ if (event.type == sf::Event::Resized)
+ glViewport(0, 0, event.size.width, event.size.height);
+ }
+
+ // Draw the background
+ window.pushGLStates();
+ window.draw(background);
+ window.popGLStates();
+
+ // Clear the depth buffer
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ // We get the position of the mouse cursor, so that we can move the box accordingly
+ float x = sf::Mouse::getPosition(window).x * 200.f / window.getSize().x - 100.f;
+ float y = -sf::Mouse::getPosition(window).y * 200.f / window.getSize().y + 100.f;
+
+ // Apply some transformations
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(x, y, -100.f);
+ glRotatef(clock.getElapsedTime().asSeconds() * 50.f, 1.f, 0.f, 0.f);
+ glRotatef(clock.getElapsedTime().asSeconds() * 30.f, 0.f, 1.f, 0.f);
+ glRotatef(clock.getElapsedTime().asSeconds() * 90.f, 0.f, 0.f, 1.f);
+
+ // Draw the cube
+ glDrawArrays(GL_TRIANGLES, 0, 36);
+
+ // Draw some text on top of our OpenGL object
+ window.pushGLStates();
+ window.draw(text);
+ window.draw(sRgbInstructions);
+ window.draw(mipmapInstructions);
+ window.popGLStates();
+
+ // Finally, display the rendered frame on screen
+ window.display();
+ }
}
- // Don't forget to destroy our texture
- glDeleteTextures(1, &texture);
-
return EXIT_SUCCESS;
}
diff --git a/examples/pong/Pong.cpp b/examples/pong/Pong.cpp
index e9edf23..58c9fd7 100644
--- a/examples/pong/Pong.cpp
+++ b/examples/pong/Pong.cpp
@@ -71,7 +71,7 @@ int main()
pauseMessage.setFont(font);
pauseMessage.setCharacterSize(40);
pauseMessage.setPosition(170.f, 150.f);
- pauseMessage.setColor(sf::Color::White);
+ pauseMessage.setFillColor(sf::Color::White);
pauseMessage.setString("Welcome to SFML pong!\nPress space to start the game");
// Define the paddles properties
diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp
index ab147d9..8a81fde 100644
--- a/examples/shader/Shader.cpp
+++ b/examples/shader/Shader.cpp
@@ -31,14 +31,14 @@ public:
// Load the shader
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
return false;
- m_shader.setParameter("texture", sf::Shader::CurrentTexture);
+ m_shader.setUniform("texture", sf::Shader::CurrentTexture);
return true;
}
void onUpdate(float, float x, float y)
{
- m_shader.setParameter("pixel_threshold", (x + y) / 30);
+ m_shader.setUniform("pixel_threshold", (x + y) / 30);
}
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
@@ -101,9 +101,9 @@ public:
void onUpdate(float time, float x, float y)
{
- m_shader.setParameter("wave_phase", time);
- m_shader.setParameter("wave_amplitude", x * 40, y * 40);
- m_shader.setParameter("blur_radius", (x + y) * 0.008f);
+ m_shader.setUniform("wave_phase", time);
+ m_shader.setUniform("wave_amplitude", sf::Vector2f(x * 40, y * 40));
+ m_shader.setUniform("blur_radius", (x + y) * 0.008f);
}
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
@@ -155,10 +155,10 @@ public:
void onUpdate(float time, float x, float y)
{
float radius = 200 + std::cos(time) * 150;
- m_shader.setParameter("storm_position", x * 800, y * 600);
- m_shader.setParameter("storm_inner_radius", radius / 3);
- m_shader.setParameter("storm_total_radius", radius);
- m_shader.setParameter("blink_alpha", 0.5f + std::cos(time * 3) * 0.25f);
+ m_shader.setUniform("storm_position", sf::Vector2f(x * 800, y * 600));
+ m_shader.setUniform("storm_inner_radius", radius / 3);
+ m_shader.setUniform("storm_total_radius", radius);
+ m_shader.setUniform("blink_alpha", 0.5f + std::cos(time * 3) * 0.25f);
}
void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
@@ -215,14 +215,14 @@ public:
// Load the shader
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Fragment))
return false;
- m_shader.setParameter("texture", sf::Shader::CurrentTexture);
+ m_shader.setUniform("texture", sf::Shader::CurrentTexture);
return true;
}
void onUpdate(float time, float x, float y)
{
- m_shader.setParameter("edge_threshold", 1 - (x + y) / 2);
+ m_shader.setUniform("edge_threshold", 1 - (x + y) / 2);
// Update the position of the moving entities
for (std::size_t i = 0; i < m_entities.size(); ++i)
@@ -259,6 +259,85 @@ private:
////////////////////////////////////////////////////////////
+// "Geometry" geometry shader example
+////////////////////////////////////////////////////////////
+class Geometry : public Effect
+{
+public:
+
+ Geometry() :
+ Effect("geometry shader billboards"),
+ m_pointCloud(sf::Points, 10000)
+ {
+ }
+
+ bool onLoad()
+ {
+ // Check if geometry shaders are supported
+ if (!sf::Shader::isGeometryAvailable())
+ return false;
+
+ // Move the points in the point cloud to random positions
+ for (std::size_t i = 0; i < 10000; i++)
+ {
+ // Spread the coordinates from -480 to +480
+ // So they'll always fill the viewport at 800x600
+ m_pointCloud[i].position.x = rand() % 960 - 480.f;
+ m_pointCloud[i].position.y = rand() % 960 - 480.f;
+ }
+
+ // Load the texture
+ if (!m_logoTexture.loadFromFile("resources/logo.png"))
+ return false;
+
+ // Load the shader
+ if (!m_shader.loadFromFile("resources/billboard.vert", "resources/billboard.geom", "resources/billboard.frag"))
+ return false;
+ m_shader.setUniform("texture", sf::Shader::CurrentTexture);
+
+ // Set the render resolution (used for proper scaling)
+ m_shader.setUniform("resolution", sf::Vector2f(800, 600));
+
+ return true;
+ }
+
+ void onUpdate(float time, float x, float y)
+ {
+ // Reset our transformation matrix
+ m_transform = sf::Transform::Identity;
+ // Move to the center of the window
+ m_transform.translate(400, 300);
+ // Rotate everything based on cursor position
+ m_transform.rotate(x * 360.f);
+
+ // Adjust billboard size to scale between 25 and 75
+ float size = 25 + std::abs(y) * 50;
+
+ // Update the shader parameter
+ m_shader.setUniform("size", sf::Vector2f(size, size));
+ }
+
+ void onDraw(sf::RenderTarget& target, sf::RenderStates states) const
+ {
+ // Prepare the render state
+ states.shader = &m_shader;
+ states.texture = &m_logoTexture;
+ states.transform = m_transform;
+
+ // Draw the point cloud
+ target.draw(m_pointCloud, states);
+ }
+
+private:
+
+ sf::Texture m_logoTexture;
+ sf::Transform m_transform;
+ sf::Shader m_shader;
+ sf::VertexArray m_pointCloud;
+};
+
+
+////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
@@ -283,6 +362,7 @@ int main()
effects.push_back(new WaveBlur);
effects.push_back(new StormBlink);
effects.push_back(new Edge);
+ effects.push_back(new Geometry);
std::size_t current = 0;
// Initialize them
@@ -300,12 +380,12 @@ int main()
// Create the description text
sf::Text description("Current effect: " + effects[current]->getName(), font, 20);
description.setPosition(10, 530);
- description.setColor(sf::Color(80, 80, 80));
+ description.setFillColor(sf::Color(80, 80, 80));
// Create the instructions text
sf::Text instructions("Press left and right arrows to change the current shader", font, 20);
instructions.setPosition(280, 555);
- instructions.setColor(sf::Color(80, 80, 80));
+ instructions.setFillColor(sf::Color(80, 80, 80));
// Start the game loop
sf::Clock clock;
diff --git a/examples/shader/resources/billboard.frag b/examples/shader/resources/billboard.frag
new file mode 100644
index 0000000..3057f64
--- /dev/null
+++ b/examples/shader/resources/billboard.frag
@@ -0,0 +1,11 @@
+#version 150
+
+uniform sampler2D texture;
+
+in vec2 tex_coord;
+
+void main()
+{
+ // Read and apply a color from the texture
+ gl_FragColor = texture2D(texture, tex_coord);
+}
diff --git a/examples/shader/resources/billboard.geom b/examples/shader/resources/billboard.geom
new file mode 100644
index 0000000..2f47a1f
--- /dev/null
+++ b/examples/shader/resources/billboard.geom
@@ -0,0 +1,56 @@
+#version 150
+
+// The render target's resolution (used for scaling)
+uniform vec2 resolution;
+
+// The billboards' size
+uniform vec2 size;
+
+// Input is the passed point cloud
+layout (points) in;
+
+// The output will consist of triangle strips with four vertices each
+layout (triangle_strip, max_vertices = 4) out;
+
+// Output texture coordinates
+out vec2 tex_coord;
+
+// Main entry point
+void main()
+{
+ // Caculate the half width/height of the billboards
+ vec2 half_size = size / 2.f;
+
+ // Scale the size based on resolution (1 would be full width/height)
+ half_size /= resolution;
+
+ // Iterate over all vertices
+ for (int i = 0; i < gl_in.length(); i++)
+ {
+ // Retrieve the passed vertex position
+ vec2 pos = gl_in[i].gl_Position.xy;
+
+ // Bottom left vertex
+ gl_Position = vec4(pos - half_size, 0.f, 1.f);
+ tex_coord = vec2(1.f, 1.f);
+ EmitVertex();
+
+ // Bottom right vertex
+ gl_Position = vec4(pos.x + half_size.x, pos.y - half_size.y, 0.f, 1.f);
+ tex_coord = vec2(0.f, 1.f);
+ EmitVertex();
+
+ // Top left vertex
+ gl_Position = vec4(pos.x - half_size.x, pos.y + half_size.y, 0.f, 1.f);
+ tex_coord = vec2(1.f, 0.f);
+ EmitVertex();
+
+ // Top right vertex
+ gl_Position = vec4(pos + half_size, 0.f, 1.f);
+ tex_coord = vec2(0.f, 0.f);
+ EmitVertex();
+
+ // And finalize the primitive
+ EndPrimitive();
+ }
+}
diff --git a/examples/shader/resources/billboard.vert b/examples/shader/resources/billboard.vert
new file mode 100644
index 0000000..3a89905
--- /dev/null
+++ b/examples/shader/resources/billboard.vert
@@ -0,0 +1,5 @@
+void main()
+{
+ // Transform the vertex position
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
diff --git a/examples/shader/resources/logo.png b/examples/shader/resources/logo.png
new file mode 100644
index 0000000..29ba010
--- /dev/null
+++ b/examples/shader/resources/logo.png
Binary files differ
diff --git a/examples/sound/Sound.cpp b/examples/sound/Sound.cpp
index b579fb5..e71aa0d 100644
--- a/examples/sound/Sound.cpp
+++ b/examples/sound/Sound.cpp
@@ -3,7 +3,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
-#include <iomanip>
#include <iostream>
#include <string>
@@ -36,7 +35,7 @@ void playSound()
sf::sleep(sf::milliseconds(100));
// Display the playing position
- std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.getPlayingOffset().asSeconds() << " sec ";
+ std::cout << "\rPlaying... " << sound.getPlayingOffset().asSeconds() << " sec ";
std::cout << std::flush;
}
std::cout << std::endl << std::endl;
@@ -70,7 +69,7 @@ void playMusic(const std::string& filename)
sf::sleep(sf::milliseconds(100));
// Display the playing position
- std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.getPlayingOffset().asSeconds() << " sec ";
+ std::cout << "\rPlaying... " << music.getPlayingOffset().asSeconds() << " sec ";
std::cout << std::flush;
}
std::cout << std::endl << std::endl;
diff --git a/examples/sound_capture/SoundCapture.cpp b/examples/sound_capture/SoundCapture.cpp
index 02f2db2..19f114b 100644
--- a/examples/sound_capture/SoundCapture.cpp
+++ b/examples/sound_capture/SoundCapture.cpp
@@ -3,7 +3,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
-#include <iomanip>
#include <iostream>
@@ -76,7 +75,7 @@ int main()
while (sound.getStatus() == sf::Sound::Playing)
{
// Display the playing position
- std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.getPlayingOffset().asSeconds() << " sec";
+ std::cout << "\rPlaying... " << sound.getPlayingOffset().asSeconds() << " sec ";
std::cout << std::flush;
// Leave some CPU time for other threads
diff --git a/examples/voip/Client.cpp b/examples/voip/Client.cpp
index 595d624..d66e0e2 100644
--- a/examples/voip/Client.cpp
+++ b/examples/voip/Client.cpp
@@ -32,10 +32,22 @@ public:
{
}
+ ////////////////////////////////////////////////////////////
+ /// Destructor
+ ///
+ /// \see SoundRecorder::~SoundRecorder()
+ ///
+ ////////////////////////////////////////////////////////////
+ ~NetworkRecorder()
+ {
+ // Make sure to stop the recording thread
+ stop();
+ }
+
private:
////////////////////////////////////////////////////////////
- /// /see SoundRecorder::OnStart
+ /// \see SoundRecorder::onStart
///
////////////////////////////////////////////////////////////
virtual bool onStart()
@@ -52,7 +64,7 @@ private:
}
////////////////////////////////////////////////////////////
- /// /see SoundRecorder::ProcessSamples
+ /// \see SoundRecorder::onProcessSamples
///
////////////////////////////////////////////////////////////
virtual bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
@@ -67,7 +79,7 @@ private:
}
////////////////////////////////////////////////////////////
- /// /see SoundRecorder::OnStop
+ /// \see SoundRecorder::onStop
///
////////////////////////////////////////////////////////////
virtual void onStop()
@@ -98,7 +110,7 @@ private:
void doClient(unsigned short port)
{
// Check that the device can capture audio
- if (sf::SoundRecorder::isAvailable() == false)
+ if (!sf::SoundRecorder::isAvailable())
{
std::cout << "Sorry, audio capture is not supported by your system" << std::endl;
return;
diff --git a/include/SFML/Audio.hpp b/include/SFML/Audio.hpp
index 41737cf..43a4a75 100644
--- a/include/SFML/Audio.hpp
+++ b/include/SFML/Audio.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/AlResource.hpp b/include/SFML/Audio/AlResource.hpp
index ca5d2c0..d925314 100644
--- a/include/SFML/Audio/AlResource.hpp
+++ b/include/SFML/Audio/AlResource.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/Export.hpp b/include/SFML/Audio/Export.hpp
index 1ea6f42..3269041 100644
--- a/include/SFML/Audio/Export.hpp
+++ b/include/SFML/Audio/Export.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/InputSoundFile.hpp b/include/SFML/Audio/InputSoundFile.hpp
index 5e306ae..e59f2a2 100644
--- a/include/SFML/Audio/InputSoundFile.hpp
+++ b/include/SFML/Audio/InputSoundFile.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -62,7 +62,8 @@ public:
////////////////////////////////////////////////////////////
/// \brief Open a sound file from the disk for reading
///
- /// The supported audio formats are: WAV, OGG/Vorbis, FLAC.
+ /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.
+ /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.
///
/// \param filename Path of the sound file to load
///
@@ -74,7 +75,8 @@ public:
////////////////////////////////////////////////////////////
/// \brief Open a sound file in memory for reading
///
- /// The supported audio formats are: WAV, OGG/Vorbis, FLAC.
+ /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.
+ /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.
///
/// \param data Pointer to the file data in memory
/// \param sizeInBytes Size of the data to load, in bytes
@@ -87,7 +89,8 @@ public:
////////////////////////////////////////////////////////////
/// \brief Open a sound file from a custom stream for reading
///
- /// The supported audio formats are: WAV, OGG/Vorbis, FLAC.
+ /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.
+ /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.
///
/// \param stream Source stream to read from
///
@@ -150,6 +153,9 @@ public:
/// precision. If you need to jump to a given time, use the
/// other overload.
///
+ /// The sample offset takes the channels into account.
+ /// Offsets can be calculated like this:
+ /// `sampleNumber * sampleRate * channelCount`
/// If the given offset exceeds to total number of samples,
/// this function jumps to the end of the sound file.
///
diff --git a/include/SFML/Audio/Listener.hpp b/include/SFML/Audio/Listener.hpp
index 04e4af3..a9b1817 100644
--- a/include/SFML/Audio/Listener.hpp
+++ b/include/SFML/Audio/Listener.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp
index 76b4254..1dc0e0c 100644
--- a/include/SFML/Audio/Music.hpp
+++ b/include/SFML/Audio/Music.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/OutputSoundFile.hpp b/include/SFML/Audio/OutputSoundFile.hpp
index 8f60498..8c50bd1 100644
--- a/include/SFML/Audio/OutputSoundFile.hpp
+++ b/include/SFML/Audio/OutputSoundFile.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp
index 8b0771d..fb78677 100644
--- a/include/SFML/Audio/Sound.hpp
+++ b/include/SFML/Audio/Sound.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp
index 42eda6f..0a155ab 100644
--- a/include/SFML/Audio/SoundBuffer.hpp
+++ b/include/SFML/Audio/SoundBuffer.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/SoundBufferRecorder.hpp b/include/SFML/Audio/SoundBufferRecorder.hpp
index 7715ac5..cb27afc 100644
--- a/include/SFML/Audio/SoundBufferRecorder.hpp
+++ b/include/SFML/Audio/SoundBufferRecorder.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -46,6 +46,12 @@ class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder
public:
////////////////////////////////////////////////////////////
+ /// \brief destructor
+ ///
+ ////////////////////////////////////////////////////////////
+ ~SoundBufferRecorder();
+
+ ////////////////////////////////////////////////////////////
/// \brief Get the sound buffer containing the captured audio data
///
/// The sound buffer is valid only after the capture has ended.
diff --git a/include/SFML/Audio/SoundFileFactory.hpp b/include/SFML/Audio/SoundFileFactory.hpp
index bd346cc..be8dd56 100644
--- a/include/SFML/Audio/SoundFileFactory.hpp
+++ b/include/SFML/Audio/SoundFileFactory.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/SoundFileFactory.inl b/include/SFML/Audio/SoundFileFactory.inl
index 19d334b..c5bba65 100644
--- a/include/SFML/Audio/SoundFileFactory.inl
+++ b/include/SFML/Audio/SoundFileFactory.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/SoundFileReader.hpp b/include/SFML/Audio/SoundFileReader.hpp
index 549f50b..84aa606 100644
--- a/include/SFML/Audio/SoundFileReader.hpp
+++ b/include/SFML/Audio/SoundFileReader.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -79,6 +79,9 @@ public:
////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given sample offset
///
+ /// The sample offset takes the channels into account.
+ /// Offsets can be calculated like this:
+ /// `sampleNumber * sampleRate * channelCount`
/// If the given offset exceeds to total number of samples,
/// this function must jump to the end of the file.
///
diff --git a/include/SFML/Audio/SoundFileWriter.hpp b/include/SFML/Audio/SoundFileWriter.hpp
index 36a2678..72b99ea 100644
--- a/include/SFML/Audio/SoundFileWriter.hpp
+++ b/include/SFML/Audio/SoundFileWriter.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Audio/SoundRecorder.hpp b/include/SFML/Audio/SoundRecorder.hpp
index 964e4f3..d23e3e5 100644
--- a/include/SFML/Audio/SoundRecorder.hpp
+++ b/include/SFML/Audio/SoundRecorder.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -145,6 +145,34 @@ public:
const std::string& getDevice() const;
////////////////////////////////////////////////////////////
+ /// \brief Set the channel count of the audio capture device
+ ///
+ /// This method allows you to specify the number of channels
+ /// used for recording. Currently only 16-bit mono and
+ /// 16-bit stereo are supported.
+ ///
+ /// \param channelCount Number of channels. Currently only
+ /// mono (1) and stereo (2) are supported.
+ ///
+ /// \see getChannelCount
+ ///
+ ////////////////////////////////////////////////////////////
+ void setChannelCount(unsigned int channelCount);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the number of channels used by this recorder
+ ///
+ /// Currently only mono and stereo are supported, so the
+ /// value is either 1 (for mono) or 2 (for stereo).
+ ///
+ /// \return Number of channels
+ ///
+ /// \see setChannelCount
+ ///
+ ////////////////////////////////////////////////////////////
+ unsigned int getChannelCount() const;
+
+ ////////////////////////////////////////////////////////////
/// \brief Check if the system supports audio capture
///
/// This function should always be called before using
@@ -263,6 +291,7 @@ private:
Time m_processingInterval; ///< Time period between calls to onProcessSamples
bool m_isCapturing; ///< Capturing state
std::string m_deviceName; ///< Name of the audio capture device
+ unsigned int m_channelCount; ///< Number of recording channels
};
} // namespace sf
@@ -309,6 +338,12 @@ private:
/// by calling setDevice() with the appropriate device. Otherwise
/// the default capturing device will be used.
///
+/// By default the recording is in 16-bit mono. Using the
+/// setChannelCount method you can change the number of channels
+/// used by the audio capture device to record. Note that you
+/// have to decide whether you want to record in mono or stereo
+/// before starting the recording.
+///
/// It is important to note that the audio capture happens in a
/// separate thread, so that it doesn't block the rest of the
/// program. In particular, the onProcessSamples virtual function
@@ -316,11 +351,20 @@ private:
/// from this separate thread. It is important to keep this in
/// mind, because you may have to take care of synchronization
/// issues if you share data between threads.
+/// Another thing to bear in mind is that you must call stop()
+/// in the destructor of your derived class, so that the recording
+/// thread finishes before your object is destroyed.
///
/// Usage example:
/// \code
/// class CustomRecorder : public sf::SoundRecorder
/// {
+/// ~CustomRecorder()
+/// {
+/// // Make sure to stop the recording thread
+/// stop();
+/// }
+///
/// virtual bool onStart() // optional
/// {
/// // Initialize whatever has to be done before the capture starts
diff --git a/include/SFML/Audio/SoundSource.hpp b/include/SFML/Audio/SoundSource.hpp
index cde0a3b..83d5e8c 100644
--- a/include/SFML/Audio/SoundSource.hpp
+++ b/include/SFML/Audio/SoundSource.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -240,6 +240,16 @@ public:
////////////////////////////////////////////////////////////
float getAttenuation() const;
+ ////////////////////////////////////////////////////////////
+ /// \brief Overload of assignment operator
+ ///
+ /// \param right Instance to assign
+ ///
+ /// \return Reference to self
+ ///
+ ////////////////////////////////////////////////////////////
+ SoundSource& operator =(const SoundSource& right);
+
protected:
////////////////////////////////////////////////////////////
diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp
index 22ae8cd..a2d7cb9 100644
--- a/include/SFML/Audio/SoundStream.hpp
+++ b/include/SFML/Audio/SoundStream.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp
index 05c7719..497ef67 100644
--- a/include/SFML/Config.hpp
+++ b/include/SFML/Config.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,8 +30,8 @@
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 2
-#define SFML_VERSION_MINOR 3
-#define SFML_VERSION_PATCH 2
+#define SFML_VERSION_MINOR 4
+#define SFML_VERSION_PATCH 0
////////////////////////////////////////////////////////////
@@ -158,6 +158,44 @@
////////////////////////////////////////////////////////////
+// Cross-platform warning for deprecated functions and classes
+//
+// Usage:
+// class SFML_DEPRECATED MyClass
+// {
+// SFML_DEPRECATED void memberFunc();
+// };
+//
+// SFML_DEPRECATED void globalFunc();
+////////////////////////////////////////////////////////////
+#if defined(SFML_NO_DEPRECATED_WARNINGS)
+
+ // User explicitly requests to disable deprecation warnings
+ #define SFML_DEPRECATED
+
+#elif defined(_MSC_VER)
+
+ // Microsoft C++ compiler
+ // Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to
+ // trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.
+ #define SFML_DEPRECATED __declspec(deprecated)
+
+#elif defined(__GNUC__)
+
+ // g++ and Clang
+ #define SFML_DEPRECATED __attribute__ ((deprecated))
+
+#else
+
+ // Other compilers are not supported, leave class or function as-is.
+ // With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.
+ #pragma message("SFML_DEPRECATED is not supported for your compiler, please contact the SFML team")
+ #define SFML_DEPRECATED
+
+#endif
+
+
+////////////////////////////////////////////////////////////
// Define portable fixed-size types
////////////////////////////////////////////////////////////
namespace sf
diff --git a/include/SFML/Graphics.hpp b/include/SFML/Graphics.hpp
index 7a7f4da..6bcf299 100644
--- a/include/SFML/Graphics.hpp
+++ b/include/SFML/Graphics.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/BlendMode.hpp b/include/SFML/Graphics/BlendMode.hpp
index 7f5803b..76aa72c 100644
--- a/include/SFML/Graphics/BlendMode.hpp
+++ b/include/SFML/Graphics/BlendMode.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -68,8 +68,9 @@ struct SFML_GRAPHICS_API BlendMode
////////////////////////////////////////////////////////
enum Equation
{
- Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor
- Subtract ///< Pixel = Src * SrcFactor - Dst * DstFactor
+ Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor
+ Subtract, ///< Pixel = Src * SrcFactor - Dst * DstFactor
+ ReverseSubtract ///< Pixel = Dst * DstFactor - Src * SrcFactor
};
////////////////////////////////////////////////////////////
@@ -201,7 +202,7 @@ SFML_GRAPHICS_API extern const BlendMode BlendNone; ///< Overwrite dest with
/// \code
/// sf::BlendMode alphaBlending = sf::BlendAlpha;
/// sf::BlendMode additiveBlending = sf::BlendAdd;
-/// sf::BlendMode multiplicativeBlending = sf::BlendMultipy;
+/// sf::BlendMode multiplicativeBlending = sf::BlendMultiply;
/// sf::BlendMode noBlending = sf::BlendNone;
/// \endcode
///
diff --git a/include/SFML/Graphics/CircleShape.hpp b/include/SFML/Graphics/CircleShape.hpp
index 2d5ac00..018a52a 100644
--- a/include/SFML/Graphics/CircleShape.hpp
+++ b/include/SFML/Graphics/CircleShape.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp
index 87a1598..ff35de5 100644
--- a/include/SFML/Graphics/Color.hpp
+++ b/include/SFML/Graphics/Color.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/ConvexShape.hpp b/include/SFML/Graphics/ConvexShape.hpp
index 82991a7..5c548a8 100644
--- a/include/SFML/Graphics/ConvexShape.hpp
+++ b/include/SFML/Graphics/ConvexShape.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Drawable.hpp b/include/SFML/Graphics/Drawable.hpp
index 5ddf2da..9ade3bc 100644
--- a/include/SFML/Graphics/Drawable.hpp
+++ b/include/SFML/Graphics/Drawable.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Export.hpp b/include/SFML/Graphics/Export.hpp
index 624f1eb..d11f419 100644
--- a/include/SFML/Graphics/Export.hpp
+++ b/include/SFML/Graphics/Export.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp
index ac6b00e..1420b70 100644
--- a/include/SFML/Graphics/Font.hpp
+++ b/include/SFML/Graphics/Font.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -166,14 +166,18 @@ public:
/// might be available. If the glyph is not available at the
/// requested size, an empty glyph is returned.
///
- /// \param codePoint Unicode code point of the character to get
- /// \param characterSize Reference character size
- /// \param bold Retrieve the bold version or the regular one?
+ /// Be aware that using a negative value for the outline
+ /// thickness will cause distorted rendering.
+ ///
+ /// \param codePoint Unicode code point of the character to get
+ /// \param characterSize Reference character size
+ /// \param bold Retrieve the bold version or the regular one?
+ /// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled)
///
/// \return The glyph corresponding to \a codePoint and \a characterSize
///
////////////////////////////////////////////////////////////
- const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
+ const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness = 0) const;
////////////////////////////////////////////////////////////
/// \brief Get the kerning offset of two glyphs
@@ -277,7 +281,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
- typedef std::map<Uint32, Glyph> GlyphTable; ///< Table mapping a codepoint to its glyph
+ typedef std::map<Uint64, Glyph> GlyphTable; ///< Table mapping a codepoint to its glyph
////////////////////////////////////////////////////////////
/// \brief Structure defining a page of glyphs
@@ -302,14 +306,15 @@ private:
////////////////////////////////////////////////////////////
/// \brief Load a new glyph and store it in the cache
///
- /// \param codePoint Unicode code point of the character to load
- /// \param characterSize Reference character size
- /// \param bold Retrieve the bold version or the regular one?
+ /// \param codePoint Unicode code point of the character to load
+ /// \param characterSize Reference character size
+ /// \param bold Retrieve the bold version or the regular one?
+ /// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled)
///
/// \return The glyph corresponding to \a codePoint and \a characterSize
///
////////////////////////////////////////////////////////////
- Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
+ Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const;
////////////////////////////////////////////////////////////
/// \brief Find a suitable rectangle within the texture for a glyph
@@ -344,6 +349,7 @@ private:
void* m_library; ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details)
void* m_face; ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details)
void* m_streamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)
+ void* m_stroker; ///< Pointer to the stroker (it is typeless to avoid exposing implementation details)
int* m_refCount; ///< Reference counter used by implicit sharing
Info m_info; ///< Information about the font
mutable PageTable m_pages; ///< Table containing the glyphs pages by character size
diff --git a/include/SFML/Graphics/Glsl.hpp b/include/SFML/Graphics/Glsl.hpp
new file mode 100644
index 0000000..74b087f
--- /dev/null
+++ b/include/SFML/Graphics/Glsl.hpp
@@ -0,0 +1,227 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_GLSL_HPP
+#define SFML_GLSL_HPP
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Graphics/Transform.hpp>
+#include <SFML/Graphics/Color.hpp>
+#include <SFML/System/Vector2.hpp>
+#include <SFML/System/Vector3.hpp>
+
+
+namespace sf
+{
+namespace priv
+{
+ // Forward declarations
+ template <std::size_t Columns, std::size_t Rows>
+ struct Matrix;
+
+ template <typename T>
+ struct Vector4;
+
+#include <SFML/Graphics/Glsl.inl>
+
+} // namespace priv
+
+
+////////////////////////////////////////////////////////////
+/// \brief Namespace with GLSL types
+///
+////////////////////////////////////////////////////////////
+namespace Glsl
+{
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 2D float vector (\p vec2 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector2<float> Vec2;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 2D int vector (\p ivec2 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector2<int> Ivec2;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 2D bool vector (\p bvec2 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector2<bool> Bvec2;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 3D float vector (\p vec3 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector3<float> Vec3;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 3D int vector (\p ivec3 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector3<int> Ivec3;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 3D bool vector (\p bvec3 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef Vector3<bool> Bvec3;
+
+#ifdef SFML_DOXYGEN
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 4D float vector (\p vec4 in GLSL)
+ ///
+ /// 4D float vectors can be implicitly converted from sf::Color
+ /// instances. Each color channel is normalized from integers
+ /// in [0, 255] to floating point values in [0, 1].
+ /// \code
+ /// sf::Glsl::Vec4 zeroVector;
+ /// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);
+ /// sf::Glsl::Vec4 color = sf::Color::Cyan;
+ /// \endcode
+ ////////////////////////////////////////////////////////////
+ typedef implementation-defined Vec4;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 4D int vector (\p ivec4 in GLSL)
+ ///
+ /// 4D int vectors can be implicitly converted from sf::Color
+ /// instances. Each color channel remains unchanged inside
+ /// the integer interval [0, 255].
+ /// \code
+ /// sf::Glsl::Ivec4 zeroVector;
+ /// sf::Glsl::Ivec4 vector(1, 2, 3, 4);
+ /// sf::Glsl::Ivec4 color = sf::Color::Cyan;
+ /// \endcode
+ ////////////////////////////////////////////////////////////
+ typedef implementation-defined Ivec4;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 4D bool vector (\p bvec4 in GLSL)
+ ///
+ ////////////////////////////////////////////////////////////
+ typedef implementation-defined Bvec4;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 3x3 float matrix (\p mat3 in GLSL)
+ ///
+ /// The matrix can be constructed from an array with 3x3
+ /// elements, aligned in column-major order. For example,
+ /// a translation by (x, y) looks as follows:
+ /// \code
+ /// float array[9] =
+ /// {
+ /// 1, 0, 0,
+ /// 0, 1, 0,
+ /// x, y, 1
+ /// };
+ ///
+ /// sf::Glsl::Mat3 matrix(array);
+ /// \endcode
+ ///
+ /// Mat3 can also be implicitly converted from sf::Transform:
+ /// \code
+ /// sf::Transform transform;
+ /// sf::Glsl::Mat3 matrix = transform;
+ /// \endcode
+ ////////////////////////////////////////////////////////////
+ typedef implementation-defined Mat3;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief 4x4 float matrix (\p mat4 in GLSL)
+ ///
+ /// The matrix can be constructed from an array with 4x4
+ /// elements, aligned in column-major order. For example,
+ /// a translation by (x, y, z) looks as follows:
+ /// \code
+ /// float array[16] =
+ /// {
+ /// 1, 0, 0, 0,
+ /// 0, 1, 0, 0,
+ /// 0, 0, 1, 0,
+ /// x, y, z, 1
+ /// };
+ ///
+ /// sf::Glsl::Mat4 matrix(array);
+ /// \endcode
+ ///
+ /// Mat4 can also be implicitly converted from sf::Transform:
+ /// \code
+ /// sf::Transform transform;
+ /// sf::Glsl::Mat4 matrix = transform;
+ /// \endcode
+ ////////////////////////////////////////////////////////////
+ typedef implementation-defined Mat4;
+
+#else // SFML_DOXYGEN
+
+ typedef priv::Vector4<float> Vec4;
+ typedef priv::Vector4<int> Ivec4;
+ typedef priv::Vector4<bool> Bvec4;
+ typedef priv::Matrix<3, 3> Mat3;
+ typedef priv::Matrix<4, 4> Mat4;
+
+#endif // SFML_DOXYGEN
+
+} // namespace Glsl
+} // namespace sf
+
+#endif // SFML_GLSL_HPP
+
+
+////////////////////////////////////////////////////////////
+/// \namespace sf::Glsl
+/// \ingroup graphics
+///
+/// \details The sf::Glsl namespace contains types that match
+/// their equivalents in GLSL, the OpenGL shading language.
+/// These types are exclusively used by the sf::Shader class.
+///
+/// Types that already exist in SFML, such as \ref sf::Vector2<T>
+/// and \ref sf::Vector3<T>, are reused as typedefs, so you can use
+/// the types in this namespace as well as the original ones.
+/// Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their
+/// actual type is an implementation detail and should not be used.
+///
+/// All vector types support a default constructor that
+/// initializes every component to zero, in addition to a
+/// constructor with one parameter for each component.
+/// The components are stored in member variables called
+/// x, y, z, and w.
+///
+/// All matrix types support a constructor with a float*
+/// parameter that points to a float array of the appropriate
+/// size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix).
+/// Furthermore, they can be converted from sf::Transform
+/// objects.
+///
+/// \see sf::Shader
+///
+////////////////////////////////////////////////////////////
diff --git a/include/SFML/Graphics/Glsl.inl b/include/SFML/Graphics/Glsl.inl
new file mode 100644
index 0000000..3f2b027
--- /dev/null
+++ b/include/SFML/Graphics/Glsl.inl
@@ -0,0 +1,155 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////
+/// \brief Helper functions to copy sf::Transform to sf::Glsl::Mat3/4
+///
+////////////////////////////////////////////////////////////
+void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<3, 3>& dest);
+void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<4, 4>& dest);
+
+////////////////////////////////////////////////////////////
+/// \brief Copy array-based matrix with given number of elements
+///
+/// Indirection to std::copy() to avoid inclusion of
+/// <algorithm> and MSVC's annoying 4996 warning in header
+///
+////////////////////////////////////////////////////////////
+void SFML_GRAPHICS_API copyMatrix(const float* source, std::size_t elements, float* dest);
+
+////////////////////////////////////////////////////////////
+/// \brief Helper functions to copy sf::Color to sf::Glsl::Vec4/Ivec4
+///
+////////////////////////////////////////////////////////////
+void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<float>& dest);
+void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<int>& dest);
+
+
+////////////////////////////////////////////////////////////
+/// \brief Matrix type, used to set uniforms in GLSL
+///
+////////////////////////////////////////////////////////////
+template <std::size_t Columns, std::size_t Rows>
+struct Matrix
+{
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct from raw data
+ ///
+ /// \param pointer Points to the beginning of an array that
+ /// has the size of the matrix. The elements
+ /// are copied to the instance.
+ ///
+ ////////////////////////////////////////////////////////////
+ explicit Matrix(const float* pointer)
+ {
+ copyMatrix(pointer, Columns * Rows, array);
+ }
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct implicitly from SFML transform
+ ///
+ /// This constructor is only supported for 3x3 and 4x4
+ /// matrices.
+ ///
+ /// \param transform Object containing a transform.
+ ///
+ ////////////////////////////////////////////////////////////
+ Matrix(const Transform& transform)
+ {
+ copyMatrix(transform, *this);
+ }
+
+ float array[Columns * Rows]; ///< Array holding matrix data
+};
+
+////////////////////////////////////////////////////////////
+/// \brief 4D vector type, used to set uniforms in GLSL
+///
+////////////////////////////////////////////////////////////
+template <typename T>
+struct Vector4
+{
+ ////////////////////////////////////////////////////////////
+ /// \brief Default constructor, creates a zero vector
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector4() :
+ x(0),
+ y(0),
+ z(0),
+ w(0)
+ {
+ }
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct from 4 vector components
+ ///
+ /// \param X Component of the 4D vector
+ /// \param Y Component of the 4D vector
+ /// \param Z Component of the 4D vector
+ /// \param W Component of the 4D vector
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector4(T X, T Y, T Z, T W) :
+ x(X),
+ y(Y),
+ z(Z),
+ w(W)
+ {
+ }
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Conversion constructor
+ ///
+ /// \param other 4D vector of different type
+ ///
+ ////////////////////////////////////////////////////////////
+ template <typename U>
+ explicit Vector4(const Vector4<U>& other) :
+ x(static_cast<T>(other.x)),
+ y(static_cast<T>(other.y)),
+ z(static_cast<T>(other.z)),
+ w(static_cast<T>(other.w))
+ {
+ }
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Construct float vector implicitly from color
+ ///
+ /// \param color Color instance. Is normalized to [0, 1]
+ /// for floats, and left as-is for ints.
+ ///
+ ////////////////////////////////////////////////////////////
+ Vector4(const Color& color)
+ // uninitialized
+ {
+ copyVector(color, *this);
+ }
+
+ T x; ///< 1st component (X) of the 4D vector
+ T y; ///< 2nd component (Y) of the 4D vector
+ T z; ///< 3rd component (Z) of the 4D vector
+ T w; ///< 4th component (W) of the 4D vector
+};
diff --git a/include/SFML/Graphics/Glyph.hpp b/include/SFML/Graphics/Glyph.hpp
index 0068872..174eb84 100644
--- a/include/SFML/Graphics/Glyph.hpp
+++ b/include/SFML/Graphics/Glyph.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp
index 11dc8f7..6eaa1f7 100644
--- a/include/SFML/Graphics/Image.hpp
+++ b/include/SFML/Graphics/Image.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/PrimitiveType.hpp b/include/SFML/Graphics/PrimitiveType.hpp
index 9dae947..931530b 100644
--- a/include/SFML/Graphics/PrimitiveType.hpp
+++ b/include/SFML/Graphics/PrimitiveType.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -38,13 +38,18 @@ namespace sf
////////////////////////////////////////////////////////////
enum PrimitiveType
{
- Points, ///< List of individual points
- Lines, ///< List of individual lines
- LinesStrip, ///< List of connected lines, a point uses the previous point to form a line
- Triangles, ///< List of individual triangles
- TrianglesStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle
- TrianglesFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
- Quads ///< List of individual quads (deprecated, don't work with OpenGL ES)
+ Points, ///< List of individual points
+ Lines, ///< List of individual lines
+ LineStrip, ///< List of connected lines, a point uses the previous point to form a line
+ Triangles, ///< List of individual triangles
+ TriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle
+ TriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
+ Quads, ///< List of individual quads (deprecated, don't work with OpenGL ES)
+
+ // Deprecated names
+ LinesStrip = LineStrip, ///< \deprecated Use LineStrip instead
+ TrianglesStrip = TriangleStrip, ///< \deprecated Use TriangleStrip instead
+ TrianglesFan = TriangleFan ///< \deprecated Use TriangleFan instead
};
} // namespace sf
diff --git a/include/SFML/Graphics/Rect.hpp b/include/SFML/Graphics/Rect.hpp
index f11a920..1b09388 100644
--- a/include/SFML/Graphics/Rect.hpp
+++ b/include/SFML/Graphics/Rect.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Rect.inl b/include/SFML/Graphics/Rect.inl
index 9ac4870..036fb47 100644
--- a/include/SFML/Graphics/Rect.inl
+++ b/include/SFML/Graphics/Rect.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/RectangleShape.hpp b/include/SFML/Graphics/RectangleShape.hpp
index 3195dc3..35dcc67 100644
--- a/include/SFML/Graphics/RectangleShape.hpp
+++ b/include/SFML/Graphics/RectangleShape.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/RenderStates.hpp b/include/SFML/Graphics/RenderStates.hpp
index 3ab3271..94f1197 100644
--- a/include/SFML/Graphics/RenderStates.hpp
+++ b/include/SFML/Graphics/RenderStates.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp
index eb02355..adfa9ad 100644
--- a/include/SFML/Graphics/RenderTarget.hpp
+++ b/include/SFML/Graphics/RenderTarget.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/RenderTexture.hpp b/include/SFML/Graphics/RenderTexture.hpp
index 5d38562..4c6a833 100644
--- a/include/SFML/Graphics/RenderTexture.hpp
+++ b/include/SFML/Graphics/RenderTexture.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -132,7 +132,23 @@ public:
bool isRepeated() const;
////////////////////////////////////////////////////////////
- /// \brief Activate of deactivate the render-texture for rendering
+ /// \brief Generate a mipmap using the current texture data
+ ///
+ /// This function is similar to Texture::generateMipmap and operates
+ /// on the texture used as the target for drawing.
+ /// Be aware that any draw operation may modify the base level image data.
+ /// For this reason, calling this function only makes sense after all
+ /// drawing is completed and display has been called. Not calling display
+ /// after subsequent drawing will lead to undefined behavior if a mipmap
+ /// had been previously generated.
+ ///
+ /// \return True if mipmap generation was successful, false if unsuccessful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool generateMipmap();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Activate or deactivate the render-texture for rendering
///
/// This function makes the render-texture's context current for
/// future OpenGL rendering operations (so you shouldn't care
diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp
index 98e5b9a..fc55af4 100644
--- a/include/SFML/Graphics/RenderWindow.hpp
+++ b/include/SFML/Graphics/RenderWindow.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -115,6 +115,17 @@ public:
////////////////////////////////////////////////////////////
/// \brief Copy the current contents of the window to an image
///
+ /// \deprecated
+ /// Use a sf::Texture and its sf::Texture::update(const Window&)
+ /// function and copy its contents into an sf::Image instead.
+ /// \code
+ /// sf::Vector2u windowSize = window.getSize();
+ /// sf::Texture texture;
+ /// texture.create(windowSize.x, windowSize.y);
+ /// texture.update(window);
+ /// sf::Image screenshot = texture.copyToImage();
+ /// \endcode
+ ///
/// This is a slow operation, whose main purpose is to make
/// screenshots of the application. If you want to update an
/// image with the contents of the window and then use it for
@@ -126,7 +137,7 @@ public:
/// \return Image containing the captured contents
///
////////////////////////////////////////////////////////////
- Image capture() const;
+ SFML_DEPRECATED Image capture() const;
protected:
diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp
index 55cc3bb..9597fcb 100644
--- a/include/SFML/Graphics/Shader.hpp
+++ b/include/SFML/Graphics/Shader.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -29,8 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.hpp>
-#include <SFML/Graphics/Transform.hpp>
-#include <SFML/Graphics/Color.hpp>
+#include <SFML/Graphics/Glsl.hpp>
#include <SFML/Window/GlResource.hpp>
#include <SFML/System/NonCopyable.hpp>
#include <SFML/System/Vector2.hpp>
@@ -41,11 +40,13 @@
namespace sf
{
+class Color;
class InputStream;
class Texture;
+class Transform;
////////////////////////////////////////////////////////////
-/// \brief Shader class (vertex and fragment)
+/// \brief Shader class (vertex, geometry and fragment)
///
////////////////////////////////////////////////////////////
class SFML_GRAPHICS_API Shader : GlResource, NonCopyable
@@ -58,15 +59,16 @@ public:
////////////////////////////////////////////////////////////
enum Type
{
- Vertex, ///< Vertex shader
- Fragment ///< Fragment (pixel) shader
+ Vertex, ///< %Vertex shader
+ Geometry, ///< Geometry shader
+ Fragment ///< Fragment (pixel) shader
};
////////////////////////////////////////////////////////////
- /// \brief Special type that can be passed to setParameter,
+ /// \brief Special type that can be passed to setUniform(),
/// and that represents the texture of the object being drawn
///
- /// \see setParameter(const std::string&, CurrentTextureType)
+ /// \see setUniform(const std::string&, CurrentTextureType)
///
////////////////////////////////////////////////////////////
struct CurrentTextureType {};
@@ -74,7 +76,7 @@ public:
////////////////////////////////////////////////////////////
/// \brief Represents the texture of the object being drawn
///
- /// \see setParameter(const std::string&, CurrentTextureType)
+ /// \see setUniform(const std::string&, CurrentTextureType)
///
////////////////////////////////////////////////////////////
static CurrentTextureType CurrentTexture;
@@ -96,9 +98,9 @@ public:
~Shader();
////////////////////////////////////////////////////////////
- /// \brief Load either the vertex or fragment shader from a file
+ /// \brief Load the vertex, geometry or fragment shader from a file
///
- /// This function loads a single shader, either vertex or
+ /// This function loads a single shader, vertex, geometry or
/// fragment, identified by the second argument.
/// The source must be a text file containing a valid
/// shader in GLSL language. GLSL is a C-like language
@@ -106,8 +108,8 @@ public:
/// read a good documentation for it before writing your
/// own shaders.
///
- /// \param filename Path of the vertex or fragment shader file to load
- /// \param type Type of shader (vertex or fragment)
+ /// \param filename Path of the vertex, geometry or fragment shader file to load
+ /// \param type Type of shader (vertex, geometry or fragment)
///
/// \return True if loading succeeded, false if it failed
///
@@ -138,17 +140,39 @@ public:
bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
////////////////////////////////////////////////////////////
- /// \brief Load either the vertex or fragment shader from a source code in memory
+ /// \brief Load the vertex, geometry and fragment shaders from files
///
- /// This function loads a single shader, either vertex or
- /// fragment, identified by the second argument.
+ /// This function loads the vertex, geometry and fragment
+ /// shaders. If one of them fails to load, the shader is left
+ /// empty (the valid shader is unloaded).
+ /// The sources must be text files containing valid shaders
+ /// in GLSL language. GLSL is a C-like language dedicated to
+ /// OpenGL shaders; you'll probably need to read a good documentation
+ /// for it before writing your own shaders.
+ ///
+ /// \param vertexShaderFilename Path of the vertex shader file to load
+ /// \param geometryShaderFilename Path of the geometry shader file to load
+ /// \param fragmentShaderFilename Path of the fragment shader file to load
+ ///
+ /// \return True if loading succeeded, false if it failed
+ ///
+ /// \see loadFromMemory, loadFromStream
+ ///
+ ////////////////////////////////////////////////////////////
+ bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Load the vertex, geometry or fragment shader from a source code in memory
+ ///
+ /// This function loads a single shader, vertex, geometry
+ /// or fragment, identified by the second argument.
/// The source code must be a valid shader in GLSL language.
/// GLSL is a C-like language dedicated to OpenGL shaders;
/// you'll probably need to read a good documentation for
/// it before writing your own shaders.
///
/// \param shader String containing the source code of the shader
- /// \param type Type of shader (vertex or fragment)
+ /// \param type Type of shader (vertex, geometry or fragment)
///
/// \return True if loading succeeded, false if it failed
///
@@ -179,17 +203,39 @@ public:
bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
////////////////////////////////////////////////////////////
- /// \brief Load either the vertex or fragment shader from a custom stream
+ /// \brief Load the vertex, geometry and fragment shaders from source codes in memory
///
- /// This function loads a single shader, either vertex or
- /// fragment, identified by the second argument.
+ /// This function loads the vertex, geometry and fragment
+ /// shaders. If one of them fails to load, the shader is left
+ /// empty (the valid shader is unloaded).
+ /// The sources must be valid shaders in GLSL language. GLSL is
+ /// a C-like language dedicated to OpenGL shaders; you'll
+ /// probably need to read a good documentation for it before
+ /// writing your own shaders.
+ ///
+ /// \param vertexShader String containing the source code of the vertex shader
+ /// \param geometryShader String containing the source code of the geometry shader
+ /// \param fragmentShader String containing the source code of the fragment shader
+ ///
+ /// \return True if loading succeeded, false if it failed
+ ///
+ /// \see loadFromFile, loadFromStream
+ ///
+ ////////////////////////////////////////////////////////////
+ bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Load the vertex, geometry or fragment shader from a custom stream
+ ///
+ /// This function loads a single shader, vertex, geometry
+ /// or fragment, identified by the second argument.
/// The source code must be a valid shader in GLSL language.
/// GLSL is a C-like language dedicated to OpenGL shaders;
/// you'll probably need to read a good documentation for it
/// before writing your own shaders.
///
/// \param stream Source stream to read from
- /// \param type Type of shader (vertex or fragment)
+ /// \param type Type of shader (vertex, geometry or fragment)
///
/// \return True if loading succeeded, false if it failed
///
@@ -220,193 +266,176 @@ public:
bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
////////////////////////////////////////////////////////////
- /// \brief Change a float parameter of the shader
+ /// \brief Load the vertex, geometry and fragment shaders from custom streams
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a float
- /// (float GLSL type).
+ /// This function loads the vertex, geometry and fragment
+ /// shaders. If one of them fails to load, the shader is left
+ /// empty (the valid shader is unloaded).
+ /// The source codes must be valid shaders in GLSL language.
+ /// GLSL is a C-like language dedicated to OpenGL shaders;
+ /// you'll probably need to read a good documentation for
+ /// it before writing your own shaders.
///
- /// Example:
- /// \code
- /// uniform float myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", 5.2f);
- /// \endcode
+ /// \param vertexShaderStream Source stream to read the vertex shader from
+ /// \param geometryShaderStream Source stream to read the geometry shader from
+ /// \param fragmentShaderStream Source stream to read the fragment shader from
+ ///
+ /// \return True if loading succeeded, false if it failed
///
- /// \param name Name of the parameter in the shader
- /// \param x Value to assign
+ /// \see loadFromFile, loadFromMemory
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, float x);
+ bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream);
////////////////////////////////////////////////////////////
- /// \brief Change a 2-components vector parameter of the shader
+ /// \brief Specify value for \p float uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 2x1 vector
- /// (vec2 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param x Value of the float scalar
///
- /// Example:
- /// \code
- /// uniform vec2 myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", 5.2f, 6.0f);
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, float x);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p vec2 uniform
///
- /// \param name Name of the parameter in the shader
- /// \param x First component of the value to assign
- /// \param y Second component of the value to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the vec2 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, float x, float y);
+ void setUniform(const std::string& name, const Glsl::Vec2& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a 3-components vector parameter of the shader
+ /// \brief Specify value for \p vec3 uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 3x1 vector
- /// (vec3 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the vec3 vector
///
- /// Example:
- /// \code
- /// uniform vec3 myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f);
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, const Glsl::Vec3& vector);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p vec4 uniform
+ ///
+ /// This overload can also be called with sf::Color objects
+ /// that are converted to sf::Glsl::Vec4.
+ ///
+ /// It is important to note that the components of the color are
+ /// normalized before being passed to the shader. Therefore,
+ /// they are converted from range [0 .. 255] to range [0 .. 1].
+ /// For example, a sf::Color(255, 127, 0, 255) will be transformed
+ /// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.
///
- /// \param name Name of the parameter in the shader
- /// \param x First component of the value to assign
- /// \param y Second component of the value to assign
- /// \param z Third component of the value to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the vec4 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, float x, float y, float z);
+ void setUniform(const std::string& name, const Glsl::Vec4& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a 4-components vector parameter of the shader
+ /// \brief Specify value for \p int uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 4x1 vector
- /// (vec4 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param x Value of the int scalar
///
- /// Example:
- /// \code
- /// uniform vec4 myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f, 0.4f);
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, int x);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p ivec2 uniform
///
- /// \param name Name of the parameter in the shader
- /// \param x First component of the value to assign
- /// \param y Second component of the value to assign
- /// \param z Third component of the value to assign
- /// \param w Fourth component of the value to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the ivec2 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, float x, float y, float z, float w);
+ void setUniform(const std::string& name, const Glsl::Ivec2& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a 2-components vector parameter of the shader
+ /// \brief Specify value for \p ivec3 uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 2x1 vector
- /// (vec2 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the ivec3 vector
///
- /// Example:
- /// \code
- /// uniform vec2 myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", sf::Vector2f(5.2f, 6.0f));
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, const Glsl::Ivec3& vector);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p ivec4 uniform
+ ///
+ /// This overload can also be called with sf::Color objects
+ /// that are converted to sf::Glsl::Ivec4.
+ ///
+ /// If color conversions are used, the ivec4 uniform in GLSL
+ /// will hold the same values as the original sf::Color
+ /// instance. For example, sf::Color(255, 127, 0, 255) is
+ /// mapped to ivec4(255, 127, 0, 255).
///
- /// \param name Name of the parameter in the shader
- /// \param vector Vector to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the ivec4 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, const Vector2f& vector);
+ void setUniform(const std::string& name, const Glsl::Ivec4& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a 3-components vector parameter of the shader
+ /// \brief Specify value for \p bool uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 3x1 vector
- /// (vec3 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param x Value of the bool scalar
///
- /// Example:
- /// \code
- /// uniform vec3 myparam; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("myparam", sf::Vector3f(5.2f, 6.0f, -8.1f));
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, bool x);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p bvec2 uniform
///
- /// \param name Name of the parameter in the shader
- /// \param vector Vector to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the bvec2 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, const Vector3f& vector);
+ void setUniform(const std::string& name, const Glsl::Bvec2& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a color parameter of the shader
+ /// \brief Specify value for \p bvec3 uniform
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 4x1 vector
- /// (vec4 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the bvec3 vector
///
- /// It is important to note that the components of the color are
- /// normalized before being passed to the shader. Therefore,
- /// they are converted from range [0 .. 255] to range [0 .. 1].
- /// For example, a sf::Color(255, 125, 0, 255) will be transformed
- /// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.
- ///
- /// Example:
- /// \code
- /// uniform vec4 color; // this is the variable in the shader
- /// \endcode
- /// \code
- /// shader.setParameter("color", sf::Color(255, 128, 0, 255));
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, const Glsl::Bvec3& vector);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p bvec4 uniform
///
- /// \param name Name of the parameter in the shader
- /// \param color Color to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vector Value of the bvec4 vector
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, const Color& color);
+ void setUniform(const std::string& name, const Glsl::Bvec4& vector);
////////////////////////////////////////////////////////////
- /// \brief Change a matrix parameter of the shader
+ /// \brief Specify value for \p mat3 matrix
///
- /// \a name is the name of the variable to change in the shader.
- /// The corresponding parameter in the shader must be a 4x4 matrix
- /// (mat4 GLSL type).
+ /// \param name Name of the uniform variable in GLSL
+ /// \param matrix Value of the mat3 matrix
///
- /// Example:
- /// \code
- /// uniform mat4 matrix; // this is the variable in the shader
- /// \endcode
- /// \code
- /// sf::Transform transform;
- /// transform.translate(5, 10);
- /// shader.setParameter("matrix", transform);
- /// \endcode
+ ////////////////////////////////////////////////////////////
+ void setUniform(const std::string& name, const Glsl::Mat3& matrix);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify value for \p mat4 matrix
///
- /// \param name Name of the parameter in the shader
- /// \param transform Transform to assign
+ /// \param name Name of the uniform variable in GLSL
+ /// \param matrix Value of the mat4 matrix
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, const Transform& transform);
+ void setUniform(const std::string& name, const Glsl::Mat4& matrix);
////////////////////////////////////////////////////////////
- /// \brief Change a texture parameter of the shader
+ /// \brief Specify a texture as \p sampler2D uniform
///
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2D texture
- /// (sampler2D GLSL type).
+ /// (\p sampler2D GLSL type).
///
/// Example:
/// \code
@@ -415,46 +444,186 @@ public:
/// \code
/// sf::Texture texture;
/// ...
- /// shader.setParameter("the_texture", texture);
+ /// shader.setUniform("the_texture", texture);
/// \endcode
/// It is important to note that \a texture must remain alive as long
/// as the shader uses it, no copy is made internally.
///
- /// To use the texture of the object being draw, which cannot be
+ /// To use the texture of the object being drawn, which cannot be
/// known in advance, you can pass the special value
/// sf::Shader::CurrentTexture:
/// \code
- /// shader.setParameter("the_texture", sf::Shader::CurrentTexture).
+ /// shader.setUniform("the_texture", sf::Shader::CurrentTexture).
/// \endcode
///
/// \param name Name of the texture in the shader
/// \param texture Texture to assign
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, const Texture& texture);
+ void setUniform(const std::string& name, const Texture& texture);
////////////////////////////////////////////////////////////
- /// \brief Change a texture parameter of the shader
+ /// \brief Specify current texture as \p sampler2D uniform
///
/// This overload maps a shader texture variable to the
/// texture of the object being drawn, which cannot be
/// known in advance. The second argument must be
/// sf::Shader::CurrentTexture.
/// The corresponding parameter in the shader must be a 2D texture
- /// (sampler2D GLSL type).
+ /// (\p sampler2D GLSL type).
///
/// Example:
/// \code
/// uniform sampler2D current; // this is the variable in the shader
/// \endcode
/// \code
- /// shader.setParameter("current", sf::Shader::CurrentTexture);
+ /// shader.setUniform("current", sf::Shader::CurrentTexture);
/// \endcode
///
/// \param name Name of the texture in the shader
///
////////////////////////////////////////////////////////////
- void setParameter(const std::string& name, CurrentTextureType);
+ void setUniform(const std::string& name, CurrentTextureType);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p float[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param scalarArray pointer to array of \p float values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const float* scalarArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p vec2[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vectorArray pointer to array of \p vec2 values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const Glsl::Vec2* vectorArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p vec3[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vectorArray pointer to array of \p vec3 values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const Glsl::Vec3* vectorArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p vec4[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param vectorArray pointer to array of \p vec4 values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const Glsl::Vec4* vectorArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p mat3[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param matrixArray pointer to array of \p mat3 values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const Glsl::Mat3* matrixArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Specify values for \p mat4[] array uniform
+ ///
+ /// \param name Name of the uniform variable in GLSL
+ /// \param matrixArray pointer to array of \p mat4 values
+ /// \param length Number of elements in the array
+ ///
+ ////////////////////////////////////////////////////////////
+ void setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a float parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, float) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, float x);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a 2-components vector parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, float x, float y);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a 3-components vector parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a 4-components vector parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z, float w);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a 2-components vector parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, const Vector2f& vector);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a 3-components vector parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, const Vector3f& vector);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a color parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, const Color& color);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a matrix parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Glsl::Mat4&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, const Transform& transform);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a texture parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, const Texture&) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, const Texture& texture);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Change a texture parameter of the shader
+ ///
+ /// \deprecated Use setUniform(const std::string&, CurrentTextureType) instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setParameter(const std::string& name, CurrentTextureType);
////////////////////////////////////////////////////////////
/// \brief Get the underlying OpenGL handle of the shader.
@@ -498,13 +667,29 @@ public:
/// the shader features. If it returns false, then
/// any attempt to use sf::Shader will fail.
///
+ /// \return True if shaders are supported, false otherwise
+ ///
+ ////////////////////////////////////////////////////////////
+ static bool isAvailable();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Tell whether or not the system supports geometry shaders
+ ///
+ /// This function should always be called before using
+ /// the geometry shader features. If it returns false, then
+ /// any attempt to use sf::Shader geometry shader features will fail.
+ ///
+ /// This function can only return true if isAvailable() would also
+ /// return true, since shaders in general have to be supported in
+ /// order for geometry shaders to be supported as well.
+ ///
/// Note: The first call to this function, whether by your
/// code or SFML will result in a context switch.
///
- /// \return True if shaders are supported, false otherwise
+ /// \return True if geometry shaders are supported, false otherwise
///
////////////////////////////////////////////////////////////
- static bool isAvailable();
+ static bool isGeometryAvailable();
private:
@@ -515,12 +700,13 @@ private:
/// is not created.
///
/// \param vertexShaderCode Source code of the vertex shader
+ /// \param geometryShaderCode Source code of the geometry shader
/// \param fragmentShaderCode Source code of the fragment shader
///
/// \return True on success, false if any error happened
///
////////////////////////////////////////////////////////////
- bool compile(const char* vertexShaderCode, const char* fragmentShaderCode);
+ bool compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode);
////////////////////////////////////////////////////////////
/// \brief Bind all the textures used by the shader
@@ -532,20 +718,29 @@ private:
void bindTextures() const;
////////////////////////////////////////////////////////////
- /// \brief Get the location ID of a shader parameter
+ /// \brief Get the location ID of a shader uniform
///
- /// \param name Name of the parameter to search
+ /// \param name Name of the uniform variable to search
///
- /// \return Location ID of the parameter, or -1 if not found
+ /// \return Location ID of the uniform, or -1 if not found
///
////////////////////////////////////////////////////////////
- int getParamLocation(const std::string& name);
+ int getUniformLocation(const std::string& name);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief RAII object to save and restore the program
+ /// binding while uniforms are being set
+ ///
+ /// Implementation is private in the .cpp file.
+ ///
+ ////////////////////////////////////////////////////////////
+ struct UniformBinder;
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<int, const Texture*> TextureTable;
- typedef std::map<std::string, int> ParamTable;
+ typedef std::map<std::string, int> UniformTable;
////////////////////////////////////////////////////////////
// Member data
@@ -553,7 +748,7 @@ private:
unsigned int m_shaderProgram; ///< OpenGL identifier for the program
int m_currentTexture; ///< Location of the current texture in the shader
TextureTable m_textures; ///< Texture variables in the shader, mapped to their location
- ParamTable m_params; ///< Parameters location cache
+ UniformTable m_uniforms; ///< Parameters location cache
};
} // namespace sf
@@ -570,45 +765,64 @@ private:
/// executed directly by the graphics card and allowing
/// to apply real-time operations to the rendered entities.
///
-/// There are two kinds of shaders:
-/// \li Vertex shaders, that process vertices
+/// There are three kinds of shaders:
+/// \li %Vertex shaders, that process vertices
+/// \li Geometry shaders, that process primitives
/// \li Fragment (pixel) shaders, that process pixels
///
/// A sf::Shader can be composed of either a vertex shader
-/// alone, a fragment shader alone, or both combined
-/// (see the variants of the load functions).
+/// alone, a geometry shader alone, a fragment shader alone,
+/// or any combination of them. (see the variants of the
+/// load functions).
///
/// Shaders are written in GLSL, which is a C-like
/// language dedicated to OpenGL shaders. You'll probably
/// need to learn its basics before writing your own shaders
/// for SFML.
///
-/// Like any C/C++ program, a shader has its own variables
-/// that you can set from your C++ application. sf::Shader
-/// handles 5 different types of variables:
-/// \li floats
+/// Like any C/C++ program, a GLSL shader has its own variables
+/// called \a uniforms that you can set from your C++ application.
+/// sf::Shader handles different types of uniforms:
+/// \li scalars: \p float, \p int, \p bool
/// \li vectors (2, 3 or 4 components)
-/// \li colors
-/// \li textures
-/// \li transforms (matrices)
+/// \li matrices (3x3 or 4x4)
+/// \li samplers (textures)
///
-/// The value of the variables can be changed at any time
-/// with the various overloads of the setParameter function:
+/// Some SFML-specific types can be converted:
+/// \li sf::Color as a 4D vector (\p vec4)
+/// \li sf::Transform as matrices (\p mat3 or \p mat4)
+///
+/// Every uniform variable in a shader can be set through one of the
+/// setUniform() or setUniformArray() overloads. For example, if you
+/// have a shader with the following uniforms:
/// \code
-/// shader.setParameter("offset", 2.f);
-/// shader.setParameter("point", 0.5f, 0.8f, 0.3f);
-/// shader.setParameter("color", sf::Color(128, 50, 255));
-/// shader.setParameter("matrix", transform); // transform is a sf::Transform
-/// shader.setParameter("overlay", texture); // texture is a sf::Texture
-/// shader.setParameter("texture", sf::Shader::CurrentTexture);
+/// uniform float offset;
+/// uniform vec3 point;
+/// uniform vec4 color;
+/// uniform mat4 matrix;
+/// uniform sampler2D overlay;
+/// uniform sampler2D current;
/// \endcode
+/// You can set their values from C++ code as follows, using the types
+/// defined in the sf::Glsl namespace:
+/// \code
+/// shader.setUniform("offset", 2.f);
+/// shader.setUniform("point", sf::Vector3f(0.5f, 0.8f, 0.3f));
+/// shader.setUniform("color", sf::Glsl::Vec4(color)); // color is a sf::Color
+/// shader.setUniform("matrix", sf::Glsl::Mat4(transform)); // transform is a sf::Transform
+/// shader.setUniform("overlay", texture); // texture is a sf::Texture
+/// shader.setUniform("current", sf::Shader::CurrentTexture);
+/// \endcode
+///
+/// The old setParameter() overloads are deprecated and will be removed in a
+/// future version. You should use their setUniform() equivalents instead.
///
/// The special Shader::CurrentTexture argument maps the
-/// given texture variable to the current texture of the
+/// given \p sampler2D uniform to the current texture of the
/// object being drawn (which cannot be known in advance).
///
/// To apply a shader to a drawable, you must pass it as an
-/// additional parameter to the Draw function:
+/// additional parameter to the \ref Window::draw() draw() function:
/// \code
/// window.draw(sprite, &shader);
/// \endcode
@@ -656,4 +870,6 @@ private:
/// sf::Shader::bind(NULL);
/// \endcode
///
+/// \see sf::Glsl
+///
////////////////////////////////////////////////////////////
diff --git a/include/SFML/Graphics/Shape.hpp b/include/SFML/Graphics/Shape.hpp
index 5983a9d..2878cc5 100644
--- a/include/SFML/Graphics/Shape.hpp
+++ b/include/SFML/Graphics/Shape.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp
index c7447df..712fa15 100644
--- a/include/SFML/Graphics/Sprite.hpp
+++ b/include/SFML/Graphics/Sprite.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp
index c31ec61..9d54d97 100644
--- a/include/SFML/Graphics/Text.hpp
+++ b/include/SFML/Graphics/Text.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -159,16 +159,63 @@ public:
void setStyle(Uint32 style);
////////////////////////////////////////////////////////////
- /// \brief Set the global color of the text
+ /// \brief Set the fill color of the text
///
- /// By default, the text's color is opaque white.
+ /// By default, the text's fill color is opaque white.
+ /// Setting the fill color to a transparent color with an outline
+ /// will cause the outline to be displayed in the fill area of the text.
///
- /// \param color New color of the text
+ /// \param color New fill color of the text
///
- /// \see getColor
+ /// \see getFillColor
+ ///
+ /// \deprecated There is now fill and outline colors instead
+ /// of a single global color.
+ /// Use setFillColor() or setOutlineColor() instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED void setColor(const Color& color);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Set the fill color of the text
+ ///
+ /// By default, the text's fill color is opaque white.
+ /// Setting the fill color to a transparent color with an outline
+ /// will cause the outline to be displayed in the fill area of the text.
+ ///
+ /// \param color New fill color of the text
+ ///
+ /// \see getFillColor
+ ///
+ ////////////////////////////////////////////////////////////
+ void setFillColor(const Color& color);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Set the outline color of the text
+ ///
+ /// By default, the text's outline color is opaque black.
+ ///
+ /// \param color New outline color of the text
+ ///
+ /// \see getOutlineColor
+ ///
+ ////////////////////////////////////////////////////////////
+ void setOutlineColor(const Color& color);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Set the thickness of the text's outline
+ ///
+ /// By default, the outline thickness is 0.
+ ///
+ /// Be aware that using a negative value for the outline
+ /// thickness will cause distorted rendering.
+ ///
+ /// \param thickness New outline thickness, in pixels
+ ///
+ /// \see getOutlineThickness
///
////////////////////////////////////////////////////////////
- void setColor(const Color& color);
+ void setOutlineThickness(float thickness);
////////////////////////////////////////////////////////////
/// \brief Get the text's string
@@ -224,14 +271,48 @@ public:
Uint32 getStyle() const;
////////////////////////////////////////////////////////////
- /// \brief Get the global color of the text
+ /// \brief Get the fill color of the text
+ ///
+ /// \return Fill color of the text
+ ///
+ /// \see setFillColor
+ ///
+ /// \deprecated There is now fill and outline colors instead
+ /// of a single global color.
+ /// Use getFillColor() or getOutlineColor() instead.
+ ///
+ ////////////////////////////////////////////////////////////
+ SFML_DEPRECATED const Color& getColor() const;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the fill color of the text
+ ///
+ /// \return Fill color of the text
+ ///
+ /// \see setFillColor
+ ///
+ ////////////////////////////////////////////////////////////
+ const Color& getFillColor() const;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the outline color of the text
+ ///
+ /// \return Outline color of the text
+ ///
+ /// \see setOutlineColor
+ ///
+ ////////////////////////////////////////////////////////////
+ const Color& getOutlineColor() const;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the outline thickness of the text
///
- /// \return Global color of the text
+ /// \return Outline thickness of the text, in pixels
///
- /// \see setColor
+ /// \see setOutlineThickness
///
////////////////////////////////////////////////////////////
- const Color& getColor() const;
+ float getOutlineThickness() const;
////////////////////////////////////////////////////////////
/// \brief Return the position of the \a index-th character
@@ -305,8 +386,11 @@ private:
const Font* m_font; ///< Font used to display the string
unsigned int m_characterSize; ///< Base size of characters, in pixels
Uint32 m_style; ///< Text style (see Style enum)
- Color m_color; ///< Text color
- mutable VertexArray m_vertices; ///< Vertex array containing the text's geometry
+ Color m_fillColor; ///< Text fill color
+ Color m_outlineColor; ///< Text outline color
+ float m_outlineThickness; ///< Thickness of the text's outline
+ mutable VertexArray m_vertices; ///< Vertex array containing the fill geometry
+ mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry
mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates)
mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?
};
diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp
index 2471531..6434ab0 100644
--- a/include/SFML/Graphics/Texture.hpp
+++ b/include/SFML/Graphics/Texture.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -377,6 +377,41 @@ public:
bool isSmooth() const;
////////////////////////////////////////////////////////////
+ /// \brief Enable or disable conversion from sRGB
+ ///
+ /// When providing texture data from an image file or memory, it can
+ /// either be stored in a linear color space or an sRGB color space.
+ /// Most digital images account for gamma correction already, so they
+ /// would need to be "uncorrected" back to linear color space before
+ /// being processed by the hardware. The hardware can automatically
+ /// convert it from the sRGB color space to a linear color space when
+ /// it gets sampled. When the rendered image gets output to the final
+ /// framebuffer, it gets converted back to sRGB.
+ ///
+ /// After enabling or disabling sRGB conversion, make sure to reload
+ /// the texture data in order for the setting to take effect.
+ ///
+ /// This option is only useful in conjunction with an sRGB capable
+ /// framebuffer. This can be requested during window creation.
+ ///
+ /// \param sRgb True to enable sRGB conversion, false to disable it
+ ///
+ /// \see isSrgb
+ ///
+ ////////////////////////////////////////////////////////////
+ void setSrgb(bool sRgb);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Tell whether the texture source is converted from sRGB or not
+ ///
+ /// \return True if the texture source is converted from sRGB, false if not
+ ///
+ /// \see setSrgb
+ ///
+ ////////////////////////////////////////////////////////////
+ bool isSrgb() const;
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable repeating
///
/// Repeating is involved when using texture coordinates
@@ -411,6 +446,31 @@ public:
bool isRepeated() const;
////////////////////////////////////////////////////////////
+ /// \brief Generate a mipmap using the current texture data
+ ///
+ /// Mipmaps are pre-computed chains of optimized textures. Each
+ /// level of texture in a mipmap is generated by halving each of
+ /// the previous level's dimensions. This is done until the final
+ /// level has the size of 1x1. The textures generated in this process may
+ /// make use of more advanced filters which might improve the visual quality
+ /// of textures when they are applied to objects much smaller than they are.
+ /// This is known as minification. Because fewer texels (texture elements)
+ /// have to be sampled from when heavily minified, usage of mipmaps
+ /// can also improve rendering performance in certain scenarios.
+ ///
+ /// Mipmap generation relies on the necessary OpenGL extension being
+ /// available. If it is unavailable or generation fails due to another
+ /// reason, this function will return false. Mipmap data is only valid from
+ /// the time it is generated until the next time the base level image is
+ /// modified, at which point this function will have to be called again to
+ /// regenerate it.
+ ///
+ /// \return True if mipmap generation was successful, false if unsuccessful
+ ///
+ ////////////////////////////////////////////////////////////
+ bool generateMipmap();
+
+ ////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
/// \param right Instance to assign
@@ -472,9 +532,6 @@ public:
/// You can expect a value of 512 pixels for low-end graphics
/// card, and up to 8192 pixels or more for newer hardware.
///
- /// Note: The first call to this function, whether by your
- /// code or SFML will result in a context switch.
- ///
/// \return Maximum size allowed for textures, in pixels
///
////////////////////////////////////////////////////////////
@@ -501,15 +558,26 @@ private:
static unsigned int getValidSize(unsigned int size);
////////////////////////////////////////////////////////////
+ /// \brief Invalidate the mipmap if one exists
+ ///
+ /// This also resets the texture's minifying function.
+ /// This function is mainly for internal use by RenderTexture.
+ ///
+ ////////////////////////////////////////////////////////////
+ void invalidateMipmap();
+
+ ////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Vector2u m_size; ///< Public texture size
Vector2u m_actualSize; ///< Actual texture size (can be greater than public size because of padding)
unsigned int m_texture; ///< Internal texture identifier
bool m_isSmooth; ///< Status of the smooth filter
+ bool m_sRgb; ///< Should the texture source be converted from sRGB?
bool m_isRepeated; ///< Is the texture in repeat mode?
mutable bool m_pixelsFlipped; ///< To work around the inconsistency in Y orientation
bool m_fboAttachment; ///< Is this texture owned by a framebuffer object?
+ bool m_hasMipmap; ///< Has the mipmap been generated?
Uint64 m_cacheId; ///< Unique number that identifies the texture to the render target's cache
};
diff --git a/include/SFML/Graphics/Transform.hpp b/include/SFML/Graphics/Transform.hpp
index a555a33..f1094ce 100644
--- a/include/SFML/Graphics/Transform.hpp
+++ b/include/SFML/Graphics/Transform.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Transformable.hpp b/include/SFML/Graphics/Transformable.hpp
index e4b86cf..d73cca4 100644
--- a/include/SFML/Graphics/Transformable.hpp
+++ b/include/SFML/Graphics/Transformable.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/Vertex.hpp b/include/SFML/Graphics/Vertex.hpp
index 2509976..d2693f9 100644
--- a/include/SFML/Graphics/Vertex.hpp
+++ b/include/SFML/Graphics/Vertex.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Graphics/VertexArray.hpp b/include/SFML/Graphics/VertexArray.hpp
index f0820a5..33dfe95 100644
--- a/include/SFML/Graphics/VertexArray.hpp
+++ b/include/SFML/Graphics/VertexArray.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -209,7 +209,7 @@ private:
///
/// Example:
/// \code
-/// sf::VertexArray lines(sf::LinesStrip, 4);
+/// sf::VertexArray lines(sf::LineStrip, 4);
/// lines[0].position = sf::Vector2f(10, 0);
/// lines[1].position = sf::Vector2f(20, 0);
/// lines[2].position = sf::Vector2f(30, 5);
diff --git a/include/SFML/Graphics/View.hpp b/include/SFML/Graphics/View.hpp
index 4bd62d8..2e4f510 100644
--- a/include/SFML/Graphics/View.hpp
+++ b/include/SFML/Graphics/View.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -302,11 +302,11 @@ private:
/// The viewport allows to map the scene to a custom part
/// of the render target, and can be used for split-screen
/// or for displaying a minimap, for example. If the source
-/// rectangle has not the same size as the viewport, its
+/// rectangle doesn't have the same size as the viewport, its
/// contents will be stretched to fit in.
///
/// To apply a view, you have to assign it to the render target.
-/// Then, every objects drawn in this render target will be
+/// Then, objects drawn in this render target will be
/// affected by the view until you use another view.
///
/// Usage example:
diff --git a/include/SFML/Main.hpp b/include/SFML/Main.hpp
index 23973d0..d61b82e 100644
--- a/include/SFML/Main.hpp
+++ b/include/SFML/Main.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network.hpp b/include/SFML/Network.hpp
index 68507af..1deaa03 100644
--- a/include/SFML/Network.hpp
+++ b/include/SFML/Network.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/Export.hpp b/include/SFML/Network/Export.hpp
index 6c880f6..43adf18 100644
--- a/include/SFML/Network/Export.hpp
+++ b/include/SFML/Network/Export.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp
index c62db7b..ad0cbc3 100644
--- a/include/SFML/Network/Ftp.hpp
+++ b/include/SFML/Network/Ftp.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -529,7 +529,8 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
- TcpSocket m_commandSocket; ///< Socket holding the control connection with the server
+ TcpSocket m_commandSocket; ///< Socket holding the control connection with the server
+ std::string m_receiveBuffer; ///< Received command data that is yet to be processed
};
} // namespace sf
diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp
index 057b86b..231da15 100644
--- a/include/SFML/Network/Http.hpp
+++ b/include/SFML/Network/Http.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp
index 8205e9f..b6852a2 100644
--- a/include/SFML/Network/IpAddress.hpp
+++ b/include/SFML/Network/IpAddress.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -99,7 +99,7 @@ public:
/// This constructor uses the internal representation of
/// the address directly. It should be used for optimization
/// purposes, and only if you got that representation from
- /// IpAddress::ToInteger().
+ /// IpAddress::toInteger().
///
/// \param address 4 bytes of the address packed into a 32-bits integer
///
@@ -182,15 +182,27 @@ public:
// Static member data
////////////////////////////////////////////////////////////
static const IpAddress None; ///< Value representing an empty/invalid address
+ static const IpAddress Any; ///< Value representing any address (0.0.0.0)
static const IpAddress LocalHost; ///< The "localhost" address (for connecting a computer to itself locally)
static const IpAddress Broadcast; ///< The "broadcast" address (for sending UDP messages to everyone on a local network)
private:
+ friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Resolve the given address string
+ ///
+ /// \param address Address string
+ ///
+ ////////////////////////////////////////////////////////////
+ void resolve(const std::string& address);
+
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Uint32 m_address; ///< Address stored as an unsigned 32 bits integer
+ bool m_valid; ///< Is the address valid?
};
////////////////////////////////////////////////////////////
diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp
index 0b7da9f..7810c2e 100644
--- a/include/SFML/Network/Packet.hpp
+++ b/include/SFML/Network/Packet.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/Socket.hpp b/include/SFML/Network/Socket.hpp
index d63f55e..57d58f7 100644
--- a/include/SFML/Network/Socket.hpp
+++ b/include/SFML/Network/Socket.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/SocketHandle.hpp b/include/SFML/Network/SocketHandle.hpp
index 7808ab5..5faef7a 100644
--- a/include/SFML/Network/SocketHandle.hpp
+++ b/include/SFML/Network/SocketHandle.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/SocketSelector.hpp b/include/SFML/Network/SocketSelector.hpp
index 4d334c6..13f9665 100644
--- a/include/SFML/Network/SocketSelector.hpp
+++ b/include/SFML/Network/SocketSelector.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/TcpListener.hpp b/include/SFML/Network/TcpListener.hpp
index a46ef29..1115eef 100644
--- a/include/SFML/Network/TcpListener.hpp
+++ b/include/SFML/Network/TcpListener.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
+#include <SFML/Network/IpAddress.hpp>
namespace sf
@@ -71,14 +72,15 @@ public:
/// If the socket was previously listening to another port,
/// it will be stopped first and bound to the new port.
///
- /// \param port Port to listen for new connections
+ /// \param port Port to listen for new connections
+ /// \param address Address of the interface to listen on
///
/// \return Status code
///
/// \see accept, close
///
////////////////////////////////////////////////////////////
- Status listen(unsigned short port);
+ Status listen(unsigned short port, const IpAddress& address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Stop listening and close the socket
diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp
index a402506..012cca0 100644
--- a/include/SFML/Network/TcpSocket.hpp
+++ b/include/SFML/Network/TcpSocket.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Network/UdpSocket.hpp b/include/SFML/Network/UdpSocket.hpp
index f00c257..20cb7c6 100644
--- a/include/SFML/Network/UdpSocket.hpp
+++ b/include/SFML/Network/UdpSocket.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,12 +30,12 @@
////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/Socket.hpp>
+#include <SFML/Network/IpAddress.hpp>
#include <vector>
namespace sf
{
-class IpAddress;
class Packet;
////////////////////////////////////////////////////////////
@@ -82,14 +82,15 @@ public:
/// system to automatically pick an available port, and then
/// call getLocalPort to retrieve the chosen port.
///
- /// \param port Port to bind the socket to
+ /// \param port Port to bind the socket to
+ /// \param address Address of the interface to bind to
///
/// \return Status code
///
/// \see unbind, getLocalPort
///
////////////////////////////////////////////////////////////
- Status bind(unsigned short port);
+ Status bind(unsigned short port, const IpAddress& address = IpAddress::Any);
////////////////////////////////////////////////////////////
/// \brief Unbind the socket from the local port to which it is bound
diff --git a/include/SFML/OpenGL.hpp b/include/SFML/OpenGL.hpp
index a5d964f..245d976 100644
--- a/include/SFML/OpenGL.hpp
+++ b/include/SFML/OpenGL.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -67,6 +67,9 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
+
+ // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
+ #include <GLES2/gl2ext.h>
#endif
diff --git a/include/SFML/System.hpp b/include/SFML/System.hpp
index 6af0652..499d423 100644
--- a/include/SFML/System.hpp
+++ b/include/SFML/System.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Clock.hpp b/include/SFML/System/Clock.hpp
index 684c616..1062b22 100644
--- a/include/SFML/System/Clock.hpp
+++ b/include/SFML/System/Clock.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Err.hpp b/include/SFML/System/Err.hpp
index 1c5b468..b2f0976 100644
--- a/include/SFML/System/Err.hpp
+++ b/include/SFML/System/Err.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Export.hpp b/include/SFML/System/Export.hpp
index f4adc10..df41668 100644
--- a/include/SFML/System/Export.hpp
+++ b/include/SFML/System/Export.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/FileInputStream.hpp b/include/SFML/System/FileInputStream.hpp
index 995351c..b4e4377 100644
--- a/include/SFML/System/FileInputStream.hpp
+++ b/include/SFML/System/FileInputStream.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -136,7 +136,7 @@ private:
////////////////////////////////////////////////////////////
-/// \class FileInputStream
+/// \class sf::FileInputStream
/// \ingroup system
///
/// This class is a specialization of InputStream that
@@ -153,17 +153,17 @@ private:
///
/// SFML resource classes can usually be loaded directly from
/// a filename, so this class shouldn't be useful to you unless
-/// you create your own algorithms that operate on a InputStream.
+/// you create your own algorithms that operate on an InputStream.
///
/// Usage example:
/// \code
/// void process(InputStream& stream);
///
-/// FileStream stream;
+/// FileInputStream stream;
/// if (stream.open("some_file.dat"))
/// process(stream);
/// \endcode
///
-/// InputStream, MemoryStream
+/// InputStream, MemoryInputStream
///
////////////////////////////////////////////////////////////
diff --git a/include/SFML/System/InputStream.hpp b/include/SFML/System/InputStream.hpp
index e5694fa..ae60b2b 100644
--- a/include/SFML/System/InputStream.hpp
+++ b/include/SFML/System/InputStream.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Lock.hpp b/include/SFML/System/Lock.hpp
index 05dac10..d36fea6 100644
--- a/include/SFML/System/Lock.hpp
+++ b/include/SFML/System/Lock.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/MemoryInputStream.hpp b/include/SFML/System/MemoryInputStream.hpp
index 250466c..16e71f2 100644
--- a/include/SFML/System/MemoryInputStream.hpp
+++ b/include/SFML/System/MemoryInputStream.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -116,7 +116,7 @@ private:
////////////////////////////////////////////////////////////
-/// \class MemoryeInputStream
+/// \class sf::MemoryInputStream
/// \ingroup system
///
/// This class is a specialization of InputStream that
@@ -132,17 +132,17 @@ private:
///
/// SFML resource classes can usually be loaded directly from
/// memory, so this class shouldn't be useful to you unless
-/// you create your own algorithms that operate on a InputStream.
+/// you create your own algorithms that operate on an InputStream.
///
/// Usage example:
/// \code
/// void process(InputStream& stream);
///
-/// MemoryStream stream;
+/// MemoryInputStream stream;
/// stream.open(thePtr, theSize);
/// process(stream);
/// \endcode
///
-/// InputStream, FileStream
+/// InputStream, FileInputStream
///
////////////////////////////////////////////////////////////
diff --git a/include/SFML/System/Mutex.hpp b/include/SFML/System/Mutex.hpp
index 67a8473..f2abdb3 100644
--- a/include/SFML/System/Mutex.hpp
+++ b/include/SFML/System/Mutex.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/NativeActivity.hpp b/include/SFML/System/NativeActivity.hpp
new file mode 100644
index 0000000..59d32db
--- /dev/null
+++ b/include/SFML/System/NativeActivity.hpp
@@ -0,0 +1,62 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+#ifndef SFML_NATIVEACTIVITY_HPP
+#define SFML_NATIVEACTIVITY_HPP
+
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/Export.hpp>
+
+
+#if !defined(SFML_SYSTEM_ANDROID)
+#error NativeActivity.hpp: This header is Android only.
+#endif
+
+
+struct ANativeActivity;
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+/// \ingroup system
+/// \brief Return a pointer to the Android native activity
+///
+/// You shouldn't have to use this function, unless you want
+/// to implement very specific details, that SFML doesn't
+/// support, or to use a workaround for a known issue.
+///
+/// \return Pointer to Android native activity structure
+///
+/// \sfplatform{Android,SFML/System/NativeActivity.hpp}
+///
+////////////////////////////////////////////////////////////
+SFML_SYSTEM_API ANativeActivity* getNativeActivity();
+
+} // namespace sf
+
+
+#endif // SFML_NATIVEACTIVITY_HPP
diff --git a/include/SFML/System/NonCopyable.hpp b/include/SFML/System/NonCopyable.hpp
index 9eb291c..4094376 100644
--- a/include/SFML/System/NonCopyable.hpp
+++ b/include/SFML/System/NonCopyable.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Sleep.hpp b/include/SFML/System/Sleep.hpp
index 3c0d04a..6da6860 100644
--- a/include/SFML/System/Sleep.hpp
+++ b/include/SFML/System/Sleep.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/String.hpp b/include/SFML/System/String.hpp
index 5a8c576..6001083 100644
--- a/include/SFML/System/String.hpp
+++ b/include/SFML/System/String.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <SFML/System/Utf.hpp>
+#include <iterator>
#include <locale>
#include <string>
diff --git a/include/SFML/System/String.inl b/include/SFML/System/String.inl
index 2b22efa..9ce4017 100644
--- a/include/SFML/System/String.inl
+++ b/include/SFML/System/String.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Thread.hpp b/include/SFML/System/Thread.hpp
index 3321615..3a90ab6 100644
--- a/include/SFML/System/Thread.hpp
+++ b/include/SFML/System/Thread.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Thread.inl b/include/SFML/System/Thread.inl
index 8e0236f..180b20a 100644
--- a/include/SFML/System/Thread.inl
+++ b/include/SFML/System/Thread.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/ThreadLocal.hpp b/include/SFML/System/ThreadLocal.hpp
index d1f9e4f..7516702 100644
--- a/include/SFML/System/ThreadLocal.hpp
+++ b/include/SFML/System/ThreadLocal.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/ThreadLocalPtr.hpp b/include/SFML/System/ThreadLocalPtr.hpp
index 3ee7abf..c776b45 100644
--- a/include/SFML/System/ThreadLocalPtr.hpp
+++ b/include/SFML/System/ThreadLocalPtr.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/ThreadLocalPtr.inl b/include/SFML/System/ThreadLocalPtr.inl
index 1d735bf..149213d 100644
--- a/include/SFML/System/ThreadLocalPtr.inl
+++ b/include/SFML/System/ThreadLocalPtr.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp
index 95a0a35..e3601fb 100644
--- a/include/SFML/System/Time.hpp
+++ b/include/SFML/System/Time.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp
index 9e9d153..a0b0561 100644
--- a/include/SFML/System/Utf.hpp
+++ b/include/SFML/System/Utf.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl
index a69ca07..b7a2ae4 100644
--- a/include/SFML/System/Utf.inl
+++ b/include/SFML/System/Utf.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -322,7 +322,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)
template <typename Out>
Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)
{
- if (input < 0xFFFF)
+ if (input <= 0xFFFF)
{
// The character can be copied directly, we just need to check if it's in the valid range
if ((input >= 0xD800) && (input <= 0xDFFF))
diff --git a/include/SFML/System/Vector2.hpp b/include/SFML/System/Vector2.hpp
index 6284026..a88334d 100644
--- a/include/SFML/System/Vector2.hpp
+++ b/include/SFML/System/Vector2.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Vector2.inl b/include/SFML/System/Vector2.inl
index 5cc67ca..0e49e4e 100644
--- a/include/SFML/System/Vector2.inl
+++ b/include/SFML/System/Vector2.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Vector3.hpp b/include/SFML/System/Vector3.hpp
index 51704b8..dcde39b 100644
--- a/include/SFML/System/Vector3.hpp
+++ b/include/SFML/System/Vector3.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/System/Vector3.inl b/include/SFML/System/Vector3.inl
index 3c69f2c..29d3e56 100644
--- a/include/SFML/System/Vector3.inl
+++ b/include/SFML/System/Vector3.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window.hpp b/include/SFML/Window.hpp
index 103f888..2a96efe 100644
--- a/include/SFML/Window.hpp
+++ b/include/SFML/Window.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Context.hpp b/include/SFML/Window/Context.hpp
index 29df67c..e59e772 100644
--- a/include/SFML/Window/Context.hpp
+++ b/include/SFML/Window/Context.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -77,7 +77,28 @@ public:
////////////////////////////////////////////////////////////
bool setActive(bool active);
-public:
+ ////////////////////////////////////////////////////////////
+ /// \brief Get the settings of the context
+ ///
+ /// Note that these settings may be different than the ones
+ /// passed to the constructor; they are indeed adjusted if the
+ /// original settings are not directly supported by the system.
+ ///
+ /// \return Structure containing the settings
+ ///
+ ////////////////////////////////////////////////////////////
+ const ContextSettings& getSettings() const;
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Check whether a given OpenGL extension is available
+ ///
+ /// \param name Name of the extension to check for
+ ///
+ /// \return True if available, false if unavailable
+ ///
+ ////////////////////////////////////////////////////////////
+ static bool isExtensionAvailable(const char* name);
+
////////////////////////////////////////////////////////////
/// \brief Get the address of an OpenGL function
///
@@ -89,6 +110,14 @@ public:
static GlFunctionPointer getFunction(const char* name);
////////////////////////////////////////////////////////////
+ /// \brief Get the currently active context
+ ///
+ /// \return The currently active context or NULL if none is active
+ ///
+ ////////////////////////////////////////////////////////////
+ static const Context* getActiveContext();
+
+ ////////////////////////////////////////////////////////////
/// \brief Construct a in-memory context
///
/// This constructor is for internal use, you don't need
diff --git a/include/SFML/Window/ContextSettings.hpp b/include/SFML/Window/ContextSettings.hpp
index 26ea910..1dd52f2 100644
--- a/include/SFML/Window/ContextSettings.hpp
+++ b/include/SFML/Window/ContextSettings.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -55,15 +55,17 @@ struct ContextSettings
/// \param major Major number of the context version
/// \param minor Minor number of the context version
/// \param attributes Attribute flags of the context
+ /// \param sRgb sRGB capable framebuffer
///
////////////////////////////////////////////////////////////
- explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 1, unsigned int minor = 1, unsigned int attributes = Default) :
+ explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 1, unsigned int minor = 1, unsigned int attributes = Default, bool sRgb = false) :
depthBits (depth),
stencilBits (stencil),
antialiasingLevel(antialiasing),
majorVersion (major),
minorVersion (minor),
- attributeFlags (attributes)
+ attributeFlags (attributes),
+ sRgbCapable (sRgb)
{
}
@@ -76,6 +78,7 @@ struct ContextSettings
unsigned int majorVersion; ///< Major number of the context version to create
unsigned int minorVersion; ///< Minor number of the context version to create
Uint32 attributeFlags; ///< The attribute flags to create the context with
+ bool sRgbCapable; ///< Whether the context framebuffer is sRGB capable
};
} // namespace sf
diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp
index 5fc9a10..0850adf 100644
--- a/include/SFML/Window/Event.hpp
+++ b/include/SFML/Window/Event.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Export.hpp b/include/SFML/Window/Export.hpp
index 4a708ec..e09f995 100644
--- a/include/SFML/Window/Export.hpp
+++ b/include/SFML/Window/Export.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/GlResource.hpp b/include/SFML/Window/GlResource.hpp
index a341f64..9deb35a 100644
--- a/include/SFML/Window/GlResource.hpp
+++ b/include/SFML/Window/GlResource.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Joystick.hpp b/include/SFML/Window/Joystick.hpp
index 27f6291..463daf0 100644
--- a/include/SFML/Window/Joystick.hpp
+++ b/include/SFML/Window/Joystick.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Keyboard.hpp b/include/SFML/Window/Keyboard.hpp
index b3186e9..2adad91 100644
--- a/include/SFML/Window/Keyboard.hpp
+++ b/include/SFML/Window/Keyboard.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Mouse.hpp b/include/SFML/Window/Mouse.hpp
index 0056f8c..c83d6fa 100644
--- a/include/SFML/Window/Mouse.hpp
+++ b/include/SFML/Window/Mouse.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Sensor.hpp b/include/SFML/Window/Sensor.hpp
index 6078881..1fd23b3 100644
--- a/include/SFML/Window/Sensor.hpp
+++ b/include/SFML/Window/Sensor.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Touch.hpp b/include/SFML/Window/Touch.hpp
index bf44f43..933523e 100644
--- a/include/SFML/Window/Touch.hpp
+++ b/include/SFML/Window/Touch.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -71,7 +71,7 @@ public:
/// \brief Get the current position of a touch in window coordinates
///
/// This function returns the current touch position
- /// in global (desktop) coordinates.
+ /// relative to the given window.
///
/// \param finger Finger index
/// \param relativeTo Reference window
diff --git a/include/SFML/Window/VideoMode.hpp b/include/SFML/Window/VideoMode.hpp
index 5eb268c..31c3a20 100644
--- a/include/SFML/Window/VideoMode.hpp
+++ b/include/SFML/Window/VideoMode.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp
index 44f0752..0839287 100644
--- a/include/SFML/Window/Window.hpp
+++ b/include/SFML/Window/Window.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -98,8 +98,7 @@ public:
/// advanced OpenGL context settings such as antialiasing,
/// depth-buffer bits, etc.
///
- /// \param handle Platform-specific handle of the control (\a HWND on
- /// Windows, \a %Window on Linux/FreeBSD, \a NSWindow on OS X)
+ /// \param handle Platform-specific handle of the control
/// \param settings Additional settings for the underlying OpenGL context
///
////////////////////////////////////////////////////////////
@@ -143,8 +142,7 @@ public:
/// advanced OpenGL context settings such as antialiasing,
/// depth-buffer bits, etc.
///
- /// \param handle Platform-specific handle of the control (\a HWND on
- /// Windows, \a %Window on Linux/FreeBSD, \a NSWindow on OS X)
+ /// \param handle Platform-specific handle of the control
/// \param settings Additional settings for the underlying OpenGL context
///
////////////////////////////////////////////////////////////
@@ -351,6 +349,21 @@ public:
void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor
+ ///
+ /// If set, grabs the mouse cursor inside this window's client
+ /// area so it may no longer be moved outside its bounds.
+ /// Note that grabbing is only active while the window has
+ /// focus and calling this function for fullscreen windows
+ /// won't have any effect (fullscreen windows always grab the
+ /// cursor).
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// If key repeat is enabled, you will receive repeated
@@ -459,8 +472,6 @@ public:
/// You shouldn't need to use this function, unless you have
/// very specific stuff to implement that SFML doesn't support,
/// or implement a temporary workaround until a bug is fixed.
- /// The type is \a HWND on Windows, \a %Window on Linux/FreeBSD
- /// and \a NSWindow on OS X.
///
/// \return System handle of the window
///
diff --git a/include/SFML/Window/WindowHandle.hpp b/include/SFML/Window/WindowHandle.hpp
index 9da3042..c8b0149 100644
--- a/include/SFML/Window/WindowHandle.hpp
+++ b/include/SFML/Window/WindowHandle.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -37,10 +37,6 @@
namespace sf
{
-////////////////////////////////////////////////////////////
-/// Define a low-level window handle type, specific to
-/// each platform
-////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS)
// Window handle is HWND (HWND__*) on Windows
@@ -53,7 +49,7 @@ namespace sf
#elif defined(SFML_SYSTEM_MACOS)
- // Window handle is NSWindow (void*) on Mac OS X - Cocoa
+ // Window handle is NSWindow or NSView (void*) on Mac OS X - Cocoa
typedef void* WindowHandle;
#elif defined(SFML_SYSTEM_IOS)
@@ -63,12 +59,43 @@ namespace sf
#elif defined(SFML_SYSTEM_ANDROID)
- // Window handle is ANativeWindow (void*) on Android
+ // Window handle is ANativeWindow* (void*) on Android
typedef void* WindowHandle;
+#elif defined(SFML_DOXYGEN)
+
+ // Define typedef symbol so that Doxygen can attach some documentation to it
+ typedef "platform–specific" WindowHandle;
+
#endif
} // namespace sf
#endif // SFML_WINDOWHANDLE_HPP
+
+////////////////////////////////////////////////////////////
+/// \typedef sf::WindowHandle
+/// \ingroup window
+///
+/// Define a low-level window handle type, specific to
+/// each platform.
+///
+/// Platform | Type
+/// ----------------|------------------------------------------------------------
+/// Windows | \p HWND
+/// Linux/FreeBSD | \p %Window
+/// Mac OS X | either \p NSWindow* or \p NSView*, disguised as \p void*
+/// iOS | \p UIWindow*
+/// Android | \p ANativeWindow*
+///
+/// \par Mac OS X Specification
+///
+/// On Mac OS X, a sf::Window can be created either from an
+/// existing \p NSWindow* or an \p NSView*. When the window
+/// is created from a window, SFML will use its content view
+/// as the OpenGL area. sf::Window::getSystemHandle() will
+/// return the handle that was used to create the window,
+/// which is a \p NSWindow* by default.
+///
+////////////////////////////////////////////////////////////
diff --git a/include/SFML/Window/WindowStyle.hpp b/include/SFML/Window/WindowStyle.hpp
index b9253db..3b182a9 100644
--- a/include/SFML/Window/WindowStyle.hpp
+++ b/include/SFML/Window/WindowStyle.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/license.txt b/license.txt
index 0d6e05f..ba59bbf 100644
--- a/license.txt
+++ b/license.txt
@@ -1,7 +1,7 @@
SFML
----
-SFML - Copyright (C) 2007-2015 Laurent Gomila - laurent@sfml-dev.org
+SFML - Copyright (C) 2007-2016 Laurent Gomila - laurent@sfml-dev.org
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
diff --git a/src/SFML/Audio/ALCheck.cpp b/src/SFML/Audio/ALCheck.cpp
index 3bb8e28..a6ca87b 100644
--- a/src/SFML/Audio/ALCheck.cpp
+++ b/src/SFML/Audio/ALCheck.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/ALCheck.hpp b/src/SFML/Audio/ALCheck.hpp
index 750af9e..8cae1ee 100644
--- a/src/SFML/Audio/ALCheck.hpp
+++ b/src/SFML/Audio/ALCheck.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/AlResource.cpp b/src/SFML/Audio/AlResource.cpp
index 8ea9247..ce7fe7f 100644
--- a/src/SFML/Audio/AlResource.cpp
+++ b/src/SFML/Audio/AlResource.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp
index e2005e8..cccd7bc 100644
--- a/src/SFML/Audio/AudioDevice.cpp
+++ b/src/SFML/Audio/AudioDevice.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/AudioDevice.hpp b/src/SFML/Audio/AudioDevice.hpp
index 74edb18..b407258 100644
--- a/src/SFML/Audio/AudioDevice.hpp
+++ b/src/SFML/Audio/AudioDevice.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/InputSoundFile.cpp b/src/SFML/Audio/InputSoundFile.cpp
index ede0f47..8487c53 100644
--- a/src/SFML/Audio/InputSoundFile.cpp
+++ b/src/SFML/Audio/InputSoundFile.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/Listener.cpp b/src/SFML/Audio/Listener.cpp
index b173d5e..fab995a 100644
--- a/src/SFML/Audio/Listener.cpp
+++ b/src/SFML/Audio/Listener.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp
index 7bf91d9..c40500c 100644
--- a/src/SFML/Audio/Music.cpp
+++ b/src/SFML/Audio/Music.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/OutputSoundFile.cpp b/src/SFML/Audio/OutputSoundFile.cpp
index 8f43ca7..34e3006 100644
--- a/src/SFML/Audio/OutputSoundFile.cpp
+++ b/src/SFML/Audio/OutputSoundFile.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/Sound.cpp b/src/SFML/Audio/Sound.cpp
index 82c1cca..e8dc005 100644
--- a/src/SFML/Audio/Sound.cpp
+++ b/src/SFML/Audio/Sound.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -157,7 +157,11 @@ Sound::Status Sound::getStatus() const
Sound& Sound::operator =(const Sound& right)
{
// Here we don't use the copy-and-swap idiom, because it would mess up
- // the list of sound instances contained in the buffers
+ // the list of sound instances contained in the buffers and unnecessarily
+ // destroy/create OpenAL sound sources
+
+ // Delegate to base class, which copies all the sound attributes
+ SoundSource::operator=(right);
// Detach the sound instance from the previous buffer (if any)
if (m_buffer)
@@ -167,16 +171,10 @@ Sound& Sound::operator =(const Sound& right)
m_buffer = NULL;
}
- // Copy the sound attributes
+ // Copy the remaining sound attributes
if (right.m_buffer)
setBuffer(*right.m_buffer);
setLoop(right.getLoop());
- setPitch(right.getPitch());
- setVolume(right.getVolume());
- setPosition(right.getPosition());
- setRelativeToListener(right.isRelativeToListener());
- setMinDistance(right.getMinDistance());
- setAttenuation(right.getAttenuation());
return *this;
}
diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp
index a6ff7ea..42adef7 100644
--- a/src/SFML/Audio/SoundBuffer.cpp
+++ b/src/SFML/Audio/SoundBuffer.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundBufferRecorder.cpp b/src/SFML/Audio/SoundBufferRecorder.cpp
index 23f5deb..f9e10c5 100644
--- a/src/SFML/Audio/SoundBufferRecorder.cpp
+++ b/src/SFML/Audio/SoundBufferRecorder.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -33,6 +33,14 @@
namespace sf
{
////////////////////////////////////////////////////////////
+SoundBufferRecorder::~SoundBufferRecorder()
+{
+ // Make sure to stop the recording thread
+ stop();
+}
+
+
+////////////////////////////////////////////////////////////
bool SoundBufferRecorder::onStart()
{
m_samples.clear();
@@ -55,7 +63,7 @@ bool SoundBufferRecorder::onProcessSamples(const Int16* samples, std::size_t sam
void SoundBufferRecorder::onStop()
{
if (!m_samples.empty())
- m_buffer.loadFromSamples(&m_samples[0], m_samples.size(), 1, getSampleRate());
+ m_buffer.loadFromSamples(&m_samples[0], m_samples.size(), getChannelCount(), getSampleRate());
}
diff --git a/src/SFML/Audio/SoundFileFactory.cpp b/src/SFML/Audio/SoundFileFactory.cpp
index fa2811c..6d64064 100644
--- a/src/SFML/Audio/SoundFileFactory.cpp
+++ b/src/SFML/Audio/SoundFileFactory.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp
index 646b031..d5cba9c 100644
--- a/src/SFML/Audio/SoundFileReaderFlac.cpp
+++ b/src/SFML/Audio/SoundFileReaderFlac.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -209,7 +209,9 @@ bool SoundFileReaderFlac::check(InputStream& stream)
////////////////////////////////////////////////////////////
SoundFileReaderFlac::SoundFileReaderFlac() :
-m_decoder(NULL)
+m_decoder(NULL),
+m_clientData(),
+m_channelCount(0)
{
}
@@ -247,6 +249,9 @@ bool SoundFileReaderFlac::open(InputStream& stream, Info& info)
// Retrieve the sound properties
info = m_clientData.info; // was filled in the "metadata" callback
+ // We must keep the channel count for the seek function
+ m_channelCount = info.channelCount;
+
return true;
}
@@ -261,7 +266,8 @@ void SoundFileReaderFlac::seek(Uint64 sampleOffset)
m_clientData.remaining = 0;
m_clientData.leftovers.clear();
- FLAC__stream_decoder_seek_absolute(m_decoder, sampleOffset);
+ // FLAC decoder expects absolute sample offset, so we take the channel count out
+ FLAC__stream_decoder_seek_absolute(m_decoder, sampleOffset / m_channelCount);
}
diff --git a/src/SFML/Audio/SoundFileReaderFlac.hpp b/src/SFML/Audio/SoundFileReaderFlac.hpp
index ee9079a..f7739a4 100644
--- a/src/SFML/Audio/SoundFileReaderFlac.hpp
+++ b/src/SFML/Audio/SoundFileReaderFlac.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -82,6 +82,9 @@ public:
////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given sample offset
///
+ /// The sample offset takes the channels into account.
+ /// Offsets can be calculated like this:
+ /// `sampleNumber * sampleRate * channelCount`
/// If the given offset exceeds to total number of samples,
/// this function must jump to the end of the file.
///
@@ -128,8 +131,9 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
- FLAC__StreamDecoder* m_decoder; ///< FLAC decoder
- ClientData m_clientData; ///< Structure passed to the decoder callbacks
+ FLAC__StreamDecoder* m_decoder; ///< FLAC decoder
+ ClientData m_clientData; ///< Structure passed to the decoder callbacks
+ unsigned int m_channelCount; ///< number of channels of the sound file
};
} // namespace priv
diff --git a/src/SFML/Audio/SoundFileReaderOgg.cpp b/src/SFML/Audio/SoundFileReaderOgg.cpp
index d9f8628..800ea55 100644
--- a/src/SFML/Audio/SoundFileReaderOgg.cpp
+++ b/src/SFML/Audio/SoundFileReaderOgg.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileReaderOgg.hpp b/src/SFML/Audio/SoundFileReaderOgg.hpp
index 2b9917b..36ac7a6 100644
--- a/src/SFML/Audio/SoundFileReaderOgg.hpp
+++ b/src/SFML/Audio/SoundFileReaderOgg.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -82,6 +82,9 @@ public:
////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given sample offset
///
+ /// The sample offset takes the channels into account.
+ /// Offsets can be calculated like this:
+ /// `sampleNumber * sampleRate * channelCount`
/// If the given offset exceeds to total number of samples,
/// this function must jump to the end of the file.
///
diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp
index 730f841..a4d2498 100644
--- a/src/SFML/Audio/SoundFileReaderWav.cpp
+++ b/src/SFML/Audio/SoundFileReaderWav.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -65,13 +65,13 @@ namespace
return true;
}
- bool decode(sf::InputStream& stream, sf::Int32& value)
+ bool decode24bit(sf::InputStream& stream, sf::Uint32& value)
{
- unsigned char bytes[sizeof(value)];
+ unsigned char bytes[3];
if (stream.read(bytes, sizeof(bytes)) != sizeof(bytes))
return false;
- value = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
+ value = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16);
return true;
}
@@ -110,7 +110,8 @@ bool SoundFileReaderWav::check(InputStream& stream)
SoundFileReaderWav::SoundFileReaderWav() :
m_stream (NULL),
m_bytesPerSample(0),
-m_dataStart (0)
+m_dataStart (0),
+m_dataEnd (0)
{
}
@@ -145,7 +146,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
assert(m_stream);
Uint64 count = 0;
- while (count < maxCount)
+ while ((count < maxCount) && (m_stream->tell() < m_dataEnd))
{
switch (m_bytesPerSample)
{
@@ -169,15 +170,31 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount)
break;
}
+ case 3:
+ {
+ Uint32 sample = 0;
+ if (decode24bit(*m_stream, sample))
+ *samples++ = sample >> 8;
+ else
+ return count;
+ break;
+ }
+
case 4:
{
- Int32 sample = 0;
+ Uint32 sample = 0;
if (decode(*m_stream, sample))
*samples++ = sample >> 16;
else
return count;
break;
}
+
+ default:
+ {
+ assert(false);
+ return 0;
+ }
}
++count;
@@ -248,6 +265,11 @@ bool SoundFileReaderWav::parseHeader(Info& info)
Uint16 bitsPerSample = 0;
if (!decode(*m_stream, bitsPerSample))
return false;
+ if (bitsPerSample != 8 && bitsPerSample != 16 && bitsPerSample != 24 && bitsPerSample != 32)
+ {
+ err() << "Unsupported sample size: " << bitsPerSample << " bit (Supported sample sizes are 8/16/24/32 bit)" << std::endl;
+ return false;
+ }
m_bytesPerSample = bitsPerSample / 8;
// Skip potential extra information (should not exist for PCM)
@@ -264,8 +286,9 @@ bool SoundFileReaderWav::parseHeader(Info& info)
// Compute the total number of samples
info.sampleCount = subChunkSize / m_bytesPerSample;
- // Store the starting position of samples in the file
+ // Store the start and end position of samples in the file
m_dataStart = m_stream->tell();
+ m_dataEnd = m_dataStart + info.sampleCount * m_bytesPerSample;
dataChunkFound = true;
}
diff --git a/src/SFML/Audio/SoundFileReaderWav.hpp b/src/SFML/Audio/SoundFileReaderWav.hpp
index a52bc1f..b481bb4 100644
--- a/src/SFML/Audio/SoundFileReaderWav.hpp
+++ b/src/SFML/Audio/SoundFileReaderWav.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -74,6 +74,9 @@ public:
////////////////////////////////////////////////////////////
/// \brief Change the current read position to the given sample offset
///
+ /// The sample offset takes the channels into account.
+ /// Offsets can be calculated like this:
+ /// `sampleNumber * sampleRate * channelCount`
/// If the given offset exceeds to total number of samples,
/// this function must jump to the end of the file.
///
@@ -111,6 +114,7 @@ private:
InputStream* m_stream; ///< Source stream to read from
unsigned int m_bytesPerSample; ///< Size of a sample, in bytes
Uint64 m_dataStart; ///< Starting position of the audio data in the open file
+ Uint64 m_dataEnd; ///< Position one byte past the end of the audio data in the open file
};
} // namespace priv
diff --git a/src/SFML/Audio/SoundFileWriterFlac.cpp b/src/SFML/Audio/SoundFileWriterFlac.cpp
index 5236896..8045a67 100644
--- a/src/SFML/Audio/SoundFileWriterFlac.cpp
+++ b/src/SFML/Audio/SoundFileWriterFlac.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileWriterFlac.hpp b/src/SFML/Audio/SoundFileWriterFlac.hpp
index 4946564..33b7ed0 100644
--- a/src/SFML/Audio/SoundFileWriterFlac.hpp
+++ b/src/SFML/Audio/SoundFileWriterFlac.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileWriterOgg.cpp b/src/SFML/Audio/SoundFileWriterOgg.cpp
index 0091f84..8962a10 100644
--- a/src/SFML/Audio/SoundFileWriterOgg.cpp
+++ b/src/SFML/Audio/SoundFileWriterOgg.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -130,21 +130,31 @@ bool SoundFileWriterOgg::open(const std::string& filename, unsigned int sampleRa
////////////////////////////////////////////////////////////
void SoundFileWriterOgg::write(const Int16* samples, Uint64 count)
{
- // Prepare a buffer to hold our samples
+ // Vorbis has issues with buffers that are too large, so we ask for 64K
+ static const int bufferSize = 65536;
+
+ // A frame contains a sample from each channel
int frameCount = static_cast<int>(count / m_channelCount);
- float** buffer = vorbis_analysis_buffer(&m_state, frameCount);
- assert(buffer);
- // Write the samples to the buffer, converted to float
- for (int i = 0; i < frameCount; ++i)
- for (unsigned int j = 0; j < m_channelCount; ++j)
- buffer[j][i] = *samples++ / 32767.0f;
+ while (frameCount > 0)
+ {
+ // Prepare a buffer to hold our samples
+ float** buffer = vorbis_analysis_buffer(&m_state, bufferSize);
+ assert(buffer);
+
+ // Write the samples to the buffer, converted to float
+ for (int i = 0; i < std::min(frameCount, bufferSize); ++i)
+ for (unsigned int j = 0; j < m_channelCount; ++j)
+ buffer[j][i] = *samples++ / 32767.0f;
- // Tell the library how many samples we've written
- vorbis_analysis_wrote(&m_state, frameCount);
+ // Tell the library how many samples we've written
+ vorbis_analysis_wrote(&m_state, std::min(frameCount, bufferSize));
+
+ frameCount -= bufferSize;
- // Flush any produced block
- flushBlocks();
+ // Flush any produced block
+ flushBlocks();
+ }
}
diff --git a/src/SFML/Audio/SoundFileWriterOgg.hpp b/src/SFML/Audio/SoundFileWriterOgg.hpp
index bac570d..f0e26c0 100644
--- a/src/SFML/Audio/SoundFileWriterOgg.hpp
+++ b/src/SFML/Audio/SoundFileWriterOgg.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileWriterWav.cpp b/src/SFML/Audio/SoundFileWriterWav.cpp
index e7f977d..125444b 100644
--- a/src/SFML/Audio/SoundFileWriterWav.cpp
+++ b/src/SFML/Audio/SoundFileWriterWav.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundFileWriterWav.hpp b/src/SFML/Audio/SoundFileWriterWav.hpp
index d96b4d3..8920978 100644
--- a/src/SFML/Audio/SoundFileWriterWav.hpp
+++ b/src/SFML/Audio/SoundFileWriterWav.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp
index f051b96..7374d65 100644
--- a/src/SFML/Audio/SoundRecorder.cpp
+++ b/src/SFML/Audio/SoundRecorder.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -31,6 +31,7 @@
#include <SFML/System/Sleep.hpp>
#include <SFML/System/Err.hpp>
#include <cstring>
+#include <cassert>
#ifdef _MSC_VER
#pragma warning(disable: 4355) // 'this' used in base member initializer list
@@ -49,17 +50,23 @@ SoundRecorder::SoundRecorder() :
m_thread (&SoundRecorder::record, this),
m_sampleRate (0),
m_processingInterval(milliseconds(100)),
-m_isCapturing (false)
+m_isCapturing (false),
+m_deviceName (getDefaultDevice()),
+m_channelCount (1)
{
- // Set the device name to the default device
- m_deviceName = getDefaultDevice();
+
}
////////////////////////////////////////////////////////////
SoundRecorder::~SoundRecorder()
{
- // Nothing to do
+ // This assertion is triggered if the recording is still running while
+ // the object is destroyed. It ensures that stop() is called in the
+ // destructor of the derived class, which makes sure that the recording
+ // thread finishes before the derived object is destroyed. Otherwise a
+ // "pure virtual method called" exception is triggered.
+ assert(!m_isCapturing && "You must call stop() in the destructor of your derived class, so that the recording thread finishes before your object is destroyed.");
}
@@ -80,8 +87,11 @@ bool SoundRecorder::start(unsigned int sampleRate)
return false;
}
- // Open the capture device for capturing 16 bits mono samples
- captureDevice = alcCaptureOpenDevice(m_deviceName.c_str(), sampleRate, AL_FORMAT_MONO16, sampleRate);
+ // Determine the recording format
+ ALCenum format = (m_channelCount == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
+
+ // Open the capture device for capturing 16 bits samples
+ captureDevice = alcCaptureOpenDevice(m_deviceName.c_str(), sampleRate, format, sampleRate);
if (!captureDevice)
{
err() << "Failed to open the audio capture device with the name: " << m_deviceName << std::endl;
@@ -114,12 +124,15 @@ bool SoundRecorder::start(unsigned int sampleRate)
////////////////////////////////////////////////////////////
void SoundRecorder::stop()
{
- // Stop the capturing thread
- m_isCapturing = false;
- m_thread.wait();
+ // Stop the capturing thread if there is one
+ if (m_isCapturing)
+ {
+ m_isCapturing = false;
+ m_thread.wait();
- // Notify derived class
- onStop();
+ // Notify derived class
+ onStop();
+ }
}
@@ -171,8 +184,11 @@ bool SoundRecorder::setDevice(const std::string& name)
m_isCapturing = false;
m_thread.wait();
- // Open the requested capture device for capturing 16 bits mono samples
- captureDevice = alcCaptureOpenDevice(name.c_str(), m_sampleRate, AL_FORMAT_MONO16, m_sampleRate);
+ // Determine the recording format
+ ALCenum format = (m_channelCount == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
+
+ // Open the requested capture device for capturing 16 bits samples
+ captureDevice = alcCaptureOpenDevice(name.c_str(), m_sampleRate, format, m_sampleRate);
if (!captureDevice)
{
// Notify derived class
@@ -202,6 +218,32 @@ const std::string& SoundRecorder::getDevice() const
////////////////////////////////////////////////////////////
+void SoundRecorder::setChannelCount(unsigned int channelCount)
+{
+ if (m_isCapturing)
+ {
+ err() << "It's not possible to change the channels while recording." << std::endl;
+ return;
+ }
+
+ if (channelCount < 1 || channelCount > 2)
+ {
+ err() << "Unsupported channel count: " << channelCount << " Currently only mono (1) and stereo (2) recording is supported." << std::endl;
+ return;
+ }
+
+ m_channelCount = channelCount;
+}
+
+
+////////////////////////////////////////////////////////////
+unsigned int SoundRecorder::getChannelCount() const
+{
+ return m_channelCount;
+}
+
+
+////////////////////////////////////////////////////////////
bool SoundRecorder::isAvailable()
{
return (priv::AudioDevice::isExtensionSupported("ALC_EXT_CAPTURE") != AL_FALSE) ||
@@ -258,7 +300,7 @@ void SoundRecorder::processCapturedSamples()
if (samplesAvailable > 0)
{
// Get the recorded samples
- m_samples.resize(samplesAvailable);
+ m_samples.resize(samplesAvailable * getChannelCount());
alcCaptureSamples(captureDevice, &m_samples[0], samplesAvailable);
// Forward them to the derived class
diff --git a/src/SFML/Audio/SoundSource.cpp b/src/SFML/Audio/SoundSource.cpp
index 977769e..d9f291d 100644
--- a/src/SFML/Audio/SoundSource.cpp
+++ b/src/SFML/Audio/SoundSource.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -75,6 +75,7 @@ void SoundSource::setVolume(float volume)
alCheck(alSourcef(m_source, AL_GAIN, volume * 0.01f));
}
+
////////////////////////////////////////////////////////////
void SoundSource::setPosition(float x, float y, float z)
{
@@ -171,6 +172,24 @@ float SoundSource::getAttenuation() const
////////////////////////////////////////////////////////////
+SoundSource& SoundSource::operator =(const SoundSource& right)
+{
+ // Leave m_source untouched -- it's not necessary to destroy and
+ // recreate the OpenAL sound source, hence no copy-and-swap idiom
+
+ // Assign the sound attributes
+ setPitch(right.getPitch());
+ setVolume(right.getVolume());
+ setPosition(right.getPosition());
+ setRelativeToListener(right.isRelativeToListener());
+ setMinDistance(right.getMinDistance());
+ setAttenuation(right.getAttenuation());
+
+ return *this;
+}
+
+
+////////////////////////////////////////////////////////////
SoundSource::Status SoundSource::getStatus() const
{
ALint status;
diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp
index 81977fd..901d174 100644
--- a/src/SFML/Audio/SoundStream.cpp
+++ b/src/SFML/Audio/SoundStream.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -45,11 +45,13 @@ m_thread (&SoundStream::streamData, this),
m_threadMutex (),
m_threadStartState(Stopped),
m_isStreaming (false),
+m_buffers (),
m_channelCount (0),
m_sampleRate (0),
m_format (0),
m_loop (false),
-m_samplesProcessed(0)
+m_samplesProcessed(0),
+m_endBuffers ()
{
}
diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt
index 392ed82..8eb334d 100644
--- a/src/SFML/CMakeLists.txt
+++ b/src/SFML/CMakeLists.txt
@@ -14,10 +14,18 @@ if (SFML_OS_WINDOWS)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x64")
endif()
elseif(SFML_COMPILER_MSVC)
- if(ARCH_32BITS)
- set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x86")
- elseif(ARCH_64BITS)
- set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x64")
+ if(SFML_MSVC_VERSION LESS 14)
+ if(ARCH_32BITS)
+ set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x86")
+ elseif(ARCH_64BITS)
+ set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x64")
+ endif()
+ else()
+ if(ARCH_32BITS)
+ set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x86")
+ elseif(ARCH_64BITS)
+ set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc-universal/x64")
+ endif()
endif()
endif()
elseif(SFML_OS_MACOSX)
diff --git a/src/SFML/Graphics/BlendMode.cpp b/src/SFML/Graphics/BlendMode.cpp
index a9fb085..25019ca 100644
--- a/src/SFML/Graphics/BlendMode.cpp
+++ b/src/SFML/Graphics/BlendMode.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt
index 6f02fb6..57dfa80 100644
--- a/src/SFML/Graphics/CMakeLists.txt
+++ b/src/SFML/Graphics/CMakeLists.txt
@@ -11,6 +11,9 @@ set(SRC
${INCROOT}/Export.hpp
${SRCROOT}/Font.cpp
${INCROOT}/Font.hpp
+ ${SRCROOT}/Glsl.cpp
+ ${INCROOT}/Glsl.hpp
+ ${INCROOT}/Glsl.inl
${INCROOT}/Glyph.hpp
${SRCROOT}/GLCheck.cpp
${SRCROOT}/GLCheck.hpp
diff --git a/src/SFML/Graphics/CircleShape.cpp b/src/SFML/Graphics/CircleShape.cpp
index 24bd9d3..c813e22 100644
--- a/src/SFML/Graphics/CircleShape.cpp
+++ b/src/SFML/Graphics/CircleShape.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/Color.cpp b/src/SFML/Graphics/Color.cpp
index 0bcd502..5021b30 100644
--- a/src/SFML/Graphics/Color.cpp
+++ b/src/SFML/Graphics/Color.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/ConvexShape.cpp b/src/SFML/Graphics/ConvexShape.cpp
index f605647..477bb34 100644
--- a/src/SFML/Graphics/ConvexShape.cpp
+++ b/src/SFML/Graphics/ConvexShape.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp
index 9940ce1..f58454a 100644
--- a/src/SFML/Graphics/Font.cpp
+++ b/src/SFML/Graphics/Font.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -37,6 +37,7 @@
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
+#include FT_STROKER_H
#include <cstdlib>
#include <cstring>
@@ -70,6 +71,7 @@ Font::Font() :
m_library (NULL),
m_face (NULL),
m_streamRec(NULL),
+m_stroker (NULL),
m_refCount (NULL),
m_info ()
{
@@ -84,6 +86,7 @@ Font::Font(const Font& copy) :
m_library (copy.m_library),
m_face (copy.m_face),
m_streamRec (copy.m_streamRec),
+m_stroker (copy.m_stroker),
m_refCount (copy.m_refCount),
m_info (copy.m_info),
m_pages (copy.m_pages),
@@ -143,6 +146,15 @@ bool Font::loadFromFile(const std::string& filename)
return false;
}
+ // Load the stroker that will be used to outline the font
+ FT_Stroker stroker;
+ if (FT_Stroker_New(static_cast<FT_Library>(m_library), &stroker) != 0)
+ {
+ err() << "Failed to load font \"" << filename << "\" (failed to create the stroker)" << std::endl;
+ return false;
+ }
+ m_stroker = stroker;
+
// Select the unicode character map
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
{
@@ -197,6 +209,15 @@ bool Font::loadFromMemory(const void* data, std::size_t sizeInBytes)
return false;
}
+ // Load the stroker that will be used to outline the font
+ FT_Stroker stroker;
+ if (FT_Stroker_New(static_cast<FT_Library>(m_library), &stroker) != 0)
+ {
+ err() << "Failed to load font from memory (failed to create the stroker)" << std::endl;
+ return false;
+ }
+ m_stroker = stroker;
+
// Select the Unicode character map
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
{
@@ -261,6 +282,15 @@ bool Font::loadFromStream(InputStream& stream)
return false;
}
+ // Load the stroker that will be used to outline the font
+ FT_Stroker stroker;
+ if (FT_Stroker_New(static_cast<FT_Library>(m_library), &stroker) != 0)
+ {
+ err() << "Failed to load font from stream (failed to create the stroker)" << std::endl;
+ return false;
+ }
+ m_stroker = stroker;
+
// Select the Unicode character map
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
{
@@ -289,13 +319,15 @@ const Font::Info& Font::getInfo() const
////////////////////////////////////////////////////////////
-const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
+const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const
{
// Get the page corresponding to the character size
GlyphTable& glyphs = m_pages[characterSize].glyphs;
- // Build the key by combining the code point and the bold flag
- Uint32 key = ((bold ? 1 : 0) << 31) | codePoint;
+ // Build the key by combining the code point, bold flag, and outline thickness
+ Uint64 key = (static_cast<Uint64>(*reinterpret_cast<Uint32*>(&outlineThickness)) << 32)
+ | (static_cast<Uint64>(bold ? 1 : 0) << 31)
+ | static_cast<Uint64>(codePoint);
// Search the glyph into the cache
GlyphTable::const_iterator it = glyphs.find(key);
@@ -307,7 +339,7 @@ const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool b
else
{
// Not found: we have to load it
- Glyph glyph = loadGlyph(codePoint, characterSize, bold);
+ Glyph glyph = loadGlyph(codePoint, characterSize, bold, outlineThickness);
return glyphs.insert(std::make_pair(key, glyph)).first->second;
}
}
@@ -418,11 +450,16 @@ Font& Font::operator =(const Font& right)
std::swap(m_library, temp.m_library);
std::swap(m_face, temp.m_face);
std::swap(m_streamRec, temp.m_streamRec);
+ std::swap(m_stroker, temp.m_stroker);
std::swap(m_refCount, temp.m_refCount);
std::swap(m_info, temp.m_info);
std::swap(m_pages, temp.m_pages);
std::swap(m_pixelBuffer, temp.m_pixelBuffer);
+ #ifdef SFML_SYSTEM_ANDROID
+ std::swap(m_stream, temp.m_stream);
+ #endif
+
return *this;
}
@@ -442,6 +479,10 @@ void Font::cleanup()
// Delete the reference counter
delete m_refCount;
+ // Destroy the stroker
+ if (m_stroker)
+ FT_Stroker_Done(static_cast<FT_Stroker>(m_stroker));
+
// Destroy the font face
if (m_face)
FT_Done_Face(static_cast<FT_Face>(m_face));
@@ -459,6 +500,7 @@ void Font::cleanup()
// Reset members
m_library = NULL;
m_face = NULL;
+ m_stroker = NULL;
m_streamRec = NULL;
m_refCount = NULL;
m_pages.clear();
@@ -467,7 +509,7 @@ void Font::cleanup()
////////////////////////////////////////////////////////////
-Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const
+Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const
{
// The glyph to return
Glyph glyph;
@@ -482,7 +524,10 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
return glyph;
// Load the glyph corresponding to the code point
- if (FT_Load_Char(face, codePoint, FT_LOAD_TARGET_NORMAL | FT_LOAD_FORCE_AUTOHINT) != 0)
+ FT_Int32 flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_FORCE_AUTOHINT;
+ if (outlineThickness != 0)
+ flags |= FT_LOAD_NO_BITMAP;
+ if (FT_Load_Char(face, codePoint, flags) != 0)
return glyph;
// Retrieve the glyph
@@ -490,13 +535,24 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
if (FT_Get_Glyph(face->glyph, &glyphDesc) != 0)
return glyph;
- // Apply bold if necessary -- first technique using outline (highest quality)
+ // Apply bold and outline (there is no fallback for outline) if necessary -- first technique using outline (highest quality)
FT_Pos weight = 1 << 6;
bool outline = (glyphDesc->format == FT_GLYPH_FORMAT_OUTLINE);
- if (bold && outline)
+ if (outline)
{
- FT_OutlineGlyph outlineGlyph = (FT_OutlineGlyph)glyphDesc;
- FT_Outline_Embolden(&outlineGlyph->outline, weight);
+ if (bold)
+ {
+ FT_OutlineGlyph outlineGlyph = (FT_OutlineGlyph)glyphDesc;
+ FT_Outline_Embolden(&outlineGlyph->outline, weight);
+ }
+
+ if (outlineThickness != 0)
+ {
+ FT_Stroker stroker = static_cast<FT_Stroker>(m_stroker);
+
+ FT_Stroker_Set(stroker, static_cast<FT_Fixed>(outlineThickness * static_cast<float>(1 << 6)), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+ FT_Glyph_Stroke(&glyphDesc, stroker, false);
+ }
}
// Convert the glyph to a bitmap (i.e. rasterize it)
@@ -504,9 +560,13 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
FT_Bitmap& bitmap = reinterpret_cast<FT_BitmapGlyph>(glyphDesc)->bitmap;
// Apply bold if necessary -- fallback technique using bitmap (lower quality)
- if (bold && !outline)
+ if (!outline)
{
- FT_Bitmap_Embolden(static_cast<FT_Library>(m_library), &bitmap, weight, weight);
+ if (bold)
+ FT_Bitmap_Embolden(static_cast<FT_Library>(m_library), &bitmap, weight, weight);
+
+ if (outlineThickness != 0)
+ err() << "Failed to outline glyph (no fallback available)" << std::endl;
}
// Compute the glyph's advance offset
@@ -537,10 +597,10 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) c
glyph.textureRect.height -= 2 * padding;
// Compute the glyph's bounding box
- glyph.bounds.left = static_cast<float>(face->glyph->metrics.horiBearingX) / static_cast<float>(1 << 6);
+ glyph.bounds.left = static_cast<float>(face->glyph->metrics.horiBearingX) / static_cast<float>(1 << 6);
glyph.bounds.top = -static_cast<float>(face->glyph->metrics.horiBearingY) / static_cast<float>(1 << 6);
- glyph.bounds.width = static_cast<float>(face->glyph->metrics.width) / static_cast<float>(1 << 6);
- glyph.bounds.height = static_cast<float>(face->glyph->metrics.height) / static_cast<float>(1 << 6);
+ glyph.bounds.width = static_cast<float>(face->glyph->metrics.width) / static_cast<float>(1 << 6) + outlineThickness * 2;
+ glyph.bounds.height = static_cast<float>(face->glyph->metrics.height) / static_cast<float>(1 << 6) + outlineThickness * 2;
// Extract the glyph's pixels from the bitmap
m_pixelBuffer.resize(width * height * 4, 255);
diff --git a/src/SFML/Graphics/GLCheck.cpp b/src/SFML/Graphics/GLCheck.cpp
index 2a706cd..4005e5b 100644
--- a/src/SFML/Graphics/GLCheck.cpp
+++ b/src/SFML/Graphics/GLCheck.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/GLCheck.hpp b/src/SFML/Graphics/GLCheck.hpp
index 9b7db8b..e585aed 100644
--- a/src/SFML/Graphics/GLCheck.hpp
+++ b/src/SFML/Graphics/GLCheck.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/GLExtensions.cpp b/src/SFML/Graphics/GLExtensions.cpp
index 0c257e8..21f718b 100644
--- a/src/SFML/Graphics/GLExtensions.cpp
+++ b/src/SFML/Graphics/GLExtensions.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -26,6 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/GLExtensions.hpp>
+#include <SFML/Window/Context.hpp>
#include <SFML/System/Err.hpp>
@@ -40,9 +41,16 @@ void ensureExtensionsInit()
static bool initialized = false;
if (!initialized)
{
+ const Context* context = Context::getActiveContext();
+
+ if (!context)
+ return;
+
sfogl_LoadFunctions();
- if (!sfogl_IsVersionGEQ(1, 1))
+ ContextSettings settings = context->getSettings();
+
+ if ((settings.majorVersion < 1) || ((settings.majorVersion == 1) && (settings.minorVersion < 1)))
{
err() << "sfml-graphics requires support for OpenGL 1.1 or greater" << std::endl;
err() << "Ensure that hardware acceleration is enabled if available" << std::endl;
diff --git a/src/SFML/Graphics/GLExtensions.hpp b/src/SFML/Graphics/GLExtensions.hpp
index 52195a1..92b31cc 100644
--- a/src/SFML/Graphics/GLExtensions.hpp
+++ b/src/SFML/Graphics/GLExtensions.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -64,6 +64,7 @@
#define GLEXT_glBlendEquation glBlendEquationOES
#define GLEXT_GL_FUNC_ADD GL_FUNC_ADD_OES
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_OES
+ #define GLEXT_GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_OES
// The following extensions are optional.
@@ -100,6 +101,7 @@
#define GLEXT_glCheckFramebufferStatus glCheckFramebufferStatusOES
#define GLEXT_glFramebufferTexture2D glFramebufferTexture2DOES
#define GLEXT_glFramebufferRenderbuffer glFramebufferRenderbufferOES
+ #define GLEXT_glGenerateMipmap glGenerateMipmapOES
#define GLEXT_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
#define GLEXT_GL_RENDERBUFFER GL_RENDERBUFFER_OES
#define GLEXT_GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT16_OES
@@ -109,6 +111,15 @@
#define GLEXT_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
+ // Core since 3.0 - EXT_sRGB
+ #ifdef GL_EXT_sRGB
+ #define GLEXT_texture_sRGB GL_EXT_sRGB
+ #define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
+ #else
+ #define GLEXT_texture_sRGB false
+ #define GLEXT_GL_SRGB8_ALPHA8 0
+ #endif
+
#else
#include <SFML/Graphics/GLLoader.hpp>
@@ -142,6 +153,7 @@
// Core since 1.2 - EXT_blend_subtract
#define GLEXT_blend_subtract sfogl_ext_EXT_blend_subtract
#define GLEXT_GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_EXT
+ #define GLEXT_GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_EXT
// Core since 1.3 - ARB_multitexture
#define GLEXT_multitexture sfogl_ext_ARB_multitexture
@@ -172,6 +184,15 @@
#define GLEXT_glUniform3f glUniform3fARB
#define GLEXT_glUniform4f glUniform4fARB
#define GLEXT_glUniform1i glUniform1iARB
+ #define GLEXT_glUniform2i glUniform2iARB
+ #define GLEXT_glUniform3i glUniform3iARB
+ #define GLEXT_glUniform4i glUniform4iARB
+ #define GLEXT_glUniform1fv glUniform1fvARB
+ #define GLEXT_glUniform2fv glUniform2fvARB
+ #define GLEXT_glUniform2iv glUniform2ivARB
+ #define GLEXT_glUniform3fv glUniform3fvARB
+ #define GLEXT_glUniform4fv glUniform4fvARB
+ #define GLEXT_glUniformMatrix3fv glUniformMatrix3fvARB
#define GLEXT_glUniformMatrix4fv glUniformMatrix4fvARB
#define GLEXT_glGetObjectParameteriv glGetObjectParameterivARB
#define GLEXT_glGetInfoLog glGetInfoLogARB
@@ -197,6 +218,10 @@
#define GLEXT_blend_equation_separate sfogl_ext_EXT_blend_equation_separate
#define GLEXT_glBlendEquationSeparate glBlendEquationSeparateEXT
+ // Core since 2.1 - EXT_texture_sRGB
+ #define GLEXT_texture_sRGB sfogl_ext_EXT_texture_sRGB
+ #define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
+
// Core since 3.0 - EXT_framebuffer_object
#define GLEXT_framebuffer_object sfogl_ext_EXT_framebuffer_object
#define GLEXT_glBindRenderbuffer glBindRenderbufferEXT
@@ -209,6 +234,7 @@
#define GLEXT_glCheckFramebufferStatus glCheckFramebufferStatusEXT
#define GLEXT_glFramebufferTexture2D glFramebufferTexture2DEXT
#define GLEXT_glFramebufferRenderbuffer glFramebufferRenderbufferEXT
+ #define GLEXT_glGenerateMipmap glGenerateMipmapEXT
#define GLEXT_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
#define GLEXT_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
#define GLEXT_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
@@ -217,6 +243,10 @@
#define GLEXT_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
+ // Core since 3.2 - ARB_geometry_shader4
+ #define GLEXT_geometry_shader4 sfogl_ext_ARB_geometry_shader4
+ #define GLEXT_GL_GEOMETRY_SHADER GL_GEOMETRY_SHADER_ARB
+
#endif
namespace sf
diff --git a/src/SFML/Graphics/GLExtensions.txt b/src/SFML/Graphics/GLExtensions.txt
index 033404d..5b62027 100644
--- a/src/SFML/Graphics/GLExtensions.txt
+++ b/src/SFML/Graphics/GLExtensions.txt
@@ -1,10 +1,8 @@
// Created with:
-// https://bitbucket.org/KhronosGroup/glloadgen
-// Commit d143d66ac90d538ed06f806188714861b8e8e2f9
-// lua LoadGen.lua -style=pointer_c -spec=gl -version=1.1 -indent=space -prefix=sf -extfile=GLExtensions.txt GLLoader
+// lua LoadGen.lua
SGIS_texture_edge_clamp
-//EXT_texture_edge_clamp
+EXT_texture_edge_clamp
EXT_blend_minmax
EXT_blend_subtract
ARB_multitexture
@@ -15,4 +13,6 @@ ARB_vertex_shader
ARB_fragment_shader
ARB_texture_non_power_of_two
EXT_blend_equation_separate
+EXT_texture_sRGB
EXT_framebuffer_object
+ARB_geometry_shader4
diff --git a/src/SFML/Graphics/GLLoader.cpp b/src/SFML/Graphics/GLLoader.cpp
index e82cd7a..f92e1bd 100644
--- a/src/SFML/Graphics/GLLoader.cpp
+++ b/src/SFML/Graphics/GLLoader.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -26,25 +26,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/GLLoader.hpp>
-#include <SFML/Graphics/GLCheck.hpp>
#include <SFML/Window/Context.hpp>
-#include <cstdlib>
-#include <cstring>
-#include <cstddef>
-#if !defined(GL_MAJOR_VERSION)
- #define GL_MAJOR_VERSION 0x821B
-#endif
-
-#if !defined(GL_MINOR_VERSION)
- #define GL_MINOR_VERSION 0x821C
-#endif
-
-#if !defined(GL_NUM_EXTENSIONS)
- #define GL_NUM_EXTENSIONS 0x821D
-#endif
-
-static sf::GlFunctionPointer IntGetProcAddress(const char* name)
+static sf::GlFunctionPointer glLoaderGetProcAddress(const char* name)
{
return sf::Context::getFunction(name);
}
@@ -61,264 +45,798 @@ int sfogl_ext_ARB_vertex_shader = sfogl_LOAD_FAILED;
int sfogl_ext_ARB_fragment_shader = sfogl_LOAD_FAILED;
int sfogl_ext_ARB_texture_non_power_of_two = sfogl_LOAD_FAILED;
int sfogl_ext_EXT_blend_equation_separate = sfogl_LOAD_FAILED;
+int sfogl_ext_EXT_texture_sRGB = sfogl_LOAD_FAILED;
int sfogl_ext_EXT_framebuffer_object = sfogl_LOAD_FAILED;
+int sfogl_ext_ARB_geometry_shader4 = sfogl_LOAD_FAILED;
-void (CODEGEN_FUNCPTR *sf_ptrc_glBlendEquationEXT)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBlendEquationEXT)(GLenum) = NULL;
static int Load_EXT_blend_minmax()
{
int numFailed = 0;
- sf_ptrc_glBlendEquationEXT = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquationEXT");
- if(!sf_ptrc_glBlendEquationEXT) numFailed++;
+
+ sf_ptrc_glBlendEquationEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glBlendEquationEXT"));
+ if (!sf_ptrc_glBlendEquationEXT)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glActiveTextureARB)(GLenum) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glClientActiveTextureARB)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glActiveTextureARB)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glClientActiveTextureARB)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1dARB)(GLenum, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1dvARB)(GLenum, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1fARB)(GLenum, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1fvARB)(GLenum, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1iARB)(GLenum, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1ivARB)(GLenum, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1sARB)(GLenum, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1svARB)(GLenum, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2dARB)(GLenum, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2dvARB)(GLenum, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2fARB)(GLenum, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2fvARB)(GLenum, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2iARB)(GLenum, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2ivARB)(GLenum, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2sARB)(GLenum, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2svARB)(GLenum, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3dARB)(GLenum, GLdouble, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3dvARB)(GLenum, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3fARB)(GLenum, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3fvARB)(GLenum, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3iARB)(GLenum, GLint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3ivARB)(GLenum, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3sARB)(GLenum, GLshort, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3svARB)(GLenum, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4dARB)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4dvARB)(GLenum, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4fARB)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4fvARB)(GLenum, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4iARB)(GLenum, GLint, GLint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4ivARB)(GLenum, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4sARB)(GLenum, GLshort, GLshort, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4svARB)(GLenum, const GLshort*) = NULL;
static int Load_ARB_multitexture()
{
int numFailed = 0;
- sf_ptrc_glActiveTextureARB = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTextureARB");
- if(!sf_ptrc_glActiveTextureARB) numFailed++;
- sf_ptrc_glClientActiveTextureARB = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glClientActiveTextureARB");
- if(!sf_ptrc_glClientActiveTextureARB) numFailed++;
+
+ sf_ptrc_glActiveTextureARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glActiveTextureARB"));
+ if (!sf_ptrc_glActiveTextureARB)
+ numFailed++;
+
+ sf_ptrc_glClientActiveTextureARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glClientActiveTextureARB"));
+ if (!sf_ptrc_glClientActiveTextureARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLdouble)>(glLoaderGetProcAddress("glMultiTexCoord1dARB"));
+ if (!sf_ptrc_glMultiTexCoord1dARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLdouble*)>(glLoaderGetProcAddress("glMultiTexCoord1dvARB"));
+ if (!sf_ptrc_glMultiTexCoord1dvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLfloat)>(glLoaderGetProcAddress("glMultiTexCoord1fARB"));
+ if (!sf_ptrc_glMultiTexCoord1fARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLfloat*)>(glLoaderGetProcAddress("glMultiTexCoord1fvARB"));
+ if (!sf_ptrc_glMultiTexCoord1fvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLint)>(glLoaderGetProcAddress("glMultiTexCoord1iARB"));
+ if (!sf_ptrc_glMultiTexCoord1iARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLint*)>(glLoaderGetProcAddress("glMultiTexCoord1ivARB"));
+ if (!sf_ptrc_glMultiTexCoord1ivARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLshort)>(glLoaderGetProcAddress("glMultiTexCoord1sARB"));
+ if (!sf_ptrc_glMultiTexCoord1sARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord1svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLshort*)>(glLoaderGetProcAddress("glMultiTexCoord1svARB"));
+ if (!sf_ptrc_glMultiTexCoord1svARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLdouble, GLdouble)>(glLoaderGetProcAddress("glMultiTexCoord2dARB"));
+ if (!sf_ptrc_glMultiTexCoord2dARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLdouble*)>(glLoaderGetProcAddress("glMultiTexCoord2dvARB"));
+ if (!sf_ptrc_glMultiTexCoord2dvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLfloat, GLfloat)>(glLoaderGetProcAddress("glMultiTexCoord2fARB"));
+ if (!sf_ptrc_glMultiTexCoord2fARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLfloat*)>(glLoaderGetProcAddress("glMultiTexCoord2fvARB"));
+ if (!sf_ptrc_glMultiTexCoord2fvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLint, GLint)>(glLoaderGetProcAddress("glMultiTexCoord2iARB"));
+ if (!sf_ptrc_glMultiTexCoord2iARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLint*)>(glLoaderGetProcAddress("glMultiTexCoord2ivARB"));
+ if (!sf_ptrc_glMultiTexCoord2ivARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLshort, GLshort)>(glLoaderGetProcAddress("glMultiTexCoord2sARB"));
+ if (!sf_ptrc_glMultiTexCoord2sARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord2svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLshort*)>(glLoaderGetProcAddress("glMultiTexCoord2svARB"));
+ if (!sf_ptrc_glMultiTexCoord2svARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble)>(glLoaderGetProcAddress("glMultiTexCoord3dARB"));
+ if (!sf_ptrc_glMultiTexCoord3dARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLdouble*)>(glLoaderGetProcAddress("glMultiTexCoord3dvARB"));
+ if (!sf_ptrc_glMultiTexCoord3dvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glMultiTexCoord3fARB"));
+ if (!sf_ptrc_glMultiTexCoord3fARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLfloat*)>(glLoaderGetProcAddress("glMultiTexCoord3fvARB"));
+ if (!sf_ptrc_glMultiTexCoord3fvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLint, GLint, GLint)>(glLoaderGetProcAddress("glMultiTexCoord3iARB"));
+ if (!sf_ptrc_glMultiTexCoord3iARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLint*)>(glLoaderGetProcAddress("glMultiTexCoord3ivARB"));
+ if (!sf_ptrc_glMultiTexCoord3ivARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort)>(glLoaderGetProcAddress("glMultiTexCoord3sARB"));
+ if (!sf_ptrc_glMultiTexCoord3sARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord3svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLshort*)>(glLoaderGetProcAddress("glMultiTexCoord3svARB"));
+ if (!sf_ptrc_glMultiTexCoord3svARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble)>(glLoaderGetProcAddress("glMultiTexCoord4dARB"));
+ if (!sf_ptrc_glMultiTexCoord4dARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLdouble*)>(glLoaderGetProcAddress("glMultiTexCoord4dvARB"));
+ if (!sf_ptrc_glMultiTexCoord4dvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glMultiTexCoord4fARB"));
+ if (!sf_ptrc_glMultiTexCoord4fARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLfloat*)>(glLoaderGetProcAddress("glMultiTexCoord4fvARB"));
+ if (!sf_ptrc_glMultiTexCoord4fvARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint)>(glLoaderGetProcAddress("glMultiTexCoord4iARB"));
+ if (!sf_ptrc_glMultiTexCoord4iARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLint*)>(glLoaderGetProcAddress("glMultiTexCoord4ivARB"));
+ if (!sf_ptrc_glMultiTexCoord4ivARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort, GLshort)>(glLoaderGetProcAddress("glMultiTexCoord4sARB"));
+ if (!sf_ptrc_glMultiTexCoord4sARB)
+ numFailed++;
+
+ sf_ptrc_glMultiTexCoord4svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, const GLshort*)>(glLoaderGetProcAddress("glMultiTexCoord4svARB"));
+ if (!sf_ptrc_glMultiTexCoord4svARB)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum) = NULL;
static int Load_EXT_blend_func_separate()
{
int numFailed = 0;
- sf_ptrc_glBlendFuncSeparateEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparateEXT");
- if(!sf_ptrc_glBlendFuncSeparateEXT) numFailed++;
+
+ sf_ptrc_glBlendFuncSeparateEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum)>(glLoaderGetProcAddress("glBlendFuncSeparateEXT"));
+ if (!sf_ptrc_glBlendFuncSeparateEXT)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glAttachObjectARB)(GLhandleARB, GLhandleARB) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glCompileShaderARB)(GLhandleARB) = NULL;
-GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glCreateProgramObjectARB)() = NULL;
-GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glCreateShaderObjectARB)(GLenum) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteObjectARB)(GLhandleARB) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glDetachObjectARB)(GLhandleARB, GLhandleARB) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *) = NULL;
-GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glGetHandleARB)(GLenum) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *) = NULL;
-GLint (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformLocationARB)(GLhandleARB, const GLcharARB *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformfvARB)(GLhandleARB, GLint, GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformivARB)(GLhandleARB, GLint, GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glLinkProgramARB)(GLhandleARB) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1fARB)(GLint, GLfloat) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1fvARB)(GLint, GLsizei, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1iARB)(GLint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1ivARB)(GLint, GLsizei, const GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2fARB)(GLint, GLfloat, GLfloat) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2fvARB)(GLint, GLsizei, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2iARB)(GLint, GLint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2ivARB)(GLint, GLsizei, const GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3fvARB)(GLint, GLsizei, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3iARB)(GLint, GLint, GLint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3ivARB)(GLint, GLsizei, const GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4fvARB)(GLint, GLsizei, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4iARB)(GLint, GLint, GLint, GLint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4ivARB)(GLint, GLsizei, const GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glUseProgramObjectARB)(GLhandleARB) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glValidateProgramARB)(GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glAttachObjectARB)(GLhandleARB, GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glCompileShaderARB)(GLhandleARB) = NULL;
+GLhandleARB (GL_FUNCPTR *sf_ptrc_glCreateProgramObjectARB)() = NULL;
+GLhandleARB (GL_FUNCPTR *sf_ptrc_glCreateShaderObjectARB)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glDeleteObjectARB)(GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glDetachObjectARB)(GLhandleARB, GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei*, GLhandleARB*) = NULL;
+GLhandleARB (GL_FUNCPTR *sf_ptrc_glGetHandleARB)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetObjectParameterivARB)(GLhandleARB, GLenum, GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*) = NULL;
+GLint (GL_FUNCPTR *sf_ptrc_glGetUniformLocationARB)(GLhandleARB, const GLcharARB*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetUniformfvARB)(GLhandleARB, GLint, GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetUniformivARB)(GLhandleARB, GLint, GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glLinkProgramARB)(GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB**, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform1fARB)(GLint, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform1fvARB)(GLint, GLsizei, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform1iARB)(GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform1ivARB)(GLint, GLsizei, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform2fARB)(GLint, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform2fvARB)(GLint, GLsizei, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform2iARB)(GLint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform2ivARB)(GLint, GLsizei, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform3fvARB)(GLint, GLsizei, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform3iARB)(GLint, GLint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform3ivARB)(GLint, GLsizei, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform4fvARB)(GLint, GLsizei, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform4iARB)(GLint, GLint, GLint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniform4ivARB)(GLint, GLsizei, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glUseProgramObjectARB)(GLhandleARB) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glValidateProgramARB)(GLhandleARB) = NULL;
static int Load_ARB_shader_objects()
{
int numFailed = 0;
- sf_ptrc_glAttachObjectARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLhandleARB))IntGetProcAddress("glAttachObjectARB");
- if(!sf_ptrc_glAttachObjectARB) numFailed++;
- sf_ptrc_glCompileShaderARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB))IntGetProcAddress("glCompileShaderARB");
- if(!sf_ptrc_glCompileShaderARB) numFailed++;
- sf_ptrc_glCreateProgramObjectARB = (GLhandleARB (CODEGEN_FUNCPTR *)())IntGetProcAddress("glCreateProgramObjectARB");
- if(!sf_ptrc_glCreateProgramObjectARB) numFailed++;
- sf_ptrc_glCreateShaderObjectARB = (GLhandleARB (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCreateShaderObjectARB");
- if(!sf_ptrc_glCreateShaderObjectARB) numFailed++;
- sf_ptrc_glDeleteObjectARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB))IntGetProcAddress("glDeleteObjectARB");
- if(!sf_ptrc_glDeleteObjectARB) numFailed++;
- sf_ptrc_glDetachObjectARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLhandleARB))IntGetProcAddress("glDetachObjectARB");
- if(!sf_ptrc_glDetachObjectARB) numFailed++;
- sf_ptrc_glGetActiveUniformARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *))IntGetProcAddress("glGetActiveUniformARB");
- if(!sf_ptrc_glGetActiveUniformARB) numFailed++;
- sf_ptrc_glGetAttachedObjectsARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *))IntGetProcAddress("glGetAttachedObjectsARB");
- if(!sf_ptrc_glGetAttachedObjectsARB) numFailed++;
- sf_ptrc_glGetHandleARB = (GLhandleARB (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetHandleARB");
- if(!sf_ptrc_glGetHandleARB) numFailed++;
- sf_ptrc_glGetInfoLogARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *))IntGetProcAddress("glGetInfoLogARB");
- if(!sf_ptrc_glGetInfoLogARB) numFailed++;
- sf_ptrc_glGetObjectParameterfvARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLenum, GLfloat *))IntGetProcAddress("glGetObjectParameterfvARB");
- if(!sf_ptrc_glGetObjectParameterfvARB) numFailed++;
- sf_ptrc_glGetObjectParameterivARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLenum, GLint *))IntGetProcAddress("glGetObjectParameterivARB");
- if(!sf_ptrc_glGetObjectParameterivARB) numFailed++;
- sf_ptrc_glGetShaderSourceARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *))IntGetProcAddress("glGetShaderSourceARB");
- if(!sf_ptrc_glGetShaderSourceARB) numFailed++;
- sf_ptrc_glGetUniformLocationARB = (GLint (CODEGEN_FUNCPTR *)(GLhandleARB, const GLcharARB *))IntGetProcAddress("glGetUniformLocationARB");
- if(!sf_ptrc_glGetUniformLocationARB) numFailed++;
- sf_ptrc_glGetUniformfvARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLint, GLfloat *))IntGetProcAddress("glGetUniformfvARB");
- if(!sf_ptrc_glGetUniformfvARB) numFailed++;
- sf_ptrc_glGetUniformivARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLint, GLint *))IntGetProcAddress("glGetUniformivARB");
- if(!sf_ptrc_glGetUniformivARB) numFailed++;
- sf_ptrc_glLinkProgramARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB))IntGetProcAddress("glLinkProgramARB");
- if(!sf_ptrc_glLinkProgramARB) numFailed++;
- sf_ptrc_glShaderSourceARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *))IntGetProcAddress("glShaderSourceARB");
- if(!sf_ptrc_glShaderSourceARB) numFailed++;
- sf_ptrc_glUniform1fARB = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress("glUniform1fARB");
- if(!sf_ptrc_glUniform1fARB) numFailed++;
- sf_ptrc_glUniform1fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform1fvARB");
- if(!sf_ptrc_glUniform1fvARB) numFailed++;
- sf_ptrc_glUniform1iARB = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glUniform1iARB");
- if(!sf_ptrc_glUniform1iARB) numFailed++;
- sf_ptrc_glUniform1ivARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform1ivARB");
- if(!sf_ptrc_glUniform1ivARB) numFailed++;
- sf_ptrc_glUniform2fARB = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress("glUniform2fARB");
- if(!sf_ptrc_glUniform2fARB) numFailed++;
- sf_ptrc_glUniform2fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform2fvARB");
- if(!sf_ptrc_glUniform2fvARB) numFailed++;
- sf_ptrc_glUniform2iARB = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glUniform2iARB");
- if(!sf_ptrc_glUniform2iARB) numFailed++;
- sf_ptrc_glUniform2ivARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform2ivARB");
- if(!sf_ptrc_glUniform2ivARB) numFailed++;
- sf_ptrc_glUniform3fARB = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform3fARB");
- if(!sf_ptrc_glUniform3fARB) numFailed++;
- sf_ptrc_glUniform3fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform3fvARB");
- if(!sf_ptrc_glUniform3fvARB) numFailed++;
- sf_ptrc_glUniform3iARB = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform3iARB");
- if(!sf_ptrc_glUniform3iARB) numFailed++;
- sf_ptrc_glUniform3ivARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform3ivARB");
- if(!sf_ptrc_glUniform3ivARB) numFailed++;
- sf_ptrc_glUniform4fARB = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform4fARB");
- if(!sf_ptrc_glUniform4fARB) numFailed++;
- sf_ptrc_glUniform4fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform4fvARB");
- if(!sf_ptrc_glUniform4fvARB) numFailed++;
- sf_ptrc_glUniform4iARB = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform4iARB");
- if(!sf_ptrc_glUniform4iARB) numFailed++;
- sf_ptrc_glUniform4ivARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform4ivARB");
- if(!sf_ptrc_glUniform4ivARB) numFailed++;
- sf_ptrc_glUniformMatrix2fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2fvARB");
- if(!sf_ptrc_glUniformMatrix2fvARB) numFailed++;
- sf_ptrc_glUniformMatrix3fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3fvARB");
- if(!sf_ptrc_glUniformMatrix3fvARB) numFailed++;
- sf_ptrc_glUniformMatrix4fvARB = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4fvARB");
- if(!sf_ptrc_glUniformMatrix4fvARB) numFailed++;
- sf_ptrc_glUseProgramObjectARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB))IntGetProcAddress("glUseProgramObjectARB");
- if(!sf_ptrc_glUseProgramObjectARB) numFailed++;
- sf_ptrc_glValidateProgramARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB))IntGetProcAddress("glValidateProgramARB");
- if(!sf_ptrc_glValidateProgramARB) numFailed++;
+
+ sf_ptrc_glAttachObjectARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLhandleARB)>(glLoaderGetProcAddress("glAttachObjectARB"));
+ if (!sf_ptrc_glAttachObjectARB)
+ numFailed++;
+
+ sf_ptrc_glCompileShaderARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB)>(glLoaderGetProcAddress("glCompileShaderARB"));
+ if (!sf_ptrc_glCompileShaderARB)
+ numFailed++;
+
+ sf_ptrc_glCreateProgramObjectARB = reinterpret_cast<GLhandleARB (GL_FUNCPTR *)()>(glLoaderGetProcAddress("glCreateProgramObjectARB"));
+ if (!sf_ptrc_glCreateProgramObjectARB)
+ numFailed++;
+
+ sf_ptrc_glCreateShaderObjectARB = reinterpret_cast<GLhandleARB (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glCreateShaderObjectARB"));
+ if (!sf_ptrc_glCreateShaderObjectARB)
+ numFailed++;
+
+ sf_ptrc_glDeleteObjectARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB)>(glLoaderGetProcAddress("glDeleteObjectARB"));
+ if (!sf_ptrc_glDeleteObjectARB)
+ numFailed++;
+
+ sf_ptrc_glDetachObjectARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLhandleARB)>(glLoaderGetProcAddress("glDetachObjectARB"));
+ if (!sf_ptrc_glDetachObjectARB)
+ numFailed++;
+
+ sf_ptrc_glGetActiveUniformARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*)>(glLoaderGetProcAddress("glGetActiveUniformARB"));
+ if (!sf_ptrc_glGetActiveUniformARB)
+ numFailed++;
+
+ sf_ptrc_glGetAttachedObjectsARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei*, GLhandleARB*)>(glLoaderGetProcAddress("glGetAttachedObjectsARB"));
+ if (!sf_ptrc_glGetAttachedObjectsARB)
+ numFailed++;
+
+ sf_ptrc_glGetHandleARB = reinterpret_cast<GLhandleARB (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glGetHandleARB"));
+ if (!sf_ptrc_glGetHandleARB)
+ numFailed++;
+
+ sf_ptrc_glGetInfoLogARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*)>(glLoaderGetProcAddress("glGetInfoLogARB"));
+ if (!sf_ptrc_glGetInfoLogARB)
+ numFailed++;
+
+ sf_ptrc_glGetObjectParameterfvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLenum, GLfloat*)>(glLoaderGetProcAddress("glGetObjectParameterfvARB"));
+ if (!sf_ptrc_glGetObjectParameterfvARB)
+ numFailed++;
+
+ sf_ptrc_glGetObjectParameterivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLenum, GLint*)>(glLoaderGetProcAddress("glGetObjectParameterivARB"));
+ if (!sf_ptrc_glGetObjectParameterivARB)
+ numFailed++;
+
+ sf_ptrc_glGetShaderSourceARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*)>(glLoaderGetProcAddress("glGetShaderSourceARB"));
+ if (!sf_ptrc_glGetShaderSourceARB)
+ numFailed++;
+
+ sf_ptrc_glGetUniformLocationARB = reinterpret_cast<GLint (GL_FUNCPTR *)(GLhandleARB, const GLcharARB*)>(glLoaderGetProcAddress("glGetUniformLocationARB"));
+ if (!sf_ptrc_glGetUniformLocationARB)
+ numFailed++;
+
+ sf_ptrc_glGetUniformfvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLint, GLfloat*)>(glLoaderGetProcAddress("glGetUniformfvARB"));
+ if (!sf_ptrc_glGetUniformfvARB)
+ numFailed++;
+
+ sf_ptrc_glGetUniformivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLint, GLint*)>(glLoaderGetProcAddress("glGetUniformivARB"));
+ if (!sf_ptrc_glGetUniformivARB)
+ numFailed++;
+
+ sf_ptrc_glLinkProgramARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB)>(glLoaderGetProcAddress("glLinkProgramARB"));
+ if (!sf_ptrc_glLinkProgramARB)
+ numFailed++;
+
+ sf_ptrc_glShaderSourceARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLsizei, const GLcharARB**, const GLint*)>(glLoaderGetProcAddress("glShaderSourceARB"));
+ if (!sf_ptrc_glShaderSourceARB)
+ numFailed++;
+
+ sf_ptrc_glUniform1fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLfloat)>(glLoaderGetProcAddress("glUniform1fARB"));
+ if (!sf_ptrc_glUniform1fARB)
+ numFailed++;
+
+ sf_ptrc_glUniform1fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLfloat*)>(glLoaderGetProcAddress("glUniform1fvARB"));
+ if (!sf_ptrc_glUniform1fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniform1iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLint)>(glLoaderGetProcAddress("glUniform1iARB"));
+ if (!sf_ptrc_glUniform1iARB)
+ numFailed++;
+
+ sf_ptrc_glUniform1ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLint*)>(glLoaderGetProcAddress("glUniform1ivARB"));
+ if (!sf_ptrc_glUniform1ivARB)
+ numFailed++;
+
+ sf_ptrc_glUniform2fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLfloat, GLfloat)>(glLoaderGetProcAddress("glUniform2fARB"));
+ if (!sf_ptrc_glUniform2fARB)
+ numFailed++;
+
+ sf_ptrc_glUniform2fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLfloat*)>(glLoaderGetProcAddress("glUniform2fvARB"));
+ if (!sf_ptrc_glUniform2fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniform2iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLint, GLint)>(glLoaderGetProcAddress("glUniform2iARB"));
+ if (!sf_ptrc_glUniform2iARB)
+ numFailed++;
+
+ sf_ptrc_glUniform2ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLint*)>(glLoaderGetProcAddress("glUniform2ivARB"));
+ if (!sf_ptrc_glUniform2ivARB)
+ numFailed++;
+
+ sf_ptrc_glUniform3fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glUniform3fARB"));
+ if (!sf_ptrc_glUniform3fARB)
+ numFailed++;
+
+ sf_ptrc_glUniform3fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLfloat*)>(glLoaderGetProcAddress("glUniform3fvARB"));
+ if (!sf_ptrc_glUniform3fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniform3iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLint, GLint, GLint)>(glLoaderGetProcAddress("glUniform3iARB"));
+ if (!sf_ptrc_glUniform3iARB)
+ numFailed++;
+
+ sf_ptrc_glUniform3ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLint*)>(glLoaderGetProcAddress("glUniform3ivARB"));
+ if (!sf_ptrc_glUniform3ivARB)
+ numFailed++;
+
+ sf_ptrc_glUniform4fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glUniform4fARB"));
+ if (!sf_ptrc_glUniform4fARB)
+ numFailed++;
+
+ sf_ptrc_glUniform4fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLfloat*)>(glLoaderGetProcAddress("glUniform4fvARB"));
+ if (!sf_ptrc_glUniform4fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniform4iARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint)>(glLoaderGetProcAddress("glUniform4iARB"));
+ if (!sf_ptrc_glUniform4iARB)
+ numFailed++;
+
+ sf_ptrc_glUniform4ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, const GLint*)>(glLoaderGetProcAddress("glUniform4ivARB"));
+ if (!sf_ptrc_glUniform4ivARB)
+ numFailed++;
+
+ sf_ptrc_glUniformMatrix2fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat*)>(glLoaderGetProcAddress("glUniformMatrix2fvARB"));
+ if (!sf_ptrc_glUniformMatrix2fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniformMatrix3fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat*)>(glLoaderGetProcAddress("glUniformMatrix3fvARB"));
+ if (!sf_ptrc_glUniformMatrix3fvARB)
+ numFailed++;
+
+ sf_ptrc_glUniformMatrix4fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat*)>(glLoaderGetProcAddress("glUniformMatrix4fvARB"));
+ if (!sf_ptrc_glUniformMatrix4fvARB)
+ numFailed++;
+
+ sf_ptrc_glUseProgramObjectARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB)>(glLoaderGetProcAddress("glUseProgramObjectARB"));
+ if (!sf_ptrc_glUseProgramObjectARB)
+ numFailed++;
+
+ sf_ptrc_glValidateProgramARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB)>(glLoaderGetProcAddress("glValidateProgramARB"));
+ if (!sf_ptrc_glValidateProgramARB)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *) = NULL;
-GLint (CODEGEN_FUNCPTR *sf_ptrc_glGetAttribLocationARB)(GLhandleARB, const GLcharARB *) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glDisableVertexAttribArrayARB)(GLuint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glEnableVertexAttribArrayARB)(GLuint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*) = NULL;
+GLint (GL_FUNCPTR *sf_ptrc_glGetAttribLocationARB)(GLhandleARB, const GLcharARB*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribPointervARB)(GLuint, GLenum, void**) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribdvARB)(GLuint, GLenum, GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribfvARB)(GLuint, GLenum, GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribivARB)(GLuint, GLenum, GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1dARB)(GLuint, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1dvARB)(GLuint, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1fARB)(GLuint, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1fvARB)(GLuint, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1sARB)(GLuint, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1svARB)(GLuint, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2dARB)(GLuint, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2dvARB)(GLuint, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2fARB)(GLuint, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2fvARB)(GLuint, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2sARB)(GLuint, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2svARB)(GLuint, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3dvARB)(GLuint, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3fvARB)(GLuint, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3svARB)(GLuint, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NbvARB)(GLuint, const GLbyte*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NivARB)(GLuint, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NsvARB)(GLuint, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NubvARB)(GLuint, const GLubyte*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NuivARB)(GLuint, const GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NusvARB)(GLuint, const GLushort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4bvARB)(GLuint, const GLbyte*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4dvARB)(GLuint, const GLdouble*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4fvARB)(GLuint, const GLfloat*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4ivARB)(GLuint, const GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4svARB)(GLuint, const GLshort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4ubvARB)(GLuint, const GLubyte*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4uivARB)(GLuint, const GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4usvARB)(GLuint, const GLushort*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*) = NULL;
static int Load_ARB_vertex_shader()
{
int numFailed = 0;
- sf_ptrc_glBindAttribLocationARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLuint, const GLcharARB *))IntGetProcAddress("glBindAttribLocationARB");
- if(!sf_ptrc_glBindAttribLocationARB) numFailed++;
- sf_ptrc_glGetActiveAttribARB = (void (CODEGEN_FUNCPTR *)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *))IntGetProcAddress("glGetActiveAttribARB");
- if(!sf_ptrc_glGetActiveAttribARB) numFailed++;
- sf_ptrc_glGetAttribLocationARB = (GLint (CODEGEN_FUNCPTR *)(GLhandleARB, const GLcharARB *))IntGetProcAddress("glGetAttribLocationARB");
- if(!sf_ptrc_glGetAttribLocationARB) numFailed++;
+
+ sf_ptrc_glBindAttribLocationARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLuint, const GLcharARB*)>(glLoaderGetProcAddress("glBindAttribLocationARB"));
+ if (!sf_ptrc_glBindAttribLocationARB)
+ numFailed++;
+
+ sf_ptrc_glDisableVertexAttribArrayARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint)>(glLoaderGetProcAddress("glDisableVertexAttribArrayARB"));
+ if (!sf_ptrc_glDisableVertexAttribArrayARB)
+ numFailed++;
+
+ sf_ptrc_glEnableVertexAttribArrayARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint)>(glLoaderGetProcAddress("glEnableVertexAttribArrayARB"));
+ if (!sf_ptrc_glEnableVertexAttribArrayARB)
+ numFailed++;
+
+ sf_ptrc_glGetActiveAttribARB = reinterpret_cast<void (GL_FUNCPTR *)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*)>(glLoaderGetProcAddress("glGetActiveAttribARB"));
+ if (!sf_ptrc_glGetActiveAttribARB)
+ numFailed++;
+
+ sf_ptrc_glGetAttribLocationARB = reinterpret_cast<GLint (GL_FUNCPTR *)(GLhandleARB, const GLcharARB*)>(glLoaderGetProcAddress("glGetAttribLocationARB"));
+ if (!sf_ptrc_glGetAttribLocationARB)
+ numFailed++;
+
+ sf_ptrc_glGetVertexAttribPointervARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLenum, void**)>(glLoaderGetProcAddress("glGetVertexAttribPointervARB"));
+ if (!sf_ptrc_glGetVertexAttribPointervARB)
+ numFailed++;
+
+ sf_ptrc_glGetVertexAttribdvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLenum, GLdouble*)>(glLoaderGetProcAddress("glGetVertexAttribdvARB"));
+ if (!sf_ptrc_glGetVertexAttribdvARB)
+ numFailed++;
+
+ sf_ptrc_glGetVertexAttribfvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLenum, GLfloat*)>(glLoaderGetProcAddress("glGetVertexAttribfvARB"));
+ if (!sf_ptrc_glGetVertexAttribfvARB)
+ numFailed++;
+
+ sf_ptrc_glGetVertexAttribivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLenum, GLint*)>(glLoaderGetProcAddress("glGetVertexAttribivARB"));
+ if (!sf_ptrc_glGetVertexAttribivARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLdouble)>(glLoaderGetProcAddress("glVertexAttrib1dARB"));
+ if (!sf_ptrc_glVertexAttrib1dARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLdouble*)>(glLoaderGetProcAddress("glVertexAttrib1dvARB"));
+ if (!sf_ptrc_glVertexAttrib1dvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLfloat)>(glLoaderGetProcAddress("glVertexAttrib1fARB"));
+ if (!sf_ptrc_glVertexAttrib1fARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLfloat*)>(glLoaderGetProcAddress("glVertexAttrib1fvARB"));
+ if (!sf_ptrc_glVertexAttrib1fvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLshort)>(glLoaderGetProcAddress("glVertexAttrib1sARB"));
+ if (!sf_ptrc_glVertexAttrib1sARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib1svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLshort*)>(glLoaderGetProcAddress("glVertexAttrib1svARB"));
+ if (!sf_ptrc_glVertexAttrib1svARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLdouble, GLdouble)>(glLoaderGetProcAddress("glVertexAttrib2dARB"));
+ if (!sf_ptrc_glVertexAttrib2dARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLdouble*)>(glLoaderGetProcAddress("glVertexAttrib2dvARB"));
+ if (!sf_ptrc_glVertexAttrib2dvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLfloat, GLfloat)>(glLoaderGetProcAddress("glVertexAttrib2fARB"));
+ if (!sf_ptrc_glVertexAttrib2fARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLfloat*)>(glLoaderGetProcAddress("glVertexAttrib2fvARB"));
+ if (!sf_ptrc_glVertexAttrib2fvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLshort, GLshort)>(glLoaderGetProcAddress("glVertexAttrib2sARB"));
+ if (!sf_ptrc_glVertexAttrib2sARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib2svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLshort*)>(glLoaderGetProcAddress("glVertexAttrib2svARB"));
+ if (!sf_ptrc_glVertexAttrib2svARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble)>(glLoaderGetProcAddress("glVertexAttrib3dARB"));
+ if (!sf_ptrc_glVertexAttrib3dARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLdouble*)>(glLoaderGetProcAddress("glVertexAttrib3dvARB"));
+ if (!sf_ptrc_glVertexAttrib3dvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glVertexAttrib3fARB"));
+ if (!sf_ptrc_glVertexAttrib3fARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLfloat*)>(glLoaderGetProcAddress("glVertexAttrib3fvARB"));
+ if (!sf_ptrc_glVertexAttrib3fvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort)>(glLoaderGetProcAddress("glVertexAttrib3sARB"));
+ if (!sf_ptrc_glVertexAttrib3sARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib3svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLshort*)>(glLoaderGetProcAddress("glVertexAttrib3svARB"));
+ if (!sf_ptrc_glVertexAttrib3svARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NbvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLbyte*)>(glLoaderGetProcAddress("glVertexAttrib4NbvARB"));
+ if (!sf_ptrc_glVertexAttrib4NbvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLint*)>(glLoaderGetProcAddress("glVertexAttrib4NivARB"));
+ if (!sf_ptrc_glVertexAttrib4NivARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NsvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLshort*)>(glLoaderGetProcAddress("glVertexAttrib4NsvARB"));
+ if (!sf_ptrc_glVertexAttrib4NsvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NubARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)>(glLoaderGetProcAddress("glVertexAttrib4NubARB"));
+ if (!sf_ptrc_glVertexAttrib4NubARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NubvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLubyte*)>(glLoaderGetProcAddress("glVertexAttrib4NubvARB"));
+ if (!sf_ptrc_glVertexAttrib4NubvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NuivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLuint*)>(glLoaderGetProcAddress("glVertexAttrib4NuivARB"));
+ if (!sf_ptrc_glVertexAttrib4NuivARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4NusvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLushort*)>(glLoaderGetProcAddress("glVertexAttrib4NusvARB"));
+ if (!sf_ptrc_glVertexAttrib4NusvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4bvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLbyte*)>(glLoaderGetProcAddress("glVertexAttrib4bvARB"));
+ if (!sf_ptrc_glVertexAttrib4bvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4dARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)>(glLoaderGetProcAddress("glVertexAttrib4dARB"));
+ if (!sf_ptrc_glVertexAttrib4dARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4dvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLdouble*)>(glLoaderGetProcAddress("glVertexAttrib4dvARB"));
+ if (!sf_ptrc_glVertexAttrib4dvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4fARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)>(glLoaderGetProcAddress("glVertexAttrib4fARB"));
+ if (!sf_ptrc_glVertexAttrib4fARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4fvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLfloat*)>(glLoaderGetProcAddress("glVertexAttrib4fvARB"));
+ if (!sf_ptrc_glVertexAttrib4fvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4ivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLint*)>(glLoaderGetProcAddress("glVertexAttrib4ivARB"));
+ if (!sf_ptrc_glVertexAttrib4ivARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4sARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort)>(glLoaderGetProcAddress("glVertexAttrib4sARB"));
+ if (!sf_ptrc_glVertexAttrib4sARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4svARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLshort*)>(glLoaderGetProcAddress("glVertexAttrib4svARB"));
+ if (!sf_ptrc_glVertexAttrib4svARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4ubvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLubyte*)>(glLoaderGetProcAddress("glVertexAttrib4ubvARB"));
+ if (!sf_ptrc_glVertexAttrib4ubvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4uivARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLuint*)>(glLoaderGetProcAddress("glVertexAttrib4uivARB"));
+ if (!sf_ptrc_glVertexAttrib4uivARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttrib4usvARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, const GLushort*)>(glLoaderGetProcAddress("glVertexAttrib4usvARB"));
+ if (!sf_ptrc_glVertexAttrib4usvARB)
+ numFailed++;
+
+ sf_ptrc_glVertexAttribPointerARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*)>(glLoaderGetProcAddress("glVertexAttribPointerARB"));
+ if (!sf_ptrc_glVertexAttribPointerARB)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glBlendEquationSeparateEXT)(GLenum, GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBlendEquationSeparateEXT)(GLenum, GLenum) = NULL;
static int Load_EXT_blend_equation_separate()
{
int numFailed = 0;
- sf_ptrc_glBlendEquationSeparateEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendEquationSeparateEXT");
- if(!sf_ptrc_glBlendEquationSeparateEXT) numFailed++;
+
+ sf_ptrc_glBlendEquationSeparateEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum)>(glLoaderGetProcAddress("glBlendEquationSeparateEXT"));
+ if (!sf_ptrc_glBlendEquationSeparateEXT)
+ numFailed++;
+
return numFailed;
}
-void (CODEGEN_FUNCPTR *sf_ptrc_glBindFramebufferEXT)(GLenum, GLuint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glBindRenderbufferEXT)(GLenum, GLuint) = NULL;
-GLenum (CODEGEN_FUNCPTR *sf_ptrc_glCheckFramebufferStatusEXT)(GLenum) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGenerateMipmapEXT)(GLenum) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *) = NULL;
-GLboolean (CODEGEN_FUNCPTR *sf_ptrc_glIsFramebufferEXT)(GLuint) = NULL;
-GLboolean (CODEGEN_FUNCPTR *sf_ptrc_glIsRenderbufferEXT)(GLuint) = NULL;
-void (CODEGEN_FUNCPTR *sf_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBindFramebufferEXT)(GLenum, GLuint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glBindRenderbufferEXT)(GLenum, GLuint) = NULL;
+GLenum (GL_FUNCPTR *sf_ptrc_glCheckFramebufferStatusEXT)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGenerateMipmapEXT)(GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint*) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint*) = NULL;
+GLboolean (GL_FUNCPTR *sf_ptrc_glIsFramebufferEXT)(GLuint) = NULL;
+GLboolean (GL_FUNCPTR *sf_ptrc_glIsRenderbufferEXT)(GLuint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei) = NULL;
static int Load_EXT_framebuffer_object()
{
int numFailed = 0;
- sf_ptrc_glBindFramebufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebufferEXT");
- if(!sf_ptrc_glBindFramebufferEXT) numFailed++;
- sf_ptrc_glBindRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindRenderbufferEXT");
- if(!sf_ptrc_glBindRenderbufferEXT) numFailed++;
- sf_ptrc_glCheckFramebufferStatusEXT = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCheckFramebufferStatusEXT");
- if(!sf_ptrc_glCheckFramebufferStatusEXT) numFailed++;
- sf_ptrc_glDeleteFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteFramebuffersEXT");
- if(!sf_ptrc_glDeleteFramebuffersEXT) numFailed++;
- sf_ptrc_glDeleteRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteRenderbuffersEXT");
- if(!sf_ptrc_glDeleteRenderbuffersEXT) numFailed++;
- sf_ptrc_glFramebufferRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress("glFramebufferRenderbufferEXT");
- if(!sf_ptrc_glFramebufferRenderbufferEXT) numFailed++;
- sf_ptrc_glFramebufferTexture1DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture1DEXT");
- if(!sf_ptrc_glFramebufferTexture1DEXT) numFailed++;
- sf_ptrc_glFramebufferTexture2DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture2DEXT");
- if(!sf_ptrc_glFramebufferTexture2DEXT) numFailed++;
- sf_ptrc_glFramebufferTexture3DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTexture3DEXT");
- if(!sf_ptrc_glFramebufferTexture3DEXT) numFailed++;
- sf_ptrc_glGenFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenFramebuffersEXT");
- if(!sf_ptrc_glGenFramebuffersEXT) numFailed++;
- sf_ptrc_glGenRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenRenderbuffersEXT");
- if(!sf_ptrc_glGenRenderbuffersEXT) numFailed++;
- sf_ptrc_glGenerateMipmapEXT = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGenerateMipmapEXT");
- if(!sf_ptrc_glGenerateMipmapEXT) numFailed++;
- sf_ptrc_glGetFramebufferAttachmentParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
- if(!sf_ptrc_glGetFramebufferAttachmentParameterivEXT) numFailed++;
- sf_ptrc_glGetRenderbufferParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetRenderbufferParameterivEXT");
- if(!sf_ptrc_glGetRenderbufferParameterivEXT) numFailed++;
- sf_ptrc_glIsFramebufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsFramebufferEXT");
- if(!sf_ptrc_glIsFramebufferEXT) numFailed++;
- sf_ptrc_glIsRenderbufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsRenderbufferEXT");
- if(!sf_ptrc_glIsRenderbufferEXT) numFailed++;
- sf_ptrc_glRenderbufferStorageEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorageEXT");
- if(!sf_ptrc_glRenderbufferStorageEXT) numFailed++;
+
+ sf_ptrc_glBindFramebufferEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLuint)>(glLoaderGetProcAddress("glBindFramebufferEXT"));
+ if (!sf_ptrc_glBindFramebufferEXT)
+ numFailed++;
+
+ sf_ptrc_glBindRenderbufferEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLuint)>(glLoaderGetProcAddress("glBindRenderbufferEXT"));
+ if (!sf_ptrc_glBindRenderbufferEXT)
+ numFailed++;
+
+ sf_ptrc_glCheckFramebufferStatusEXT = reinterpret_cast<GLenum (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glCheckFramebufferStatusEXT"));
+ if (!sf_ptrc_glCheckFramebufferStatusEXT)
+ numFailed++;
+
+ sf_ptrc_glDeleteFramebuffersEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLsizei, const GLuint*)>(glLoaderGetProcAddress("glDeleteFramebuffersEXT"));
+ if (!sf_ptrc_glDeleteFramebuffersEXT)
+ numFailed++;
+
+ sf_ptrc_glDeleteRenderbuffersEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLsizei, const GLuint*)>(glLoaderGetProcAddress("glDeleteRenderbuffersEXT"));
+ if (!sf_ptrc_glDeleteRenderbuffersEXT)
+ numFailed++;
+
+ sf_ptrc_glFramebufferRenderbufferEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint)>(glLoaderGetProcAddress("glFramebufferRenderbufferEXT"));
+ if (!sf_ptrc_glFramebufferRenderbufferEXT)
+ numFailed++;
+
+ sf_ptrc_glFramebufferTexture1DEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint)>(glLoaderGetProcAddress("glFramebufferTexture1DEXT"));
+ if (!sf_ptrc_glFramebufferTexture1DEXT)
+ numFailed++;
+
+ sf_ptrc_glFramebufferTexture2DEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint)>(glLoaderGetProcAddress("glFramebufferTexture2DEXT"));
+ if (!sf_ptrc_glFramebufferTexture2DEXT)
+ numFailed++;
+
+ sf_ptrc_glFramebufferTexture3DEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint)>(glLoaderGetProcAddress("glFramebufferTexture3DEXT"));
+ if (!sf_ptrc_glFramebufferTexture3DEXT)
+ numFailed++;
+
+ sf_ptrc_glGenFramebuffersEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLsizei, GLuint*)>(glLoaderGetProcAddress("glGenFramebuffersEXT"));
+ if (!sf_ptrc_glGenFramebuffersEXT)
+ numFailed++;
+
+ sf_ptrc_glGenRenderbuffersEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLsizei, GLuint*)>(glLoaderGetProcAddress("glGenRenderbuffersEXT"));
+ if (!sf_ptrc_glGenRenderbuffersEXT)
+ numFailed++;
+
+ sf_ptrc_glGenerateMipmapEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum)>(glLoaderGetProcAddress("glGenerateMipmapEXT"));
+ if (!sf_ptrc_glGenerateMipmapEXT)
+ numFailed++;
+
+ sf_ptrc_glGetFramebufferAttachmentParameterivEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLenum, GLint*)>(glLoaderGetProcAddress("glGetFramebufferAttachmentParameterivEXT"));
+ if (!sf_ptrc_glGetFramebufferAttachmentParameterivEXT)
+ numFailed++;
+
+ sf_ptrc_glGetRenderbufferParameterivEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLint*)>(glLoaderGetProcAddress("glGetRenderbufferParameterivEXT"));
+ if (!sf_ptrc_glGetRenderbufferParameterivEXT)
+ numFailed++;
+
+ sf_ptrc_glIsFramebufferEXT = reinterpret_cast<GLboolean (GL_FUNCPTR *)(GLuint)>(glLoaderGetProcAddress("glIsFramebufferEXT"));
+ if (!sf_ptrc_glIsFramebufferEXT)
+ numFailed++;
+
+ sf_ptrc_glIsRenderbufferEXT = reinterpret_cast<GLboolean (GL_FUNCPTR *)(GLuint)>(glLoaderGetProcAddress("glIsRenderbufferEXT"));
+ if (!sf_ptrc_glIsRenderbufferEXT)
+ numFailed++;
+
+ sf_ptrc_glRenderbufferStorageEXT = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei)>(glLoaderGetProcAddress("glRenderbufferStorageEXT"));
+ if (!sf_ptrc_glRenderbufferStorageEXT)
+ numFailed++;
+
return numFailed;
}
-static int Load_Version_1_1()
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureARB)(GLenum, GLenum, GLuint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureFaceARB)(GLenum, GLenum, GLuint, GLint, GLenum) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureLayerARB)(GLenum, GLenum, GLuint, GLint, GLint) = NULL;
+void (GL_FUNCPTR *sf_ptrc_glProgramParameteriARB)(GLuint, GLenum, GLint) = NULL;
+
+static int Load_ARB_geometry_shader4()
{
int numFailed = 0;
+
+ sf_ptrc_glFramebufferTextureARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLuint, GLint)>(glLoaderGetProcAddress("glFramebufferTextureARB"));
+ if (!sf_ptrc_glFramebufferTextureARB)
+ numFailed++;
+
+ sf_ptrc_glFramebufferTextureFaceARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLenum)>(glLoaderGetProcAddress("glFramebufferTextureFaceARB"));
+ if (!sf_ptrc_glFramebufferTextureFaceARB)
+ numFailed++;
+
+ sf_ptrc_glFramebufferTextureLayerARB = reinterpret_cast<void (GL_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint)>(glLoaderGetProcAddress("glFramebufferTextureLayerARB"));
+ if (!sf_ptrc_glFramebufferTextureLayerARB)
+ numFailed++;
+
+ sf_ptrc_glProgramParameteriARB = reinterpret_cast<void (GL_FUNCPTR *)(GLuint, GLenum, GLint)>(glLoaderGetProcAddress("glProgramParameteriARB"));
+ if (!sf_ptrc_glProgramParameteriARB)
+ numFailed++;
+
return numFailed;
}
typedef int (*PFN_LOADFUNCPOINTERS)();
typedef struct sfogl_StrToExtMap_s
{
- const char *extensionName;
- int *extensionVariable;
+ const char* extensionName;
+ int* extensionVariable;
PFN_LOADFUNCPOINTERS LoadExtension;
} sfogl_StrToExtMap;
-static sfogl_StrToExtMap ExtensionMap[13] = {
+static sfogl_StrToExtMap ExtensionMap[15] = {
{"GL_SGIS_texture_edge_clamp", &sfogl_ext_SGIS_texture_edge_clamp, NULL},
{"GL_EXT_texture_edge_clamp", &sfogl_ext_EXT_texture_edge_clamp, NULL},
{"GL_EXT_blend_minmax", &sfogl_ext_EXT_blend_minmax, Load_EXT_blend_minmax},
@@ -331,23 +849,13 @@ static sfogl_StrToExtMap ExtensionMap[13] = {
{"GL_ARB_fragment_shader", &sfogl_ext_ARB_fragment_shader, NULL},
{"GL_ARB_texture_non_power_of_two", &sfogl_ext_ARB_texture_non_power_of_two, NULL},
{"GL_EXT_blend_equation_separate", &sfogl_ext_EXT_blend_equation_separate, Load_EXT_blend_equation_separate},
- {"GL_EXT_framebuffer_object", &sfogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}
+ {"GL_EXT_texture_sRGB", &sfogl_ext_EXT_texture_sRGB, NULL},
+ {"GL_EXT_framebuffer_object", &sfogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object},
+ {"GL_ARB_geometry_shader4", &sfogl_ext_ARB_geometry_shader4, Load_ARB_geometry_shader4}
};
-static int g_extensionMapSize = 13;
+static int g_extensionMapSize = 15;
-static sfogl_StrToExtMap *FindExtEntry(const char *extensionName)
-{
- int loop;
- sfogl_StrToExtMap *currLoc = ExtensionMap;
- for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
- {
- if(strcmp(extensionName, currLoc->extensionName) == 0)
- return currLoc;
- }
-
- return NULL;
-}
static void ClearExtensionVars()
{
@@ -363,192 +871,32 @@ static void ClearExtensionVars()
sfogl_ext_ARB_fragment_shader = sfogl_LOAD_FAILED;
sfogl_ext_ARB_texture_non_power_of_two = sfogl_LOAD_FAILED;
sfogl_ext_EXT_blend_equation_separate = sfogl_LOAD_FAILED;
+ sfogl_ext_EXT_texture_sRGB = sfogl_LOAD_FAILED;
sfogl_ext_EXT_framebuffer_object = sfogl_LOAD_FAILED;
+ sfogl_ext_ARB_geometry_shader4 = sfogl_LOAD_FAILED;
}
-static void LoadExtByName(const char *extensionName)
+static void LoadExtension(sfogl_StrToExtMap& extension)
{
- sfogl_StrToExtMap *entry = NULL;
- entry = FindExtEntry(extensionName);
- if(entry)
+ if (extension.LoadExtension)
{
- if(entry->LoadExtension)
- {
- int numFailed = entry->LoadExtension();
- if(numFailed == 0)
- {
- *(entry->extensionVariable) = sfogl_LOAD_SUCCEEDED;
- }
- else
- {
- *(entry->extensionVariable) = sfogl_LOAD_SUCCEEDED + numFailed;
- }
- }
- else
- {
- *(entry->extensionVariable) = sfogl_LOAD_SUCCEEDED;
- }
- }
-}
-
-
-static void ProcExtsFromExtString(const char *strExtList)
-{
- if (!strExtList)
- strExtList = "";
-
- size_t iExtListLen = strlen(strExtList);
- const char *strExtListEnd = strExtList + iExtListLen;
- const char *strCurrPos = strExtList;
- char strWorkBuff[256];
-
- while(*strCurrPos)
- {
- /*Get the extension at our position.*/
- int iStrLen = 0;
- const char *strEndStr = strchr(strCurrPos, ' ');
- int iStop = 0;
- if(strEndStr == NULL)
- {
- strEndStr = strExtListEnd;
- iStop = 1;
- }
-
- iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
-
- if(iStrLen > 255)
- return;
-
- strncpy(strWorkBuff, strCurrPos, iStrLen);
- strWorkBuff[iStrLen] = '\0';
-
- LoadExtByName(strWorkBuff);
-
- strCurrPos = strEndStr + 1;
- if(iStop) break;
- }
-}
-
-int sfogl_LoadFunctions()
-{
- int numFailed = 0;
- ClearExtensionVars();
-
- const char* extensionString = NULL;
-
- if(sfogl_GetMajorVersion() < 3)
- {
- // Try to load the < 3.0 way
- glCheck(extensionString = (const char *)glGetString(GL_EXTENSIONS));
-
- ProcExtsFromExtString(extensionString);
+ *(extension.extensionVariable) = sfogl_LOAD_SUCCEEDED + extension.LoadExtension();
}
else
{
- // Try to load the >= 3.0 way
- const GLubyte* (CODEGEN_FUNCPTR *glGetStringiFunc)(GLenum, GLuint) = NULL;
- glGetStringiFunc = (const GLubyte* (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi");
-
- if (glGetStringiFunc)
- {
- int numExtensions = 0;
- glCheck(glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions));
-
- if (numExtensions)
- {
- for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
- {
- glCheck(extensionString = (const char *)glGetStringiFunc(GL_EXTENSIONS, i));
-
- ProcExtsFromExtString(extensionString);
- }
- }
- }
+ *(extension.extensionVariable) = sfogl_LOAD_SUCCEEDED;
}
-
- numFailed = Load_Version_1_1();
-
- if(numFailed == 0)
- return sfogl_LOAD_SUCCEEDED;
- else
- return sfogl_LOAD_SUCCEEDED + numFailed;
}
-static int g_major_version = 0;
-static int g_minor_version = 0;
-
-static void ParseVersionFromString(int *pOutMajor, int *pOutMinor, const char *strVersion)
-{
- const char *strDotPos = NULL;
- int iLength = 0;
- char strWorkBuff[10];
- *pOutMinor = 0;
- *pOutMajor = 0;
-
- strDotPos = strchr(strVersion, '.');
- if(!strDotPos)
- return;
-
- iLength = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion);
- strncpy(strWorkBuff, strVersion, iLength);
- strWorkBuff[iLength] = '\0';
-
- *pOutMajor = atoi(strWorkBuff);
- strDotPos = strchr(strVersion + iLength + 1, ' ');
- if(!strDotPos)
- {
- /*No extra data. Take the whole rest of the string.*/
- strcpy(strWorkBuff, strVersion + iLength + 1);
- }
- else
- {
- /*Copy only up until the space.*/
- int iLengthMinor = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion);
- iLengthMinor = iLengthMinor - (iLength + 1);
- strncpy(strWorkBuff, strVersion + iLength + 1, iLengthMinor);
- strWorkBuff[iLengthMinor] = '\0';
- }
-
- *pOutMinor = atoi(strWorkBuff);
-}
-static void GetGLVersion()
+void sfogl_LoadFunctions()
{
- glGetIntegerv(GL_MAJOR_VERSION, &g_major_version);
- glGetIntegerv(GL_MINOR_VERSION, &g_minor_version);
+ ClearExtensionVars();
- // Check if we have to retrieve the context version using the legacy method
- if (glGetError() == GL_INVALID_ENUM)
+ for (int i = 0; i < g_extensionMapSize; ++i)
{
- const char* versionString = NULL;
- glCheck(versionString = (const char*)glGetString(GL_VERSION));
- ParseVersionFromString(&g_major_version, &g_minor_version, versionString);
+ if (sf::Context::isExtensionAvailable(ExtensionMap[i].extensionName))
+ LoadExtension(ExtensionMap[i]);
}
}
-
-int sfogl_GetMajorVersion()
-{
- if(g_major_version == 0)
- GetGLVersion();
- return g_major_version;
-}
-
-int sfogl_GetMinorVersion()
-{
- if(g_major_version == 0) //Yes, check the major version to get the minor one.
- GetGLVersion();
- return g_minor_version;
-}
-
-int sfogl_IsVersionGEQ(int majorVersion, int minorVersion)
-{
- if(g_major_version == 0)
- GetGLVersion();
-
- if(majorVersion > g_major_version) return 0;
- if(majorVersion < g_major_version) return 1;
- if(g_minor_version >= minorVersion) return 1;
- return 0;
-}
-
diff --git a/src/SFML/Graphics/GLLoader.hpp b/src/SFML/Graphics/GLLoader.hpp
index 0006406..cb56036 100644
--- a/src/SFML/Graphics/GLLoader.hpp
+++ b/src/SFML/Graphics/GLLoader.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -22,8 +22,8 @@
//
////////////////////////////////////////////////////////////
-#ifndef SF_POINTER_C_GENERATED_HEADER_OPENGL_HPP
-#define SF_POINTER_C_GENERATED_HEADER_OPENGL_HPP
+#ifndef SFML_GLLOADER_HPP
+#define SFML_GLLOADER_HPP
#if defined(__glew_h__) || defined(__GLEW_H__)
#error Attempt to include auto-generated header after including glew.h
@@ -51,50 +51,47 @@
#define __gl_ATI_h_
#ifndef APIENTRY
- #if defined(__MINGW32__) || defined(__CYGWIN__)
- #define APIENTRY __stdcall
+ #if defined(__MINGW32__)
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN 1
+ #endif
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif
+ #include <windows.h>
#elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)
- #define APIENTRY __stdcall
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN 1
+ #endif
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif
+ #include <windows.h>
#else
#define APIENTRY
#endif
-#endif /*APIENTRY*/
+#endif // APIENTRY
-#ifndef CODEGEN_FUNCPTR
- #define CODEGEN_REMOVE_FUNCPTR
+#ifndef GL_FUNCPTR
+ #define GL_REMOVE_FUNCPTR
#if defined(_WIN32)
- #define CODEGEN_FUNCPTR APIENTRY
+ #define GL_FUNCPTR APIENTRY
#else
- #define CODEGEN_FUNCPTR
+ #define GL_FUNCPTR
#endif
-#endif /*CODEGEN_FUNCPTR*/
+#endif // GL_FUNCPTR
#ifndef GLAPI
- #if defined(_WIN32)
- #if defined(__MINGW32__) || defined(__CYGWIN__)
- #define GLAPI extern
- #else
- #define GLAPI __declspec(dllimport)
- #endif
- #else
- #define GLAPI extern
- #endif
+ #define GLAPI extern
#endif
-#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
-#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
-
-
-#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/
-
-
#include <stddef.h>
#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glxext.h, so must be protected */
+// This code block is duplicated in glxext.h, so must be protected
#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GL_EXT_timer_query extension). */
+// Define int32_t, int64_t, and uint64_t types for UST/MSC
+// (as used in the GL_EXT_timer_query extension).
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <inttypes.h>
#elif defined(__sun__) || defined(__digital__)
@@ -106,8 +103,8 @@ typedef unsigned long int uint64_t;
#else
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
+#endif // __arch64__
+#endif // __STDC__
#elif defined( __VMS ) || defined(__sgi)
#include <inttypes.h>
#elif defined(__SCO__) || defined(__USLC__)
@@ -123,7 +120,7 @@ typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
-/* Fallback if nothing above works */
+// Fallback if nothing above works
#include <inttypes.h>
#endif
#endif
@@ -163,15 +160,15 @@ typedef uint64_t GLuint64EXT;
typedef struct __GLsync *GLsync;
struct _cl_context;
struct _cl_event;
-typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
+typedef void (APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);
+typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);
+typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam);
typedef unsigned short GLhalfNV;
typedef GLintptr GLvdpauSurfaceNV;
#ifdef __cplusplus
extern "C" {
-#endif /*__cplusplus*/
+#endif // __cplusplus
extern int sfogl_ext_SGIS_texture_edge_clamp;
extern int sfogl_ext_EXT_texture_edge_clamp;
@@ -185,7 +182,9 @@ extern int sfogl_ext_ARB_vertex_shader;
extern int sfogl_ext_ARB_fragment_shader;
extern int sfogl_ext_ARB_texture_non_power_of_two;
extern int sfogl_ext_EXT_blend_equation_separate;
+extern int sfogl_ext_EXT_texture_sRGB;
extern int sfogl_ext_EXT_framebuffer_object;
+extern int sfogl_ext_ARB_geometry_shader4;
#define GL_CLAMP_TO_EDGE_SGIS 0x812F
@@ -277,12 +276,31 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_SAMPLER_CUBE_ARB 0x8B60
#define GL_SHADER_OBJECT_ARB 0x8B48
+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
+#define GL_FLOAT 0x1406
+// Copied GL_FLOAT_MAT2_ARB From: ARB_shader_objects
+// Copied GL_FLOAT_MAT3_ARB From: ARB_shader_objects
+// Copied GL_FLOAT_MAT4_ARB From: ARB_shader_objects
+// Copied GL_FLOAT_VEC2_ARB From: ARB_shader_objects
+// Copied GL_FLOAT_VEC3_ARB From: ARB_shader_objects
+// Copied GL_FLOAT_VEC4_ARB From: ARB_shader_objects
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
#define GL_VERTEX_SHADER_ARB 0x8B31
#define GL_FRAGMENT_SHADER_ARB 0x8B30
@@ -292,6 +310,23 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
#define GL_BLEND_EQUATION_RGB_EXT 0x8009
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
+#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
+#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
+#define GL_COMPRESSED_SRGB_EXT 0x8C48
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
+#define GL_SLUMINANCE8_EXT 0x8C47
+#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
+#define GL_SLUMINANCE_EXT 0x8C46
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SRGB8_EXT 0x8C41
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB_EXT 0x8C40
+
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
@@ -344,6 +379,27 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_STENCIL_INDEX4_EXT 0x8D47
#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
+#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC
+#define GL_GEOMETRY_SHADER_ARB 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA
+#define GL_LINES_ADJACENCY_ARB 0x000A
+#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
+#define GL_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_TRIANGLES_ADJACENCY_ARB 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D
+
#define GL_2D 0x0600
#define GL_2_BYTES 0x1407
#define GL_3D 0x0601
@@ -380,7 +436,14 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_AND_REVERSE 0x1502
#define GL_ATTRIB_STACK_DEPTH 0x0BB0
#define GL_AUTO_NORMAL 0x0D80
+#define GL_AUX0 0x0409
+#define GL_AUX1 0x040A
+#define GL_AUX2 0x040B
+#define GL_AUX3 0x040C
+#define GL_AUX_BUFFERS 0x0C00
#define GL_BACK 0x0405
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
#define GL_BITMAP 0x1A00
#define GL_BITMAP_TOKEN 0x0704
#define GL_BLEND 0x0BE2
@@ -457,6 +520,7 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_DEPTH_SCALE 0x0D1E
#define GL_DEPTH_TEST 0x0B71
#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DIFFUSE 0x1201
#define GL_DITHER 0x0BD0
#define GL_DOMAIN 0x0A02
#define GL_DONT_CARE 0x1100
@@ -488,10 +552,21 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
#define GL_FILL 0x1B02
#define GL_FLAT 0x1D00
-#define GL_FLOAT 0x1406
+// Copied GL_FLOAT From: ARB_vertex_shader
+#define GL_FOG 0x0B60
+#define GL_FOG_BIT 0x00000080
+#define GL_FOG_COLOR 0x0B66
+#define GL_FOG_DENSITY 0x0B62
+#define GL_FOG_END 0x0B64
+#define GL_FOG_HINT 0x0C54
+#define GL_FOG_INDEX 0x0B61
+#define GL_FOG_MODE 0x0B65
+#define GL_FOG_START 0x0B63
#define GL_FRONT 0x0404
#define GL_FRONT_AND_BACK 0x0408
#define GL_FRONT_FACE 0x0B46
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
#define GL_GEQUAL 0x0206
#define GL_GREATER 0x0204
#define GL_GREEN 0x1904
@@ -522,9 +597,22 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_INVALID_VALUE 0x0501
#define GL_INVERT 0x150A
#define GL_KEEP 0x1E00
+#define GL_LEFT 0x0406
#define GL_LEQUAL 0x0203
#define GL_LESS 0x0201
+#define GL_LIGHT0 0x4000
+#define GL_LIGHT1 0x4001
+#define GL_LIGHT2 0x4002
+#define GL_LIGHT3 0x4003
+#define GL_LIGHT4 0x4004
+#define GL_LIGHT5 0x4005
+#define GL_LIGHT6 0x4006
+#define GL_LIGHT7 0x4007
#define GL_LIGHTING 0x0B50
+#define GL_LIGHTING_BIT 0x00000040
+#define GL_LIGHT_MODEL_AMBIENT 0x0B53
+#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
+#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
#define GL_LINE 0x1B01
#define GL_LINEAR 0x2601
#define GL_LINEAR_ATTENUATION 0x1208
@@ -544,6 +632,10 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_LINE_WIDTH 0x0B21
#define GL_LINE_WIDTH_GRANULARITY 0x0B23
#define GL_LINE_WIDTH_RANGE 0x0B22
+#define GL_LIST_BASE 0x0B32
+#define GL_LIST_BIT 0x00020000
+#define GL_LIST_INDEX 0x0B33
+#define GL_LIST_MODE 0x0B30
#define GL_LOAD 0x0101
#define GL_LOGIC_OP 0x0BF1
#define GL_LOGIC_OP_MODE 0x0BF0
@@ -559,6 +651,28 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_LUMINANCE8 0x8040
#define GL_LUMINANCE8_ALPHA8 0x8045
#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_MAP1_COLOR_4 0x0D90
+#define GL_MAP1_GRID_DOMAIN 0x0DD0
+#define GL_MAP1_GRID_SEGMENTS 0x0DD1
+#define GL_MAP1_INDEX 0x0D91
+#define GL_MAP1_NORMAL 0x0D92
+#define GL_MAP1_TEXTURE_COORD_1 0x0D93
+#define GL_MAP1_TEXTURE_COORD_2 0x0D94
+#define GL_MAP1_TEXTURE_COORD_3 0x0D95
+#define GL_MAP1_TEXTURE_COORD_4 0x0D96
+#define GL_MAP1_VERTEX_3 0x0D97
+#define GL_MAP1_VERTEX_4 0x0D98
+#define GL_MAP2_COLOR_4 0x0DB0
+#define GL_MAP2_GRID_DOMAIN 0x0DD2
+#define GL_MAP2_GRID_SEGMENTS 0x0DD3
+#define GL_MAP2_INDEX 0x0DB1
+#define GL_MAP2_NORMAL 0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
+#define GL_MAP2_VERTEX_3 0x0DB7
+#define GL_MAP2_VERTEX_4 0x0DB8
#define GL_MAP_COLOR 0x0D10
#define GL_MAP_STENCIL 0x0D11
#define GL_MATRIX_MODE 0x0BA0
@@ -581,6 +695,7 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_MODULATE 0x2100
#define GL_MULT 0x0103
#define GL_N3F_V3F 0x2A25
+#define GL_NAME_STACK_DEPTH 0x0D70
#define GL_NAND 0x150E
#define GL_NEAREST 0x2600
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
@@ -617,6 +732,26 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_PACK_SWAP_BYTES 0x0D00
#define GL_PASS_THROUGH_TOKEN 0x0700
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
+#define GL_PIXEL_MAP_A_TO_A 0x0C79
+#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
+#define GL_PIXEL_MAP_B_TO_B 0x0C78
+#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
+#define GL_PIXEL_MAP_G_TO_G 0x0C77
+#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
+#define GL_PIXEL_MAP_I_TO_A 0x0C75
+#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
+#define GL_PIXEL_MAP_I_TO_B 0x0C74
+#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
+#define GL_PIXEL_MAP_I_TO_G 0x0C73
+#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
+#define GL_PIXEL_MAP_I_TO_I 0x0C70
+#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
+#define GL_PIXEL_MAP_I_TO_R 0x0C72
+#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
+#define GL_PIXEL_MAP_R_TO_R 0x0C76
+#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
+#define GL_PIXEL_MAP_S_TO_S 0x0C71
+#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
#define GL_PIXEL_MODE_BIT 0x00000020
#define GL_POINT 0x1B00
#define GL_POINTS 0x0000
@@ -679,10 +814,14 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_RGBA4 0x8056
#define GL_RGBA8 0x8058
#define GL_RGBA_MODE 0x0C31
+#define GL_RIGHT 0x0407
#define GL_S 0x2000
#define GL_SCISSOR_BIT 0x00080000
#define GL_SCISSOR_BOX 0x0C10
#define GL_SCISSOR_TEST 0x0C11
+#define GL_SELECT 0x1C02
+#define GL_SELECTION_BUFFER_POINTER 0x0DF3
+#define GL_SELECTION_BUFFER_SIZE 0x0DF4
#define GL_SET 0x150F
#define GL_SHADE_MODEL 0x0B54
#define GL_SHININESS 0x1601
@@ -690,6 +829,9 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_SMOOTH 0x1D01
#define GL_SPECULAR 0x1202
#define GL_SPHERE_MAP 0x2402
+#define GL_SPOT_CUTOFF 0x1206
+#define GL_SPOT_DIRECTION 0x1204
+#define GL_SPOT_EXPONENT 0x1205
#define GL_SRC_ALPHA 0x0302
#define GL_SRC_ALPHA_SATURATE 0x0308
#define GL_SRC_COLOR 0x0300
@@ -787,252 +929,668 @@ extern int sfogl_ext_EXT_framebuffer_object;
#define GL_ZOOM_X 0x0D16
#define GL_ZOOM_Y 0x0D17
+
+
#ifndef GL_EXT_blend_minmax
#define GL_EXT_blend_minmax 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBlendEquationEXT)(GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glBlendEquationEXT)(GLenum);
#define glBlendEquationEXT sf_ptrc_glBlendEquationEXT
-#endif /*GL_EXT_blend_minmax*/
+#endif // GL_EXT_blend_minmax
#ifndef GL_ARB_multitexture
#define GL_ARB_multitexture 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glActiveTextureARB)(GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glActiveTextureARB)(GLenum);
#define glActiveTextureARB sf_ptrc_glActiveTextureARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glClientActiveTextureARB)(GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glClientActiveTextureARB)(GLenum);
#define glClientActiveTextureARB sf_ptrc_glClientActiveTextureARB
-#endif /*GL_ARB_multitexture*/
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1dARB)(GLenum, GLdouble);
+#define glMultiTexCoord1dARB sf_ptrc_glMultiTexCoord1dARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1dvARB)(GLenum, const GLdouble*);
+#define glMultiTexCoord1dvARB sf_ptrc_glMultiTexCoord1dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1fARB)(GLenum, GLfloat);
+#define glMultiTexCoord1fARB sf_ptrc_glMultiTexCoord1fARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1fvARB)(GLenum, const GLfloat*);
+#define glMultiTexCoord1fvARB sf_ptrc_glMultiTexCoord1fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1iARB)(GLenum, GLint);
+#define glMultiTexCoord1iARB sf_ptrc_glMultiTexCoord1iARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1ivARB)(GLenum, const GLint*);
+#define glMultiTexCoord1ivARB sf_ptrc_glMultiTexCoord1ivARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1sARB)(GLenum, GLshort);
+#define glMultiTexCoord1sARB sf_ptrc_glMultiTexCoord1sARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord1svARB)(GLenum, const GLshort*);
+#define glMultiTexCoord1svARB sf_ptrc_glMultiTexCoord1svARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2dARB)(GLenum, GLdouble, GLdouble);
+#define glMultiTexCoord2dARB sf_ptrc_glMultiTexCoord2dARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2dvARB)(GLenum, const GLdouble*);
+#define glMultiTexCoord2dvARB sf_ptrc_glMultiTexCoord2dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2fARB)(GLenum, GLfloat, GLfloat);
+#define glMultiTexCoord2fARB sf_ptrc_glMultiTexCoord2fARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2fvARB)(GLenum, const GLfloat*);
+#define glMultiTexCoord2fvARB sf_ptrc_glMultiTexCoord2fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2iARB)(GLenum, GLint, GLint);
+#define glMultiTexCoord2iARB sf_ptrc_glMultiTexCoord2iARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2ivARB)(GLenum, const GLint*);
+#define glMultiTexCoord2ivARB sf_ptrc_glMultiTexCoord2ivARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2sARB)(GLenum, GLshort, GLshort);
+#define glMultiTexCoord2sARB sf_ptrc_glMultiTexCoord2sARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord2svARB)(GLenum, const GLshort*);
+#define glMultiTexCoord2svARB sf_ptrc_glMultiTexCoord2svARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3dARB)(GLenum, GLdouble, GLdouble, GLdouble);
+#define glMultiTexCoord3dARB sf_ptrc_glMultiTexCoord3dARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3dvARB)(GLenum, const GLdouble*);
+#define glMultiTexCoord3dvARB sf_ptrc_glMultiTexCoord3dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3fARB)(GLenum, GLfloat, GLfloat, GLfloat);
+#define glMultiTexCoord3fARB sf_ptrc_glMultiTexCoord3fARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3fvARB)(GLenum, const GLfloat*);
+#define glMultiTexCoord3fvARB sf_ptrc_glMultiTexCoord3fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3iARB)(GLenum, GLint, GLint, GLint);
+#define glMultiTexCoord3iARB sf_ptrc_glMultiTexCoord3iARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3ivARB)(GLenum, const GLint*);
+#define glMultiTexCoord3ivARB sf_ptrc_glMultiTexCoord3ivARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3sARB)(GLenum, GLshort, GLshort, GLshort);
+#define glMultiTexCoord3sARB sf_ptrc_glMultiTexCoord3sARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord3svARB)(GLenum, const GLshort*);
+#define glMultiTexCoord3svARB sf_ptrc_glMultiTexCoord3svARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4dARB)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+#define glMultiTexCoord4dARB sf_ptrc_glMultiTexCoord4dARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4dvARB)(GLenum, const GLdouble*);
+#define glMultiTexCoord4dvARB sf_ptrc_glMultiTexCoord4dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4fARB)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+#define glMultiTexCoord4fARB sf_ptrc_glMultiTexCoord4fARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4fvARB)(GLenum, const GLfloat*);
+#define glMultiTexCoord4fvARB sf_ptrc_glMultiTexCoord4fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4iARB)(GLenum, GLint, GLint, GLint, GLint);
+#define glMultiTexCoord4iARB sf_ptrc_glMultiTexCoord4iARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4ivARB)(GLenum, const GLint*);
+#define glMultiTexCoord4ivARB sf_ptrc_glMultiTexCoord4ivARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4sARB)(GLenum, GLshort, GLshort, GLshort, GLshort);
+#define glMultiTexCoord4sARB sf_ptrc_glMultiTexCoord4sARB
+extern void (GL_FUNCPTR *sf_ptrc_glMultiTexCoord4svARB)(GLenum, const GLshort*);
+#define glMultiTexCoord4svARB sf_ptrc_glMultiTexCoord4svARB
+#endif // GL_ARB_multitexture
#ifndef GL_EXT_blend_func_separate
#define GL_EXT_blend_func_separate 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
#define glBlendFuncSeparateEXT sf_ptrc_glBlendFuncSeparateEXT
-#endif /*GL_EXT_blend_func_separate*/
+#endif // GL_EXT_blend_func_separate
+
#ifndef GL_ARB_shader_objects
#define GL_ARB_shader_objects 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glAttachObjectARB)(GLhandleARB, GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glAttachObjectARB)(GLhandleARB, GLhandleARB);
#define glAttachObjectARB sf_ptrc_glAttachObjectARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glCompileShaderARB)(GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glCompileShaderARB)(GLhandleARB);
#define glCompileShaderARB sf_ptrc_glCompileShaderARB
-extern GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glCreateProgramObjectARB)();
+extern GLhandleARB (GL_FUNCPTR *sf_ptrc_glCreateProgramObjectARB)();
#define glCreateProgramObjectARB sf_ptrc_glCreateProgramObjectARB
-extern GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glCreateShaderObjectARB)(GLenum);
+extern GLhandleARB (GL_FUNCPTR *sf_ptrc_glCreateShaderObjectARB)(GLenum);
#define glCreateShaderObjectARB sf_ptrc_glCreateShaderObjectARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteObjectARB)(GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glDeleteObjectARB)(GLhandleARB);
#define glDeleteObjectARB sf_ptrc_glDeleteObjectARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glDetachObjectARB)(GLhandleARB, GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glDetachObjectARB)(GLhandleARB, GLhandleARB);
#define glDetachObjectARB sf_ptrc_glDetachObjectARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetActiveUniformARB)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*);
#define glGetActiveUniformARB sf_ptrc_glGetActiveUniformARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetAttachedObjectsARB)(GLhandleARB, GLsizei, GLsizei*, GLhandleARB*);
#define glGetAttachedObjectsARB sf_ptrc_glGetAttachedObjectsARB
-extern GLhandleARB (CODEGEN_FUNCPTR *sf_ptrc_glGetHandleARB)(GLenum);
+extern GLhandleARB (GL_FUNCPTR *sf_ptrc_glGetHandleARB)(GLenum);
#define glGetHandleARB sf_ptrc_glGetHandleARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetInfoLogARB)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*);
#define glGetInfoLogARB sf_ptrc_glGetInfoLogARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetObjectParameterfvARB)(GLhandleARB, GLenum, GLfloat*);
#define glGetObjectParameterfvARB sf_ptrc_glGetObjectParameterfvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetObjectParameterivARB)(GLhandleARB, GLenum, GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetObjectParameterivARB)(GLhandleARB, GLenum, GLint*);
#define glGetObjectParameterivARB sf_ptrc_glGetObjectParameterivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetShaderSourceARB)(GLhandleARB, GLsizei, GLsizei*, GLcharARB*);
#define glGetShaderSourceARB sf_ptrc_glGetShaderSourceARB
-extern GLint (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformLocationARB)(GLhandleARB, const GLcharARB *);
+extern GLint (GL_FUNCPTR *sf_ptrc_glGetUniformLocationARB)(GLhandleARB, const GLcharARB*);
#define glGetUniformLocationARB sf_ptrc_glGetUniformLocationARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformfvARB)(GLhandleARB, GLint, GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetUniformfvARB)(GLhandleARB, GLint, GLfloat*);
#define glGetUniformfvARB sf_ptrc_glGetUniformfvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetUniformivARB)(GLhandleARB, GLint, GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetUniformivARB)(GLhandleARB, GLint, GLint*);
#define glGetUniformivARB sf_ptrc_glGetUniformivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glLinkProgramARB)(GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glLinkProgramARB)(GLhandleARB);
#define glLinkProgramARB sf_ptrc_glLinkProgramARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glShaderSourceARB)(GLhandleARB, GLsizei, const GLcharARB**, const GLint*);
#define glShaderSourceARB sf_ptrc_glShaderSourceARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1fARB)(GLint, GLfloat);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform1fARB)(GLint, GLfloat);
#define glUniform1fARB sf_ptrc_glUniform1fARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1fvARB)(GLint, GLsizei, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform1fvARB)(GLint, GLsizei, const GLfloat*);
#define glUniform1fvARB sf_ptrc_glUniform1fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1iARB)(GLint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform1iARB)(GLint, GLint);
#define glUniform1iARB sf_ptrc_glUniform1iARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform1ivARB)(GLint, GLsizei, const GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform1ivARB)(GLint, GLsizei, const GLint*);
#define glUniform1ivARB sf_ptrc_glUniform1ivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2fARB)(GLint, GLfloat, GLfloat);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform2fARB)(GLint, GLfloat, GLfloat);
#define glUniform2fARB sf_ptrc_glUniform2fARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2fvARB)(GLint, GLsizei, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform2fvARB)(GLint, GLsizei, const GLfloat*);
#define glUniform2fvARB sf_ptrc_glUniform2fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2iARB)(GLint, GLint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform2iARB)(GLint, GLint, GLint);
#define glUniform2iARB sf_ptrc_glUniform2iARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform2ivARB)(GLint, GLsizei, const GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform2ivARB)(GLint, GLsizei, const GLint*);
#define glUniform2ivARB sf_ptrc_glUniform2ivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform3fARB)(GLint, GLfloat, GLfloat, GLfloat);
#define glUniform3fARB sf_ptrc_glUniform3fARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3fvARB)(GLint, GLsizei, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform3fvARB)(GLint, GLsizei, const GLfloat*);
#define glUniform3fvARB sf_ptrc_glUniform3fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3iARB)(GLint, GLint, GLint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform3iARB)(GLint, GLint, GLint, GLint);
#define glUniform3iARB sf_ptrc_glUniform3iARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform3ivARB)(GLint, GLsizei, const GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform3ivARB)(GLint, GLsizei, const GLint*);
#define glUniform3ivARB sf_ptrc_glUniform3ivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform4fARB)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
#define glUniform4fARB sf_ptrc_glUniform4fARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4fvARB)(GLint, GLsizei, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform4fvARB)(GLint, GLsizei, const GLfloat*);
#define glUniform4fvARB sf_ptrc_glUniform4fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4iARB)(GLint, GLint, GLint, GLint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform4iARB)(GLint, GLint, GLint, GLint, GLint);
#define glUniform4iARB sf_ptrc_glUniform4iARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniform4ivARB)(GLint, GLsizei, const GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniform4ivARB)(GLint, GLsizei, const GLint*);
#define glUniform4ivARB sf_ptrc_glUniform4ivARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniformMatrix2fvARB)(GLint, GLsizei, GLboolean, const GLfloat*);
#define glUniformMatrix2fvARB sf_ptrc_glUniformMatrix2fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniformMatrix3fvARB)(GLint, GLsizei, GLboolean, const GLfloat*);
#define glUniformMatrix3fvARB sf_ptrc_glUniformMatrix3fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat *);
+extern void (GL_FUNCPTR *sf_ptrc_glUniformMatrix4fvARB)(GLint, GLsizei, GLboolean, const GLfloat*);
#define glUniformMatrix4fvARB sf_ptrc_glUniformMatrix4fvARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glUseProgramObjectARB)(GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glUseProgramObjectARB)(GLhandleARB);
#define glUseProgramObjectARB sf_ptrc_glUseProgramObjectARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glValidateProgramARB)(GLhandleARB);
+extern void (GL_FUNCPTR *sf_ptrc_glValidateProgramARB)(GLhandleARB);
#define glValidateProgramARB sf_ptrc_glValidateProgramARB
-#endif /*GL_ARB_shader_objects*/
+#endif // GL_ARB_shader_objects
#ifndef GL_ARB_vertex_shader
#define GL_ARB_vertex_shader 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glBindAttribLocationARB)(GLhandleARB, GLuint, const GLcharARB*);
#define glBindAttribLocationARB sf_ptrc_glBindAttribLocationARB
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+extern void (GL_FUNCPTR *sf_ptrc_glDisableVertexAttribArrayARB)(GLuint);
+#define glDisableVertexAttribArrayARB sf_ptrc_glDisableVertexAttribArrayARB
+extern void (GL_FUNCPTR *sf_ptrc_glEnableVertexAttribArrayARB)(GLuint);
+#define glEnableVertexAttribArrayARB sf_ptrc_glEnableVertexAttribArrayARB
+extern void (GL_FUNCPTR *sf_ptrc_glGetActiveAttribARB)(GLhandleARB, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLcharARB*);
#define glGetActiveAttribARB sf_ptrc_glGetActiveAttribARB
-extern GLint (CODEGEN_FUNCPTR *sf_ptrc_glGetAttribLocationARB)(GLhandleARB, const GLcharARB *);
+extern GLint (GL_FUNCPTR *sf_ptrc_glGetAttribLocationARB)(GLhandleARB, const GLcharARB*);
#define glGetAttribLocationARB sf_ptrc_glGetAttribLocationARB
-#endif /*GL_ARB_vertex_shader*/
+extern void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribPointervARB)(GLuint, GLenum, void**);
+#define glGetVertexAttribPointervARB sf_ptrc_glGetVertexAttribPointervARB
+extern void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribdvARB)(GLuint, GLenum, GLdouble*);
+#define glGetVertexAttribdvARB sf_ptrc_glGetVertexAttribdvARB
+extern void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribfvARB)(GLuint, GLenum, GLfloat*);
+#define glGetVertexAttribfvARB sf_ptrc_glGetVertexAttribfvARB
+extern void (GL_FUNCPTR *sf_ptrc_glGetVertexAttribivARB)(GLuint, GLenum, GLint*);
+#define glGetVertexAttribivARB sf_ptrc_glGetVertexAttribivARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1dARB)(GLuint, GLdouble);
+#define glVertexAttrib1dARB sf_ptrc_glVertexAttrib1dARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1dvARB)(GLuint, const GLdouble*);
+#define glVertexAttrib1dvARB sf_ptrc_glVertexAttrib1dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1fARB)(GLuint, GLfloat);
+#define glVertexAttrib1fARB sf_ptrc_glVertexAttrib1fARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1fvARB)(GLuint, const GLfloat*);
+#define glVertexAttrib1fvARB sf_ptrc_glVertexAttrib1fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1sARB)(GLuint, GLshort);
+#define glVertexAttrib1sARB sf_ptrc_glVertexAttrib1sARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib1svARB)(GLuint, const GLshort*);
+#define glVertexAttrib1svARB sf_ptrc_glVertexAttrib1svARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2dARB)(GLuint, GLdouble, GLdouble);
+#define glVertexAttrib2dARB sf_ptrc_glVertexAttrib2dARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2dvARB)(GLuint, const GLdouble*);
+#define glVertexAttrib2dvARB sf_ptrc_glVertexAttrib2dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2fARB)(GLuint, GLfloat, GLfloat);
+#define glVertexAttrib2fARB sf_ptrc_glVertexAttrib2fARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2fvARB)(GLuint, const GLfloat*);
+#define glVertexAttrib2fvARB sf_ptrc_glVertexAttrib2fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2sARB)(GLuint, GLshort, GLshort);
+#define glVertexAttrib2sARB sf_ptrc_glVertexAttrib2sARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib2svARB)(GLuint, const GLshort*);
+#define glVertexAttrib2svARB sf_ptrc_glVertexAttrib2svARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3dARB)(GLuint, GLdouble, GLdouble, GLdouble);
+#define glVertexAttrib3dARB sf_ptrc_glVertexAttrib3dARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3dvARB)(GLuint, const GLdouble*);
+#define glVertexAttrib3dvARB sf_ptrc_glVertexAttrib3dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3fARB)(GLuint, GLfloat, GLfloat, GLfloat);
+#define glVertexAttrib3fARB sf_ptrc_glVertexAttrib3fARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3fvARB)(GLuint, const GLfloat*);
+#define glVertexAttrib3fvARB sf_ptrc_glVertexAttrib3fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3sARB)(GLuint, GLshort, GLshort, GLshort);
+#define glVertexAttrib3sARB sf_ptrc_glVertexAttrib3sARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib3svARB)(GLuint, const GLshort*);
+#define glVertexAttrib3svARB sf_ptrc_glVertexAttrib3svARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NbvARB)(GLuint, const GLbyte*);
+#define glVertexAttrib4NbvARB sf_ptrc_glVertexAttrib4NbvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NivARB)(GLuint, const GLint*);
+#define glVertexAttrib4NivARB sf_ptrc_glVertexAttrib4NivARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NsvARB)(GLuint, const GLshort*);
+#define glVertexAttrib4NsvARB sf_ptrc_glVertexAttrib4NsvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NubARB)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+#define glVertexAttrib4NubARB sf_ptrc_glVertexAttrib4NubARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NubvARB)(GLuint, const GLubyte*);
+#define glVertexAttrib4NubvARB sf_ptrc_glVertexAttrib4NubvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NuivARB)(GLuint, const GLuint*);
+#define glVertexAttrib4NuivARB sf_ptrc_glVertexAttrib4NuivARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4NusvARB)(GLuint, const GLushort*);
+#define glVertexAttrib4NusvARB sf_ptrc_glVertexAttrib4NusvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4bvARB)(GLuint, const GLbyte*);
+#define glVertexAttrib4bvARB sf_ptrc_glVertexAttrib4bvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4dARB)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+#define glVertexAttrib4dARB sf_ptrc_glVertexAttrib4dARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4dvARB)(GLuint, const GLdouble*);
+#define glVertexAttrib4dvARB sf_ptrc_glVertexAttrib4dvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4fARB)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+#define glVertexAttrib4fARB sf_ptrc_glVertexAttrib4fARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4fvARB)(GLuint, const GLfloat*);
+#define glVertexAttrib4fvARB sf_ptrc_glVertexAttrib4fvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4ivARB)(GLuint, const GLint*);
+#define glVertexAttrib4ivARB sf_ptrc_glVertexAttrib4ivARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4sARB)(GLuint, GLshort, GLshort, GLshort, GLshort);
+#define glVertexAttrib4sARB sf_ptrc_glVertexAttrib4sARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4svARB)(GLuint, const GLshort*);
+#define glVertexAttrib4svARB sf_ptrc_glVertexAttrib4svARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4ubvARB)(GLuint, const GLubyte*);
+#define glVertexAttrib4ubvARB sf_ptrc_glVertexAttrib4ubvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4uivARB)(GLuint, const GLuint*);
+#define glVertexAttrib4uivARB sf_ptrc_glVertexAttrib4uivARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttrib4usvARB)(GLuint, const GLushort*);
+#define glVertexAttrib4usvARB sf_ptrc_glVertexAttrib4usvARB
+extern void (GL_FUNCPTR *sf_ptrc_glVertexAttribPointerARB)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*);
+#define glVertexAttribPointerARB sf_ptrc_glVertexAttribPointerARB
+#endif // GL_ARB_vertex_shader
#ifndef GL_EXT_blend_equation_separate
#define GL_EXT_blend_equation_separate 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBlendEquationSeparateEXT)(GLenum, GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glBlendEquationSeparateEXT)(GLenum, GLenum);
#define glBlendEquationSeparateEXT sf_ptrc_glBlendEquationSeparateEXT
-#endif /*GL_EXT_blend_equation_separate*/
+#endif // GL_EXT_blend_equation_separate
+
#ifndef GL_EXT_framebuffer_object
#define GL_EXT_framebuffer_object 1
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBindFramebufferEXT)(GLenum, GLuint);
+extern void (GL_FUNCPTR *sf_ptrc_glBindFramebufferEXT)(GLenum, GLuint);
#define glBindFramebufferEXT sf_ptrc_glBindFramebufferEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glBindRenderbufferEXT)(GLenum, GLuint);
+extern void (GL_FUNCPTR *sf_ptrc_glBindRenderbufferEXT)(GLenum, GLuint);
#define glBindRenderbufferEXT sf_ptrc_glBindRenderbufferEXT
-extern GLenum (CODEGEN_FUNCPTR *sf_ptrc_glCheckFramebufferStatusEXT)(GLenum);
+extern GLenum (GL_FUNCPTR *sf_ptrc_glCheckFramebufferStatusEXT)(GLenum);
#define glCheckFramebufferStatusEXT sf_ptrc_glCheckFramebufferStatusEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint *);
+extern void (GL_FUNCPTR *sf_ptrc_glDeleteFramebuffersEXT)(GLsizei, const GLuint*);
#define glDeleteFramebuffersEXT sf_ptrc_glDeleteFramebuffersEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint *);
+extern void (GL_FUNCPTR *sf_ptrc_glDeleteRenderbuffersEXT)(GLsizei, const GLuint*);
#define glDeleteRenderbuffersEXT sf_ptrc_glDeleteRenderbuffersEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint);
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferRenderbufferEXT)(GLenum, GLenum, GLenum, GLuint);
#define glFramebufferRenderbufferEXT sf_ptrc_glFramebufferRenderbufferEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture1DEXT)(GLenum, GLenum, GLenum, GLuint, GLint);
#define glFramebufferTexture1DEXT sf_ptrc_glFramebufferTexture1DEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture2DEXT)(GLenum, GLenum, GLenum, GLuint, GLint);
#define glFramebufferTexture2DEXT sf_ptrc_glFramebufferTexture2DEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTexture3DEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLint);
#define glFramebufferTexture3DEXT sf_ptrc_glFramebufferTexture3DEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGenFramebuffersEXT)(GLsizei, GLuint*);
#define glGenFramebuffersEXT sf_ptrc_glGenFramebuffersEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGenRenderbuffersEXT)(GLsizei, GLuint*);
#define glGenRenderbuffersEXT sf_ptrc_glGenRenderbuffersEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGenerateMipmapEXT)(GLenum);
+extern void (GL_FUNCPTR *sf_ptrc_glGenerateMipmapEXT)(GLenum);
#define glGenerateMipmapEXT sf_ptrc_glGenerateMipmapEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum, GLenum, GLenum, GLint*);
#define glGetFramebufferAttachmentParameterivEXT sf_ptrc_glGetFramebufferAttachmentParameterivEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint *);
+extern void (GL_FUNCPTR *sf_ptrc_glGetRenderbufferParameterivEXT)(GLenum, GLenum, GLint*);
#define glGetRenderbufferParameterivEXT sf_ptrc_glGetRenderbufferParameterivEXT
-extern GLboolean (CODEGEN_FUNCPTR *sf_ptrc_glIsFramebufferEXT)(GLuint);
+extern GLboolean (GL_FUNCPTR *sf_ptrc_glIsFramebufferEXT)(GLuint);
#define glIsFramebufferEXT sf_ptrc_glIsFramebufferEXT
-extern GLboolean (CODEGEN_FUNCPTR *sf_ptrc_glIsRenderbufferEXT)(GLuint);
+extern GLboolean (GL_FUNCPTR *sf_ptrc_glIsRenderbufferEXT)(GLuint);
#define glIsRenderbufferEXT sf_ptrc_glIsRenderbufferEXT
-extern void (CODEGEN_FUNCPTR *sf_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei);
+extern void (GL_FUNCPTR *sf_ptrc_glRenderbufferStorageEXT)(GLenum, GLenum, GLsizei, GLsizei);
#define glRenderbufferStorageEXT sf_ptrc_glRenderbufferStorageEXT
-#endif /*GL_EXT_framebuffer_object*/
+#endif // GL_EXT_framebuffer_object
+#ifndef GL_ARB_geometry_shader4
+#define GL_ARB_geometry_shader4 1
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureARB)(GLenum, GLenum, GLuint, GLint);
+#define glFramebufferTextureARB sf_ptrc_glFramebufferTextureARB
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureFaceARB)(GLenum, GLenum, GLuint, GLint, GLenum);
+#define glFramebufferTextureFaceARB sf_ptrc_glFramebufferTextureFaceARB
+extern void (GL_FUNCPTR *sf_ptrc_glFramebufferTextureLayerARB)(GLenum, GLenum, GLuint, GLint, GLint);
+#define glFramebufferTextureLayerARB sf_ptrc_glFramebufferTextureLayerARB
+extern void (GL_FUNCPTR *sf_ptrc_glProgramParameteriARB)(GLuint, GLenum, GLint);
+#define glProgramParameteriARB sf_ptrc_glProgramParameteriARB
+#endif // GL_ARB_geometry_shader4
+
+GLAPI void APIENTRY glAccum(GLenum, GLfloat);
+GLAPI void APIENTRY glAlphaFunc(GLenum, GLfloat);
+GLAPI void APIENTRY glBegin(GLenum);
+GLAPI void APIENTRY glBitmap(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte*);
GLAPI void APIENTRY glBlendFunc(GLenum, GLenum);
+GLAPI void APIENTRY glCallList(GLuint);
+GLAPI void APIENTRY glCallLists(GLsizei, GLenum, const void*);
GLAPI void APIENTRY glClear(GLbitfield);
+GLAPI void APIENTRY glClearAccum(GLfloat, GLfloat, GLfloat, GLfloat);
GLAPI void APIENTRY glClearColor(GLfloat, GLfloat, GLfloat, GLfloat);
GLAPI void APIENTRY glClearDepth(GLdouble);
+GLAPI void APIENTRY glClearIndex(GLfloat);
GLAPI void APIENTRY glClearStencil(GLint);
-GLAPI void APIENTRY glClipPlane(GLenum, const GLdouble *);
+GLAPI void APIENTRY glClipPlane(GLenum, const GLdouble*);
+GLAPI void APIENTRY glColor3b(GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glColor3bv(const GLbyte*);
+GLAPI void APIENTRY glColor3d(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glColor3dv(const GLdouble*);
+GLAPI void APIENTRY glColor3f(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor3fv(const GLfloat*);
+GLAPI void APIENTRY glColor3i(GLint, GLint, GLint);
+GLAPI void APIENTRY glColor3iv(const GLint*);
+GLAPI void APIENTRY glColor3s(GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glColor3sv(const GLshort*);
+GLAPI void APIENTRY glColor3ub(GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glColor3ubv(const GLubyte*);
+GLAPI void APIENTRY glColor3ui(GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColor3uiv(const GLuint*);
+GLAPI void APIENTRY glColor3us(GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glColor3usv(const GLushort*);
+GLAPI void APIENTRY glColor4b(GLbyte, GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glColor4bv(const GLbyte*);
+GLAPI void APIENTRY glColor4d(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glColor4dv(const GLdouble*);
+GLAPI void APIENTRY glColor4f(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4fv(const GLfloat*);
+GLAPI void APIENTRY glColor4i(GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glColor4iv(const GLint*);
+GLAPI void APIENTRY glColor4s(GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glColor4sv(const GLshort*);
+GLAPI void APIENTRY glColor4ub(GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glColor4ubv(const GLubyte*);
+GLAPI void APIENTRY glColor4ui(GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColor4uiv(const GLuint*);
+GLAPI void APIENTRY glColor4us(GLushort, GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glColor4usv(const GLushort*);
GLAPI void APIENTRY glColorMask(GLboolean, GLboolean, GLboolean, GLboolean);
+GLAPI void APIENTRY glColorMaterial(GLenum, GLenum);
GLAPI void APIENTRY glCopyPixels(GLint, GLint, GLsizei, GLsizei, GLenum);
GLAPI void APIENTRY glCullFace(GLenum);
+GLAPI void APIENTRY glDeleteLists(GLuint, GLsizei);
GLAPI void APIENTRY glDepthFunc(GLenum);
GLAPI void APIENTRY glDepthMask(GLboolean);
GLAPI void APIENTRY glDepthRange(GLdouble, GLdouble);
GLAPI void APIENTRY glDisable(GLenum);
GLAPI void APIENTRY glDrawBuffer(GLenum);
+GLAPI void APIENTRY glDrawPixels(GLsizei, GLsizei, GLenum, GLenum, const void*);
+GLAPI void APIENTRY glEdgeFlag(GLboolean);
+GLAPI void APIENTRY glEdgeFlagv(const GLboolean*);
GLAPI void APIENTRY glEnable(GLenum);
+GLAPI void APIENTRY glEnd();
+GLAPI void APIENTRY glEndList();
+GLAPI void APIENTRY glEvalCoord1d(GLdouble);
+GLAPI void APIENTRY glEvalCoord1dv(const GLdouble*);
+GLAPI void APIENTRY glEvalCoord1f(GLfloat);
+GLAPI void APIENTRY glEvalCoord1fv(const GLfloat*);
+GLAPI void APIENTRY glEvalCoord2d(GLdouble, GLdouble);
+GLAPI void APIENTRY glEvalCoord2dv(const GLdouble*);
+GLAPI void APIENTRY glEvalCoord2f(GLfloat, GLfloat);
+GLAPI void APIENTRY glEvalCoord2fv(const GLfloat*);
+GLAPI void APIENTRY glEvalMesh1(GLenum, GLint, GLint);
+GLAPI void APIENTRY glEvalMesh2(GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glEvalPoint1(GLint);
+GLAPI void APIENTRY glEvalPoint2(GLint, GLint);
+GLAPI void APIENTRY glFeedbackBuffer(GLsizei, GLenum, GLfloat*);
GLAPI void APIENTRY glFinish();
GLAPI void APIENTRY glFlush();
+GLAPI void APIENTRY glFogf(GLenum, GLfloat);
+GLAPI void APIENTRY glFogfv(GLenum, const GLfloat*);
+GLAPI void APIENTRY glFogi(GLenum, GLint);
+GLAPI void APIENTRY glFogiv(GLenum, const GLint*);
GLAPI void APIENTRY glFrontFace(GLenum);
GLAPI void APIENTRY glFrustum(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glGetBooleanv(GLenum, GLboolean *);
-GLAPI void APIENTRY glGetDoublev(GLenum, GLdouble *);
+GLAPI GLuint APIENTRY glGenLists(GLsizei);
+GLAPI void APIENTRY glGetBooleanv(GLenum, GLboolean*);
+GLAPI void APIENTRY glGetClipPlane(GLenum, GLdouble*);
+GLAPI void APIENTRY glGetDoublev(GLenum, GLdouble*);
GLAPI GLenum APIENTRY glGetError();
-GLAPI void APIENTRY glGetFloatv(GLenum, GLfloat *);
-GLAPI void APIENTRY glGetIntegerv(GLenum, GLint *);
-GLAPI const GLubyte * APIENTRY glGetString(GLenum);
-GLAPI void APIENTRY glGetTexEnvfv(GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetTexEnviv(GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetTexGendv(GLenum, GLenum, GLdouble *);
-GLAPI void APIENTRY glGetTexGenfv(GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetTexGeniv(GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetTexImage(GLenum, GLint, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetTexLevelParameterfv(GLenum, GLint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetTexLevelParameteriv(GLenum, GLint, GLenum, GLint *);
-GLAPI void APIENTRY glGetTexParameterfv(GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetTexParameteriv(GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFloatv(GLenum, GLfloat*);
+GLAPI void APIENTRY glGetIntegerv(GLenum, GLint*);
+GLAPI void APIENTRY glGetLightfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetLightiv(GLenum, GLenum, GLint*);
+GLAPI void APIENTRY glGetMapdv(GLenum, GLenum, GLdouble*);
+GLAPI void APIENTRY glGetMapfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetMapiv(GLenum, GLenum, GLint*);
+GLAPI void APIENTRY glGetMaterialfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetMaterialiv(GLenum, GLenum, GLint*);
+GLAPI void APIENTRY glGetPixelMapfv(GLenum, GLfloat*);
+GLAPI void APIENTRY glGetPixelMapuiv(GLenum, GLuint*);
+GLAPI void APIENTRY glGetPixelMapusv(GLenum, GLushort*);
+GLAPI void APIENTRY glGetPolygonStipple(GLubyte*);
+GLAPI const GLubyte* APIENTRY glGetString(GLenum);
+GLAPI void APIENTRY glGetTexEnvfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetTexEnviv(GLenum, GLenum, GLint*);
+GLAPI void APIENTRY glGetTexGendv(GLenum, GLenum, GLdouble*);
+GLAPI void APIENTRY glGetTexGenfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetTexGeniv(GLenum, GLenum, GLint*);
+GLAPI void APIENTRY glGetTexImage(GLenum, GLint, GLenum, GLenum, void*);
+GLAPI void APIENTRY glGetTexLevelParameterfv(GLenum, GLint, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetTexLevelParameteriv(GLenum, GLint, GLenum, GLint*);
+GLAPI void APIENTRY glGetTexParameterfv(GLenum, GLenum, GLfloat*);
+GLAPI void APIENTRY glGetTexParameteriv(GLenum, GLenum, GLint*);
GLAPI void APIENTRY glHint(GLenum, GLenum);
GLAPI void APIENTRY glIndexMask(GLuint);
+GLAPI void APIENTRY glIndexd(GLdouble);
+GLAPI void APIENTRY glIndexdv(const GLdouble*);
+GLAPI void APIENTRY glIndexf(GLfloat);
+GLAPI void APIENTRY glIndexfv(const GLfloat*);
+GLAPI void APIENTRY glIndexi(GLint);
+GLAPI void APIENTRY glIndexiv(const GLint*);
+GLAPI void APIENTRY glIndexs(GLshort);
+GLAPI void APIENTRY glIndexsv(const GLshort*);
+GLAPI void APIENTRY glInitNames();
GLAPI GLboolean APIENTRY glIsEnabled(GLenum);
+GLAPI GLboolean APIENTRY glIsList(GLuint);
+GLAPI void APIENTRY glLightModelf(GLenum, GLfloat);
+GLAPI void APIENTRY glLightModelfv(GLenum, const GLfloat*);
+GLAPI void APIENTRY glLightModeli(GLenum, GLint);
+GLAPI void APIENTRY glLightModeliv(GLenum, const GLint*);
+GLAPI void APIENTRY glLightf(GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glLightfv(GLenum, GLenum, const GLfloat*);
+GLAPI void APIENTRY glLighti(GLenum, GLenum, GLint);
+GLAPI void APIENTRY glLightiv(GLenum, GLenum, const GLint*);
+GLAPI void APIENTRY glLineStipple(GLint, GLushort);
GLAPI void APIENTRY glLineWidth(GLfloat);
+GLAPI void APIENTRY glListBase(GLuint);
GLAPI void APIENTRY glLoadIdentity();
-GLAPI void APIENTRY glLoadMatrixd(const GLdouble *);
-GLAPI void APIENTRY glLoadMatrixf(const GLfloat *);
+GLAPI void APIENTRY glLoadMatrixd(const GLdouble*);
+GLAPI void APIENTRY glLoadMatrixf(const GLfloat*);
+GLAPI void APIENTRY glLoadName(GLuint);
+GLAPI void APIENTRY glLogicOp(GLenum);
+GLAPI void APIENTRY glMap1d(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble*);
+GLAPI void APIENTRY glMap1f(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat*);
+GLAPI void APIENTRY glMap2d(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble*);
+GLAPI void APIENTRY glMap2f(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat*);
+GLAPI void APIENTRY glMapGrid1d(GLint, GLdouble, GLdouble);
+GLAPI void APIENTRY glMapGrid1f(GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glMapGrid2d(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble);
+GLAPI void APIENTRY glMapGrid2f(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glMaterialf(GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glMaterialfv(GLenum, GLenum, const GLfloat*);
+GLAPI void APIENTRY glMateriali(GLenum, GLenum, GLint);
+GLAPI void APIENTRY glMaterialiv(GLenum, GLenum, const GLint*);
GLAPI void APIENTRY glMatrixMode(GLenum);
-GLAPI void APIENTRY glMultMatrixd(const GLdouble *);
-GLAPI void APIENTRY glMultMatrixf(const GLfloat *);
+GLAPI void APIENTRY glMultMatrixd(const GLdouble*);
+GLAPI void APIENTRY glMultMatrixf(const GLfloat*);
+GLAPI void APIENTRY glNewList(GLuint, GLenum);
+GLAPI void APIENTRY glNormal3b(GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glNormal3bv(const GLbyte*);
+GLAPI void APIENTRY glNormal3d(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glNormal3dv(const GLdouble*);
+GLAPI void APIENTRY glNormal3f(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNormal3fv(const GLfloat*);
+GLAPI void APIENTRY glNormal3i(GLint, GLint, GLint);
+GLAPI void APIENTRY glNormal3iv(const GLint*);
+GLAPI void APIENTRY glNormal3s(GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glNormal3sv(const GLshort*);
GLAPI void APIENTRY glOrtho(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glPassThrough(GLfloat);
+GLAPI void APIENTRY glPixelMapfv(GLenum, GLsizei, const GLfloat*);
+GLAPI void APIENTRY glPixelMapuiv(GLenum, GLsizei, const GLuint*);
+GLAPI void APIENTRY glPixelMapusv(GLenum, GLsizei, const GLushort*);
+GLAPI void APIENTRY glPixelStoref(GLenum, GLfloat);
+GLAPI void APIENTRY glPixelStorei(GLenum, GLint);
+GLAPI void APIENTRY glPixelTransferf(GLenum, GLfloat);
+GLAPI void APIENTRY glPixelTransferi(GLenum, GLint);
+GLAPI void APIENTRY glPixelZoom(GLfloat, GLfloat);
GLAPI void APIENTRY glPointSize(GLfloat);
+GLAPI void APIENTRY glPolygonMode(GLenum, GLenum);
+GLAPI void APIENTRY glPolygonStipple(const GLubyte*);
GLAPI void APIENTRY glPopAttrib();
GLAPI void APIENTRY glPopMatrix();
+GLAPI void APIENTRY glPopName();
GLAPI void APIENTRY glPushAttrib(GLbitfield);
GLAPI void APIENTRY glPushMatrix();
+GLAPI void APIENTRY glPushName(GLuint);
+GLAPI void APIENTRY glRasterPos2d(GLdouble, GLdouble);
+GLAPI void APIENTRY glRasterPos2dv(const GLdouble*);
+GLAPI void APIENTRY glRasterPos2f(GLfloat, GLfloat);
+GLAPI void APIENTRY glRasterPos2fv(const GLfloat*);
+GLAPI void APIENTRY glRasterPos2i(GLint, GLint);
+GLAPI void APIENTRY glRasterPos2iv(const GLint*);
+GLAPI void APIENTRY glRasterPos2s(GLshort, GLshort);
+GLAPI void APIENTRY glRasterPos2sv(const GLshort*);
+GLAPI void APIENTRY glRasterPos3d(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glRasterPos3dv(const GLdouble*);
+GLAPI void APIENTRY glRasterPos3f(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glRasterPos3fv(const GLfloat*);
+GLAPI void APIENTRY glRasterPos3i(GLint, GLint, GLint);
+GLAPI void APIENTRY glRasterPos3iv(const GLint*);
+GLAPI void APIENTRY glRasterPos3s(GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glRasterPos3sv(const GLshort*);
+GLAPI void APIENTRY glRasterPos4d(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glRasterPos4dv(const GLdouble*);
+GLAPI void APIENTRY glRasterPos4f(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glRasterPos4fv(const GLfloat*);
+GLAPI void APIENTRY glRasterPos4i(GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glRasterPos4iv(const GLint*);
+GLAPI void APIENTRY glRasterPos4s(GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glRasterPos4sv(const GLshort*);
GLAPI void APIENTRY glReadBuffer(GLenum);
-GLAPI void APIENTRY glReadPixels(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glReadPixels(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void*);
+GLAPI void APIENTRY glRectd(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glRectdv(const GLdouble*, const GLdouble*);
+GLAPI void APIENTRY glRectf(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glRectfv(const GLfloat*, const GLfloat*);
+GLAPI void APIENTRY glRecti(GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glRectiv(const GLint*, const GLint*);
+GLAPI void APIENTRY glRects(GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glRectsv(const GLshort*, const GLshort*);
+GLAPI GLint APIENTRY glRenderMode(GLenum);
+GLAPI void APIENTRY glRotated(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glRotatef(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glScaled(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glScalef(GLfloat, GLfloat, GLfloat);
GLAPI void APIENTRY glScissor(GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glSelectBuffer(GLsizei, GLuint*);
GLAPI void APIENTRY glShadeModel(GLenum);
GLAPI void APIENTRY glStencilFunc(GLenum, GLint, GLuint);
GLAPI void APIENTRY glStencilMask(GLuint);
GLAPI void APIENTRY glStencilOp(GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glTexImage1D(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexImage2D(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexCoord1d(GLdouble);
+GLAPI void APIENTRY glTexCoord1dv(const GLdouble*);
+GLAPI void APIENTRY glTexCoord1f(GLfloat);
+GLAPI void APIENTRY glTexCoord1fv(const GLfloat*);
+GLAPI void APIENTRY glTexCoord1i(GLint);
+GLAPI void APIENTRY glTexCoord1iv(const GLint*);
+GLAPI void APIENTRY glTexCoord1s(GLshort);
+GLAPI void APIENTRY glTexCoord1sv(const GLshort*);
+GLAPI void APIENTRY glTexCoord2d(GLdouble, GLdouble);
+GLAPI void APIENTRY glTexCoord2dv(const GLdouble*);
+GLAPI void APIENTRY glTexCoord2f(GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fv(const GLfloat*);
+GLAPI void APIENTRY glTexCoord2i(GLint, GLint);
+GLAPI void APIENTRY glTexCoord2iv(const GLint*);
+GLAPI void APIENTRY glTexCoord2s(GLshort, GLshort);
+GLAPI void APIENTRY glTexCoord2sv(const GLshort*);
+GLAPI void APIENTRY glTexCoord3d(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glTexCoord3dv(const GLdouble*);
+GLAPI void APIENTRY glTexCoord3f(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord3fv(const GLfloat*);
+GLAPI void APIENTRY glTexCoord3i(GLint, GLint, GLint);
+GLAPI void APIENTRY glTexCoord3iv(const GLint*);
+GLAPI void APIENTRY glTexCoord3s(GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glTexCoord3sv(const GLshort*);
+GLAPI void APIENTRY glTexCoord4d(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glTexCoord4dv(const GLdouble*);
+GLAPI void APIENTRY glTexCoord4f(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord4fv(const GLfloat*);
+GLAPI void APIENTRY glTexCoord4i(GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glTexCoord4iv(const GLint*);
+GLAPI void APIENTRY glTexCoord4s(GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glTexCoord4sv(const GLshort*);
+GLAPI void APIENTRY glTexEnvf(GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glTexEnvfv(GLenum, GLenum, const GLfloat*);
+GLAPI void APIENTRY glTexEnvi(GLenum, GLenum, GLint);
+GLAPI void APIENTRY glTexEnviv(GLenum, GLenum, const GLint*);
+GLAPI void APIENTRY glTexGend(GLenum, GLenum, GLdouble);
+GLAPI void APIENTRY glTexGendv(GLenum, GLenum, const GLdouble*);
+GLAPI void APIENTRY glTexGenf(GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glTexGenfv(GLenum, GLenum, const GLfloat*);
+GLAPI void APIENTRY glTexGeni(GLenum, GLenum, GLint);
+GLAPI void APIENTRY glTexGeniv(GLenum, GLenum, const GLint*);
+GLAPI void APIENTRY glTexImage1D(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void*);
+GLAPI void APIENTRY glTexImage2D(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*);
GLAPI void APIENTRY glTexParameterf(GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glTexParameterfv(GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glTexParameterfv(GLenum, GLenum, const GLfloat*);
GLAPI void APIENTRY glTexParameteri(GLenum, GLenum, GLint);
-GLAPI void APIENTRY glTexParameteriv(GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glTexParameteriv(GLenum, GLenum, const GLint*);
+GLAPI void APIENTRY glTranslated(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glTranslatef(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertex2d(GLdouble, GLdouble);
+GLAPI void APIENTRY glVertex2dv(const GLdouble*);
+GLAPI void APIENTRY glVertex2f(GLfloat, GLfloat);
+GLAPI void APIENTRY glVertex2fv(const GLfloat*);
+GLAPI void APIENTRY glVertex2i(GLint, GLint);
+GLAPI void APIENTRY glVertex2iv(const GLint*);
+GLAPI void APIENTRY glVertex2s(GLshort, GLshort);
+GLAPI void APIENTRY glVertex2sv(const GLshort*);
+GLAPI void APIENTRY glVertex3d(GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertex3dv(const GLdouble*);
+GLAPI void APIENTRY glVertex3f(GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertex3fv(const GLfloat*);
+GLAPI void APIENTRY glVertex3i(GLint, GLint, GLint);
+GLAPI void APIENTRY glVertex3iv(const GLint*);
+GLAPI void APIENTRY glVertex3s(GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertex3sv(const GLshort*);
+GLAPI void APIENTRY glVertex4d(GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertex4dv(const GLdouble*);
+GLAPI void APIENTRY glVertex4f(GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertex4fv(const GLfloat*);
+GLAPI void APIENTRY glVertex4i(GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertex4iv(const GLint*);
+GLAPI void APIENTRY glVertex4s(GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertex4sv(const GLshort*);
GLAPI void APIENTRY glViewport(GLint, GLint, GLsizei, GLsizei);
+GLAPI GLboolean APIENTRY glAreTexturesResident(GLsizei, const GLuint*, GLboolean*);
+GLAPI void APIENTRY glArrayElement(GLint);
GLAPI void APIENTRY glBindTexture(GLenum, GLuint);
-GLAPI void APIENTRY glColorPointer(GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glColorPointer(GLint, GLenum, GLsizei, const void*);
GLAPI void APIENTRY glCopyTexImage1D(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
GLAPI void APIENTRY glCopyTexImage2D(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
GLAPI void APIENTRY glCopyTexSubImage1D(GLenum, GLint, GLint, GLint, GLint, GLsizei);
GLAPI void APIENTRY glCopyTexSubImage2D(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
-GLAPI void APIENTRY glDeleteTextures(GLsizei, const GLuint *);
+GLAPI void APIENTRY glDeleteTextures(GLsizei, const GLuint*);
GLAPI void APIENTRY glDisableClientState(GLenum);
GLAPI void APIENTRY glDrawArrays(GLenum, GLint, GLsizei);
-GLAPI void APIENTRY glDrawElements(GLenum, GLsizei, GLenum, const GLvoid *);
+GLAPI void APIENTRY glDrawElements(GLenum, GLsizei, GLenum, const void*);
+GLAPI void APIENTRY glEdgeFlagPointer(GLsizei, const void*);
GLAPI void APIENTRY glEnableClientState(GLenum);
-GLAPI void APIENTRY glGenTextures(GLsizei, GLuint *);
-GLAPI void APIENTRY glGetPointerv(GLenum, GLvoid **);
-GLAPI void APIENTRY glNormalPointer(GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGenTextures(GLsizei, GLuint*);
+GLAPI void APIENTRY glGetPointerv(GLenum, void**);
+GLAPI void APIENTRY glIndexPointer(GLenum, GLsizei, const void*);
+GLAPI void APIENTRY glIndexub(GLubyte);
+GLAPI void APIENTRY glIndexubv(const GLubyte*);
+GLAPI void APIENTRY glInterleavedArrays(GLenum, GLsizei, const void*);
+GLAPI GLboolean APIENTRY glIsTexture(GLuint);
+GLAPI void APIENTRY glNormalPointer(GLenum, GLsizei, const void*);
GLAPI void APIENTRY glPolygonOffset(GLfloat, GLfloat);
GLAPI void APIENTRY glPopClientAttrib();
+GLAPI void APIENTRY glPrioritizeTextures(GLsizei, const GLuint*, const GLfloat*);
GLAPI void APIENTRY glPushClientAttrib(GLbitfield);
-GLAPI void APIENTRY glTexCoordPointer(GLint, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage1D(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage2D(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glVertexPointer(GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glTexCoordPointer(GLint, GLenum, GLsizei, const void*);
+GLAPI void APIENTRY glTexSubImage1D(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void*);
+GLAPI void APIENTRY glTexSubImage2D(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void*);
+GLAPI void APIENTRY glVertexPointer(GLint, GLenum, GLsizei, const void*);
enum sfogl_LoadStatus
{
@@ -1040,14 +1598,10 @@ enum sfogl_LoadStatus
sfogl_LOAD_SUCCEEDED = 1
};
-int sfogl_LoadFunctions();
-
-int sfogl_GetMinorVersion();
-int sfogl_GetMajorVersion();
-int sfogl_IsVersionGEQ(int majorVersion, int minorVersion);
+void sfogl_LoadFunctions();
#ifdef __cplusplus
}
-#endif /*__cplusplus*/
+#endif // __cplusplus
-#endif //SF_POINTER_C_GENERATED_HEADER_OPENGL_HPP
+#endif // SFML_GLLOADER_HPP
diff --git a/src/SFML/Graphics/Glsl.cpp b/src/SFML/Graphics/Glsl.cpp
new file mode 100644
index 0000000..067defb
--- /dev/null
+++ b/src/SFML/Graphics/Glsl.cpp
@@ -0,0 +1,86 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Graphics/Glsl.hpp>
+#include <algorithm>
+
+
+namespace sf
+{
+namespace priv
+{
+
+ ////////////////////////////////////////////////////////////
+ void copyMatrix(const Transform& source, Matrix<3, 3>& dest)
+ {
+ const float* from = source.getMatrix(); // 4x4
+ float* to = dest.array; // 3x3
+
+ // Use only left-upper 3x3 block (for a 2D transform)
+ to[0] = from[ 0]; to[1] = from[ 1]; to[2] = from[ 3];
+ to[3] = from[ 4]; to[4] = from[ 5]; to[5] = from[ 7];
+ to[6] = from[12]; to[7] = from[13]; to[8] = from[15];
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ void copyMatrix(const Transform& source, Matrix<4, 4>& dest)
+ {
+ // Adopt 4x4 matrix as-is
+ copyMatrix(source.getMatrix(), 4 * 4, dest.array);
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ void copyMatrix(const float* source, std::size_t elements, float* dest)
+ {
+ std::copy(source, source + elements, dest);
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ void copyVector(const Color& source, Vector4<float>& dest)
+ {
+ dest.x = source.r / 255.f;
+ dest.y = source.g / 255.f;
+ dest.z = source.b / 255.f;
+ dest.w = source.a / 255.f;
+ }
+
+
+ ////////////////////////////////////////////////////////////
+ void copyVector(const Color& source, Vector4<int>& dest)
+ {
+ dest.x = static_cast<int>(source.r);
+ dest.y = static_cast<int>(source.g);
+ dest.z = static_cast<int>(source.b);
+ dest.w = static_cast<int>(source.a);
+ }
+
+} // namespace priv
+} // namespace sf
diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp
index 08fc495..be3f33f 100644
--- a/src/SFML/Graphics/Image.cpp
+++ b/src/SFML/Graphics/Image.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp
index d42be52..4568205 100644
--- a/src/SFML/Graphics/ImageLoader.cpp
+++ b/src/SFML/Graphics/ImageLoader.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -103,18 +103,23 @@ bool ImageLoader::loadImageFromFile(const std::string& filename, std::vector<Uin
pixels.clear();
// Load the image and get a pointer to the pixels in memory
- int width, height, channels;
+ int width = 0;
+ int height = 0;
+ int channels = 0;
unsigned char* ptr = stbi_load(filename.c_str(), &width, &height, &channels, STBI_rgb_alpha);
- if (ptr && width && height)
+ if (ptr)
{
// Assign the image properties
size.x = width;
size.y = height;
- // Copy the loaded pixels to the pixel buffer
- pixels.resize(width * height * 4);
- memcpy(&pixels[0], ptr, pixels.size());
+ if (width && height)
+ {
+ // Copy the loaded pixels to the pixel buffer
+ pixels.resize(width * height * 4);
+ memcpy(&pixels[0], ptr, pixels.size());
+ }
// Free the loaded pixels (they are now in our own pixel buffer)
stbi_image_free(ptr);
@@ -141,19 +146,24 @@ bool ImageLoader::loadImageFromMemory(const void* data, std::size_t dataSize, st
pixels.clear();
// Load the image and get a pointer to the pixels in memory
- int width, height, channels;
+ int width = 0;
+ int height = 0;
+ int channels = 0;
const unsigned char* buffer = static_cast<const unsigned char*>(data);
unsigned char* ptr = stbi_load_from_memory(buffer, static_cast<int>(dataSize), &width, &height, &channels, STBI_rgb_alpha);
- if (ptr && width && height)
+ if (ptr)
{
// Assign the image properties
size.x = width;
size.y = height;
- // Copy the loaded pixels to the pixel buffer
- pixels.resize(width * height * 4);
- memcpy(&pixels[0], ptr, pixels.size());
+ if (width && height)
+ {
+ // Copy the loaded pixels to the pixel buffer
+ pixels.resize(width * height * 4);
+ memcpy(&pixels[0], ptr, pixels.size());
+ }
// Free the loaded pixels (they are now in our own pixel buffer)
stbi_image_free(ptr);
@@ -192,18 +202,23 @@ bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector<Uint8>& p
callbacks.eof = &eof;
// Load the image and get a pointer to the pixels in memory
- int width, height, channels;
+ int width = 0;
+ int height = 0;
+ int channels = 0;
unsigned char* ptr = stbi_load_from_callbacks(&callbacks, &stream, &width, &height, &channels, STBI_rgb_alpha);
- if (ptr && width && height)
+ if (ptr)
{
// Assign the image properties
size.x = width;
size.y = height;
- // Copy the loaded pixels to the pixel buffer
- pixels.resize(width * height * 4);
- memcpy(&pixels[0], ptr, pixels.size());
+ if (width && height)
+ {
+ // Copy the loaded pixels to the pixel buffer
+ pixels.resize(width * height * 4);
+ memcpy(&pixels[0], ptr, pixels.size());
+ }
// Free the loaded pixels (they are now in our own pixel buffer)
stbi_image_free(ptr);
diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp
index 12e0699..93e07a1 100644
--- a/src/SFML/Graphics/ImageLoader.hpp
+++ b/src/SFML/Graphics/ImageLoader.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RectangleShape.cpp b/src/SFML/Graphics/RectangleShape.cpp
index 6fa4119..990b73c 100644
--- a/src/SFML/Graphics/RectangleShape.cpp
+++ b/src/SFML/Graphics/RectangleShape.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderStates.cpp b/src/SFML/Graphics/RenderStates.cpp
index 3da5fb1..efc2452 100644
--- a/src/SFML/Graphics/RenderStates.cpp
+++ b/src/SFML/Graphics/RenderStates.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp
index 28b35e4..7c7307c 100644
--- a/src/SFML/Graphics/RenderTarget.cpp
+++ b/src/SFML/Graphics/RenderTarget.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -67,6 +67,7 @@ namespace
{
case sf::BlendMode::Add: return GLEXT_GL_FUNC_ADD;
case sf::BlendMode::Subtract: return GLEXT_GL_FUNC_SUBTRACT;
+ case sf::BlendMode::ReverseSubtract: return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
}
sf::err() << "Invalid value for sf::BlendMode::Equation! Fallback to sf::BlendMode::Add." << std::endl;
diff --git a/src/SFML/Graphics/RenderTexture.cpp b/src/SFML/Graphics/RenderTexture.cpp
index 4602beb..b6daab7 100644
--- a/src/SFML/Graphics/RenderTexture.cpp
+++ b/src/SFML/Graphics/RenderTexture.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -117,6 +117,13 @@ bool RenderTexture::isRepeated() const
////////////////////////////////////////////////////////////
+bool RenderTexture::generateMipmap()
+{
+ return m_texture.generateMipmap();
+}
+
+
+////////////////////////////////////////////////////////////
bool RenderTexture::setActive(bool active)
{
return m_impl && m_impl->activate(active);
@@ -131,6 +138,7 @@ void RenderTexture::display()
{
m_impl->updateTexture(m_texture.m_texture);
m_texture.m_pixelsFlipped = true;
+ m_texture.invalidateMipmap();
}
}
diff --git a/src/SFML/Graphics/RenderTextureImpl.cpp b/src/SFML/Graphics/RenderTextureImpl.cpp
index f69305b..a4ab923 100644
--- a/src/SFML/Graphics/RenderTextureImpl.cpp
+++ b/src/SFML/Graphics/RenderTextureImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderTextureImpl.hpp b/src/SFML/Graphics/RenderTextureImpl.hpp
index 87562e7..cb7abcf 100644
--- a/src/SFML/Graphics/RenderTextureImpl.hpp
+++ b/src/SFML/Graphics/RenderTextureImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderTextureImplDefault.cpp b/src/SFML/Graphics/RenderTextureImplDefault.cpp
index 3d1a9dd..34cb687 100644
--- a/src/SFML/Graphics/RenderTextureImplDefault.cpp
+++ b/src/SFML/Graphics/RenderTextureImplDefault.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderTextureImplDefault.hpp b/src/SFML/Graphics/RenderTextureImplDefault.hpp
index 5c05a88..077575a 100644
--- a/src/SFML/Graphics/RenderTextureImplDefault.hpp
+++ b/src/SFML/Graphics/RenderTextureImplDefault.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderTextureImplFBO.cpp b/src/SFML/Graphics/RenderTextureImplFBO.cpp
index 20ff12c..3ce7006 100644
--- a/src/SFML/Graphics/RenderTextureImplFBO.cpp
+++ b/src/SFML/Graphics/RenderTextureImplFBO.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -37,6 +37,7 @@ namespace priv
{
////////////////////////////////////////////////////////////
RenderTextureImplFBO::RenderTextureImplFBO() :
+m_context (NULL),
m_frameBuffer(0),
m_depthBuffer(0)
{
diff --git a/src/SFML/Graphics/RenderTextureImplFBO.hpp b/src/SFML/Graphics/RenderTextureImplFBO.hpp
index cfbb53a..348da61 100644
--- a/src/SFML/Graphics/RenderTextureImplFBO.hpp
+++ b/src/SFML/Graphics/RenderTextureImplFBO.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp
index d9e884d..eb56668 100644
--- a/src/SFML/Graphics/RenderWindow.cpp
+++ b/src/SFML/Graphics/RenderWindow.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -26,7 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderWindow.hpp>
-#include <SFML/Graphics/GLCheck.hpp>
+#include <SFML/Graphics/Texture.hpp>
namespace sf
@@ -78,24 +78,13 @@ Vector2u RenderWindow::getSize() const
////////////////////////////////////////////////////////////
Image RenderWindow::capture() const
{
- Image image;
- if (setActive())
- {
- int width = static_cast<int>(getSize().x);
- int height = static_cast<int>(getSize().y);
-
- // copy rows one by one and flip them (OpenGL's origin is bottom while SFML's origin is top)
- std::vector<Uint8> pixels(width * height * 4);
- for (int i = 0; i < height; ++i)
- {
- Uint8* ptr = &pixels[i * width * 4];
- glCheck(glReadPixels(0, height - i - 1, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, ptr));
- }
-
- image.create(width, height, &pixels[0]);
- }
-
- return image;
+ Vector2u windowSize = getSize();
+
+ Texture texture;
+ texture.create(windowSize.x, windowSize.y);
+ texture.update(*this);
+
+ return texture.copyToImage();
}
diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp
index ff6a6ff..8010ff2 100644
--- a/src/SFML/Graphics/Shader.cpp
+++ b/src/SFML/Graphics/Shader.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -28,6 +28,8 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Shader.hpp>
#include <SFML/Graphics/Texture.hpp>
+#include <SFML/Graphics/Transform.hpp>
+#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/GLCheck.hpp>
#include <SFML/Window/Context.hpp>
#include <SFML/System/InputStream.hpp>
@@ -119,7 +121,21 @@ namespace
// Create a temporary context in case the user checks
// before a GlResource is created, thus initializing
// the shared context
- sf::Context context;
+ if (!sf::Context::getActiveContext())
+ {
+ sf::Context context;
+
+ // Make sure that extensions are initialized
+ sf::priv::ensureExtensionsInit();
+
+ bool available = GLEXT_multitexture &&
+ GLEXT_shading_language_100 &&
+ GLEXT_shader_objects &&
+ GLEXT_vertex_shader &&
+ GLEXT_fragment_shader;
+
+ return available;
+ }
// Make sure that extensions are initialized
sf::priv::ensureExtensionsInit();
@@ -132,6 +148,71 @@ namespace
return available;
}
+ bool checkGeometryShadersAvailable()
+ {
+ // Create a temporary context in case the user checks
+ // before a GlResource is created, thus initializing
+ // the shared context
+ sf::Context context;
+
+ // Make sure that extensions are initialized
+ sf::priv::ensureExtensionsInit();
+
+ bool available = checkShadersAvailable() && GLEXT_geometry_shader4;
+
+ return available;
+ }
+
+ // Transforms an array of 2D vectors into a contiguous array of scalars
+ template <typename T>
+ std::vector<T> flatten(const sf::Vector2<T>* vectorArray, std::size_t length)
+ {
+ const std::size_t vectorSize = 2;
+
+ std::vector<T> contiguous(vectorSize * length);
+ for (std::size_t i = 0; i < length; ++i)
+ {
+ contiguous[vectorSize * i] = vectorArray[i].x;
+ contiguous[vectorSize * i + 1] = vectorArray[i].y;
+ }
+
+ return contiguous;
+ }
+
+ // Transforms an array of 3D vectors into a contiguous array of scalars
+ template <typename T>
+ std::vector<T> flatten(const sf::Vector3<T>* vectorArray, std::size_t length)
+ {
+ const std::size_t vectorSize = 3;
+
+ std::vector<T> contiguous(vectorSize * length);
+ for (std::size_t i = 0; i < length; ++i)
+ {
+ contiguous[vectorSize * i] = vectorArray[i].x;
+ contiguous[vectorSize * i + 1] = vectorArray[i].y;
+ contiguous[vectorSize * i + 2] = vectorArray[i].z;
+ }
+
+ return contiguous;
+ }
+
+ // Transforms an array of 4D vectors into a contiguous array of scalars
+ template <typename T>
+ std::vector<T> flatten(const sf::priv::Vector4<T>* vectorArray, std::size_t length)
+ {
+ const std::size_t vectorSize = 4;
+
+ std::vector<T> contiguous(vectorSize * length);
+ for (std::size_t i = 0; i < length; ++i)
+ {
+ contiguous[vectorSize * i] = vectorArray[i].x;
+ contiguous[vectorSize * i + 1] = vectorArray[i].y;
+ contiguous[vectorSize * i + 2] = vectorArray[i].z;
+ contiguous[vectorSize * i + 3] = vectorArray[i].w;
+ }
+
+ return contiguous;
+ }
}
@@ -142,11 +223,54 @@ Shader::CurrentTextureType Shader::CurrentTexture;
////////////////////////////////////////////////////////////
+struct Shader::UniformBinder : private NonCopyable
+{
+ ////////////////////////////////////////////////////////////
+ /// \brief Constructor: set up state before uniform is set
+ ///
+ ////////////////////////////////////////////////////////////
+ UniformBinder(Shader& shader, const std::string& name) :
+ savedProgram(0),
+ currentProgram(castToGlHandle(shader.m_shaderProgram)),
+ location(-1)
+ {
+ if (currentProgram)
+ {
+ ensureGlContext();
+
+ // Enable program object
+ glCheck(savedProgram = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
+ if (currentProgram != savedProgram)
+ glCheck(GLEXT_glUseProgramObject(currentProgram));
+
+ // Store uniform location for further use outside constructor
+ location = shader.getUniformLocation(name);
+ }
+ }
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Destructor: restore state after uniform is set
+ ///
+ ////////////////////////////////////////////////////////////
+ ~UniformBinder()
+ {
+ // Disable program object
+ if (currentProgram && (currentProgram != savedProgram))
+ glCheck(GLEXT_glUseProgramObject(savedProgram));
+ }
+
+ GLEXT_GLhandle savedProgram; ///< Handle to the previously active program object
+ GLEXT_GLhandle currentProgram; ///< Handle to the program object of the modified sf::Shader instance
+ GLint location; ///< Uniform location, used by the surrounding sf::Shader code
+};
+
+
+////////////////////////////////////////////////////////////
Shader::Shader() :
m_shaderProgram (0),
m_currentTexture(-1),
m_textures (),
-m_params ()
+m_uniforms ()
{
}
@@ -175,9 +299,11 @@ bool Shader::loadFromFile(const std::string& filename, Type type)
// Compile the shader program
if (type == Vertex)
- return compile(&shader[0], NULL);
+ return compile(&shader[0], NULL, NULL);
+ else if (type == Geometry)
+ return compile(NULL, &shader[0], NULL);
else
- return compile(NULL, &shader[0]);
+ return compile(NULL, NULL, &shader[0]);
}
@@ -201,7 +327,39 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
}
// Compile the shader program
- return compile(&vertexShader[0], &fragmentShader[0]);
+ return compile(&vertexShader[0], NULL, &fragmentShader[0]);
+}
+
+
+////////////////////////////////////////////////////////////
+bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename)
+{
+ // Read the vertex shader file
+ std::vector<char> vertexShader;
+ if (!getFileContents(vertexShaderFilename, vertexShader))
+ {
+ err() << "Failed to open vertex shader file \"" << vertexShaderFilename << "\"" << std::endl;
+ return false;
+ }
+
+ // Read the geometry shader file
+ std::vector<char> geometryShader;
+ if (!getFileContents(geometryShaderFilename, geometryShader))
+ {
+ err() << "Failed to open geometry shader file \"" << geometryShaderFilename << "\"" << std::endl;
+ return false;
+ }
+
+ // Read the fragment shader file
+ std::vector<char> fragmentShader;
+ if (!getFileContents(fragmentShaderFilename, fragmentShader))
+ {
+ err() << "Failed to open fragment shader file \"" << fragmentShaderFilename << "\"" << std::endl;
+ return false;
+ }
+
+ // Compile the shader program
+ return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]);
}
@@ -210,9 +368,11 @@ bool Shader::loadFromMemory(const std::string& shader, Type type)
{
// Compile the shader program
if (type == Vertex)
- return compile(shader.c_str(), NULL);
+ return compile(shader.c_str(), NULL, NULL);
+ else if (type == Geometry)
+ return compile(NULL, shader.c_str(), NULL);
else
- return compile(NULL, shader.c_str());
+ return compile(NULL, NULL, shader.c_str());
}
@@ -220,7 +380,15 @@ bool Shader::loadFromMemory(const std::string& shader, Type type)
bool Shader::loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader)
{
// Compile the shader program
- return compile(vertexShader.c_str(), fragmentShader.c_str());
+ return compile(vertexShader.c_str(), NULL, fragmentShader.c_str());
+}
+
+
+////////////////////////////////////////////////////////////
+bool Shader::loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader)
+{
+ // Compile the shader program
+ return compile(vertexShader.c_str(), geometryShader.c_str(), fragmentShader.c_str());
}
@@ -237,9 +405,11 @@ bool Shader::loadFromStream(InputStream& stream, Type type)
// Compile the shader program
if (type == Vertex)
- return compile(&shader[0], NULL);
+ return compile(&shader[0], NULL, NULL);
+ else if (type == Geometry)
+ return compile(NULL, &shader[0], NULL);
else
- return compile(NULL, &shader[0]);
+ return compile(NULL, NULL, &shader[0]);
}
@@ -263,165 +433,169 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& fragme
}
// Compile the shader program
- return compile(&vertexShader[0], &fragmentShader[0]);
+ return compile(&vertexShader[0], NULL, &fragmentShader[0]);
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, float x)
+bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream)
{
- if (m_shaderProgram)
+ // Read the vertex shader code from the stream
+ std::vector<char> vertexShader;
+ if (!getStreamContents(vertexShaderStream, vertexShader))
{
- ensureGlContext();
-
- // Enable program
- GLEXT_GLhandle program;
- glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
- glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram)));
+ err() << "Failed to read vertex shader from stream" << std::endl;
+ return false;
+ }
- // Get parameter location and assign it new values
- GLint location = getParamLocation(name);
- if (location != -1)
- {
- glCheck(GLEXT_glUniform1f(location, x));
- }
+ // Read the geometry shader code from the stream
+ std::vector<char> geometryShader;
+ if (!getStreamContents(geometryShaderStream, geometryShader))
+ {
+ err() << "Failed to read geometry shader from stream" << std::endl;
+ return false;
+ }
- // Disable program
- glCheck(GLEXT_glUseProgramObject(program));
+ // Read the fragment shader code from the stream
+ std::vector<char> fragmentShader;
+ if (!getStreamContents(fragmentShaderStream, fragmentShader))
+ {
+ err() << "Failed to read fragment shader from stream" << std::endl;
+ return false;
}
+
+ // Compile the shader program
+ return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]);
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, float x, float y)
+void Shader::setUniform(const std::string& name, float x)
{
- if (m_shaderProgram)
- {
- ensureGlContext();
-
- // Enable program
- GLEXT_GLhandle program;
- glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
- glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram)));
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform1f(binder.location, x));
+}
- // Get parameter location and assign it new values
- GLint location = getParamLocation(name);
- if (location != -1)
- {
- glCheck(GLEXT_glUniform2f(location, x, y));
- }
- // Disable program
- glCheck(GLEXT_glUseProgramObject(program));
- }
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Vec2& v)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform2f(binder.location, v.x, v.y));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, float x, float y, float z)
+void Shader::setUniform(const std::string& name, const Glsl::Vec3& v)
{
- if (m_shaderProgram)
- {
- ensureGlContext();
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform3f(binder.location, v.x, v.y, v.z));
+}
- // Enable program
- GLEXT_GLhandle program;
- glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
- glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram)));
- // Get parameter location and assign it new values
- GLint location = getParamLocation(name);
- if (location != -1)
- {
- glCheck(GLEXT_glUniform3f(location, x, y, z));
- }
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Vec4& v)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform4f(binder.location, v.x, v.y, v.z, v.w));
+}
- // Disable program
- glCheck(GLEXT_glUseProgramObject(program));
- }
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, int x)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform1i(binder.location, x));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, float x, float y, float z, float w)
+void Shader::setUniform(const std::string& name, const Glsl::Ivec2& v)
{
- if (m_shaderProgram)
- {
- ensureGlContext();
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform2i(binder.location, v.x, v.y));
+}
- // Enable program
- GLEXT_GLhandle program;
- glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
- glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram)));
- // Get parameter location and assign it new values
- GLint location = getParamLocation(name);
- if (location != -1)
- {
- glCheck(GLEXT_glUniform4f(location, x, y, z, w));
- }
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Ivec3& v)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform3i(binder.location, v.x, v.y, v.z));
+}
- // Disable program
- glCheck(GLEXT_glUseProgramObject(program));
- }
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Ivec4& v)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform4i(binder.location, v.x, v.y, v.z, v.w));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, const Vector2f& v)
+void Shader::setUniform(const std::string& name, bool x)
{
- setParameter(name, v.x, v.y);
+ setUniform(name, static_cast<int>(x));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, const Vector3f& v)
+void Shader::setUniform(const std::string& name, const Glsl::Bvec2& v)
{
- setParameter(name, v.x, v.y, v.z);
+ setUniform(name, Glsl::Ivec2(v));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, const Color& color)
+void Shader::setUniform(const std::string& name, const Glsl::Bvec3& v)
{
- setParameter(name, color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f);
+ setUniform(name, Glsl::Ivec3(v));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, const Transform& transform)
+void Shader::setUniform(const std::string& name, const Glsl::Bvec4& v)
{
- if (m_shaderProgram)
- {
- ensureGlContext();
+ setUniform(name, Glsl::Ivec4(v));
+}
- // Enable program
- GLEXT_GLhandle program;
- glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT));
- glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram)));
- // Get parameter location and assign it new values
- GLint location = getParamLocation(name);
- if (location != -1)
- {
- glCheck(GLEXT_glUniformMatrix4fv(location, 1, GL_FALSE, transform.getMatrix()));
- }
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Mat3& matrix)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniformMatrix3fv(binder.location, 1, GL_FALSE, matrix.array));
+}
- // Disable program
- glCheck(GLEXT_glUseProgramObject(program));
- }
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Mat4& matrix)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniformMatrix4fv(binder.location, 1, GL_FALSE, matrix.array));
}
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, const Texture& texture)
+void Shader::setUniform(const std::string& name, const Texture& texture)
{
if (m_shaderProgram)
{
ensureGlContext();
// Find the location of the variable in the shader
- int location = getParamLocation(name);
+ int location = getUniformLocation(name);
if (location != -1)
{
// Store the location -> texture mapping
@@ -449,19 +623,161 @@ void Shader::setParameter(const std::string& name, const Texture& texture)
////////////////////////////////////////////////////////////
-void Shader::setParameter(const std::string& name, CurrentTextureType)
+void Shader::setUniform(const std::string& name, CurrentTextureType)
{
if (m_shaderProgram)
{
ensureGlContext();
// Find the location of the variable in the shader
- m_currentTexture = getParamLocation(name);
+ m_currentTexture = getUniformLocation(name);
}
}
////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const float* scalarArray, std::size_t length)
+{
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform1fv(binder.location, length, scalarArray));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorArray, std::size_t length)
+{
+ std::vector<float> contiguous = flatten(vectorArray, length);
+
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform2fv(binder.location, length, &contiguous[0]));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorArray, std::size_t length)
+{
+ std::vector<float> contiguous = flatten(vectorArray, length);
+
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform3fv(binder.location, length, &contiguous[0]));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorArray, std::size_t length)
+{
+ std::vector<float> contiguous = flatten(vectorArray, length);
+
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniform4fv(binder.location, length, &contiguous[0]));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixArray, std::size_t length)
+{
+ const std::size_t matrixSize = 3 * 3;
+
+ std::vector<float> contiguous(matrixSize * length);
+ for (std::size_t i = 0; i < length; ++i)
+ priv::copyMatrix(matrixArray[i].array, matrixSize, &contiguous[matrixSize * i]);
+
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, &contiguous[0]));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length)
+{
+ const std::size_t matrixSize = 4 * 4;
+
+ std::vector<float> contiguous(matrixSize * length);
+ for (std::size_t i = 0; i < length; ++i)
+ priv::copyMatrix(matrixArray[i].array, matrixSize, &contiguous[matrixSize * i]);
+
+ UniformBinder binder(*this, name);
+ if (binder.location != -1)
+ glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, &contiguous[0]));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, float x)
+{
+ setUniform(name, x);
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, float x, float y)
+{
+ setUniform(name, Glsl::Vec2(x, y));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, float x, float y, float z)
+{
+ setUniform(name, Glsl::Vec3(x, y, z));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, float x, float y, float z, float w)
+{
+ setUniform(name, Glsl::Vec4(x, y, z, w));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, const Vector2f& v)
+{
+ setUniform(name, v);
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, const Vector3f& v)
+{
+ setUniform(name, v);
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, const Color& color)
+{
+ setUniform(name, Glsl::Vec4(color));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, const Transform& transform)
+{
+ setUniform(name, Glsl::Mat4(transform));
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, const Texture& texture)
+{
+ setUniform(name, texture);
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setParameter(const std::string& name, CurrentTextureType)
+{
+ setUniform(name, CurrentTexture);
+}
+
+
+////////////////////////////////////////////////////////////
unsigned int Shader::getNativeHandle() const
{
return m_shaderProgram;
@@ -514,7 +830,19 @@ bool Shader::isAvailable()
////////////////////////////////////////////////////////////
-bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCode)
+bool Shader::isGeometryAvailable()
+{
+ // TODO: Remove this lock when it becomes unnecessary in C++11
+ Lock lock(mutex);
+
+ static bool available = checkGeometryShadersAvailable();
+
+ return available;
+}
+
+
+////////////////////////////////////////////////////////////
+bool Shader::compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode)
{
ensureGlContext();
@@ -526,6 +854,14 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod
return false;
}
+ // Make sure we can use geometry shaders
+ if (geometryShaderCode && !isGeometryAvailable())
+ {
+ err() << "Failed to create a shader: your system doesn't support geometry shaders "
+ << "(you should test Shader::isGeometryAvailable() before trying to use geometry shaders)" << std::endl;
+ return false;
+ }
+
// Destroy the shader if it was already created
if (m_shaderProgram)
{
@@ -536,7 +872,7 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod
// Reset the internal state
m_currentTexture = -1;
m_textures.clear();
- m_params.clear();
+ m_uniforms.clear();
// Create the program
GLEXT_GLhandle shaderProgram;
@@ -570,6 +906,33 @@ bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCod
glCheck(GLEXT_glDeleteObject(vertexShader));
}
+ // Create the geometry shader if needed
+ if (geometryShaderCode)
+ {
+ // Create and compile the shader
+ GLEXT_GLhandle geometryShader = GLEXT_glCreateShaderObject(GLEXT_GL_GEOMETRY_SHADER);
+ glCheck(GLEXT_glShaderSource(geometryShader, 1, &geometryShaderCode, NULL));
+ glCheck(GLEXT_glCompileShader(geometryShader));
+
+ // Check the compile log
+ GLint success;
+ glCheck(GLEXT_glGetObjectParameteriv(geometryShader, GLEXT_GL_OBJECT_COMPILE_STATUS, &success));
+ if (success == GL_FALSE)
+ {
+ char log[1024];
+ glCheck(GLEXT_glGetInfoLog(geometryShader, sizeof(log), 0, log));
+ err() << "Failed to compile geometry shader:" << std::endl
+ << log << std::endl;
+ glCheck(GLEXT_glDeleteObject(geometryShader));
+ glCheck(GLEXT_glDeleteObject(shaderProgram));
+ return false;
+ }
+
+ // Attach the shader to the program, and delete it (not needed anymore)
+ glCheck(GLEXT_glAttachObject(shaderProgram, geometryShader));
+ glCheck(GLEXT_glDeleteObject(geometryShader));
+ }
+
// Create the fragment shader if needed
if (fragmentShaderCode)
{
@@ -643,11 +1006,11 @@ void Shader::bindTextures() const
////////////////////////////////////////////////////////////
-int Shader::getParamLocation(const std::string& name)
+int Shader::getUniformLocation(const std::string& name)
{
// Check the cache
- ParamTable::const_iterator it = m_params.find(name);
- if (it != m_params.end())
+ UniformTable::const_iterator it = m_uniforms.find(name);
+ if (it != m_uniforms.end())
{
// Already in cache, return it
return it->second;
@@ -656,7 +1019,7 @@ int Shader::getParamLocation(const std::string& name)
{
// Not in cache, request the location from OpenGL
int location = GLEXT_glGetUniformLocation(castToGlHandle(m_shaderProgram), name.c_str());
- m_params.insert(std::make_pair(name, location));
+ m_uniforms.insert(std::make_pair(name, location));
if (location == -1)
err() << "Parameter \"" << name << "\" not found in shader" << std::endl;
@@ -706,6 +1069,13 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
////////////////////////////////////////////////////////////
+bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename)
+{
+ return false;
+}
+
+
+////////////////////////////////////////////////////////////
bool Shader::loadFromMemory(const std::string& shader, Type type)
{
return false;
@@ -720,6 +1090,13 @@ bool Shader::loadFromMemory(const std::string& vertexShader, const std::string&
////////////////////////////////////////////////////////////
+bool Shader::loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader)
+{
+ return false;
+}
+
+
+////////////////////////////////////////////////////////////
bool Shader::loadFromStream(InputStream& stream, Type type)
{
return false;
@@ -734,6 +1111,145 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& fragme
////////////////////////////////////////////////////////////
+bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream)
+{
+ return false;
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, float x)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Vec2& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Vec3& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Vec4& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, int x)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Ivec2& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Ivec3& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Ivec4& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, bool x)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Bvec2& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Bvec3& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Bvec4& v)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Mat3& matrix)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Glsl::Mat4& matrix)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, const Texture& texture)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniform(const std::string& name, CurrentTextureType)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const float* scalarArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
+void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length)
+{
+}
+
+
+////////////////////////////////////////////////////////////
void Shader::setParameter(const std::string& name, float x)
{
}
@@ -814,7 +1330,14 @@ bool Shader::isAvailable()
////////////////////////////////////////////////////////////
-bool Shader::compile(const char* vertexShaderCode, const char* fragmentShaderCode)
+bool Shader::isGeometryAvailable()
+{
+ return false;
+}
+
+
+////////////////////////////////////////////////////////////
+bool Shader::compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode)
{
return false;
}
diff --git a/src/SFML/Graphics/Shape.cpp b/src/SFML/Graphics/Shape.cpp
index 5403b40..f31a230 100644
--- a/src/SFML/Graphics/Shape.cpp
+++ b/src/SFML/Graphics/Shape.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -163,8 +163,8 @@ m_textureRect (),
m_fillColor (255, 255, 255),
m_outlineColor (255, 255, 255),
m_outlineThickness(0),
-m_vertices (TrianglesFan),
-m_outlineVertices (TrianglesStrip),
+m_vertices (TriangleFan),
+m_outlineVertices (TriangleStrip),
m_insideBounds (),
m_bounds ()
{
diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp
index e24c8f2..41183ec 100644
--- a/src/SFML/Graphics/Sprite.cpp
+++ b/src/SFML/Graphics/Sprite.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -140,7 +140,7 @@ void Sprite::draw(RenderTarget& target, RenderStates states) const
{
states.transform *= getTransform();
states.texture = m_texture;
- target.draw(m_vertices, 4, TrianglesStrip, states);
+ target.draw(m_vertices, 4, TriangleStrip, states);
}
}
diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp
index 0635a0e..5942921 100644
--- a/src/SFML/Graphics/Text.cpp
+++ b/src/SFML/Graphics/Text.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -31,6 +31,45 @@
#include <cmath>
+namespace
+{
+ // Add an underline or strikethrough line to the vertex array
+ void addLine(sf::VertexArray& vertices, float lineLength, float lineTop, const sf::Color& color, float offset, float thickness, float outlineThickness = 0)
+ {
+ float top = std::floor(lineTop + offset - (thickness / 2) + 0.5f);
+ float bottom = top + std::floor(thickness + 0.5f);
+
+ vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1)));
+ vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1)));
+ vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1)));
+ vertices.append(sf::Vertex(sf::Vector2f(-outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1)));
+ vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, top - outlineThickness), color, sf::Vector2f(1, 1)));
+ vertices.append(sf::Vertex(sf::Vector2f(lineLength + outlineThickness, bottom + outlineThickness), color, sf::Vector2f(1, 1)));
+ }
+
+ // Add a glyph quad to the vertex array
+ void addGlyphQuad(sf::VertexArray& vertices, sf::Vector2f position, const sf::Color& color, const sf::Glyph& glyph, float italic, float outlineThickness = 0)
+ {
+ float left = glyph.bounds.left;
+ float top = glyph.bounds.top;
+ float right = glyph.bounds.left + glyph.bounds.width;
+ float bottom = glyph.bounds.top + glyph.bounds.height;
+
+ float u1 = static_cast<float>(glyph.textureRect.left);
+ float v1 = static_cast<float>(glyph.textureRect.top);
+ float u2 = static_cast<float>(glyph.textureRect.left + glyph.textureRect.width);
+ float v2 = static_cast<float>(glyph.textureRect.top + glyph.textureRect.height);
+
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + left - italic * top - outlineThickness, position.y + top - outlineThickness), color, sf::Vector2f(u1, v1)));
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + right - italic * top - outlineThickness, position.y + top - outlineThickness), color, sf::Vector2f(u2, v1)));
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + left - italic * bottom - outlineThickness, position.y + bottom - outlineThickness), color, sf::Vector2f(u1, v2)));
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + left - italic * bottom - outlineThickness, position.y + bottom - outlineThickness), color, sf::Vector2f(u1, v2)));
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + right - italic * top - outlineThickness, position.y + top - outlineThickness), color, sf::Vector2f(u2, v1)));
+ vertices.append(sf::Vertex(sf::Vector2f(position.x + right - italic * bottom - outlineThickness, position.y + bottom - outlineThickness), color, sf::Vector2f(u2, v2)));
+ }
+}
+
+
namespace sf
{
////////////////////////////////////////////////////////////
@@ -39,8 +78,11 @@ m_string (),
m_font (NULL),
m_characterSize (30),
m_style (Regular),
-m_color (255, 255, 255),
+m_fillColor (255, 255, 255),
+m_outlineColor (0, 0, 0),
+m_outlineThickness (0),
m_vertices (Triangles),
+m_outlineVertices (Triangles),
m_bounds (),
m_geometryNeedUpdate(false)
{
@@ -54,8 +96,11 @@ m_string (string),
m_font (&font),
m_characterSize (characterSize),
m_style (Regular),
-m_color (255, 255, 255),
+m_fillColor (255, 255, 255),
+m_outlineColor (0, 0, 0),
+m_outlineThickness (0),
m_vertices (Triangles),
+m_outlineVertices (Triangles),
m_bounds (),
m_geometryNeedUpdate(true)
{
@@ -110,22 +155,58 @@ void Text::setStyle(Uint32 style)
////////////////////////////////////////////////////////////
void Text::setColor(const Color& color)
{
- if (color != m_color)
+ setFillColor(color);
+}
+
+
+////////////////////////////////////////////////////////////
+void Text::setFillColor(const Color& color)
+{
+ if (color != m_fillColor)
{
- m_color = color;
+ m_fillColor = color;
// Change vertex colors directly, no need to update whole geometry
// (if geometry is updated anyway, we can skip this step)
if (!m_geometryNeedUpdate)
{
for (std::size_t i = 0; i < m_vertices.getVertexCount(); ++i)
- m_vertices[i].color = m_color;
+ m_vertices[i].color = m_fillColor;
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+void Text::setOutlineColor(const Color& color)
+{
+ if (color != m_outlineColor)
+ {
+ m_outlineColor = color;
+
+ // Change vertex colors directly, no need to update whole geometry
+ // (if geometry is updated anyway, we can skip this step)
+ if (!m_geometryNeedUpdate)
+ {
+ for (std::size_t i = 0; i < m_outlineVertices.getVertexCount(); ++i)
+ m_outlineVertices[i].color = m_outlineColor;
}
}
}
////////////////////////////////////////////////////////////
+void Text::setOutlineThickness(float thickness)
+{
+ if (thickness != m_outlineThickness)
+ {
+ m_outlineThickness = thickness;
+ m_geometryNeedUpdate = true;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
const String& Text::getString() const
{
return m_string;
@@ -156,7 +237,28 @@ Uint32 Text::getStyle() const
////////////////////////////////////////////////////////////
const Color& Text::getColor() const
{
- return m_color;
+ return getFillColor();
+}
+
+
+////////////////////////////////////////////////////////////
+const Color& Text::getFillColor() const
+{
+ return m_fillColor;
+}
+
+
+////////////////////////////////////////////////////////////
+const Color& Text::getOutlineColor() const
+{
+ return m_outlineColor;
+}
+
+
+////////////////////////////////////////////////////////////
+float Text::getOutlineThickness() const
+{
+ return m_outlineThickness;
}
@@ -231,6 +333,11 @@ void Text::draw(RenderTarget& target, RenderStates states) const
states.transform *= getTransform();
states.texture = &m_font->getTexture(m_characterSize);
+
+ // Only draw the outline if there is something to draw
+ if (m_outlineThickness != 0)
+ target.draw(m_outlineVertices, states);
+
target.draw(m_vertices, states);
}
}
@@ -248,14 +355,11 @@ void Text::ensureGeometryUpdate() const
// Clear the previous geometry
m_vertices.clear();
+ m_outlineVertices.clear();
m_bounds = FloatRect();
- // No font: nothing to draw
- if (!m_font)
- return;
-
- // No text: nothing to draw
- if (m_string.isEmpty())
+ // No font or text: nothing to draw
+ if (!m_font || m_string.isEmpty())
return;
// Compute values related to the text style
@@ -289,35 +393,25 @@ void Text::ensureGeometryUpdate() const
Uint32 curChar = m_string[i];
// Apply the kerning offset
- x += static_cast<float>(m_font->getKerning(prevChar, curChar, m_characterSize));
+ x += m_font->getKerning(prevChar, curChar, m_characterSize);
prevChar = curChar;
// If we're using the underlined style and there's a new line, draw a line
if (underlined && (curChar == L'\n'))
{
- float top = std::floor(y + underlineOffset - (underlineThickness / 2) + 0.5f);
- float bottom = top + std::floor(underlineThickness + 0.5f);
-
- m_vertices.append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
+ addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness);
+
+ if (m_outlineThickness != 0)
+ addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness);
}
// If we're using the strike through style and there's a new line, draw a line across all characters
if (strikeThrough && (curChar == L'\n'))
{
- float top = std::floor(y + strikeThroughOffset - (underlineThickness / 2) + 0.5f);
- float bottom = top + std::floor(underlineThickness + 0.5f);
-
- m_vertices.append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
+ addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness);
+
+ if (m_outlineThickness != 0)
+ addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness);
}
// Handle special characters
@@ -342,63 +436,67 @@ void Text::ensureGeometryUpdate() const
continue;
}
- // Extract the current glyph's description
- const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold);
+
+ // Apply the outline
+ if (m_outlineThickness != 0)
+ {
+ const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold, m_outlineThickness);
- float left = glyph.bounds.left;
- float top = glyph.bounds.top;
- float right = glyph.bounds.left + glyph.bounds.width;
- float bottom = glyph.bounds.top + glyph.bounds.height;
+ float left = glyph.bounds.left;
+ float top = glyph.bounds.top;
+ float right = glyph.bounds.left + glyph.bounds.width;
+ float bottom = glyph.bounds.top + glyph.bounds.height;
- float u1 = static_cast<float>(glyph.textureRect.left);
- float v1 = static_cast<float>(glyph.textureRect.top);
- float u2 = static_cast<float>(glyph.textureRect.left + glyph.textureRect.width);
- float v2 = static_cast<float>(glyph.textureRect.top + glyph.textureRect.height);
+ // Add the outline glyph to the vertices
+ addGlyphQuad(m_outlineVertices, Vector2f(x, y), m_outlineColor, glyph, italic, m_outlineThickness);
+
+ // Update the current bounds with the outlined glyph bounds
+ minX = std::min(minX, x + left - italic * bottom - m_outlineThickness);
+ maxX = std::max(maxX, x + right - italic * top - m_outlineThickness);
+ minY = std::min(minY, y + top - m_outlineThickness);
+ maxY = std::max(maxY, y + bottom - m_outlineThickness);
+ }
+
+ // Extract the current glyph's description
+ const Glyph& glyph = m_font->getGlyph(curChar, m_characterSize, bold);
- // Add a quad for the current character
- m_vertices.append(Vertex(Vector2f(x + left - italic * top, y + top), m_color, Vector2f(u1, v1)));
- m_vertices.append(Vertex(Vector2f(x + right - italic * top, y + top), m_color, Vector2f(u2, v1)));
- m_vertices.append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), m_color, Vector2f(u1, v2)));
- m_vertices.append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), m_color, Vector2f(u1, v2)));
- m_vertices.append(Vertex(Vector2f(x + right - italic * top, y + top), m_color, Vector2f(u2, v1)));
- m_vertices.append(Vertex(Vector2f(x + right - italic * bottom, y + bottom), m_color, Vector2f(u2, v2)));
+ // Add the glyph to the vertices
+ addGlyphQuad(m_vertices, Vector2f(x, y), m_fillColor, glyph, italic);
- // Update the current bounds
- minX = std::min(minX, x + left - italic * bottom);
- maxX = std::max(maxX, x + right - italic * top);
- minY = std::min(minY, y + top);
- maxY = std::max(maxY, y + bottom);
+ // Update the current bounds with the non outlined glyph bounds
+ if (m_outlineThickness == 0)
+ {
+ float left = glyph.bounds.left;
+ float top = glyph.bounds.top;
+ float right = glyph.bounds.left + glyph.bounds.width;
+ float bottom = glyph.bounds.top + glyph.bounds.height;
+
+ minX = std::min(minX, x + left - italic * bottom);
+ maxX = std::max(maxX, x + right - italic * top);
+ minY = std::min(minY, y + top);
+ maxY = std::max(maxY, y + bottom);
+ }
// Advance to the next character
x += glyph.advance;
}
// If we're using the underlined style, add the last line
- if (underlined)
+ if (underlined && (x > 0))
{
- float top = std::floor(y + underlineOffset - (underlineThickness / 2) + 0.5f);
- float bottom = top + std::floor(underlineThickness + 0.5f);
-
- m_vertices.append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
+ addLine(m_vertices, x, y, m_fillColor, underlineOffset, underlineThickness);
+
+ if (m_outlineThickness != 0)
+ addLine(m_outlineVertices, x, y, m_outlineColor, underlineOffset, underlineThickness, m_outlineThickness);
}
// If we're using the strike through style, add the last line across all characters
- if (strikeThrough)
+ if (strikeThrough && (x > 0))
{
- float top = std::floor(y + strikeThroughOffset - (underlineThickness / 2) + 0.5f);
- float bottom = top + std::floor(underlineThickness + 0.5f);
-
- m_vertices.append(Vertex(Vector2f(0, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(0, bottom), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, top), m_color, Vector2f(1, 1)));
- m_vertices.append(Vertex(Vector2f(x, bottom), m_color, Vector2f(1, 1)));
+ addLine(m_vertices, x, y, m_fillColor, strikeThroughOffset, underlineThickness);
+
+ if (m_outlineThickness != 0)
+ addLine(m_outlineVertices, x, y, m_outlineColor, strikeThroughOffset, underlineThickness, m_outlineThickness);
}
// Update the bounding rectangle
diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp
index 4be52e7..a3e813f 100644
--- a/src/SFML/Graphics/Texture.cpp
+++ b/src/SFML/Graphics/Texture.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -58,7 +58,15 @@ namespace
// Create a temporary context in case the user queries
// the size before a GlResource is created, thus
// initializing the shared context
- sf::Context context;
+ if (!sf::Context::getActiveContext())
+ {
+ sf::Context context;
+
+ GLint size;
+ glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size));
+
+ return static_cast<unsigned int>(size);
+ }
GLint size;
glCheck(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size));
@@ -76,9 +84,11 @@ m_size (0, 0),
m_actualSize (0, 0),
m_texture (0),
m_isSmooth (false),
+m_sRgb (false),
m_isRepeated (false),
m_pixelsFlipped(false),
m_fboAttachment(false),
+m_hasMipmap (false),
m_cacheId (getUniqueId())
{
}
@@ -90,9 +100,11 @@ m_size (0, 0),
m_actualSize (0, 0),
m_texture (0),
m_isSmooth (copy.m_isSmooth),
+m_sRgb (copy.m_sRgb),
m_isRepeated (copy.m_isRepeated),
m_pixelsFlipped(false),
m_fboAttachment(false),
+m_hasMipmap (false),
m_cacheId (getUniqueId())
{
if (copy.m_texture)
@@ -177,15 +189,38 @@ bool Texture::create(unsigned int width, unsigned int height)
}
}
+ static bool textureSrgb = GLEXT_texture_sRGB;
+
+ if (m_sRgb && !textureSrgb)
+ {
+ static bool warned = false;
+
+ if (!warned)
+ {
+#ifndef SFML_OPENGL_ES
+ err() << "OpenGL extension EXT_texture_sRGB unavailable" << std::endl;
+#else
+ err() << "OpenGL ES extension EXT_sRGB unavailable" << std::endl;
+#endif
+ err() << "Automatic sRGB to linear conversion disabled" << std::endl;
+
+ warned = true;
+ }
+
+ m_sRgb = false;
+ }
+
// Initialize the texture
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
- glCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_actualSize.x, m_actualSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
+ glCheck(glTexImage2D(GL_TEXTURE_2D, 0, (m_sRgb ? GLEXT_GL_SRGB8_ALPHA8 : GL_RGBA), m_actualSize.x, m_actualSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, m_isRepeated ? GL_REPEAT : (textureEdgeClamp ? GLEXT_GL_CLAMP_TO_EDGE : GLEXT_GL_CLAMP)));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
m_cacheId = getUniqueId();
+ m_hasMipmap = false;
+
return true;
}
@@ -267,6 +302,9 @@ bool Texture::loadFromImage(const Image& image, const IntRect& area)
pixels += 4 * width;
}
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+ m_hasMipmap = false;
+
// Force an OpenGL flush, so that the texture will appear updated
// in all contexts immediately (solves problems in multi-threaded apps)
glCheck(glFlush());
@@ -394,6 +432,8 @@ void Texture::update(const Uint8* pixels, unsigned int width, unsigned int heigh
// Copy pixels from the given array to the texture
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+ m_hasMipmap = false;
m_pixelsFlipped = false;
m_cacheId = getUniqueId();
}
@@ -436,6 +476,8 @@ void Texture::update(const Window& window, unsigned int x, unsigned int y)
// Copy pixels from the back-buffer to the texture
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, window.getSize().x, window.getSize().y));
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+ m_hasMipmap = false;
m_pixelsFlipped = true;
m_cacheId = getUniqueId();
}
@@ -458,7 +500,15 @@ void Texture::setSmooth(bool smooth)
glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
- glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+
+ if (m_hasMipmap)
+ {
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR));
+ }
+ else
+ {
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+ }
}
}
}
@@ -472,6 +522,20 @@ bool Texture::isSmooth() const
////////////////////////////////////////////////////////////
+void Texture::setSrgb(bool sRgb)
+{
+ m_sRgb = sRgb;
+}
+
+
+////////////////////////////////////////////////////////////
+bool Texture::isSrgb() const
+{
+ return m_sRgb;
+}
+
+
+////////////////////////////////////////////////////////////
void Texture::setRepeated(bool repeated)
{
if (repeated != m_isRepeated)
@@ -517,6 +581,51 @@ bool Texture::isRepeated() const
////////////////////////////////////////////////////////////
+bool Texture::generateMipmap()
+{
+ if (!m_texture)
+ return false;
+
+ ensureGlContext();
+
+ // Make sure that extensions are initialized
+ priv::ensureExtensionsInit();
+
+ if (!GLEXT_framebuffer_object)
+ return false;
+
+ // Make sure that the current texture binding will be preserved
+ priv::TextureSaver save;
+
+ glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
+ glCheck(GLEXT_glGenerateMipmap(GL_TEXTURE_2D));
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR));
+
+ m_hasMipmap = true;
+
+ return true;
+}
+
+
+////////////////////////////////////////////////////////////
+void Texture::invalidateMipmap()
+{
+ if (!m_hasMipmap)
+ return;
+
+ ensureGlContext();
+
+ // Make sure that the current texture binding will be preserved
+ priv::TextureSaver save;
+
+ glCheck(glBindTexture(GL_TEXTURE_2D, m_texture));
+ glCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_isSmooth ? GL_LINEAR : GL_NEAREST));
+
+ m_hasMipmap = false;
+}
+
+
+////////////////////////////////////////////////////////////
void Texture::bind(const Texture* texture, CoordinateType coordinateType)
{
ensureGlContext();
@@ -596,6 +705,7 @@ Texture& Texture::operator =(const Texture& right)
std::swap(m_isRepeated, temp.m_isRepeated);
std::swap(m_pixelsFlipped, temp.m_pixelsFlipped);
std::swap(m_fboAttachment, temp.m_fboAttachment);
+ std::swap(m_hasMipmap, temp.m_hasMipmap);
m_cacheId = getUniqueId();
return *this;
diff --git a/src/SFML/Graphics/TextureSaver.cpp b/src/SFML/Graphics/TextureSaver.cpp
index 47ad6e9..768c086 100644
--- a/src/SFML/Graphics/TextureSaver.cpp
+++ b/src/SFML/Graphics/TextureSaver.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/TextureSaver.hpp b/src/SFML/Graphics/TextureSaver.hpp
index 4c87e4e..01e0d81 100644
--- a/src/SFML/Graphics/TextureSaver.hpp
+++ b/src/SFML/Graphics/TextureSaver.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/Transform.cpp b/src/SFML/Graphics/Transform.cpp
index e027031..c1818a1 100644
--- a/src/SFML/Graphics/Transform.cpp
+++ b/src/SFML/Graphics/Transform.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/Transformable.cpp b/src/SFML/Graphics/Transformable.cpp
index c45452d..4478aee 100644
--- a/src/SFML/Graphics/Transformable.cpp
+++ b/src/SFML/Graphics/Transformable.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/Vertex.cpp b/src/SFML/Graphics/Vertex.cpp
index b95eb71..9febb90 100644
--- a/src/SFML/Graphics/Vertex.cpp
+++ b/src/SFML/Graphics/Vertex.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/VertexArray.cpp b/src/SFML/Graphics/VertexArray.cpp
index e2d0218..19a112c 100644
--- a/src/SFML/Graphics/VertexArray.cpp
+++ b/src/SFML/Graphics/VertexArray.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Graphics/View.cpp b/src/SFML/Graphics/View.cpp
index 4fc6178..4ed6072 100644
--- a/src/SFML/Graphics/View.cpp
+++ b/src/SFML/Graphics/View.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Main/MainAndroid.cpp b/src/SFML/Main/MainAndroid.cpp
index 52e3816..4b76456 100644
--- a/src/SFML/Main/MainAndroid.cpp
+++ b/src/SFML/Main/MainAndroid.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Main/MainWin32.cpp b/src/SFML/Main/MainWin32.cpp
index c9f2873..c4211c7 100644
--- a/src/SFML/Main/MainWin32.cpp
+++ b/src/SFML/Main/MainWin32.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -41,6 +41,13 @@
#include <windows.h>
+// Inform the Nvidia/AMD driver that this SFML application could
+// benefit from using the more powerful discrete GPU
+extern "C"
+{
+__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
+__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
+}
extern int main(int argc, char* argv[]);
diff --git a/src/SFML/Main/MainiOS.mm b/src/SFML/Main/MainiOS.mm
index 48040e6..e6ffe67 100644
--- a/src/SFML/Main/MainiOS.mm
+++ b/src/SFML/Main/MainiOS.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.prg)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.prg)
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp
index 44a03b8..9415335 100644
--- a/src/SFML/Network/Ftp.cpp
+++ b/src/SFML/Network/Ftp.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -395,8 +395,18 @@ Ftp::Response Ftp::getResponse()
// Receive the response from the server
char buffer[1024];
std::size_t length;
- if (m_commandSocket.receive(buffer, sizeof(buffer), length) != Socket::Done)
- return Response(Response::ConnectionClosed);
+
+ if (m_receiveBuffer.empty())
+ {
+ if (m_commandSocket.receive(buffer, sizeof(buffer), length) != Socket::Done)
+ return Response(Response::ConnectionClosed);
+ }
+ else
+ {
+ std::copy(m_receiveBuffer.begin(), m_receiveBuffer.end(), buffer);
+ length = m_receiveBuffer.size();
+ m_receiveBuffer.clear();
+ }
// There can be several lines inside the received buffer, extract them all
std::istringstream in(std::string(buffer, length), std::ios_base::binary);
@@ -452,6 +462,9 @@ Ftp::Response Ftp::getResponse()
message = separator + line;
}
+ // Save the remaining data for the next time getResponse() is called
+ m_receiveBuffer.assign(buffer + in.tellg(), length - in.tellg());
+
// Return the response code and message
return Response(static_cast<Response::Status>(code), message);
}
diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp
index 68737f4..eb284e0 100644
--- a/src/SFML/Network/Http.cpp
+++ b/src/SFML/Network/Http.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -259,7 +259,8 @@ void Http::Response::parse(const std::string& data)
// Copy the actual content data
std::istreambuf_iterator<char> it(in);
- for (std::size_t i = 0; i < length; i++)
+ std::istreambuf_iterator<char> itEnd;
+ for (std::size_t i = 0; ((i < length) && (it != itEnd)); i++)
m_body.push_back(*it++);
}
diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp
index 19f0840..7a2bd0f 100644
--- a/src/SFML/Network/IpAddress.cpp
+++ b/src/SFML/Network/IpAddress.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -29,89 +29,56 @@
#include <SFML/Network/Http.hpp>
#include <SFML/Network/SocketImpl.hpp>
#include <cstring>
-
-
-namespace
-{
- sf::Uint32 resolve(const std::string& address)
- {
- if (address == "255.255.255.255")
- {
- // The broadcast address needs to be handled explicitly,
- // because it is also the value returned by inet_addr on error
- return INADDR_BROADCAST;
- }
- else
- {
- // Try to convert the address as a byte representation ("xxx.xxx.xxx.xxx")
- sf::Uint32 ip = inet_addr(address.c_str());
- if (ip != INADDR_NONE)
- return ip;
-
- // Not a valid address, try to convert it as a host name
- addrinfo hints;
- std::memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET;
- addrinfo* result = NULL;
- if (getaddrinfo(address.c_str(), NULL, &hints, &result) == 0)
- {
- if (result)
- {
- ip = reinterpret_cast<sockaddr_in*>(result->ai_addr)->sin_addr.s_addr;
- freeaddrinfo(result);
- return ip;
- }
- }
-
- // Not a valid address nor a host name
- return 0;
- }
- }
-}
+#include <utility>
namespace sf
{
////////////////////////////////////////////////////////////
const IpAddress IpAddress::None;
+const IpAddress IpAddress::Any(0, 0, 0, 0);
const IpAddress IpAddress::LocalHost(127, 0, 0, 1);
const IpAddress IpAddress::Broadcast(255, 255, 255, 255);
////////////////////////////////////////////////////////////
IpAddress::IpAddress() :
-m_address(0)
+m_address(0),
+m_valid (false)
{
- // We're using 0 (INADDR_ANY) instead of INADDR_NONE to represent the invalid address,
- // because the latter is also the broadcast address (255.255.255.255); it's ok because
- // SFML doesn't publicly use INADDR_ANY (it is always used implicitly)
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const std::string& address) :
-m_address(resolve(address))
+m_address(0),
+m_valid (false)
{
+ resolve(address);
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(const char* address) :
-m_address(resolve(address))
+m_address(0),
+m_valid (false)
{
+ resolve(address);
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3) :
-m_address(htonl((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3))
+m_address(htonl((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3)),
+m_valid (true)
{
}
////////////////////////////////////////////////////////////
IpAddress::IpAddress(Uint32 address) :
-m_address(htonl(address))
+m_address(htonl(address)),
+m_valid (true)
{
}
@@ -194,9 +161,58 @@ IpAddress IpAddress::getPublicAddress(Time timeout)
////////////////////////////////////////////////////////////
+void IpAddress::resolve(const std::string& address)
+{
+ m_address = 0;
+ m_valid = false;
+
+ if (address == "255.255.255.255")
+ {
+ // The broadcast address needs to be handled explicitly,
+ // because it is also the value returned by inet_addr on error
+ m_address = INADDR_BROADCAST;
+ m_valid = true;
+ }
+ else if (address == "0.0.0.0")
+ {
+ m_address = INADDR_ANY;
+ m_valid = true;
+ }
+ else
+ {
+ // Try to convert the address as a byte representation ("xxx.xxx.xxx.xxx")
+ Uint32 ip = inet_addr(address.c_str());
+ if (ip != INADDR_NONE)
+ {
+ m_address = ip;
+ m_valid = true;
+ }
+ else
+ {
+ // Not a valid address, try to convert it as a host name
+ addrinfo hints;
+ std::memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ addrinfo* result = NULL;
+ if (getaddrinfo(address.c_str(), NULL, &hints, &result) == 0)
+ {
+ if (result)
+ {
+ ip = reinterpret_cast<sockaddr_in*>(result->ai_addr)->sin_addr.s_addr;
+ freeaddrinfo(result);
+ m_address = ip;
+ m_valid = true;
+ }
+ }
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////
bool operator ==(const IpAddress& left, const IpAddress& right)
{
- return left.toInteger() == right.toInteger();
+ return !(left < right) && !(right < left);
}
@@ -210,7 +226,7 @@ bool operator !=(const IpAddress& left, const IpAddress& right)
////////////////////////////////////////////////////////////
bool operator <(const IpAddress& left, const IpAddress& right)
{
- return left.toInteger() < right.toInteger();
+ return std::make_pair(left.m_valid, left.m_address) < std::make_pair(right.m_valid, right.m_address);
}
diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp
index 2c5d0e0..1c15154 100644
--- a/src/SFML/Network/Packet.cpp
+++ b/src/SFML/Network/Packet.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/Socket.cpp b/src/SFML/Network/Socket.cpp
index 58ff16a..37e56b3 100644
--- a/src/SFML/Network/Socket.cpp
+++ b/src/SFML/Network/Socket.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -82,6 +82,13 @@ void Socket::create()
if (m_socket == priv::SocketImpl::invalidSocket())
{
SocketHandle handle = socket(PF_INET, m_type == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
+
+ if (handle == priv::SocketImpl::invalidSocket())
+ {
+ err() << "Failed to create socket" << std::endl;
+ return;
+ }
+
create(handle);
}
}
diff --git a/src/SFML/Network/SocketImpl.hpp b/src/SFML/Network/SocketImpl.hpp
index 423787e..7c4efff 100644
--- a/src/SFML/Network/SocketImpl.hpp
+++ b/src/SFML/Network/SocketImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/SocketSelector.cpp b/src/SFML/Network/SocketSelector.cpp
index 31e82d8..e73a0fe 100644
--- a/src/SFML/Network/SocketSelector.cpp
+++ b/src/SFML/Network/SocketSelector.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/TcpListener.cpp b/src/SFML/Network/TcpListener.cpp
index 7a68707..5222b27 100644
--- a/src/SFML/Network/TcpListener.cpp
+++ b/src/SFML/Network/TcpListener.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -61,14 +61,18 @@ unsigned short TcpListener::getLocalPort() const
////////////////////////////////////////////////////////////
-Socket::Status TcpListener::listen(unsigned short port)
+Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address)
{
// Create the internal socket if it doesn't exist
create();
+ // Check if the address is valid
+ if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
+ return Error;
+
// Bind the socket to the specified port
- sockaddr_in address = priv::SocketImpl::createAddress(INADDR_ANY, port);
- if (bind(getHandle(), reinterpret_cast<sockaddr*>(&address), sizeof(address)) == -1)
+ sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
+ if (bind(getHandle(), reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1)
{
// Not likely to happen, but...
err() << "Failed to bind listener socket to port " << port << std::endl;
diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp
index 6476c53..f4abe5e 100644
--- a/src/SFML/Network/TcpSocket.cpp
+++ b/src/SFML/Network/TcpSocket.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp
index ffa1494..f3e544d 100644
--- a/src/SFML/Network/UdpSocket.cpp
+++ b/src/SFML/Network/UdpSocket.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -64,14 +64,18 @@ unsigned short UdpSocket::getLocalPort() const
////////////////////////////////////////////////////////////
-Socket::Status UdpSocket::bind(unsigned short port)
+Socket::Status UdpSocket::bind(unsigned short port, const IpAddress& address)
{
// Create the internal socket if it doesn't exist
create();
+ // Check if the address is valid
+ if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
+ return Error;
+
// Bind the socket
- sockaddr_in address = priv::SocketImpl::createAddress(INADDR_ANY, port);
- if (::bind(getHandle(), reinterpret_cast<sockaddr*>(&address), sizeof(address)) == -1)
+ sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
+ if (::bind(getHandle(), reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1)
{
err() << "Failed to bind socket to port " << port << std::endl;
return Error;
diff --git a/src/SFML/Network/Unix/SocketImpl.cpp b/src/SFML/Network/Unix/SocketImpl.cpp
index 9a33d90..7d65976 100644
--- a/src/SFML/Network/Unix/SocketImpl.cpp
+++ b/src/SFML/Network/Unix/SocketImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -26,6 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Network/Unix/SocketImpl.hpp>
+#include <SFML/System/Err.hpp>
#include <errno.h>
#include <fcntl.h>
#include <cstring>
@@ -71,9 +72,16 @@ void SocketImpl::setBlocking(SocketHandle sock, bool block)
{
int status = fcntl(sock, F_GETFL);
if (block)
- fcntl(sock, F_SETFL, status & ~O_NONBLOCK);
+ {
+ if (fcntl(sock, F_SETFL, status & ~O_NONBLOCK) == -1)
+ err() << "Failed to set file status flags: " << errno << std::endl;
+ }
else
- fcntl(sock, F_SETFL, status | O_NONBLOCK);
+ {
+ if (fcntl(sock, F_SETFL, status | O_NONBLOCK) == -1)
+ err() << "Failed to set file status flags: " << errno << std::endl;
+
+ }
}
diff --git a/src/SFML/Network/Unix/SocketImpl.hpp b/src/SFML/Network/Unix/SocketImpl.hpp
index c54c55f..87704fd 100644
--- a/src/SFML/Network/Unix/SocketImpl.hpp
+++ b/src/SFML/Network/Unix/SocketImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/Win32/SocketImpl.cpp b/src/SFML/Network/Win32/SocketImpl.cpp
index 0f19842..c37ecaa 100644
--- a/src/SFML/Network/Win32/SocketImpl.cpp
+++ b/src/SFML/Network/Win32/SocketImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Network/Win32/SocketImpl.hpp b/src/SFML/Network/Win32/SocketImpl.hpp
index f6cabaf..efe0f61 100644
--- a/src/SFML/Network/Win32/SocketImpl.hpp
+++ b/src/SFML/Network/Win32/SocketImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Android/Activity.cpp b/src/SFML/System/Android/Activity.cpp
index fe3d015..89b9fb8 100644
--- a/src/SFML/System/Android/Activity.cpp
+++ b/src/SFML/System/Android/Activity.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/System/Android/NativeActivity.cpp b/src/SFML/System/Android/NativeActivity.cpp
new file mode 100644
index 0000000..99aef3f
--- /dev/null
+++ b/src/SFML/System/Android/NativeActivity.cpp
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/System/NativeActivity.hpp>
+#include <SFML/System/Android/Activity.hpp>
+
+namespace sf
+{
+////////////////////////////////////////////////////////////
+ANativeActivity* getNativeActivity()
+{
+ return priv::getActivity()->activity;
+}
+
+} // namespace sf
diff --git a/src/SFML/System/Android/ResourceStream.cpp b/src/SFML/System/Android/ResourceStream.cpp
index fbc1ec4..93280aa 100644
--- a/src/SFML/System/Android/ResourceStream.cpp
+++ b/src/SFML/System/Android/ResourceStream.cpp
@@ -49,35 +49,66 @@ m_file (NULL)
////////////////////////////////////////////////////////////
ResourceStream::~ResourceStream()
{
- AAsset_close(m_file);
+ if (m_file)
+ {
+ AAsset_close(m_file);
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::read(void *data, Int64 size)
{
- return AAsset_read(m_file, data, size);
+ if (m_file)
+ {
+ return AAsset_read(m_file, data, size);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::seek(Int64 position)
{
- return AAsset_seek(m_file, position, SEEK_SET);
+ if (m_file)
+ {
+ return AAsset_seek(m_file, position, SEEK_SET);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::tell()
{
- return getSize() - AAsset_getRemainingLength(m_file);
+ if (m_file)
+ {
+ return getSize() - AAsset_getRemainingLength(m_file);
+ }
+ else
+ {
+ return -1;
+ }
}
////////////////////////////////////////////////////////////
Int64 ResourceStream::getSize()
{
- return AAsset_getLength(m_file);
+ if (m_file)
+ {
+ return AAsset_getLength(m_file);
+ }
+ else
+ {
+ return -1;
+ }
}
diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt
index 48629f4..54da9a0 100644
--- a/src/SFML/System/CMakeLists.txt
+++ b/src/SFML/System/CMakeLists.txt
@@ -14,6 +14,7 @@ set(SRC
${INCROOT}/Lock.hpp
${SRCROOT}/Mutex.cpp
${INCROOT}/Mutex.hpp
+ ${INCROOT}/NativeActivity.hpp
${INCROOT}/NonCopyable.hpp
${SRCROOT}/Sleep.cpp
${INCROOT}/Sleep.hpp
@@ -75,6 +76,7 @@ else()
set(PLATFORM_SRC ${PLATFORM_SRC}
${SRCROOT}/Android/Activity.hpp
${SRCROOT}/Android/Activity.cpp
+ ${SRCROOT}/Android/NativeActivity.cpp
${SRCROOT}/Android/ResourceStream.cpp
${SRCROOT}/Android/ResourceStream.cpp
)
diff --git a/src/SFML/System/Clock.cpp b/src/SFML/System/Clock.cpp
index ba0bddb..d8d8ac1 100644
--- a/src/SFML/System/Clock.cpp
+++ b/src/SFML/System/Clock.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Err.cpp b/src/SFML/System/Err.cpp
index a7a408e..0575409 100644
--- a/src/SFML/System/Err.cpp
+++ b/src/SFML/System/Err.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/FileInputStream.cpp b/src/SFML/System/FileInputStream.cpp
index 82f4d72..09af98d 100644
--- a/src/SFML/System/FileInputStream.cpp
+++ b/src/SFML/System/FileInputStream.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -95,7 +95,9 @@ Int64 FileInputStream::seek(Int64 position)
#else
if (m_file)
{
- std::fseek(m_file, static_cast<std::size_t>(position), SEEK_SET);
+ if (std::fseek(m_file, static_cast<std::size_t>(position), SEEK_SET))
+ return -1;
+
return tell();
}
else
diff --git a/src/SFML/System/Lock.cpp b/src/SFML/System/Lock.cpp
index 90da155..d707d77 100644
--- a/src/SFML/System/Lock.cpp
+++ b/src/SFML/System/Lock.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/MemoryInputStream.cpp b/src/SFML/System/MemoryInputStream.cpp
index 6c2d547..dd7ab1b 100644
--- a/src/SFML/System/MemoryInputStream.cpp
+++ b/src/SFML/System/MemoryInputStream.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Mutex.cpp b/src/SFML/System/Mutex.cpp
index 4d515fc..9aedf3b 100644
--- a/src/SFML/System/Mutex.cpp
+++ b/src/SFML/System/Mutex.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Sleep.cpp b/src/SFML/System/Sleep.cpp
index 4765050..25c77f5 100644
--- a/src/SFML/System/Sleep.cpp
+++ b/src/SFML/System/Sleep.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp
index df5c169..bff2480 100644
--- a/src/SFML/System/String.cpp
+++ b/src/SFML/System/String.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Thread.cpp b/src/SFML/System/Thread.cpp
index 5c4b08c..29e4d44 100644
--- a/src/SFML/System/Thread.cpp
+++ b/src/SFML/System/Thread.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/ThreadLocal.cpp b/src/SFML/System/ThreadLocal.cpp
index 8e9cda1..1b5d8d9 100644
--- a/src/SFML/System/ThreadLocal.cpp
+++ b/src/SFML/System/ThreadLocal.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Time.cpp b/src/SFML/System/Time.cpp
index 2be34c9..b203a00 100644
--- a/src/SFML/System/Time.cpp
+++ b/src/SFML/System/Time.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/ClockImpl.cpp b/src/SFML/System/Unix/ClockImpl.cpp
index 7233009..2cc7dba 100644
--- a/src/SFML/System/Unix/ClockImpl.cpp
+++ b/src/SFML/System/Unix/ClockImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/ClockImpl.hpp b/src/SFML/System/Unix/ClockImpl.hpp
index 24db7d9..9abb448 100644
--- a/src/SFML/System/Unix/ClockImpl.hpp
+++ b/src/SFML/System/Unix/ClockImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/MutexImpl.cpp b/src/SFML/System/Unix/MutexImpl.cpp
index 56d2854..4f4515c 100644
--- a/src/SFML/System/Unix/MutexImpl.cpp
+++ b/src/SFML/System/Unix/MutexImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/MutexImpl.hpp b/src/SFML/System/Unix/MutexImpl.hpp
index d89365d..f09b664 100644
--- a/src/SFML/System/Unix/MutexImpl.hpp
+++ b/src/SFML/System/Unix/MutexImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/SleepImpl.cpp b/src/SFML/System/Unix/SleepImpl.cpp
index 611a554..dc0ff3c 100644
--- a/src/SFML/System/Unix/SleepImpl.cpp
+++ b/src/SFML/System/Unix/SleepImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/SleepImpl.hpp b/src/SFML/System/Unix/SleepImpl.hpp
index 4912581..616cbab 100644
--- a/src/SFML/System/Unix/SleepImpl.hpp
+++ b/src/SFML/System/Unix/SleepImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/ThreadImpl.cpp b/src/SFML/System/Unix/ThreadImpl.cpp
index 39cdeab..d9efe50 100644
--- a/src/SFML/System/Unix/ThreadImpl.cpp
+++ b/src/SFML/System/Unix/ThreadImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/ThreadImpl.hpp b/src/SFML/System/Unix/ThreadImpl.hpp
index 37daae4..152661b 100644
--- a/src/SFML/System/Unix/ThreadImpl.hpp
+++ b/src/SFML/System/Unix/ThreadImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Unix/ThreadLocalImpl.cpp b/src/SFML/System/Unix/ThreadLocalImpl.cpp
index 8af3974..0d5365b 100644
--- a/src/SFML/System/Unix/ThreadLocalImpl.cpp
+++ b/src/SFML/System/Unix/ThreadLocalImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -33,7 +33,8 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
-ThreadLocalImpl::ThreadLocalImpl()
+ThreadLocalImpl::ThreadLocalImpl() :
+m_key(0)
{
pthread_key_create(&m_key, NULL);
}
diff --git a/src/SFML/System/Unix/ThreadLocalImpl.hpp b/src/SFML/System/Unix/ThreadLocalImpl.hpp
index b591cb2..fb46277 100644
--- a/src/SFML/System/Unix/ThreadLocalImpl.hpp
+++ b/src/SFML/System/Unix/ThreadLocalImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ClockImpl.cpp b/src/SFML/System/Win32/ClockImpl.cpp
index 7ba7b9a..67b19f9 100644
--- a/src/SFML/System/Win32/ClockImpl.cpp
+++ b/src/SFML/System/Win32/ClockImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ClockImpl.hpp b/src/SFML/System/Win32/ClockImpl.hpp
index 3790491..c250c60 100644
--- a/src/SFML/System/Win32/ClockImpl.hpp
+++ b/src/SFML/System/Win32/ClockImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/MutexImpl.cpp b/src/SFML/System/Win32/MutexImpl.cpp
index 047ea52..2cf9788 100644
--- a/src/SFML/System/Win32/MutexImpl.cpp
+++ b/src/SFML/System/Win32/MutexImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/MutexImpl.hpp b/src/SFML/System/Win32/MutexImpl.hpp
index 75a5fb6..b23bed7 100644
--- a/src/SFML/System/Win32/MutexImpl.hpp
+++ b/src/SFML/System/Win32/MutexImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/SleepImpl.cpp b/src/SFML/System/Win32/SleepImpl.cpp
index 090c219..a363c98 100644
--- a/src/SFML/System/Win32/SleepImpl.cpp
+++ b/src/SFML/System/Win32/SleepImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/SleepImpl.hpp b/src/SFML/System/Win32/SleepImpl.hpp
index 682ec7f..49051f6 100644
--- a/src/SFML/System/Win32/SleepImpl.hpp
+++ b/src/SFML/System/Win32/SleepImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ThreadImpl.cpp b/src/SFML/System/Win32/ThreadImpl.cpp
index dfe3c64..bdcd085 100644
--- a/src/SFML/System/Win32/ThreadImpl.cpp
+++ b/src/SFML/System/Win32/ThreadImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ThreadImpl.hpp b/src/SFML/System/Win32/ThreadImpl.hpp
index 94b45f8..d4e7af6 100644
--- a/src/SFML/System/Win32/ThreadImpl.hpp
+++ b/src/SFML/System/Win32/ThreadImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ThreadLocalImpl.cpp b/src/SFML/System/Win32/ThreadLocalImpl.cpp
index 0f0fb4a..3df52af 100644
--- a/src/SFML/System/Win32/ThreadLocalImpl.cpp
+++ b/src/SFML/System/Win32/ThreadLocalImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/System/Win32/ThreadLocalImpl.hpp b/src/SFML/System/Win32/ThreadLocalImpl.hpp
index 38bef43..e6c0323 100644
--- a/src/SFML/System/Win32/ThreadLocalImpl.hpp
+++ b/src/SFML/System/Win32/ThreadLocalImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Android/InputImpl.cpp b/src/SFML/Window/Android/InputImpl.cpp
index 8940b9e..9da3a13 100644
--- a/src/SFML/Window/Android/InputImpl.cpp
+++ b/src/SFML/Window/Android/InputImpl.cpp
@@ -125,7 +125,6 @@ void InputImpl::setVirtualKeyboardVisible(bool visible)
MethodHideSoftInput, lBinder, lFlags);
lJNIEnv->DeleteLocalRef(lBinder);
}
- lJNIEnv->DeleteLocalRef(lNativeActivity);
lJNIEnv->DeleteLocalRef(ClassNativeActivity);
lJNIEnv->DeleteLocalRef(ClassInputMethodManager);
lJNIEnv->DeleteLocalRef(lDecorView);
diff --git a/src/SFML/Window/Android/SensorImpl.cpp b/src/SFML/Window/Android/SensorImpl.cpp
index 2b691a1..756833f 100644
--- a/src/SFML/Window/Android/SensorImpl.cpp
+++ b/src/SFML/Window/Android/SensorImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Android/SensorImpl.hpp b/src/SFML/Window/Android/SensorImpl.hpp
index 0b34997..0adb44d 100644
--- a/src/SFML/Window/Android/SensorImpl.hpp
+++ b/src/SFML/Window/Android/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp
index fb1906b..27d2f10 100644
--- a/src/SFML/Window/Android/WindowImplAndroid.cpp
+++ b/src/SFML/Window/Android/WindowImplAndroid.cpp
@@ -179,6 +179,13 @@ void WindowImplAndroid::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void WindowImplAndroid::setMouseCursorGrabbed(bool grabbed)
+{
+ // Not applicable
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplAndroid::setKeyRepeatEnabled(bool enabled)
{
// Not applicable
@@ -433,7 +440,7 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates* s
if (device == AINPUT_SOURCE_MOUSE)
event.type = Event::MouseMoved;
- else if (device == AINPUT_SOURCE_TOUCHSCREEN)
+ else if (device & AINPUT_SOURCE_TOUCHSCREEN)
event.type = Event::TouchMoved;
int pointerCount = AMotionEvent_getPointerCount(_event);
@@ -452,7 +459,7 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates* s
states->mousePosition = Vector2i(event.mouseMove.x, event.mouseMove.y);
}
- else if (device == AINPUT_SOURCE_TOUCHSCREEN)
+ else if (device & AINPUT_SOURCE_TOUCHSCREEN)
{
if (states->touchEvents[id].x == x && states->touchEvents[id].y == y)
continue;
@@ -496,7 +503,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
if (id >= 0 && id < Mouse::ButtonCount)
states->isButtonPressed[id] = true;
}
- else if (device == AINPUT_SOURCE_TOUCHSCREEN)
+ else if (device & AINPUT_SOURCE_TOUCHSCREEN)
{
event.type = Event::TouchBegan;
event.touch.finger = id;
@@ -518,7 +525,7 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
if (id >= 0 && id < Mouse::ButtonCount)
states->isButtonPressed[id] = false;
}
- else if (device == AINPUT_SOURCE_TOUCHSCREEN)
+ else if (device & AINPUT_SOURCE_TOUCHSCREEN)
{
event.type = Event::TouchEnded;
event.touch.finger = id;
diff --git a/src/SFML/Window/Android/WindowImplAndroid.hpp b/src/SFML/Window/Android/WindowImplAndroid.hpp
index fb05b35..88250d4 100644
--- a/src/SFML/Window/Android/WindowImplAndroid.hpp
+++ b/src/SFML/Window/Android/WindowImplAndroid.hpp
@@ -147,6 +147,14 @@ public:
virtual void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Clips or releases the mouse cursor
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt
index 386c077..231dee8 100644
--- a/src/SFML/Window/CMakeLists.txt
+++ b/src/SFML/Window/CMakeLists.txt
@@ -111,7 +111,7 @@ elseif(SFML_OS_MACOSX)
${SRCROOT}/OSX/cpp_objc_conversion.h
${SRCROOT}/OSX/cpp_objc_conversion.mm
${SRCROOT}/OSX/cg_sf_conversion.hpp
- ${SRCROOT}/OSX/cg_sf_conversion.cpp
+ ${SRCROOT}/OSX/cg_sf_conversion.mm
${SRCROOT}/OSX/InputImpl.mm
${SRCROOT}/OSX/InputImpl.hpp
${SRCROOT}/OSX/HIDInputManager.hpp
@@ -120,6 +120,9 @@ elseif(SFML_OS_MACOSX)
${SRCROOT}/OSX/HIDJoystickManager.cpp
${SRCROOT}/OSX/JoystickImpl.cpp
${SRCROOT}/OSX/JoystickImpl.hpp
+ ${SRCROOT}/OSX/NSImage+raw.h
+ ${SRCROOT}/OSX/NSImage+raw.mm
+ ${SRCROOT}/OSX/Scaling.h
${SRCROOT}/OSX/SensorImpl.cpp
${SRCROOT}/OSX/SensorImpl.hpp
${SRCROOT}/OSX/SFApplication.h
@@ -132,6 +135,10 @@ elseif(SFML_OS_MACOSX)
${SRCROOT}/OSX/SFKeyboardModifiersHelper.mm
${SRCROOT}/OSX/SFOpenGLView.h
${SRCROOT}/OSX/SFOpenGLView.mm
+ ${SRCROOT}/OSX/SFOpenGLView+keyboard.mm
+ ${SRCROOT}/OSX/SFOpenGLView+keyboard_priv.h
+ ${SRCROOT}/OSX/SFOpenGLView+mouse.mm
+ ${SRCROOT}/OSX/SFOpenGLView+mouse_priv.h
${SRCROOT}/OSX/SFSilentResponder.h
${SRCROOT}/OSX/SFSilentResponder.m
${SRCROOT}/OSX/SFWindow.h
diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp
index 0ec500a..2d51bbc 100644
--- a/src/SFML/Window/Context.cpp
+++ b/src/SFML/Window/Context.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -27,7 +27,32 @@
////////////////////////////////////////////////////////////
#include <SFML/Window/Context.hpp>
#include <SFML/Window/GlContext.hpp>
+#include <SFML/System/ThreadLocalPtr.hpp>
+#include <SFML/OpenGL.hpp>
+#include <algorithm>
+#include <vector>
+#include <string>
+#if defined(SFML_SYSTEM_WINDOWS)
+
+ typedef const GLubyte* (APIENTRY *glGetStringiFuncType)(GLenum, GLuint);
+
+#else
+
+ typedef const GLubyte* (*glGetStringiFuncType)(GLenum, GLuint);
+
+#endif
+
+#if !defined(GL_NUM_EXTENSIONS)
+ #define GL_NUM_EXTENSIONS 0x821D
+#endif
+
+
+namespace
+{
+ // This per-thread variable holds the current context for each thread
+ sf::ThreadLocalPtr<sf::Context> currentContext(NULL);
+}
namespace sf
{
@@ -42,6 +67,7 @@ Context::Context()
////////////////////////////////////////////////////////////
Context::~Context()
{
+ setActive(false);
delete m_context;
}
@@ -49,7 +75,26 @@ Context::~Context()
////////////////////////////////////////////////////////////
bool Context::setActive(bool active)
{
- return m_context->setActive(active);
+ bool result = m_context->setActive(active);
+
+ if (result)
+ currentContext = (active ? this : NULL);
+
+ return result;
+}
+
+
+////////////////////////////////////////////////////////////
+const ContextSettings& Context::getSettings() const
+{
+ return m_context->getSettings();
+}
+
+
+////////////////////////////////////////////////////////////
+const Context* Context::getActiveContext()
+{
+ return currentContext;
}
@@ -61,6 +106,67 @@ GlFunctionPointer Context::getFunction(const char* name)
////////////////////////////////////////////////////////////
+bool Context::isExtensionAvailable(const char* name)
+{
+ static std::vector<std::string> extensions;
+ static bool loaded = false;
+
+ if (!loaded)
+ {
+ const Context* context = getActiveContext();
+
+ if (!context)
+ return false;
+
+ const char* extensionString = NULL;
+
+ if(context->getSettings().majorVersion < 3)
+ {
+ // Try to load the < 3.0 way
+ extensionString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+
+ do
+ {
+ const char* extension = extensionString;
+
+ while(*extensionString && (*extensionString != ' '))
+ extensionString++;
+
+ extensions.push_back(std::string(extension, extensionString));
+ }
+ while (*extensionString++);
+ }
+ else
+ {
+ // Try to load the >= 3.0 way
+ glGetStringiFuncType glGetStringiFunc = NULL;
+ glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(getFunction("glGetStringi"));
+
+ if (glGetStringiFunc)
+ {
+ int numExtensions = 0;
+ glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
+
+ if (numExtensions)
+ {
+ for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i)
+ {
+ extensionString = reinterpret_cast<const char*>(glGetStringiFunc(GL_EXTENSIONS, i));
+
+ extensions.push_back(extensionString);
+ }
+ }
+ }
+ }
+
+ loaded = true;
+ }
+
+ return std::find(extensions.begin(), extensions.end(), name) != extensions.end();
+}
+
+
+////////////////////////////////////////////////////////////
Context::Context(const ContextSettings& settings, unsigned int width, unsigned int height)
{
m_context = priv::GlContext::create(settings, width, height);
diff --git a/src/SFML/Window/EglContext.cpp b/src/SFML/Window/EglContext.cpp
index ed7d294..f6686f1 100644
--- a/src/SFML/Window/EglContext.cpp
+++ b/src/SFML/Window/EglContext.cpp
@@ -85,6 +85,7 @@ m_config (NULL)
// Get the best EGL config matching the default video settings
m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
+ updateSettings();
// Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface,
// but this is resulting in a segfault. Bug in Android?
@@ -123,6 +124,7 @@ m_config (NULL)
// Get the best EGL config matching the requested video settings
m_config = getBestConfig(m_display, bitsPerPixel, settings);
+ updateSettings();
// Create EGL context
createContext(shared);
@@ -250,10 +252,33 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
// Ask EGL for the best config matching our video settings
eglCheck(eglChooseConfig(display, attributes, configs, 1, &configCount));
+ // TODO: This should check EGL_CONFORMANT and pick the first conformant configuration.
+
return configs[0];
}
+////////////////////////////////////////////////////////////
+void EglContext::updateSettings()
+{
+ EGLint tmp;
+
+ // Update the internal context settings with the current config
+ eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp));
+ m_settings.depthBits = tmp;
+
+ eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
+ m_settings.stencilBits = tmp;
+
+ eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
+ m_settings.antialiasingLevel = tmp;
+
+ m_settings.majorVersion = 1;
+ m_settings.minorVersion = 1;
+ m_settings.attributeFlags = ContextSettings::Default;
+}
+
+
#ifdef SFML_SYSTEM_LINUX
////////////////////////////////////////////////////////////
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)
diff --git a/src/SFML/Window/EglContext.hpp b/src/SFML/Window/EglContext.hpp
index ef30cb4..6df6a53 100644
--- a/src/SFML/Window/EglContext.hpp
+++ b/src/SFML/Window/EglContext.hpp
@@ -166,6 +166,11 @@ public:
private:
////////////////////////////////////////////////////////////
+ /// \brief Helper to copy the picked EGL configuration
+ ////////////////////////////////////////////////////////////
+ void updateSettings();
+
+ ////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
EGLDisplay m_display; ///< The internal EGL display
diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.cpp b/src/SFML/Window/FreeBSD/JoystickImpl.cpp
index ff21293..4409893 100644
--- a/src/SFML/Window/FreeBSD/JoystickImpl.cpp
+++ b/src/SFML/Window/FreeBSD/JoystickImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
// 2013-2013 David Demelier (demelier.david@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.hpp b/src/SFML/Window/FreeBSD/JoystickImpl.hpp
index b52307c..f861815 100644
--- a/src/SFML/Window/FreeBSD/JoystickImpl.hpp
+++ b/src/SFML/Window/FreeBSD/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp
index 1a66774..b74725e 100644
--- a/src/SFML/Window/GlContext.cpp
+++ b/src/SFML/Window/GlContext.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -100,6 +100,10 @@
#define GL_CONTEXT_FLAGS 0x821E
#endif
+#if !defined(GL_FRAMEBUFFER_SRGB)
+ #define GL_FRAMEBUFFER_SRGB 0x8DB9
+#endif
+
#if !defined(GL_CONTEXT_FLAG_DEBUG_BIT)
#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
#endif
@@ -131,8 +135,8 @@ namespace
ContextType* sharedContext = NULL;
// Internal contexts
- sf::ThreadLocalPtr<sf::priv::GlContext> internalContext(NULL);
- std::set<sf::priv::GlContext*> internalContexts;
+ sf::ThreadLocalPtr<sf::Context> internalContext(NULL);
+ std::set<sf::Context*> internalContexts;
sf::Mutex internalContextsMutex;
// Check if the internal context of the current thread is valid
@@ -148,11 +152,11 @@ namespace
}
// Retrieve the internal context for the current thread
- sf::priv::GlContext* getInternalContext()
+ sf::Context* getInternalContext()
{
if (!hasInternalContext())
{
- internalContext = sf::priv::GlContext::create();
+ internalContext = new sf::Context;
sf::Lock lock(internalContextsMutex);
internalContexts.insert(internalContext);
}
@@ -171,9 +175,12 @@ void GlContext::globalInit()
{
Lock lock(mutex);
+ if (sharedContext)
+ return;
+
// Create the shared context
sharedContext = new ContextType(NULL);
- sharedContext->initialize();
+ sharedContext->initialize(ContextSettings());
// This call makes sure that:
// - the shared context is inactive (it must never be)
@@ -187,13 +194,16 @@ void GlContext::globalCleanup()
{
Lock lock(mutex);
+ if (!sharedContext)
+ return;
+
// Destroy the shared context
delete sharedContext;
sharedContext = NULL;
// Destroy the internal contexts
Lock internalContextsLock(internalContextsMutex);
- for (std::set<GlContext*>::iterator it = internalContexts.begin(); it != internalContexts.end(); ++it)
+ for (std::set<Context*>::iterator it = internalContexts.begin(); it != internalContexts.end(); ++it)
delete *it;
internalContexts.clear();
}
@@ -215,7 +225,7 @@ GlContext* GlContext::create()
// Create the context
GlContext* context = new ContextType(sharedContext);
- context->initialize();
+ context->initialize(ContextSettings());
return context;
}
@@ -231,7 +241,7 @@ GlContext* GlContext::create(const ContextSettings& settings, const WindowImpl*
// Create the context
GlContext* context = new ContextType(sharedContext, settings, owner, bitsPerPixel);
- context->initialize();
+ context->initialize(settings);
context->checkSettings(settings);
return context;
@@ -248,7 +258,7 @@ GlContext* GlContext::create(const ContextSettings& settings, unsigned int width
// Create the context
GlContext* context = new ContextType(sharedContext, settings, width, height);
- context->initialize();
+ context->initialize(settings);
context->checkSettings(settings);
return context;
@@ -340,7 +350,7 @@ GlContext::GlContext()
////////////////////////////////////////////////////////////
-int GlContext::evaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing, bool accelerated)
+int GlContext::evaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing, bool accelerated, bool sRgb)
{
int colorDiff = static_cast<int>(bitsPerPixel) - colorBits;
int depthDiff = static_cast<int>(settings.depthBits) - depthBits;
@@ -356,6 +366,10 @@ int GlContext::evaluateFormat(unsigned int bitsPerPixel, const ContextSettings&
// Aggregate the scores
int score = std::abs(colorDiff) + std::abs(depthDiff) + std::abs(stencilDiff) + std::abs(antialiasingDiff);
+ // If the user wants an sRGB capable format, try really hard to get one
+ if (settings.sRgbCapable && !sRgb)
+ score += 10000000;
+
// Make sure we prefer hardware acceleration over features
if (!accelerated)
score += 100000000;
@@ -365,7 +379,7 @@ int GlContext::evaluateFormat(unsigned int bitsPerPixel, const ContextSettings&
////////////////////////////////////////////////////////////
-void GlContext::initialize()
+void GlContext::initialize(const ContextSettings& requestedSettings)
{
// Activate the context
setActive(true);
@@ -462,9 +476,32 @@ void GlContext::initialize()
}
}
- // Enable antialiasing if needed
- if (m_settings.antialiasingLevel > 0)
+ // Enable anti-aliasing if requested by the user and supported
+ if ((requestedSettings.antialiasingLevel > 0) && (m_settings.antialiasingLevel > 0))
+ {
glEnable(GL_MULTISAMPLE);
+ }
+ else
+ {
+ m_settings.antialiasingLevel = 0;
+ }
+
+ // Enable sRGB if requested by the user and supported
+ if (requestedSettings.sRgbCapable && m_settings.sRgbCapable)
+ {
+ glEnable(GL_FRAMEBUFFER_SRGB);
+
+ // Check to see if the enable was successful
+ if (glIsEnabled(GL_FRAMEBUFFER_SRGB) == GL_FALSE)
+ {
+ err() << "Warning: Failed to enable GL_FRAMEBUFFER_SRGB" << std::endl;
+ m_settings.sRgbCapable = false;
+ }
+ }
+ else
+ {
+ m_settings.sRgbCapable = false;
+ }
}
@@ -490,10 +527,11 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
int requestedVersion = requestedSettings.majorVersion * 10 + requestedSettings.minorVersion;
if ((m_settings.attributeFlags != requestedSettings.attributeFlags) ||
- (version < requestedVersion) ||
+ (version < requestedVersion) ||
(m_settings.stencilBits < requestedSettings.stencilBits) ||
(m_settings.antialiasingLevel < requestedSettings.antialiasingLevel) ||
- (m_settings.depthBits < requestedSettings.depthBits))
+ (m_settings.depthBits < requestedSettings.depthBits) ||
+ (!m_settings.sRgbCapable && requestedSettings.sRgbCapable))
{
err() << "Warning: The created OpenGL context does not fully meet the settings that were requested" << std::endl;
err() << "Requested: version = " << requestedSettings.majorVersion << "." << requestedSettings.minorVersion
@@ -503,6 +541,7 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
<< std::boolalpha
<< " ; core = " << ((requestedSettings.attributeFlags & ContextSettings::Core) != 0)
<< " ; debug = " << ((requestedSettings.attributeFlags & ContextSettings::Debug) != 0)
+ << " ; sRGB = " << requestedSettings.sRgbCapable
<< std::noboolalpha << std::endl;
err() << "Created: version = " << m_settings.majorVersion << "." << m_settings.minorVersion
<< " ; depth bits = " << m_settings.depthBits
@@ -511,6 +550,7 @@ void GlContext::checkSettings(const ContextSettings& requestedSettings)
<< std::boolalpha
<< " ; core = " << ((m_settings.attributeFlags & ContextSettings::Core) != 0)
<< " ; debug = " << ((m_settings.attributeFlags & ContextSettings::Debug) != 0)
+ << " ; sRGB = " << m_settings.sRgbCapable
<< std::noboolalpha << std::endl;
}
}
diff --git a/src/SFML/Window/GlContext.hpp b/src/SFML/Window/GlContext.hpp
index f9225cd..8c4ce01 100644
--- a/src/SFML/Window/GlContext.hpp
+++ b/src/SFML/Window/GlContext.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -217,11 +217,12 @@ protected:
/// \param stencilBits Stencil bits of the configuration to evaluate
/// \param antialiasing Antialiasing level of the configuration to evaluate
/// \param accelerated Whether the pixel format is hardware accelerated
+ /// \param sRgb Whether the pixel format is sRGB capable
///
/// \return Score of the configuration
///
////////////////////////////////////////////////////////////
- static int evaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing, bool accelerated);
+ static int evaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing, bool accelerated, bool sRgb);
////////////////////////////////////////////////////////////
// Member data
@@ -232,9 +233,10 @@ private:
////////////////////////////////////////////////////////////
/// \brief Perform various initializations after the context construction
+ /// \param requestedSettings Requested settings during context creation
///
////////////////////////////////////////////////////////////
- void initialize();
+ void initialize(const ContextSettings& requestedSettings);
////////////////////////////////////////////////////////////
/// \brief Check whether the context is compatible with the requested settings
diff --git a/src/SFML/Window/GlResource.cpp b/src/SFML/Window/GlResource.cpp
index 921874d..dfcbe7a 100644
--- a/src/SFML/Window/GlResource.cpp
+++ b/src/SFML/Window/GlResource.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/InputImpl.hpp b/src/SFML/Window/InputImpl.hpp
index df52a78..a0244e2 100644
--- a/src/SFML/Window/InputImpl.hpp
+++ b/src/SFML/Window/InputImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp
index 11cf289..c713696 100644
--- a/src/SFML/Window/Joystick.cpp
+++ b/src/SFML/Window/Joystick.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/JoystickImpl.hpp b/src/SFML/Window/JoystickImpl.hpp
index 6648b59..e7b6724 100644
--- a/src/SFML/Window/JoystickImpl.hpp
+++ b/src/SFML/Window/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/JoystickManager.cpp b/src/SFML/Window/JoystickManager.cpp
index 99c100d..9038afa 100644
--- a/src/SFML/Window/JoystickManager.cpp
+++ b/src/SFML/Window/JoystickManager.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/JoystickManager.hpp b/src/SFML/Window/JoystickManager.hpp
index 229160b..7f7a22a 100644
--- a/src/SFML/Window/JoystickManager.hpp
+++ b/src/SFML/Window/JoystickManager.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Keyboard.cpp b/src/SFML/Window/Keyboard.cpp
index 6076122..b9ad152 100644
--- a/src/SFML/Window/Keyboard.cpp
+++ b/src/SFML/Window/Keyboard.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Mouse.cpp b/src/SFML/Window/Mouse.cpp
index 0f966bc..6b43c9f 100644
--- a/src/SFML/Window/Mouse.cpp
+++ b/src/SFML/Window/Mouse.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/OSX/AutoreleasePoolWrapper.h b/src/SFML/Window/OSX/AutoreleasePoolWrapper.h
index 6921533..75c414f 100644
--- a/src/SFML/Window/OSX/AutoreleasePoolWrapper.h
+++ b/src/SFML/Window/OSX/AutoreleasePoolWrapper.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -24,26 +24,14 @@
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
-/// \brief Ensure at least one autorelease pool is available on this thread
-///
-/// Increment a retain count for *this* thread.
+/// \brief Ensure one autorelease pool is available on this thread
///
////////////////////////////////////////////////////////////
-void retainPool(void);
+void ensureThreadHasPool(void);
-////////////////////////////////////////////////////////////
-/// \brief Drain the pool
-///
-/// The pool retain count should be absolutely positive before calling this function on this thread.
-///
-////////////////////////////////////////////////////////////
-void drainCurrentPool(void);
////////////////////////////////////////////////////////////
-/// \brief Release the pool.
-///
-/// Decrease the retain count for *this* thread.
+/// \brief Drain the thread's pool but keep it alive
///
////////////////////////////////////////////////////////////
-void releasePool(void);
-
+void drainThreadPool(void);
diff --git a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm
index 2afd8ab..f0ae7b4 100644
--- a/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm
+++ b/src/SFML/Window/OSX/AutoreleasePoolWrapper.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -26,11 +26,8 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
-#include <SFML/System/Err.hpp>
-#include <SFML/System/NonCopyable.hpp>
-#include <SFML/System/ThreadLocalPtr.hpp>
-
#include <cassert>
+#include <pthread.h>
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
#import <Foundation/Foundation.h>
@@ -41,165 +38,68 @@
/// pool and making other pools invalid which can lead to a crash on 10.5 and an
/// annoying message on 10.6 (*** attempt to pop an unknown autorelease pool).
///
-/// Because NSAutoreleasePool cannot be retain we have to do it ourself.
-/// We use an sf::ThreadLocalPtr to have one PoolWrapper in each thread.
-///
-/// SPECIAL CONSIDERATION:
-/// ======================
-/// This implies that if retainPool is called X times in a thread Y then
-/// releasePool must be called X times too in the same thread Y.
-///
////////////////////////////////////////////////////////////
-namespace sf
-{
-namespace priv
-{
-////////////////////////////////////////////////////////////
-/// \brief C++ Wrapper of Obj-C Autorelease Pool
-///
-////////////////////////////////////////////////////////////
-class PoolWrapper : NonCopyable
-{
-public:
-
- ////////////////////////////////////////////////////////////
- /// \brief Default constructor
- ///
- ////////////////////////////////////////////////////////////
- PoolWrapper();
-
- ////////////////////////////////////////////////////////////
- /// \brief Default destructor
- ///
- /// Make sure the pool is drained (if appropriate)
- ///
- ////////////////////////////////////////////////////////////
- ~PoolWrapper();
-
- ////////////////////////////////////////////////////////////
- /// \brief Increment retain count and allocate memory if needed
- ///
- ////////////////////////////////////////////////////////////
- void retain();
-
- ////////////////////////////////////////////////////////////
- /// \brief Decrement retain count and releasing memory if needed
- ///
- /// \return true if the pool wrapper can be released
- ///
- ////////////////////////////////////////////////////////////
- bool release();
-
- ////////////////////////////////////////////////////////////
- /// \brief Drain the pool
- ///
- ////////////////////////////////////////////////////////////
- void drain();
-
-private:
-
- ////////////////////////////////////////////////////////////
- // Member data
- ////////////////////////////////////////////////////////////
- int m_count; ///< How many times was the pool retained?
- NSAutoreleasePool* m_pool; ///< Our dedicated pool
-};
-
-
-////////////////////////////////////////////////////////////
-PoolWrapper::PoolWrapper() :
-m_count(0),
-m_pool(nil)
-{
- /* Nothing else */
-}
-
////////////////////////////////////////////////////////////
-PoolWrapper::~PoolWrapper()
-{
- // Make sure everything is drained
- m_count = 0;
- drain();
-}
-
-
+// Private data
////////////////////////////////////////////////////////////
-void PoolWrapper::retain()
-{
- // Increase counter
- ++m_count;
-
- // Allocate pool if required
- if (m_pool == nil)
- m_pool = [[NSAutoreleasePool alloc] init];
-}
+static pthread_key_t poolKey;
+static pthread_once_t initOnceToken = PTHREAD_ONCE_INIT;
////////////////////////////////////////////////////////////
-bool PoolWrapper::release()
-{
- // Decrease counter
- --m_count;
-
- return m_count == 0;
-}
-
-void PoolWrapper::drain()
+/// \brief (local function) Drain one more time the pool
+/// but this time don't create a new one.
+///
+////////////////////////////////////////////////////////////
+static void destroyPool(void* data)
{
- [m_pool drain];
- m_pool = nil;
-
- if (m_count != 0)
- m_pool = [[NSAutoreleasePool alloc] init];
+ NSAutoreleasePool* pool = (NSAutoreleasePool*)data;
+ [pool drain];
}
-} // namespace priv
-
-} // namespace sf
-
////////////////////////////////////////////////////////////
-// Private data
+/// \brief (local function) Init the pthread key for the pool
+///
////////////////////////////////////////////////////////////
-namespace
+static void createPoolKey(void)
{
- // This per-thread variable holds the current autorelease pool for each thread
- sf::ThreadLocalPtr<sf::priv::PoolWrapper> localPool;
+ pthread_key_create(&poolKey, destroyPool);
}
////////////////////////////////////////////////////////////
-void retainPool(void)
+/// \brief (local function) Store a new pool for this thread
+///
+////////////////////////////////////////////////////////////
+static void createNewPool(void)
{
- // First, Check that we have a valid PoolWrapper object in our local pool.
- if (localPool == NULL)
- localPool = new sf::priv::PoolWrapper();
-
- // Then retains!
- localPool->retain();
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ pthread_setspecific(poolKey, pool);
}
////////////////////////////////////////////////////////////
-void drainCurrentPool(void)
+void ensureThreadHasPool(void)
{
- assert(localPool != NULL);
- localPool->drain();
+ pthread_once(&initOnceToken, createPoolKey);
+ if (pthread_getspecific(poolKey) == NULL)
+ {
+ createNewPool();
+ }
}
////////////////////////////////////////////////////////////
-void releasePool(void)
+void drainThreadPool(void)
{
- assert(localPool != NULL);
+ void* data = pthread_getspecific(poolKey);
+ assert(data != NULL);
- // If we're done with the pool, let's release the memory
- if (localPool->release())
- {
- delete localPool;
- localPool = NULL;
- }
+ // Drain the pool but keep it alive by creating a new one
+ destroyPool(data);
+ createNewPool();
}
diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp
index 01c5ccd..19e2568 100644
--- a/src/SFML/Window/OSX/HIDInputManager.hpp
+++ b/src/SFML/Window/OSX/HIDInputManager.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/HIDInputManager.mm b/src/SFML/Window/OSX/HIDInputManager.mm
index 37ef79e..c53bd53 100644
--- a/src/SFML/Window/OSX/HIDInputManager.mm
+++ b/src/SFML/Window/OSX/HIDInputManager.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -763,7 +763,7 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode)
case 0x2c: return sf::Keyboard::Slash;
case 0x2a: return sf::Keyboard::BackSlash;
-#warning sf::Keyboard::Tilde might be in conflict with some other key.
+ // sf::Keyboard::Tilde might be in conflict with some other key.
// 0x0a is for "Non-US Backslash" according to HID Calibrator,
// a sample provided by Apple.
case 0x0a: return sf::Keyboard::Tilde;
@@ -855,7 +855,7 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode)
case NSPauseFunctionKey: return sf::Keyboard::Pause;
-#warning keycode 0x1b is not bound to any key.
+ // keycode 0x1b is not bound to any key.
// This key is ' on CH-FR, ) on FR and - on US layouts.
// An unknown key.
diff --git a/src/SFML/Window/OSX/HIDJoystickManager.cpp b/src/SFML/Window/OSX/HIDJoystickManager.cpp
index 1724fe6..20b1e37 100644
--- a/src/SFML/Window/OSX/HIDJoystickManager.cpp
+++ b/src/SFML/Window/OSX/HIDJoystickManager.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -133,7 +133,7 @@ void HIDJoystickManager::update()
////////////////////////////////////////////////////////////
void HIDJoystickManager::pluggedIn(void* context, IOReturn, void*, IOHIDDeviceRef)
{
- HIDJoystickManager* manager = (HIDJoystickManager*)context;
+ HIDJoystickManager* manager = static_cast<HIDJoystickManager*>(context);
manager->m_joystickCount++;
}
@@ -141,7 +141,7 @@ void HIDJoystickManager::pluggedIn(void* context, IOReturn, void*, IOHIDDeviceRe
////////////////////////////////////////////////////////////
void HIDJoystickManager::pluggedOut(void* context, IOReturn, void*, IOHIDDeviceRef)
{
- HIDJoystickManager* manager = (HIDJoystickManager*)context;
+ HIDJoystickManager* manager = static_cast<HIDJoystickManager*>(context);
manager->m_joystickCount--;
}
diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp
index a128df5..614e58b 100644
--- a/src/SFML/Window/OSX/HIDJoystickManager.hpp
+++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/InputImpl.hpp b/src/SFML/Window/OSX/InputImpl.hpp
index ef897b1..2263551 100644
--- a/src/SFML/Window/OSX/InputImpl.hpp
+++ b/src/SFML/Window/OSX/InputImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/InputImpl.mm b/src/SFML/Window/OSX/InputImpl.mm
index f0e8ee4..0bdade5 100644
--- a/src/SFML/Window/OSX/InputImpl.mm
+++ b/src/SFML/Window/OSX/InputImpl.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -185,7 +185,7 @@ void InputImpl::setMousePosition(const Vector2i& position)
CGEventRef event = CGEventCreateMouseEvent(NULL,
kCGEventMouseMoved,
pos,
- /*we don't care about this: */0);
+ /* we don't care about this: */ kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
// This is a workaround to deprecated CGSetLocalEventsSuppressionInterval.
diff --git a/src/SFML/Window/OSX/JoystickImpl.cpp b/src/SFML/Window/OSX/JoystickImpl.cpp
index 09d7614..19acb86 100644
--- a/src/SFML/Window/OSX/JoystickImpl.cpp
+++ b/src/SFML/Window/OSX/JoystickImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/JoystickImpl.hpp b/src/SFML/Window/OSX/JoystickImpl.hpp
index 5b08ba6..a71b82d 100644
--- a/src/SFML/Window/OSX/JoystickImpl.hpp
+++ b/src/SFML/Window/OSX/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/NSImage+raw.h b/src/SFML/Window/OSX/NSImage+raw.h
new file mode 100644
index 0000000..745f49c
--- /dev/null
+++ b/src/SFML/Window/OSX/NSImage+raw.h
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Config.hpp>
+
+#import <AppKit/AppKit.h>
+
+////////////////////////////////////////////////////////////
+/// Extends NSImage with a convenience method to load images
+/// from raw data.
+///
+////////////////////////////////////////////////////////////
+
+@interface NSImage (raw)
+
+////////////////////////////////////////////////////////////
+/// \brief Load an image from raw RGBA pixels
+///
+/// \param pixels array of 4 * `size` bytes representing the image
+/// \param size size of the image
+///
+/// \return an instance of NSImage that needs to be released by the caller
+///
+////////////////////////////////////////////////////////////
++(NSImage*)imageWithRawData:(const sf::Uint8*)pixels andSize:(NSSize)size;
+
+@end
diff --git a/src/SFML/Window/OSX/NSImage+raw.mm b/src/SFML/Window/OSX/NSImage+raw.mm
new file mode 100644
index 0000000..571a286
--- /dev/null
+++ b/src/SFML/Window/OSX/NSImage+raw.mm
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#import <SFML/Window/OSX/NSImage+raw.h>
+
+@implementation NSImage (raw)
+
++(NSImage*)imageWithRawData:(const sf::Uint8*)pixels andSize:(NSSize)size
+{
+ // Create an empty image representation.
+ NSBitmapImageRep* bitmap =
+ [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:0 // if 0: only allocate memory
+ pixelsWide:size.width
+ pixelsHigh:size.height
+ bitsPerSample:8 // The number of bits used to specify
+ // one pixel in a single component of the data.
+ samplesPerPixel:4 // 3 if no alpha, 4 with it
+ hasAlpha:YES
+ isPlanar:NO // I don't know what it is but it works
+ colorSpaceName:NSCalibratedRGBColorSpace
+ bytesPerRow:0 // 0 == determine automatically
+ bitsPerPixel:0]; // 0 == determine automatically
+
+ // Load data pixels.
+ for (unsigned int y = 0; y < size.height; ++y)
+ {
+ for (unsigned int x = 0; x < size.width; ++x, pixels += 4)
+ {
+ NSUInteger pixel[4] = { pixels[0], pixels[1], pixels[2], pixels[3] };
+ [bitmap setPixel:pixel atX:x y:y];
+ }
+ }
+
+ // Create an image from the representation.
+ NSImage* image = [[NSImage alloc] initWithSize:size];
+ [image addRepresentation:bitmap];
+
+ [bitmap release];
+
+ return image;
+}
+
+@end
diff --git a/src/SFML/Window/OSX/SFApplication.h b/src/SFML/Window/OSX/SFApplication.h
index b388d80..454bf8c 100644
--- a/src/SFML/Window/OSX/SFApplication.h
+++ b/src/SFML/Window/OSX/SFApplication.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFApplication.m b/src/SFML/Window/OSX/SFApplication.m
index 6ba1f90..934e89f 100644
--- a/src/SFML/Window/OSX/SFApplication.m
+++ b/src/SFML/Window/OSX/SFApplication.m
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.h b/src/SFML/Window/OSX/SFApplicationDelegate.h
index 4a99550..53033c9 100644
--- a/src/SFML/Window/OSX/SFApplicationDelegate.h
+++ b/src/SFML/Window/OSX/SFApplicationDelegate.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFApplicationDelegate.m b/src/SFML/Window/OSX/SFApplicationDelegate.m
index c15037c..9566c46 100644
--- a/src/SFML/Window/OSX/SFApplicationDelegate.m
+++ b/src/SFML/Window/OSX/SFApplicationDelegate.m
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFContext.hpp b/src/SFML/Window/OSX/SFContext.hpp
index 761c12e..3e2a979 100644
--- a/src/SFML/Window/OSX/SFContext.hpp
+++ b/src/SFML/Window/OSX/SFContext.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm
index 810bcb4..0970007 100644
--- a/src/SFML/Window/OSX/SFContext.mm
+++ b/src/SFML/Window/OSX/SFContext.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -46,7 +46,7 @@ m_view(0),
m_window(0)
{
// Ask for a pool.
- retainPool();
+ ensureThreadHasPool();
// Create the context
createContext(shared,
@@ -62,7 +62,7 @@ m_view(0),
m_window(0)
{
// Ask for a pool.
- retainPool();
+ ensureThreadHasPool();
// Create the context.
createContext(shared, bitsPerPixel, settings);
@@ -83,7 +83,7 @@ m_window(0)
WindowImplCocoa::setUpProcess();
// Ask for a pool.
- retainPool();
+ ensureThreadHasPool();
// Create the context.
createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
@@ -108,8 +108,6 @@ SFContext::~SFContext()
[m_view release]; // Might be nil but we don't care.
[m_window release]; // Idem.
-
- releasePool();
}
@@ -244,6 +242,9 @@ void SFContext::createContext(SFContext* shared,
attrs.push_back((NSOpenGLPixelFormatAttribute)0); // end of array
+ // All OS X pixel formats are sRGB capable
+ m_settings.sRgbCapable = true;
+
// Create the pixel format.
NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attrs[0]];
diff --git a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.h b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.h
index 60bdb3f..39b18ec 100644
--- a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.h
+++ b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
index 89c23b5..08594da 100644
--- a/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
+++ b/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm b/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm
new file mode 100644
index 0000000..4fbef01
--- /dev/null
+++ b/src/SFML/Window/OSX/SFOpenGLView+keyboard.mm
@@ -0,0 +1,220 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Window/OSX/WindowImplCocoa.hpp>
+#include <SFML/Window/OSX/HIDInputManager.hpp> // For localizedKeys and nonLocalizedKeys
+
+#import <SFML/Window/OSX/SFKeyboardModifiersHelper.h>
+#import <SFML/Window/OSX/SFOpenGLView.h>
+#import <SFML/Window/OSX/SFOpenGLView+keyboard_priv.h>
+
+////////////////////////////////////////////////////////////
+/// In this file, we implement keyboard handling for SFOpenGLView
+///
+////////////////////////////////////////////////////////////
+
+
+@implementation SFOpenGLView (keyboard)
+
+
+////////////////////////////////////////////////////////
+-(BOOL)acceptsFirstResponder
+{
+ // Accepts key event.
+ return YES;
+}
+
+
+////////////////////////////////////////////////////////
+-(BOOL)canBecomeKeyView
+{
+ // Accepts key event.
+ return YES;
+}
+
+
+////////////////////////////////////////////////////////
+-(void)enableKeyRepeat
+{
+ m_useKeyRepeat = YES;
+}
+
+
+////////////////////////////////////////////////////////
+-(void)disableKeyRepeat
+{
+ m_useKeyRepeat = NO;
+}
+
+
+////////////////////////////////////////////////////////
+-(void)keyDown:(NSEvent*)theEvent
+{
+ // Transmit to non-SFML responder
+ [[self nextResponder] keyDown:theEvent];
+
+ if (m_requester == 0)
+ return;
+
+ // Handle key down event
+ if (m_useKeyRepeat || ![theEvent isARepeat])
+ {
+ sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
+
+ if (key.code != sf::Keyboard::Unknown) // The key is recognized.
+ m_requester->keyDown(key);
+ }
+
+
+ // Handle text entered event:
+ // Ignore event if we don't want repeated keystrokes
+ if (m_useKeyRepeat || ![theEvent isARepeat])
+ {
+ // Ignore escape key and other non text keycode (See NSEvent.h)
+ // because they produce a sound alert.
+ if ([SFOpenGLView isValidTextUnicode:theEvent])
+ {
+ // Send the event to the hidden text view for processing
+ [m_hiddenTextView interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+ }
+
+ // Carefully handle backspace and delete..
+ // Note: the event is intentionally sent to the hidden view
+ // even if we do something more specific below. This way
+ // key combination are correctly interpreted.
+
+ unsigned short keycode = [theEvent keyCode];
+
+ // Backspace
+ if (keycode == 0x33)
+ {
+ // Send the correct Unicode value (i.e. 8) instead of 127 (which is 'delete')
+ m_requester->textEntered(8);
+ }
+
+ // Delete
+ else if ((keycode == 0x75) || (keycode == NSDeleteFunctionKey))
+ {
+ // Instead of the value 63272 we send 127.
+ m_requester->textEntered(127);
+ }
+
+ // Otherwise, let's see what our hidden field has computed
+ else
+ {
+ NSString* string = [m_hiddenTextView string];
+
+ // Send each character to SFML event requester
+ for (NSUInteger index = 0; index < [string length]; ++index)
+ m_requester->textEntered([string characterAtIndex:index]);
+
+ // Empty our hidden cache
+ [m_hiddenTextView setString:@""];
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////
+-(void)sfKeyUp:(NSEvent*)theEvent
+{
+ // For some mystic reasons, key released events don't work the same way
+ // as key pressed events... We somewhat hijack the event chain of response
+ // in -[SFApplication sendEvent:] and resume this chain with the next
+ // responder.
+ // This is workaround to make sure key released events are fired in
+ // fullscreen window too.
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] keyUp:theEvent];
+
+ if (m_requester == 0)
+ return;
+
+ sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
+
+ if (key.code != sf::Keyboard::Unknown) // The key is recognized.
+ m_requester->keyUp(key);
+}
+
+
+////////////////////////////////////////////////////////
+-(void)flagsChanged:(NSEvent*)theEvent
+{
+ // Transmit to non-SFML responder
+ [[self nextResponder] flagsChanged:theEvent];
+
+ if (m_requester == 0)
+ return;
+
+ NSUInteger modifiers = [theEvent modifierFlags];
+ handleModifiersChanged(modifiers, *m_requester);
+}
+
+
+////////////////////////////////////////////////////////
++(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event
+{
+ // Key code
+ sf::Keyboard::Key key = sf::Keyboard::Unknown;
+
+ // First we look if the key down is from a list of characters
+ // that depend on keyboard localization.
+ NSString* string = [event charactersIgnoringModifiers];
+ if ([string length] > 0)
+ key = sf::priv::HIDInputManager::localizedKeys([string characterAtIndex:0]);
+
+ // If the key is not a localized one, we try to find a corresponding code
+ // through virtual key code.
+ if (key == sf::Keyboard::Unknown)
+ key = sf::priv::HIDInputManager::nonLocalizedKeys([event keyCode]);
+
+ return keyEventWithModifiers([event modifierFlags], key);
+}
+
+
+////////////////////////////////////////////////////////
++(BOOL)isValidTextUnicode:(NSEvent*)event
+{
+ if ([event keyCode] == 0x35) // Escape
+ {
+ return false;
+ }
+ else if ([[event characters] length] > 0)
+ {
+ unichar code = [[event characters] characterAtIndex:0];
+ return ((code < 0xF700) || (code > 0xF8FF));
+ }
+ else
+ {
+ return true;
+ }
+}
+
+@end
+
diff --git a/src/SFML/Window/OSX/SFOpenGLView+keyboard_priv.h b/src/SFML/Window/OSX/SFOpenGLView+keyboard_priv.h
new file mode 100644
index 0000000..c3710f5
--- /dev/null
+++ b/src/SFML/Window/OSX/SFOpenGLView+keyboard_priv.h
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Window/Mouse.hpp>
+
+#import <AppKit/AppKit.h>
+
+
+////////////////////////////////////////////////////////////
+/// Here are defined a few private messages for keyboard
+/// handling in SFOpenGLView.
+///
+////////////////////////////////////////////////////////////
+
+
+@interface SFOpenGLView (keyboard_priv)
+
+////////////////////////////////////////////////////////////
+/// \brief Convert a key down/up NSEvent into an SFML key event
+///
+/// The conversion is based on localizedKeys and nonLocalizedKeys functions.
+///
+/// \param event a key event
+///
+/// \return sf::Keyboard::Unknown as Code if the key is unknown
+///
+////////////////////////////////////////////////////////////
++(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event;
+
+////////////////////////////////////////////////////////////
+/// \brief Check if the event represent some Unicode text
+///
+/// The event is assumed to be a key down event.
+/// False is returned if the event is either escape or a non text Unicode.
+///
+/// \param event a key down event
+///
+/// \return true if event represents a Unicode character, false otherwise
+///
+////////////////////////////////////////////////////////////
++(BOOL)isValidTextUnicode:(NSEvent*)event;
+
+@end
diff --git a/src/SFML/Window/OSX/SFOpenGLView+mouse.mm b/src/SFML/Window/OSX/SFOpenGLView+mouse.mm
new file mode 100644
index 0000000..6349081
--- /dev/null
+++ b/src/SFML/Window/OSX/SFOpenGLView+mouse.mm
@@ -0,0 +1,402 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Window/OSX/WindowImplCocoa.hpp>
+#include <cmath>
+
+#import <SFML/Window/OSX/SFOpenGLView.h>
+#import <SFML/Window/OSX/SFOpenGLView+mouse_priv.h>
+
+
+////////////////////////////////////////////////////////////
+/// In this file, we implement mouse handling for SFOpenGLView
+///
+////////////////////////////////////////////////////////////
+
+@implementation SFOpenGLView (mouse)
+
+////////////////////////////////////////////////////////
+-(BOOL)isMouseInside
+{
+ NSPoint relativeToWindow = [[self window] mouseLocationOutsideOfEventStream];
+ NSPoint relativeToView = [self convertPoint:relativeToWindow fromView:nil];
+
+ return NSPointInRect(relativeToView, [self bounds]);
+}
+
+
+////////////////////////////////////////////////////////
+-(void)updateMouseState
+{
+ // Update in/out state
+ BOOL mouseWasIn = m_mouseIsIn;
+ m_mouseIsIn = [self isMouseInside];
+
+ // Send event if needed.
+ if (m_requester != 0)
+ {
+ if (mouseWasIn && !m_mouseIsIn)
+ m_requester->mouseMovedOut();
+ else if (!mouseWasIn && m_mouseIsIn)
+ m_requester->mouseMovedIn();
+ }
+}
+
+
+////////////////////////////////////////////////////////
+-(void)setCursorGrabbed:(BOOL)grabbed
+{
+ m_cursorGrabbed = grabbed;
+
+ [self updateCursorGrabbed];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseDown:(NSEvent*)theEvent
+{
+ [self handleMouseDown:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] mouseDown:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)rightMouseDown:(NSEvent*)theEvent
+{
+ [self handleMouseDown:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] rightMouseDown:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)otherMouseDown:(NSEvent*)theEvent
+{
+ [self handleMouseDown:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] otherMouseDown:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)handleMouseDown:(NSEvent*)theEvent
+{
+ sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
+
+ if (m_requester != 0)
+ {
+ NSPoint loc = [self cursorPositionFromEvent:theEvent];
+
+ if (button != sf::Mouse::ButtonCount)
+ m_requester->mouseDownAt(button, loc.x, loc.y);
+ }
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseUp:(NSEvent*)theEvent
+{
+ [self handleMouseUp:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] mouseUp:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)rightMouseUp:(NSEvent*)theEvent
+{
+ [self handleMouseUp:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] rightMouseUp:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)otherMouseUp:(NSEvent*)theEvent
+{
+ [self handleMouseUp:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] otherMouseUp:theEvent];
+}
+
+
+////////////////////////////////////////////////////////////
+-(void)handleMouseUp:(NSEvent*)theEvent
+{
+ sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
+
+ if (m_requester != 0)
+ {
+ NSPoint loc = [self cursorPositionFromEvent:theEvent];
+
+ if (button != sf::Mouse::ButtonCount)
+ m_requester->mouseUpAt(button, loc.x, loc.y);
+ }
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseMoved:(NSEvent*)theEvent
+{
+ [self handleMouseMove:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] mouseMoved:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)rightMouseDragged:(NSEvent*)theEvent
+{
+ [self handleMouseMove:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] rightMouseDragged:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseDragged:(NSEvent*)theEvent
+{
+ [self handleMouseMove:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] mouseDragged:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)otherMouseDragged:(NSEvent*)theEvent
+{
+ [self handleMouseMove:theEvent];
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] otherMouseUp:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)handleMouseMove:(NSEvent*)theEvent
+{
+ NSPoint loc = [self cursorPositionFromEvent:theEvent];
+
+ // If the cursor is grabbed, cursorPositionFromEvent: will
+ // return its correct position but not move actually it
+ // so we do it now.
+ if ([self isCursorCurrentlyGrabbed])
+ [self moveCursorTo:loc];
+
+ // Make sure the point is inside the view.
+ // (mouseEntered: and mouseExited: are not immediately called
+ // when the mouse is dragged. That would be too easy!)
+ [self updateMouseState];
+ if ((m_requester != 0) && m_mouseIsIn)
+ m_requester->mouseMovedAt(loc.x, loc.y);
+}
+
+
+////////////////////////////////////////////////////////
+-(BOOL)isCursorCurrentlyGrabbed
+{
+ return [[self window] isKeyWindow] && (m_cursorGrabbed || m_fullscreen);
+}
+
+
+////////////////////////////////////////////////////////
+-(void)updateCursorGrabbed
+{
+ // Disable/enable normal movements of the cursor
+ // and project the cursor if needed.
+ if ([self isCursorCurrentlyGrabbed])
+ {
+ CGAssociateMouseAndMouseCursorPosition(NO);
+
+ // Similarly to handleMouseMove: but without event.
+ NSPoint loc = [self cursorPositionFromEvent:nil];
+ [self moveCursorTo:loc];
+ }
+ else
+ {
+ CGAssociateMouseAndMouseCursorPosition(YES);
+ }
+}
+
+
+////////////////////////////////////////////////////////
+-(void)moveCursorTo:(NSPoint)loc
+{
+ // Convert the point from SFML coord system to screen coord system.
+ NSPoint screenLocation = [self computeGlobalPositionOfRelativePoint:loc];
+
+ // This won't produce a move event, which is perfect if the cursor was grabbed
+ // as we move it manually based on delta values of the cursor.
+ CGDisplayMoveCursorToPoint([self displayId], NSPointToCGPoint(screenLocation));
+}
+
+
+////////////////////////////////////////////////////////
+-(CGDirectDisplayID)displayId
+{
+ NSScreen* screen = [[self window] screen];
+ NSNumber* displayId = [[screen deviceDescription] objectForKey:@"NSScreenNumber"];
+ return [displayId intValue];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)scrollWheel:(NSEvent*)theEvent
+{
+ if (m_requester != 0)
+ {
+ NSPoint loc = [self cursorPositionFromEvent:theEvent];
+ m_requester->mouseWheelScrolledAt([theEvent deltaX], [theEvent deltaY], loc.x, loc.y);
+ }
+
+ // Transmit to non-SFML responder
+ [[self nextResponder] scrollWheel:theEvent];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseEntered:(NSEvent*)theEvent
+{
+ (void)theEvent;
+ [self updateMouseState];
+}
+
+
+////////////////////////////////////////////////////////
+-(void)mouseExited:(NSEvent*)theEvent
+{
+ (void)theEvent;
+ [self updateMouseState];
+}
+
+
+////////////////////////////////////////////////////////
+-(NSPoint)cursorPositionFromEvent:(NSEvent*)eventOrNil
+{
+ NSPoint rawPos;
+
+ // If no event given then get current mouse pos.
+ if (eventOrNil == nil)
+ rawPos = [[self window] mouseLocationOutsideOfEventStream];
+ else
+ rawPos = [eventOrNil locationInWindow];
+
+ if ([self isCursorCurrentlyGrabbed])
+ {
+ if (eventOrNil != nil)
+ {
+ // Special case when the mouse is grabbed:
+ // we need to take into account the delta since the cursor
+ // is dissociated from its position.
+
+ // Ignore any non-move related event
+ if (([eventOrNil type] == NSMouseMoved) ||
+ ([eventOrNil type] == NSLeftMouseDragged) ||
+ ([eventOrNil type] == NSRightMouseDragged) ||
+ ([eventOrNil type] == NSOtherMouseDragged))
+ {
+ // Without this factor, the cursor flies around waaay too fast!
+ // But I don't know if it because of retina display or because
+ // some event are sent twice (and that in itself is another mystery).
+ CGFloat factor = 2;
+
+ // Also, this factor is not the same when keeping track of how much
+ // we move the cursor (buffers) when projecting the cursor into the
+ // view when grabbing the cursor for the first time.
+ CGFloat factorBuffer = m_fullscreen ? 1 : 2;
+
+ CGFloat deltaX = [eventOrNil deltaX];
+ CGFloat deltaY = [eventOrNil deltaY];
+
+ // If the buffer for X is empty, move the cursor;
+ // otherwise decrement this buffer a bit.
+ if (m_deltaXBuffer <= 0)
+ rawPos.x += deltaX / factor;
+ else
+ m_deltaXBuffer -= std::abs(deltaX / factorBuffer);
+
+ // Rinse and repeat for Y.
+ if (m_deltaYBuffer <= 0)
+ rawPos.y -= deltaY / factor;
+ else
+ m_deltaYBuffer -= std::abs(deltaY / factorBuffer);
+ }
+ }
+
+ // We also make sure the new point is inside the view
+ NSSize size = [self frame].size;
+ NSPoint origin = [self frame].origin;
+ NSPoint oldPos = rawPos;
+ rawPos.x = std::min(std::max(origin.x, rawPos.x), origin.x + size.width - 1);
+ rawPos.y = std::min(std::max(origin.y + 1, rawPos.y), origin.y + size.height);
+ // Note: the `-1` and `+1` on the two lines above prevent the user to click
+ // on the left or below the window, repectively, and therefore prevent the
+ // application to lose focus by accident. The sign of this offset is determinded
+ // by the direction of the x and y axis.
+
+ // Increase X and Y buffer with the distance of the projection
+ m_deltaXBuffer += std::abs(rawPos.x - oldPos.x);
+ m_deltaYBuffer += std::abs(rawPos.y - oldPos.y);
+ }
+
+ NSPoint loc = [self convertPoint:rawPos fromView:nil];
+
+ // Don't forget to change to SFML coord system.
+ float h = [self frame].size.height;
+ loc.y = h - loc.y;
+
+ return loc;
+}
+
+
+////////////////////////////////////////////////////////
++(sf::Mouse::Button)mouseButtonFromEvent:(NSEvent*)event
+{
+ switch ([event buttonNumber])
+ {
+ case 0: return sf::Mouse::Left;
+ case 1: return sf::Mouse::Right;
+ case 2: return sf::Mouse::Middle;
+ case 3: return sf::Mouse::XButton1;
+ case 4: return sf::Mouse::XButton2;
+ default: return sf::Mouse::ButtonCount; // Never happens! (hopefully)
+ }
+}
+
+
+@end
diff --git a/src/SFML/Window/OSX/SFOpenGLView+mouse_priv.h b/src/SFML/Window/OSX/SFOpenGLView+mouse_priv.h
new file mode 100644
index 0000000..f9b2ab7
--- /dev/null
+++ b/src/SFML/Window/OSX/SFOpenGLView+mouse_priv.h
@@ -0,0 +1,110 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#include <SFML/Window/Mouse.hpp>
+
+#import <AppKit/AppKit.h>
+
+
+////////////////////////////////////////////////////////////
+/// Here are defined a few private messages for mouse
+/// handling in SFOpenGLView.
+///
+////////////////////////////////////////////////////////////
+
+
+@interface SFOpenGLView (mouse_priv)
+
+////////////////////////////////////////////////////////////
+/// \brief Update the mouse state (in or out)
+///
+/// Fire an event if its state has changed.
+///
+////////////////////////////////////////////////////////////
+-(void)updateMouseState;
+
+////////////////////////////////////////////////////////////
+/// \brief handle mouse down event
+///
+////////////////////////////////////////////////////////////
+-(void)handleMouseDown:(NSEvent*)theEvent;
+
+////////////////////////////////////////////////////////////
+/// \brief handle mouse up event
+///
+////////////////////////////////////////////////////////////
+-(void)handleMouseUp:(NSEvent*)theEvent;
+
+////////////////////////////////////////////////////////////
+/// \brief handle mouse move event
+///
+////////////////////////////////////////////////////////////
+-(void)handleMouseMove:(NSEvent*)theEvent;
+
+////////////////////////////////////////////////////////////
+/// \brief Check whether the cursor is grabbed or not
+///
+/// The cursor is grabbed if the window is active (key) and
+/// either it is in fullscreen mode or the user wants to
+/// grab it.
+///
+////////////////////////////////////////////////////////////
+-(BOOL)isCursorCurrentlyGrabbed;
+
+////////////////////////////////////////////////////////////
+/// \brief (Dis)connect the cursor's movements from/to the system
+/// and project the cursor into the view
+///
+////////////////////////////////////////////////////////////
+-(void)updateCursorGrabbed;
+
+////////////////////////////////////////////////////////////
+/// \brief Move the cursor to the given location
+///
+/// \param loc location expressed in SFML coordinate system
+///
+////////////////////////////////////////////////////////////
+-(void)moveCursorTo:(NSPoint)loc;
+
+////////////////////////////////////////////////////////////
+/// \brief Get the display identifier on which the view is
+///
+////////////////////////////////////////////////////////////
+-(CGDirectDisplayID)displayId;
+
+////////////////////////////////////////////////////////////
+/// \brief Convert the NSEvent mouse button type to SFML type
+///
+/// \param event a mouse button event
+///
+/// \return Left, Right, ..., or ButtonCount if the button is unknown
+///
+////////////////////////////////////////////////////////////
++(sf::Mouse::Button)mouseButtonFromEvent:(NSEvent*)event;
+
+@end
diff --git a/src/SFML/Window/OSX/SFOpenGLView.h b/src/SFML/Window/OSX/SFOpenGLView.h
index 6a0d0b0..41d0c76 100644
--- a/src/SFML/Window/OSX/SFOpenGLView.h
+++ b/src/SFML/Window/OSX/SFOpenGLView.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -47,6 +47,24 @@ namespace sf {
/// Modifiers keys (cmd, ctrl, alt, shift) are handled by this class
/// but the actual logic is done in SFKeyboardModifiersHelper.(h|mm).
///
+/// The interface is subdivided into several categories in order
+/// to have multiple implementation files to divide this monolithic
+/// implementation. However, all attributes are defined in the main
+/// interface declaration right below.
+///
+/// Note about deltaXBuffer and deltaYBuffer: when grabbing the cursor
+/// for the first time, either by entering fullscreen or through
+/// setCursorGrabbed:, the cursor might be projected into the view.
+/// Doing this will result in a big delta (relative movement) in the
+/// next move event (cursorPositionFromEvent:), because no move event
+/// is generated, which in turn will give the impression that the user
+/// want to move the cursor by the same distance it was projected. To
+/// prevent the cursor to fly twice the distance we keep track of how
+/// much the cursor was projected in deltaXBuffer and deltaYBuffer. In
+/// cursorPositionFromEvent: we can then reduce/augment those buffers
+/// to determine when a move event should result in an actual move of
+/// the cursor (that was disconnected from the system).
+///
////////////////////////////////////////////////////////////
@interface SFOpenGLView : NSOpenGLView
{
@@ -56,6 +74,9 @@ namespace sf {
NSTrackingArea* m_trackingArea; ///< Mouse tracking area
BOOL m_fullscreen; ///< Indicate whether the window is fullscreen or not
CGFloat m_scaleFactor; ///< Display scale factor (e.g. 1x for classic display, 2x for retina)
+ BOOL m_cursorGrabbed; ///< Is the mouse cursor trapped?
+ CGFloat m_deltaXBuffer; ///< See note about cursor grabbing above
+ CGFloat m_deltaYBuffer; ///< See note about cursor grabbing above
// Hidden text view used to convert key event to actual chars.
// We use a silent responder to prevent sound alerts.
@@ -106,6 +127,18 @@ namespace sf {
-(NSPoint)computeGlobalPositionOfRelativePoint:(NSPoint)point;
////////////////////////////////////////////////////////////
+/// \brief Get the display scale factor
+///
+/// \return e.g. 1.0 for classic display, 2.0 for retina display
+///
+////////////////////////////////////////////////////////////
+-(CGFloat)displayScaleFactor;
+
+@end
+
+@interface SFOpenGLView (keyboard)
+
+////////////////////////////////////////////////////////////
/// \brief Enable key repeat
///
////////////////////////////////////////////////////////////
@@ -117,19 +150,17 @@ namespace sf {
////////////////////////////////////////////////////////////
-(void)disableKeyRepeat;
-////////////////////////////////////////////////////////////
-/// \brief Get the display scale factor
-///
-/// \return e.g. 1.0 for classic display, 2.0 for retina display
-///
-////////////////////////////////////////////////////////////
--(CGFloat)displayScaleFactor;
+@end
+
+@interface SFOpenGLView (mouse)
////////////////////////////////////////////////////////////
/// \brief Compute the position of the cursor
///
/// \param eventOrNil if nil the cursor position is the current one
///
+/// \return the mouse position in SFML coord system
+///
////////////////////////////////////////////////////////////
-(NSPoint)cursorPositionFromEvent:(NSEvent*)eventOrNil;
@@ -141,4 +172,22 @@ namespace sf {
////////////////////////////////////////////////////////////
-(BOOL)isMouseInside;
+////////////////////////////////////////////////////////////
+/// Clips or releases the mouse cursor
+///
+/// Generate a MouseEntered event when it makes sense.
+///
+/// \param grabbed YES to grab, NO to release
+///
+////////////////////////////////////////////////////////////
+-(void)setCursorGrabbed:(BOOL)grabbed;
+
+////////////////////////////////////////////////////////////
+/// Update the cursor position according to the grabbing behaviour
+///
+/// This function has to be called when the window's state change
+///
+////////////////////////////////////////////////////////////
+-(void)updateCursorGrabbed;
+
@end
diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm
index 137b7b0..80cd624 100644
--- a/src/SFML/Window/OSX/SFOpenGLView.mm
+++ b/src/SFML/Window/OSX/SFOpenGLView.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -27,29 +27,14 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
-#include <SFML/Window/OSX/HIDInputManager.hpp> // For localizedKeys and nonLocalizedKeys
#include <SFML/System/Err.hpp>
-#import <SFML/Window/OSX/SFKeyboardModifiersHelper.h>
#import <SFML/Window/OSX/SFOpenGLView.h>
+#import <SFML/Window/OSX/SFOpenGLView+mouse_priv.h>
#import <SFML/Window/OSX/SFSilentResponder.h>
////////////////////////////////////////////////////////////
-/// \brief Check if the event represent some Unicode text
-///
-/// The event is assumed to be a key down event.
-/// False is returned if the event is either escape or a non text Unicode.
-///
-/// \param event a key down event
-///
-/// \return true if event represents a Unicode character, false otherwise
-///
-////////////////////////////////////////////////////////////
-BOOL isValidTextUnicode(NSEvent* event);
-
-
-////////////////////////////////////////////////////////////
/// SFOpenGLView class: Privates Methods Declaration
///
////////////////////////////////////////////////////////////
@@ -68,14 +53,6 @@ BOOL isValidTextUnicode(NSEvent* event);
-(void)viewDidEndLiveResize;
////////////////////////////////////////////////////////////
-/// \brief Update the mouse state (in or out)
-///
-/// Fire an event if its state has changed.
-///
-////////////////////////////////////////////////////////////
--(void)updateMouseState;
-
-////////////////////////////////////////////////////////////
/// \brief Callback for focus event
///
////////////////////////////////////////////////////////////
@@ -99,28 +76,6 @@ BOOL isValidTextUnicode(NSEvent* event);
////////////////////////////////////////////////////////////
-(void)exitFullscreen;
-////////////////////////////////////////////////////////////
-/// \brief Convert the NSEvent mouse button type to SFML type
-///
-/// \param event a mouse button event
-///
-/// \return Left, Right, ..., or ButtonCount if the button is unknown
-///
-////////////////////////////////////////////////////////////
--(sf::Mouse::Button)mouseButtonFromEvent:(NSEvent*)event;
-
-////////////////////////////////////////////////////////////
-/// \brief Convert a key down/up NSEvent into an SFML key event
-///
-/// The conversion is based on localizedKeys and nonLocalizedKeys functions.
-///
-/// \param event a key event
-///
-/// \return sf::Keyboard::Unknown as Code if the key is unknown
-///
-////////////////////////////////////////////////////////////
-+(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event;
-
@end
@implementation SFOpenGLView
@@ -153,6 +108,9 @@ BOOL isValidTextUnicode(NSEvent* event);
m_fullscreen = isFullscreen;
m_scaleFactor = 1.0; // Default value; it will be updated in finishInit
+ m_cursorGrabbed = NO;
+ m_deltaXBuffer = 0;
+ m_deltaYBuffer = 0;
// Create a hidden text view for parsing key down event properly
m_silentResponder = [[SFSilentResponder alloc] init];
@@ -171,6 +129,17 @@ BOOL isValidTextUnicode(NSEvent* event);
////////////////////////////////////////////////////////
+-(void)update
+{
+ // In order to prevent an infinite recursion when the window/view is
+ // resized to zero-height/width, we ignore update event when resizing.
+ if (![self inLiveResize]) {
+ [super update];
+ }
+}
+
+
+////////////////////////////////////////////////////////
-(void)finishInit
{
// Register for window focus events
@@ -197,8 +166,9 @@ BOOL isValidTextUnicode(NSEvent* event);
name:NSWindowDidChangeScreenProfileNotification
object:[self window]];
- // Now that we have a window, set up correctly the scale factor
+ // Now that we have a window, set up correctly the scale factor and cursor grabbing
[self updateScaleFactor];
+ [self updateCursorGrabbed]; // update for fullscreen
}
@@ -241,20 +211,6 @@ BOOL isValidTextUnicode(NSEvent* event);
////////////////////////////////////////////////////////
--(void)enableKeyRepeat
-{
- m_useKeyRepeat = YES;
-}
-
-
-////////////////////////////////////////////////////////
--(void)disableKeyRepeat
-{
- m_useKeyRepeat = NO;
-}
-
-
-////////////////////////////////////////////////////////
-(CGFloat)displayScaleFactor
{
return m_scaleFactor;
@@ -293,6 +249,7 @@ BOOL isValidTextUnicode(NSEvent* event);
// Update mouse internal state.
[self updateMouseState];
+ [self updateCursorGrabbed];
// Update the OGL view to fit the new size.
[self update];
@@ -306,39 +263,13 @@ BOOL isValidTextUnicode(NSEvent* event);
m_requester->windowResized(newSize.width, newSize.height);
}
-
-////////////////////////////////////////////////////////
--(BOOL)isMouseInside
-{
- NSPoint relativeToWindow = [[self window] mouseLocationOutsideOfEventStream];
- NSPoint relativeToView = [self convertPoint:relativeToWindow fromView:nil];
-
- return NSPointInRect(relativeToView, [self bounds]);
-}
-
-
-////////////////////////////////////////////////////////
--(void)updateMouseState
-{
- BOOL mouseWasIn = m_mouseIsIn;
- m_mouseIsIn = [self isMouseInside];
-
- if (m_requester == 0)
- return;
-
- // Send event if needed.
- if (mouseWasIn && !m_mouseIsIn)
- m_requester->mouseMovedOut();
- else if (!mouseWasIn && m_mouseIsIn)
- m_requester->mouseMovedIn();
-}
-
-
////////////////////////////////////////////////////////
-(void)windowDidBecomeKey:(NSNotification*)notification
{
(void)notification;
+ [self updateCursorGrabbed];
+
if (m_requester)
m_requester->windowGainedFocus();
@@ -352,6 +283,8 @@ BOOL isValidTextUnicode(NSEvent* event);
{
(void)notification;
+ [self updateCursorGrabbed];
+
if (m_requester)
m_requester->windowLostFocus();
@@ -415,398 +348,4 @@ BOOL isValidTextUnicode(NSEvent* event);
}
-////////////////////////////////////////////////////////
--(BOOL)acceptsFirstResponder
-{
- // Accepts key event.
- return YES;
-}
-
-
-////////////////////////////////////////////////////////
--(BOOL)canBecomeKeyView
-{
- // Accepts key event.
- return YES;
-}
-
-
-#pragma mark
-#pragma mark Mouse-event methods
-
-
-////////////////////////////////////////////////////////
--(void)mouseDown:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseDown:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] mouseDown:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)mouseUp:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseUp:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] mouseUp:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)mouseMoved:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseDragged:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] mouseMoved:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)scrollWheel:(NSEvent*)theEvent
-{
- if (m_requester != 0)
- {
- NSPoint loc = [self cursorPositionFromEvent:theEvent];
- m_requester->mouseWheelScrolledAt([theEvent deltaX], [theEvent deltaY], loc.x, loc.y);
- }
-
- // Transmit to non-SFML responder
- [[self nextResponder] scrollWheel:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)mouseEntered:(NSEvent*)theEvent
-{
- (void)theEvent;
- [self updateMouseState];
-}
-
-
-////////////////////////////////////////////////////////
--(void)mouseExited:(NSEvent*)theEvent
-{
- (void)theEvent;
- [self updateMouseState];
-}
-
-
-////////////////////////////////////////////////////////
--(void)rightMouseDown:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseDown:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] rightMouseDown:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)rightMouseUp:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseUp:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] rightMouseUp:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)otherMouseDown:(NSEvent*)theEvent
-{
- sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent];
-
- if (m_requester != 0)
- {
- NSPoint loc = [self cursorPositionFromEvent:theEvent];
-
- if (button != sf::Mouse::ButtonCount)
- m_requester->mouseDownAt(button, loc.x, loc.y);
- }
-
- // If the event is not forwarded by mouseDown or rightMouseDown...
- if ((button != sf::Mouse::Left) && (button != sf::Mouse::Right))
- {
- // ... transmit to non-SFML responder
- [[self nextResponder] otherMouseDown:theEvent];
- }
-}
-
-
-////////////////////////////////////////////////////////
--(void)otherMouseUp:(NSEvent*)theEvent
-{
- sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent];
-
- if (m_requester != 0)
- {
- NSPoint loc = [self cursorPositionFromEvent:theEvent];
-
- if (button != sf::Mouse::ButtonCount)
- m_requester->mouseUpAt(button, loc.x, loc.y);
- }
-
- // If the event is not forwarded by mouseUp or rightMouseUp...
- if ((button != sf::Mouse::Left) && (button != sf::Mouse::Right))
- {
- // ... transmit to non-SFML responder
- [[self nextResponder] otherMouseUp:theEvent];
- }
-}
-
-
-////////////////////////////////////////////////////////
--(void)rightMouseDragged:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseDragged:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] rightMouseDragged:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)mouseDragged:(NSEvent*)theEvent
-{
- // Forward to...
- [self otherMouseDragged:theEvent];
-
- // Transmit to non-SFML responder
- [[self nextResponder] mouseDragged:theEvent];
-}
-
-
-////////////////////////////////////////////////////////
--(void)otherMouseDragged:(NSEvent*)theEvent
-{
- if (m_requester != 0)
- {
- NSPoint loc = [self cursorPositionFromEvent:theEvent];
-
- // Make sure the point is inside the view.
- // (mouseEntered: and mouseExited: are not immediately called
- // when the mouse is dragged. That would be too easy!)
- [self updateMouseState];
- if (m_mouseIsIn)
- m_requester->mouseMovedAt(loc.x, loc.y);
- }
-
- // If the event is not forwarded by mouseDragged or rightMouseDragged...
- sf::Mouse::Button button = [self mouseButtonFromEvent:theEvent];
- if ((button != sf::Mouse::Left) && (button != sf::Mouse::Right))
- {
- // ... transmit to non-SFML responder
- [[self nextResponder] otherMouseUp:theEvent];
- }
-}
-
-
-////////////////////////////////////////////////////////
--(NSPoint)cursorPositionFromEvent:(NSEvent*)eventOrNil
-{
- NSPoint loc;
- // If no event given then get current mouse pos.
- if (eventOrNil == nil)
- {
- NSPoint rawPos = [[self window] mouseLocationOutsideOfEventStream];
- loc = [self convertPoint:rawPos fromView:nil];
- }
- else
- {
- loc = [self convertPoint:[eventOrNil locationInWindow] fromView:nil];
- }
-
- // Don't forget to change to SFML coord system.
- float h = [self frame].size.height;
- loc.y = h - loc.y;
-
- return loc;
-}
-
-
-////////////////////////////////////////////////////////
--(sf::Mouse::Button)mouseButtonFromEvent:(NSEvent*)event
-{
- switch ([event buttonNumber])
- {
- case 0: return sf::Mouse::Left;
- case 1: return sf::Mouse::Right;
- case 2: return sf::Mouse::Middle;
- case 3: return sf::Mouse::XButton1;
- case 4: return sf::Mouse::XButton2;
- default: return sf::Mouse::ButtonCount; // Never happens! (hopefully)
- }
-}
-
-
-#pragma mark
-#pragma mark Key-event methods
-
-
-////////////////////////////////////////////////////////
--(void)keyDown:(NSEvent*)theEvent
-{
- // Transmit to non-SFML responder
- [[self nextResponder] keyDown:theEvent];
-
- if (m_requester == 0)
- return;
-
- // Handle key down event
- if (m_useKeyRepeat || ![theEvent isARepeat])
- {
- sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
-
- if (key.code != sf::Keyboard::Unknown) // The key is recognized.
- m_requester->keyDown(key);
- }
-
-
- // Handle text entered event:
- // Ignore event if we don't want repeated keystrokes
- if (m_useKeyRepeat || ![theEvent isARepeat])
- {
- // Ignore escape key and other non text keycode (See NSEvent.h)
- // because they produce a sound alert.
- if (isValidTextUnicode(theEvent))
- {
- // Send the event to the hidden text view for processing
- [m_hiddenTextView interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
- }
-
- // Carefully handle backspace and delete..
- // Note: the event is intentionally sent to the hidden view
- // even if we do something more specific below. This way
- // key combination are correctly interpreted.
-
- unsigned short keycode = [theEvent keyCode];
-
- // Backspace
- if (keycode == 0x33)
- {
- // Send the correct Unicode value (i.e. 8) instead of 127 (which is 'delete')
- m_requester->textEntered(8);
- }
-
- // Delete
- else if ((keycode == 0x75) || (keycode == NSDeleteFunctionKey))
- {
- // Instead of the value 63272 we send 127.
- m_requester->textEntered(127);
- }
-
- // Otherwise, let's see what our hidden field has computed
- else
- {
- NSString* string = [m_hiddenTextView string];
-
- // Send each character to SFML event requester
- for (NSUInteger index = 0; index < [string length]; ++index)
- m_requester->textEntered([string characterAtIndex:index]);
-
- // Empty our hidden cache
- [m_hiddenTextView setString:@""];
- }
- }
-}
-
-
-////////////////////////////////////////////////////////
--(void)sfKeyUp:(NSEvent*)theEvent
-{
- // For some mystic reasons, key released events don't work the same way
- // as key pressed events... We somewhat hijack the event chain of response
- // in -[SFApplication sendEvent:] and resume this chain with the next
- // responder.
- // This is workaround to make sure key released events are fired in
- // fullscreen window too.
-
- // Transmit to non-SFML responder
- [[self nextResponder] keyUp:theEvent];
-
- if (m_requester == 0)
- return;
-
- sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
-
- if (key.code != sf::Keyboard::Unknown) // The key is recognized.
- m_requester->keyUp(key);
-}
-
-
-////////////////////////////////////////////////////////
--(void)flagsChanged:(NSEvent*)theEvent
-{
- // Transmit to non-SFML responder
- [[self nextResponder] flagsChanged:theEvent];
-
- if (m_requester == 0)
- return;
-
- NSUInteger modifiers = [theEvent modifierFlags];
- handleModifiersChanged(modifiers, *m_requester);
-}
-
-
-////////////////////////////////////////////////////////
-+(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event
-{
- // Key code
- sf::Keyboard::Key key = sf::Keyboard::Unknown;
-
- // First we look if the key down is from a list of characters
- // that depend on keyboard localization.
- NSString* string = [event charactersIgnoringModifiers];
- if ([string length] > 0)
- key = sf::priv::HIDInputManager::localizedKeys([string characterAtIndex:0]);
-
- // If the key is not a localized one, we try to find a corresponding code
- // through virtual key code.
- if (key == sf::Keyboard::Unknown)
- key = sf::priv::HIDInputManager::nonLocalizedKeys([event keyCode]);
-
-//#ifdef SFML_DEBUG // Don't bother the final customers with annoying messages.
-// if (key.code == sf::Keyboard::Unknown) { // The key is unknown.
-// sf::err() << "This is an unknown key. Virtual key code is 0x"
-// << std::hex
-// << [event keyCode]
-// << "."
-// << std::endl;
-// }
-//#endif
-
- return keyEventWithModifiers([event modifierFlags], key);
-}
-
@end
-
-
-#pragma mark - C-like functions
-
-BOOL isValidTextUnicode(NSEvent* event)
-{
- if ([event keyCode] == 0x35) // Escape
- {
- return false;
- }
- else if ([[event characters] length] > 0)
- {
- unichar code = [[event characters] characterAtIndex:0];
- return ((code < 0xF700) || (code > 0xF8FF));
- }
- else
- {
- return true;
- }
-}
-
diff --git a/src/SFML/Window/OSX/SFSilentResponder.h b/src/SFML/Window/OSX/SFSilentResponder.h
index 0f00dd3..0a92244 100644
--- a/src/SFML/Window/OSX/SFSilentResponder.h
+++ b/src/SFML/Window/OSX/SFSilentResponder.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFSilentResponder.m b/src/SFML/Window/OSX/SFSilentResponder.m
index f256a2f..e576d77 100644
--- a/src/SFML/Window/OSX/SFSilentResponder.m
+++ b/src/SFML/Window/OSX/SFSilentResponder.m
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFViewController.h b/src/SFML/Window/OSX/SFViewController.h
index b6d0a0a..3907538 100644
--- a/src/SFML/Window/OSX/SFViewController.h
+++ b/src/SFML/Window/OSX/SFViewController.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFViewController.mm b/src/SFML/Window/OSX/SFViewController.mm
index 8e35f79..7d736e3 100644
--- a/src/SFML/Window/OSX/SFViewController.mm
+++ b/src/SFML/Window/OSX/SFViewController.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -121,6 +121,13 @@
}
+////////////////////////////////////////////////////////
+-(void)setCursorGrabbed:(BOOL)grabbed
+{
+ [m_oglView setCursorGrabbed:grabbed];
+}
+
+
////////////////////////////////////////////////////////////
-(NSPoint)position
{
diff --git a/src/SFML/Window/OSX/SFWindow.h b/src/SFML/Window/OSX/SFWindow.h
index 36ebc92..af0e10a 100644
--- a/src/SFML/Window/OSX/SFWindow.h
+++ b/src/SFML/Window/OSX/SFWindow.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFWindow.m b/src/SFML/Window/OSX/SFWindow.m
index 7a4ee75..2e8c14b 100644
--- a/src/SFML/Window/OSX/SFWindow.m
+++ b/src/SFML/Window/OSX/SFWindow.m
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/SFWindowController.h b/src/SFML/Window/OSX/SFWindowController.h
index 4435ad0..331336b 100644
--- a/src/SFML/Window/OSX/SFWindowController.h
+++ b/src/SFML/Window/OSX/SFWindowController.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -49,12 +49,19 @@ namespace sf {
/// Used when SFML handle everything and when a NSWindow* is given
/// as handle to WindowImpl.
///
+/// When grabbing the cursor, if the window is resizeable, m_restoreResize is
+/// set to YES and the window is marked as not resizeable. This is to prevent
+/// accidental resize by the user. When the cursor is released, the window
+/// style is restored.
+///
////////////////////////////////////////////////////////////
@interface SFWindowController : NSResponder <WindowImplDelegateProtocol, NSWindowDelegate>
{
NSWindow* m_window; ///< Underlying Cocoa window to be controlled
SFOpenGLView* m_oglView; ///< OpenGL view for rendering
sf::priv::WindowImplCocoa* m_requester; ///< Requester
+ BOOL m_fullscreen; ///< Indicate whether the window is fullscreen or not
+ BOOL m_restoreResize; ///< See note above
}
////////////////////////////////////////////////////////////
diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm
index 1d2a915..a6e52ed 100644
--- a/src/SFML/Window/OSX/SFWindowController.mm
+++ b/src/SFML/Window/OSX/SFWindowController.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -32,7 +32,10 @@
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
#include <SFML/System/Err.hpp>
#include <ApplicationServices/ApplicationServices.h>
+#include <algorithm>
+#import <SFML/Window/OSX/NSImage+raw.h>
+#import <SFML/Window/OSX/Scaling.h>
#import <SFML/Window/OSX/SFApplication.h>
#import <SFML/Window/OSX/SFOpenGLView.h>
#import <SFML/Window/OSX/SFWindow.h>
@@ -94,6 +97,8 @@
m_window = nil;
m_oglView = nil;
m_requester = 0;
+ m_fullscreen = NO; // assuming this is the case... too hard to handle anyway.
+ m_restoreResize = NO;
// Retain the window for our own use.
m_window = [window retain];
@@ -144,8 +149,10 @@
m_window = nil;
m_oglView = nil;
m_requester = 0;
+ m_fullscreen = (style & sf::Style::Fullscreen);
+ m_restoreResize = NO;
- if (style & sf::Style::Fullscreen)
+ if (m_fullscreen)
[self setupFullscreenViewWithMode:mode];
else
[self setupWindowWithMode:mode andStyle:style];
@@ -161,6 +168,7 @@
{
// Create a screen-sized window on the main display
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
+ sf::priv::scaleInWidthHeight(desktop, nil);
NSRect windowRect = NSMakeRect(0, 0, desktop.width, desktop.height);
m_window = [[SFWindow alloc] initWithContentRect:windowRect
styleMask:NSBorderlessWindowMask
@@ -201,9 +209,11 @@
}
// Create our OpenGL view size and the view
- CGFloat x = (desktop.width - mode.width) / 2.0;
- CGFloat y = (desktop.height - mode.height) / 2.0;
- NSRect oglRect = NSMakeRect(x, y, mode.width, mode.height);
+ CGFloat width = std::min(mode.width, desktop.width);
+ CGFloat height = std::min(mode.height, desktop.height);
+ CGFloat x = (desktop.width - width) / 2.0;
+ CGFloat y = (desktop.height - height) / 2.0;
+ NSRect oglRect = NSMakeRect(x, y, width, height);
m_oglView = [[SFOpenGLView alloc] initWithFrame:oglRect
fullscreen:YES];
@@ -338,41 +348,66 @@
}
+////////////////////////////////////////////////////////
+-(void)setCursorGrabbed:(BOOL)grabbed
+{
+ // Remove or restore resizeable style if needed
+ BOOL resizeable = [m_window styleMask] & NSResizableWindowMask;
+ if (grabbed && resizeable)
+ {
+ m_restoreResize = YES;
+ NSUInteger newStyle = [m_window styleMask] & ~NSResizableWindowMask;
+ [m_window setStyleMask:newStyle];
+ }
+ else if (!grabbed && m_restoreResize)
+ {
+ m_restoreResize = NO;
+ NSUInteger newStyle = [m_window styleMask] | NSResizableWindowMask;
+ [m_window setStyleMask:newStyle];
+ }
+
+ // Forward to our view
+ [m_oglView setCursorGrabbed:grabbed];
+}
+
+
////////////////////////////////////////////////////////////
-(NSPoint)position
{
- // First, get the top left corner of the view in its own base system
- const NSPoint origin = [m_oglView frame].origin;
- const NSSize size = [m_oglView frame].size;
- const NSPoint topLeftCornerOfView = NSMakePoint(origin.x, origin.y + size.height);
- const NSPoint positionInView = [m_oglView convertPointToBacking:topLeftCornerOfView];
+ // Note: since 10.7 the conversion API works with NSRect
+ // instead of NSPoint. Therefore we use a NSRect but ignore
+ // its width and height.
- // Then, convert it to window base system
- const NSPoint positionInWindow = [m_oglView convertPoint:positionInView toView:nil];
- // here nil denotes the window containing the view
+ // Position of the bottom-left corner in the different coordinate systems:
+ NSRect corner = [m_oglView frame]; // bottom left; size is ignored
+ NSRect view = [m_oglView convertRectToBacking:corner];
+ NSRect window = [m_oglView convertRect:view toView:nil];
+ NSRect screen = [[m_oglView window] convertRectToScreen:window];
- // Next, convert it to the screen base system
- const NSPoint positionInScreen = [[m_oglView window] convertBaseToScreen:positionInWindow];
+ // Get the top-left corner in screen coordinates
+ CGFloat x = screen.origin.x;
+ CGFloat y = screen.origin.y + [m_oglView frame].size.height;
- // Finally, flip for SFML window coordinate system
- // Don't forget to discard the title bar !
- const NSPoint positionInSFML = NSMakePoint(positionInScreen.x,
- ([self screenHeight] - [self titlebarHeight]) - positionInScreen.y);
+ // Flip y-axis (titlebar was already taken into account above)
+ y = [self screenHeight] - y;
- return positionInSFML;
+ return NSMakePoint(x, y);
}
-////////////////////////////////////////////////////////.
+////////////////////////////////////////////////////////
-(void)setWindowPositionToX:(int)x Y:(int)y
{
NSPoint point = NSMakePoint(x, y);
- // Flip for SFML window coordinate system.
- point.y = [self screenHeight] - point.y;
+ // Flip for SFML window coordinate system and take titlebar into account
+ point.y = [self screenHeight] - point.y + [self titlebarHeight];
// Place the window.
[m_window setFrameTopLeftPoint:point];
+
+ // In case the cursor was grabbed we need to update its position
+ [m_oglView updateCursorGrabbed];
}
@@ -386,37 +421,57 @@
////////////////////////////////////////////////////////
-(void)resizeTo:(unsigned int)width by:(unsigned int)height
{
- // Before resizing, remove resizable mask to be able to resize
- // beyond the desktop boundaries.
- NSUInteger styleMask = [m_window styleMask];
+ if (m_fullscreen)
+ {
+ // Special case when fullscreen: only resize the opengl view
+ // and make sure the requested size is not bigger than the window.
+ sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
+ sf::priv::scaleInWidthHeight(desktop, nil);
- [m_window setStyleMask:styleMask ^ NSResizableWindowMask];
+ width = std::min(width, desktop.width);
+ height = std::min(height, desktop.height);
- // Add titlebar height.
- height += [self titlebarHeight];
+ CGFloat x = (desktop.width - width) / 2.0;
+ CGFloat y = (desktop.height - height) / 2.0;
+ NSRect oglRect = NSMakeRect(x, y, width, height);
- // Corner case: don't set the window height bigger than the screen height
- // or the view will be resized _later_ without generating a resize event.
- NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
- CGFloat maxVisibleHeight = screenFrame.size.height;
- if (height > maxVisibleHeight)
+ [m_oglView setFrame:oglRect];
+ [m_oglView setNeedsDisplay:YES];
+ }
+ else
{
- height = maxVisibleHeight;
+ // Before resizing, remove resizable mask to be able to resize
+ // beyond the desktop boundaries.
+ NSUInteger styleMask = [m_window styleMask];
- // The size is not the requested one, we fire an event
- if (m_requester != 0)
- m_requester->windowResized(width, height - [self titlebarHeight]);
- }
+ [m_window setStyleMask:styleMask ^ NSResizableWindowMask];
+
+ // Add titlebar height.
+ height += [self titlebarHeight];
- NSRect frame = NSMakeRect([m_window frame].origin.x,
- [m_window frame].origin.y,
- width,
- height);
+ // Corner case: don't set the window height bigger than the screen height
+ // or the view will be resized _later_ without generating a resize event.
+ NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
+ CGFloat maxVisibleHeight = screenFrame.size.height;
+ if (height > maxVisibleHeight)
+ {
+ height = maxVisibleHeight;
- [m_window setFrame:frame display:YES];
+ // The size is not the requested one, we fire an event
+ if (m_requester != 0)
+ m_requester->windowResized(width, height - [self titlebarHeight]);
+ }
- // And restore the mask
- [m_window setStyleMask:styleMask];
+ NSRect frame = NSMakeRect([m_window frame].origin.x,
+ [m_window frame].origin.y,
+ width,
+ height);
+
+ [m_window setFrame:frame display:YES];
+
+ // And restore the mask
+ [m_window setStyleMask:styleMask];
+ }
}
@@ -487,40 +542,13 @@
by:(unsigned int)height
with:(const sf::Uint8*)pixels
{
- // Create an empty image representation.
- NSBitmapImageRep* bitmap =
- [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:0 // if 0: only allocate memory
- pixelsWide:width
- pixelsHigh:height
- bitsPerSample:8 // The number of bits used to specify
- // one pixel in a single component of the data.
- samplesPerPixel:4 // 3 if no alpha, 4 with it
- hasAlpha:YES
- isPlanar:NO // I don't know what it is but it works
- colorSpaceName:NSCalibratedRGBColorSpace
- bytesPerRow:0 // 0 == determine automatically
- bitsPerPixel:0]; // 0 == determine automatically
-
- // Load data pixels.
- for (unsigned int y = 0; y < height; ++y)
- {
- for (unsigned int x = 0; x < width; ++x, pixels+=4)
- {
- NSUInteger pixel[4] = { pixels[0], pixels[1], pixels[2], pixels[3] };
- [bitmap setPixel:pixel atX:x y:y];
- }
- }
-
- // Create an image from the representation.
- NSImage* icon = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
- [icon addRepresentation:bitmap];
+ // Load image and set app icon.
+ NSImage* icon = [NSImage imageWithRawData:pixels
+ andSize:NSMakeSize(width, height)];
- // Set app icon.
[[SFApplication sharedApplication] setApplicationIconImage:icon];
- // Free up.
[icon release];
- [bitmap release];
}
@@ -591,3 +619,4 @@
}
@end
+
diff --git a/src/SFML/Window/OSX/Scaling.h b/src/SFML/Window/OSX/Scaling.h
new file mode 100644
index 0000000..ee5d29b
--- /dev/null
+++ b/src/SFML/Window/OSX/Scaling.h
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
+// Laurent Gomila (laurent@sfml-dev.org)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+// you must not claim that you wrote the original software.
+// If you use this software in a product, an acknowledgment
+// in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+// and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+// Headers
+////////////////////////////////////////////////////////////
+#import <SFML/Window/OSX/WindowImplDelegateProtocol.h>
+
+#import <AppKit/AppKit.h>
+
+namespace sf
+{
+namespace priv
+{
+
+////////////////////////////////////////////////////////////
+/// \brief Get the scale factor of the main screen
+///
+////////////////////////////////////////////////////////////
+inline CGFloat getDefaultScaleFactor()
+{
+ return [[NSScreen mainScreen] backingScaleFactor];
+}
+
+////////////////////////////////////////////////////////////
+/// \brief Scale SFML coordinates to backing coordinates
+///
+/// \param in SFML coordinates to be converted
+/// \param delegate an object implementing WindowImplDelegateProtocol, or nil for default scale
+///
+////////////////////////////////////////////////////////////
+template <class T>
+void scaleIn(T& in, id<WindowImplDelegateProtocol> delegate)
+{
+ in /= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor();
+}
+
+template <class T>
+void scaleInWidthHeight(T& in, id<WindowImplDelegateProtocol> delegate)
+{
+ scaleIn(in.width, delegate);
+ scaleIn(in.height, delegate);
+}
+
+template <class T>
+void scaleInXY(T& in, id<WindowImplDelegateProtocol> delegate)
+{
+ scaleIn(in.x, delegate);
+ scaleIn(in.y, delegate);
+}
+
+////////////////////////////////////////////////////////////
+/// \brief Scale backing coordinates to SFML coordinates
+///
+/// \param out backing coordinates to be converted
+/// \param delegate an object implementing WindowImplDelegateProtocol, or nil for default scale
+///
+////////////////////////////////////////////////////////////
+template <class T>
+void scaleOut(T& out, id<WindowImplDelegateProtocol> delegate)
+{
+ out *= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor();
+}
+
+template <class T>
+void scaleOutWidthHeight(T& out, id<WindowImplDelegateProtocol> delegate)
+{
+ scaleOut(out.width, delegate);
+ scaleOut(out.height, delegate);
+}
+
+template <class T>
+void scaleOutXY(T& out, id<WindowImplDelegateProtocol> delegate)
+{
+ scaleOut(out.x, delegate);
+ scaleOut(out.y, delegate);
+}
+
+} // namespace priv
+} // namespace sf
+
diff --git a/src/SFML/Window/OSX/SensorImpl.cpp b/src/SFML/Window/OSX/SensorImpl.cpp
index 144c6d7..fb8fce1 100644
--- a/src/SFML/Window/OSX/SensorImpl.cpp
+++ b/src/SFML/Window/OSX/SensorImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/OSX/SensorImpl.hpp b/src/SFML/Window/OSX/SensorImpl.hpp
index 68b810e..c630c39 100644
--- a/src/SFML/Window/OSX/SensorImpl.hpp
+++ b/src/SFML/Window/OSX/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/OSX/VideoModeImpl.cpp b/src/SFML/Window/OSX/VideoModeImpl.cpp
index d83d17d..94d8edd 100644
--- a/src/SFML/Window/OSX/VideoModeImpl.cpp
+++ b/src/SFML/Window/OSX/VideoModeImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -50,6 +50,8 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
return modes;
}
+ VideoMode desktop = getDesktopMode();
+
// Loop on each mode and convert it into a sf::VideoMode object.
const CFIndex modesCount = CFArrayGetCount(cgmodes);
for (CFIndex i = 0; i < modesCount; i++)
@@ -58,6 +60,10 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
VideoMode mode = convertCGModeToSFMode(cgmode);
+ // Skip if bigger than desktop as we currently don't perform hard resolution switch
+ if ((mode.width > desktop.width) || (mode.height > desktop.height))
+ continue;
+
// If not yet listed we add it to our modes array.
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
modes.push_back(mode);
@@ -73,12 +79,21 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
////////////////////////////////////////////////////////////
VideoMode VideoModeImpl::getDesktopMode()
{
+ VideoMode mode; // RVO
+
+ // Rely exclusively on mode and convertCGModeToSFMode
+ // instead of display id and CGDisplayPixelsHigh/Wide.
+
CGDirectDisplayID display = CGMainDisplayID();
- return VideoMode(CGDisplayPixelsWide(display),
- CGDisplayPixelsHigh(display),
- displayBitsPerPixel(display));
+ CGDisplayModeRef cgmode = CGDisplayCopyDisplayMode(display);
+
+ mode = convertCGModeToSFMode(cgmode);
+
+ CGDisplayModeRelease(cgmode);
+
+ return mode;
}
} // namespace priv
-
} // namespace sf
+
diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp
index 486bf78..1036f72 100644
--- a/src/SFML/Window/OSX/WindowImplCocoa.hpp
+++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -314,6 +314,14 @@ public:
virtual void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor
+ ///
+ /// \param grabbed True to grab, false to release
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
diff --git a/src/SFML/Window/OSX/WindowImplCocoa.mm b/src/SFML/Window/OSX/WindowImplCocoa.mm
index 927d5b4..78be5af 100644
--- a/src/SFML/Window/OSX/WindowImplCocoa.mm
+++ b/src/SFML/Window/OSX/WindowImplCocoa.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -28,10 +28,10 @@
////////////////////////////////////////////////////////////
#include <SFML/Window/OSX/WindowImplCocoa.hpp>
#include <SFML/System/Err.hpp>
-#include <SFML/System/String.hpp>
#import <SFML/Window/OSX/AutoreleasePoolWrapper.h>
#import <SFML/Window/OSX/cpp_objc_conversion.h>
+#import <SFML/Window/OSX/Scaling.h>
#import <SFML/Window/OSX/SFApplication.h>
#import <SFML/Window/OSX/SFApplicationDelegate.h>
#import <SFML/Window/OSX/SFKeyboardModifiersHelper.h>
@@ -44,76 +44,6 @@ namespace priv
{
////////////////////////////////////////////////////////////
-/// \brief Get the scale factor of the main screen
-///
-////////////////////////////////////////////////////////////
-CGFloat getDefaultScaleFactor()
-{
- return [[NSScreen mainScreen] backingScaleFactor];
-}
-
-////////////////////////////////////////////////////////////
-/// \brief Scale SFML coordinates to backing coordinates
-///
-/// Use -[NSScreen backingScaleFactor] to find out if the user
-/// has a retina display or not.
-///
-/// \param in SFML coordinates to be converted
-/// \param delegate a object implementing WindowImplDelegateProtocol, or nil for default scale
-///
-////////////////////////////////////////////////////////////
-template <class T>
-void scaleIn(T& in, id<WindowImplDelegateProtocol> delegate)
-{
- in /= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor();
-}
-
-template <class T>
-void scaleInWidthHeight(T& in, id<WindowImplDelegateProtocol> delegate)
-{
- scaleIn(in.width, delegate);
- scaleIn(in.height, delegate);
-}
-
-template <class T>
-void scaleInXY(T& in, id<WindowImplDelegateProtocol> delegate)
-{
- scaleIn(in.x, delegate);
- scaleIn(in.y, delegate);
-}
-
-////////////////////////////////////////////////////////////
-/// \brief Scale backing coordinates to SFML coordinates
-///
-/// Use -[NSScreen backingScaleFactor] to find out if the user
-/// has a retina display or not.
-///
-/// \param out backing coordinates to be converted
-/// \param delegate a object implementing WindowImplDelegateProtocol, or nil for default scale
-///
-////////////////////////////////////////////////////////////
-template <class T>
-void scaleOut(T& out, id<WindowImplDelegateProtocol> delegate)
-{
- out *= delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor();
-}
-
-template <class T>
-void scaleOutWidthHeight(T& out, id<WindowImplDelegateProtocol> delegate)
-{
- scaleOut(out.width, delegate);
- scaleOut(out.height, delegate);
-}
-
-template <class T>
-void scaleOutXY(T& out, id<WindowImplDelegateProtocol> delegate)
-{
- scaleOut(out.x, delegate);
- scaleOut(out.y, delegate);
-}
-
-
-////////////////////////////////////////////////////////////
/// According to Apple's documentation, each invocation of
/// unhide must be balanced by an invocation of hide in
/// order for the cursor display to be correct.
@@ -155,7 +85,7 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle) :
m_showCursor(true)
{
// Ask for a pool.
- retainPool();
+ ensureThreadHasPool();
// Treat the handle as it real type
id nsHandle = (id)handle;
@@ -200,7 +130,7 @@ m_showCursor(true)
setUpProcess();
// Ask for a pool.
- retainPool();
+ ensureThreadHasPool();
// Use backing size
scaleInWidthHeight(mode, nil);
@@ -226,11 +156,9 @@ WindowImplCocoa::~WindowImplCocoa()
if ([windows count] > 0)
[[windows objectAtIndex:0] makeKeyAndOrderFront:nil];
- drainCurrentPool(); // Make sure everything was freed
+ drainThreadPool(); // Make sure everything was freed
// This solve some issue when sf::Window::Create is called for the
// second time (nothing was render until the function was called again)
-
- releasePool();
}
@@ -467,7 +395,7 @@ void WindowImplCocoa::textEntered(unichar charcode)
void WindowImplCocoa::processEvents()
{
[m_delegate processEvent];
- drainCurrentPool(); // Reduce memory footprint
+ drainThreadPool(); // Reduce memory footprint
}
#pragma mark
@@ -559,6 +487,13 @@ void WindowImplCocoa::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void WindowImplCocoa::setMouseCursorGrabbed(bool grabbed)
+{
+ [m_delegate setCursorGrabbed:grabbed];
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplCocoa::setKeyRepeatEnabled(bool enabled)
{
if (enabled)
@@ -585,3 +520,4 @@ bool WindowImplCocoa::hasFocus() const
} // namespace priv
} // namespace sf
+
diff --git a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h
index 0c4595c..4e0c327 100644
--- a/src/SFML/Window/OSX/WindowImplDelegateProtocol.h
+++ b/src/SFML/Window/OSX/WindowImplDelegateProtocol.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -97,6 +97,14 @@ namespace sf {
-(BOOL)isMouseInside;
////////////////////////////////////////////////////////////
+/// \brief Grab or release the mouse cursor
+///
+/// \param grabbed YES to grab, NO to release
+///
+////////////////////////////////////////////////////////////
+-(void)setCursorGrabbed:(BOOL)grabbed;
+
+////////////////////////////////////////////////////////////
/// \brief Get window position
///
/// \return Top left corner of the window or view
diff --git a/src/SFML/Window/OSX/cg_sf_conversion.hpp b/src/SFML/Window/OSX/cg_sf_conversion.hpp
index c0083f8..8b3845e 100644
--- a/src/SFML/Window/OSX/cg_sf_conversion.hpp
+++ b/src/SFML/Window/OSX/cg_sf_conversion.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/cg_sf_conversion.cpp b/src/SFML/Window/OSX/cg_sf_conversion.mm
index 60318cd..32495c3 100644
--- a/src/SFML/Window/OSX/cg_sf_conversion.cpp
+++ b/src/SFML/Window/OSX/cg_sf_conversion.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
@@ -29,6 +29,8 @@
#include <SFML/Window/OSX/cg_sf_conversion.hpp>
#include <SFML/System/Err.hpp>
+#import <SFML/Window/OSX/Scaling.h>
+
namespace sf
{
namespace priv
@@ -74,51 +76,22 @@ size_t displayBitsPerPixel(CGDirectDisplayID displayId)
////////////////////////////////////////////////////////////
VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode)
{
- return VideoMode(CGDisplayModeGetWidth(cgmode),
- CGDisplayModeGetHeight(cgmode),
- modeBitsPerPixel(cgmode));
-}
-
-
-////////////////////////////////////////////////////////////
-CGDisplayModeRef convertSFModeToCGMode(VideoMode sfmode)
-{
- // Starting with 10.6 we should query the display all the modes and
- // search for the best one.
-
- // Will return NULL if sfmode is not in VideoMode::GetFullscreenModes.
- CGDisplayModeRef cgbestMode = NULL;
-
- // Retrieve all modes available for main screen only.
- CFArrayRef cgmodes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
-
- if (cgmodes == NULL) // Should not happen but anyway...
- {
- sf::err() << "Couldn't get VideoMode for main display.";
- return NULL;
- }
-
- // Loop on each mode and convert it into a sf::VideoMode object.
- const CFIndex modesCount = CFArrayGetCount(cgmodes);
- for (CFIndex i = 0; i < modesCount; i++)
- {
- CGDisplayModeRef cgmode = (CGDisplayModeRef)CFArrayGetValueAtIndex(cgmodes, i);
-
- VideoMode mode = convertCGModeToSFMode(cgmode);
-
- if (mode == sfmode)
- cgbestMode = cgmode;
- }
-
- // Clean up memory.
- CFRelease(cgmodes);
-
- if (cgbestMode == NULL)
- sf::err() << "Couldn't convert the given sf:VideoMode into a CGDisplayMode."
- << std::endl;
-
- return cgbestMode;
+ // The main documentation says the sizes returned by
+ // CGDisplayModeGetWidth and CGDisplayModeGetHeight
+ // are expressed in pixels. However, some additional
+ // documentation [1] states they actually return
+ // values in points starting with 10.8.
+ //
+ // We therefore needs to use the scaling factor to
+ // convert the dimensions properly.
+ //
+ // [1]: "APIs for Supporting High Resolution" > "Additions and Changes for OS X v10.8"
+ // https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW27
+ VideoMode mode(CGDisplayModeGetWidth(cgmode), CGDisplayModeGetHeight(cgmode), modeBitsPerPixel(cgmode));
+ scaleOutWidthHeight(mode, nil);
+ return mode;
}
} // namespace priv
} // namespace sf
+
diff --git a/src/SFML/Window/OSX/cpp_objc_conversion.h b/src/SFML/Window/OSX/cpp_objc_conversion.h
index 42f1557..9683a6e 100644
--- a/src/SFML/Window/OSX/cpp_objc_conversion.h
+++ b/src/SFML/Window/OSX/cpp_objc_conversion.h
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/OSX/cpp_objc_conversion.mm b/src/SFML/Window/OSX/cpp_objc_conversion.mm
index ea7c84b..539a41e 100644
--- a/src/SFML/Window/OSX/cpp_objc_conversion.mm
+++ b/src/SFML/Window/OSX/cpp_objc_conversion.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Marco Antognini (antognini.marco@gmail.com),
+// Copyright (C) 2007-2016 Marco Antognini (antognini.marco@gmail.com),
// Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
diff --git a/src/SFML/Window/Sensor.cpp b/src/SFML/Window/Sensor.cpp
index 64b9fff..a2ddb2b 100644
--- a/src/SFML/Window/Sensor.cpp
+++ b/src/SFML/Window/Sensor.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/SensorImpl.hpp b/src/SFML/Window/SensorImpl.hpp
index 39ca794..25b44d2 100644
--- a/src/SFML/Window/SensorImpl.hpp
+++ b/src/SFML/Window/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/SensorManager.cpp b/src/SFML/Window/SensorManager.cpp
index dd3e7a0..319767d 100644
--- a/src/SFML/Window/SensorManager.cpp
+++ b/src/SFML/Window/SensorManager.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/SensorManager.hpp b/src/SFML/Window/SensorManager.hpp
index 2d9f9c1..a0faa87 100644
--- a/src/SFML/Window/SensorManager.hpp
+++ b/src/SFML/Window/SensorManager.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Touch.cpp b/src/SFML/Window/Touch.cpp
index 4ff400e..b2d9615 100644
--- a/src/SFML/Window/Touch.cpp
+++ b/src/SFML/Window/Touch.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/Display.cpp b/src/SFML/Window/Unix/Display.cpp
index c57ae0f..a078b97 100644
--- a/src/SFML/Window/Unix/Display.cpp
+++ b/src/SFML/Window/Unix/Display.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/Display.hpp b/src/SFML/Window/Unix/Display.hpp
index 2b33c96..2743678 100644
--- a/src/SFML/Window/Unix/Display.hpp
+++ b/src/SFML/Window/Unix/Display.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp
index c89c9d3..7251db2 100644
--- a/src/SFML/Window/Unix/GlxContext.cpp
+++ b/src/SFML/Window/Unix/GlxContext.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -31,6 +31,7 @@
#include <SFML/System/Mutex.hpp>
#include <SFML/System/Lock.hpp>
#include <SFML/System/Err.hpp>
+#include <vector>
#if !defined(GLX_DEBUGGING) && defined(SFML_DEBUG)
// Enable this to print messages to err() everytime GLX produces errors
@@ -53,8 +54,8 @@ namespace
public:
GlxErrorHandler(::Display* display) :
- m_display(display),
- m_lock (glxErrorMutex)
+ m_lock (glxErrorMutex),
+ m_display(display)
{
glxErrorOccurred = false;
m_previousHandler = XSetErrorHandler(HandleXError);
@@ -95,101 +96,73 @@ void ensureExtensionsInit(::Display* display, int screen)
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared) :
+m_display (NULL),
m_window (0),
m_context (NULL),
-m_ownsWindow(true)
+m_pbuffer (0),
+m_ownsWindow(false)
{
- // Open a connection with the X server
- m_display = OpenDisplay();
- m_connection = XGetXCBConnection(m_display);
- xcb_screen_t* screen = XCBScreenOfDisplay(m_connection, DefaultScreen(m_display));
+ // Save the creation settings
+ m_settings = ContextSettings();
- // Choose the visual according to the context settings
- XVisualInfo visualInfo = selectBestVisual(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_display)
+ ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
- // Define the window attributes
- xcb_colormap_t colormap = xcb_generate_id(m_connection);
- xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visualInfo.visualid);
- const uint32_t value_list[] = {colormap};
-
- // Create a dummy window (disabled and hidden)
- m_window = xcb_generate_id(m_connection);
- xcb_create_window(
- m_connection,
- static_cast<uint8_t>(visualInfo.depth),
- m_window,
- screen->root,
- 0, 0,
- 1, 1,
- 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- visualInfo.visualid,
- XCB_CW_COLORMAP,
- value_list
- );
+ // Create the rendering surface (window or pbuffer if supported)
+ createSurface(shared, 1, 1, VideoMode::getDesktopMode().bitsPerPixel);
// Create the context
- createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
+ createContext(shared);
}
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
+m_display (NULL),
m_window (0),
m_context (NULL),
+m_pbuffer (0),
m_ownsWindow(false)
{
- // Open a connection with the X server
- // (important: must be the same display as the owner window)
- m_display = OpenDisplay();
- m_connection = XGetXCBConnection(m_display);
+ // Save the creation settings
+ m_settings = settings;
- // Get the owner window and its device context
- m_window = static_cast< ::Window>(owner->getSystemHandle());
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_display)
+ ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
+
+ // Create the rendering surface from the owner window
+ createSurface(static_cast< ::Window>(owner->getSystemHandle()));
// Create the context
- if (m_window)
- createContext(shared, bitsPerPixel, settings);
+ createContext(shared);
}
////////////////////////////////////////////////////////////
GlxContext::GlxContext(GlxContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
+m_display (NULL),
m_window (0),
m_context (NULL),
-m_ownsWindow(true)
+m_pbuffer (0),
+m_ownsWindow(false)
{
- // Open a connection with the X server
- m_display = OpenDisplay();
- m_connection = XGetXCBConnection(m_display);
- xcb_screen_t* screen = XCBScreenOfDisplay(m_connection, DefaultScreen(m_display));
+ // Save the creation settings
+ m_settings = settings;
- // Choose the visual according to the context settings
- XVisualInfo visualInfo = selectBestVisual(m_display, VideoMode::getDesktopMode().bitsPerPixel, settings);
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_display)
+ ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
- // Define the window attributes
- xcb_colormap_t colormap = xcb_generate_id(m_connection);
- xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visualInfo.visualid);
- const uint32_t value_list[] = {colormap};
-
- // Create the hidden window
- m_window = xcb_generate_id(m_connection);
- xcb_create_window(
- m_connection,
- static_cast<uint8_t>(visualInfo.depth),
- m_window,
- screen->root,
- 0, 0,
- width, height,
- 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- visualInfo.visualid,
- XCB_CW_COLORMAP,
- value_list
- );
+ // Create the rendering surface (window or pbuffer if supported)
+ createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel);
// Create the context
- createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
+ createContext(shared);
}
@@ -213,6 +186,11 @@ GlxContext::~GlxContext()
#endif
}
+ if (m_pbuffer)
+ {
+ glXDestroyPbuffer(m_display, m_pbuffer);
+ }
+
// Destroy the window if we own it
if (m_window && m_ownsWindow)
{
@@ -242,7 +220,16 @@ bool GlxContext::makeCurrent()
GlxErrorHandler handler(m_display);
#endif
- bool result = glXMakeCurrent(m_display, m_window, m_context);
+ bool result = false;
+
+ if (m_pbuffer)
+ {
+ result = glXMakeContextCurrent(m_display, m_pbuffer, m_pbuffer, m_context);
+ }
+ else if (m_window)
+ {
+ result = glXMakeCurrent(m_display, m_window, m_context);
+ }
#if defined(GLX_DEBUGGING)
if (glxErrorOccurred)
@@ -260,7 +247,9 @@ void GlxContext::display()
GlxErrorHandler handler(m_display);
#endif
- if (m_window)
+ if (m_pbuffer)
+ glXSwapBuffers(m_display, m_pbuffer);
+ else if (m_window)
glXSwapBuffers(m_display, m_window);
#if defined(GLX_DEBUGGING)
@@ -284,7 +273,7 @@ void GlxContext::setVerticalSyncEnabled(bool enabled)
// which would require us to link in an additional library
if (sfglx_ext_EXT_swap_control == sfglx_LOAD_SUCCEEDED)
{
- glXSwapIntervalEXT(m_display, glXGetCurrentDrawable(), enabled ? 1 : 0);
+ glXSwapIntervalEXT(m_display, m_pbuffer ? m_pbuffer : m_window, enabled ? 1 : 0);
}
else if (sfglx_ext_MESA_swap_control == sfglx_LOAD_SUCCEEDED)
{
@@ -321,7 +310,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
{
// Evaluate all the returned visuals, and pick the best one
int bestScore = 0x7FFFFFFF;
- XVisualInfo bestVisual;
+ XVisualInfo bestVisual = XVisualInfo();
for (int i = 0; i < count; ++i)
{
// Check mandatory attributes
@@ -331,7 +320,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
continue;
// Extract the components of the current visual
- int red, green, blue, alpha, depth, stencil, multiSampling, samples;
+ int red, green, blue, alpha, depth, stencil, multiSampling, samples, sRgb;
glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red);
glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green);
glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue);
@@ -350,12 +339,21 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
samples = 0;
}
+ if ((sfglx_ext_EXT_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED) || (sfglx_ext_ARB_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED))
+ {
+ glXGetConfig(display, &visuals[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
+ }
+ else
+ {
+ sRgb = 0;
+ }
+
// TODO: Replace this with proper acceleration detection
bool accelerated = true;
// Evaluate the visual
int color = red + green + blue + alpha;
- int score = evaluateFormat(bitsPerPixel, settings, color, depth, stencil, multiSampling ? samples : 0, accelerated);
+ int score = evaluateFormat(bitsPerPixel, settings, color, depth, stencil, multiSampling ? samples : 0, accelerated, sRgb == True);
// If it's better than the current best, make it the new best
if (score < bestScore)
@@ -379,12 +377,45 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
}
}
+
////////////////////////////////////////////////////////////
-void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
+void GlxContext::updateSettingsFromVisualInfo(XVisualInfo* visualInfo)
{
- // Save the creation settings
- m_settings = settings;
+ // Update the creation settings from the chosen format
+ int depth, stencil, multiSampling, samples, sRgb;
+ glXGetConfig(m_display, visualInfo, GLX_DEPTH_SIZE, &depth);
+ glXGetConfig(m_display, visualInfo, GLX_STENCIL_SIZE, &stencil);
+
+ if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
+ {
+ glXGetConfig(m_display, visualInfo, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
+ glXGetConfig(m_display, visualInfo, GLX_SAMPLES_ARB, &samples);
+ }
+ else
+ {
+ multiSampling = 0;
+ samples = 0;
+ }
+ if ((sfglx_ext_EXT_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED) || (sfglx_ext_ARB_framebuffer_sRGB == sfglx_LOAD_SUCCEEDED))
+ {
+ glXGetConfig(m_display, visualInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &sRgb);
+ }
+ else
+ {
+ sRgb = 0;
+ }
+
+ m_settings.depthBits = static_cast<unsigned int>(depth);
+ m_settings.stencilBits = static_cast<unsigned int>(stencil);
+ m_settings.antialiasingLevel = multiSampling ? samples : 0;
+ m_settings.sRgbCapable = (sRgb == True);
+}
+
+
+////////////////////////////////////////////////////////////
+void GlxContext::updateSettingsFromWindow()
+{
// Retrieve the attributes of the target window
XWindowAttributes windowAttributes;
if (XGetWindowAttributes(m_display, m_window, &windowAttributes) == 0)
@@ -400,6 +431,180 @@ void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, co
int nbVisuals = 0;
XVisualInfo* visualInfo = XGetVisualInfo(m_display, VisualIDMask | VisualScreenMask, &tpl, &nbVisuals);
+ if (!visualInfo)
+ return;
+
+ updateSettingsFromVisualInfo(visualInfo);
+
+ XFree(visualInfo);
+}
+
+
+////////////////////////////////////////////////////////////
+void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
+{
+ m_display = OpenDisplay();
+ m_connection = XGetXCBConnection(m_display);
+
+ // Choose the visual according to the context settings
+ XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);
+
+ // Check if the shared context already exists and pbuffers are supported
+ if (shared && (sfglx_ext_SGIX_pbuffer == sfglx_LOAD_SUCCEEDED))
+ {
+ // There are no GLX versions prior to 1.0
+ int major = 0;
+ int minor = 0;
+
+ glXQueryVersion(m_display, &major, &minor);
+
+ // Check if glXCreatePbuffer is available (requires GLX 1.3 or greater)
+ bool hasCreatePbuffer = ((major > 1) || (minor >= 3));
+
+ if (hasCreatePbuffer)
+ {
+ // Get a GLXFBConfig that matches the visual
+ GLXFBConfig* config = NULL;
+
+ // We don't supply attributes to match against, since
+ // the visual we are matching against was already
+ // deemed suitable in selectBestVisual()
+ int nbConfigs = 0;
+ GLXFBConfig* configs = glXChooseFBConfig(m_display, DefaultScreen(m_display), NULL, &nbConfigs);
+
+ for (int i = 0; configs && (i < nbConfigs); ++i)
+ {
+ XVisualInfo* visual = glXGetVisualFromFBConfig(m_display, configs[i]);
+
+ if (!visual)
+ continue;
+
+ if (visual->visualid == visualInfo.visualid)
+ {
+ config = &configs[i];
+ break;
+ }
+ }
+
+ if (config)
+ {
+ int attributes[] =
+ {
+ GLX_PBUFFER_WIDTH, static_cast<int>(width),
+ GLX_PBUFFER_HEIGHT, static_cast<int>(height),
+ 0, 0
+ };
+
+ m_pbuffer = glXCreatePbuffer(m_display, *config, attributes);
+
+ updateSettingsFromVisualInfo(&visualInfo);
+
+ XFree(configs);
+
+ return;
+ }
+
+ if (configs)
+ XFree(configs);
+ }
+ }
+
+ // If pbuffers are not available we use a hidden window as the off-screen surface to draw to
+ xcb_screen_t* screen = XCBScreenOfDisplay(m_connection, DefaultScreen(m_display));
+
+ // Define the window attributes
+ xcb_colormap_t colormap = xcb_generate_id(m_connection);
+ xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visualInfo.visualid);
+ const uint32_t value_list[] = {colormap};
+
+ // Create a dummy window (disabled and hidden)
+ m_window = xcb_generate_id(m_connection);
+ xcb_create_window(
+ m_connection,
+ static_cast<uint8_t>(visualInfo.depth),
+ m_window,
+ screen->root,
+ 0, 0,
+ width, height,
+ 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ visualInfo.visualid,
+ XCB_CW_COLORMAP,
+ value_list
+ );
+
+ m_ownsWindow = true;
+
+ updateSettingsFromWindow();
+}
+
+
+////////////////////////////////////////////////////////////
+void GlxContext::createSurface(::Window window)
+{
+ m_display = OpenDisplay();
+ m_connection = XGetXCBConnection(m_display);
+
+ // A window already exists, so just use it
+ m_window = window;
+
+ updateSettingsFromWindow();
+}
+
+
+////////////////////////////////////////////////////////////
+void GlxContext::createContext(GlxContext* shared)
+{
+ // Get a working copy of the context settings
+ ContextSettings settings = m_settings;
+
+ XVisualInfo* visualInfo = NULL;
+
+ if (m_pbuffer)
+ {
+ unsigned int fbConfigId = 0;
+
+ glXQueryDrawable(m_display, m_pbuffer, GLX_FBCONFIG_ID, &fbConfigId);
+
+ int attributes[] =
+ {
+ GLX_FBCONFIG_ID, static_cast<int>(fbConfigId),
+ 0, 0
+ };
+
+ int count = 0;
+ GLXFBConfig* fbconfig = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &count);
+
+ if (count == 1)
+ visualInfo = glXGetVisualFromFBConfig(m_display, *fbconfig);
+
+ if (fbconfig)
+ XFree(fbconfig);
+ }
+ else
+ {
+ // Retrieve the attributes of the target window
+ XWindowAttributes windowAttributes;
+ if (XGetWindowAttributes(m_display, m_window, &windowAttributes) == 0)
+ {
+ err() << "Failed to get the window attributes" << std::endl;
+ return;
+ }
+
+ // Get its visuals
+ XVisualInfo tpl;
+ tpl.screen = DefaultScreen(m_display);
+ tpl.visualid = XVisualIDFromVisual(windowAttributes.visual);
+ int nbVisuals = 0;
+ visualInfo = XGetVisualInfo(m_display, VisualIDMask | VisualScreenMask, &tpl, &nbVisuals);
+ }
+
+ if (!visualInfo)
+ {
+ err() << "Failed to get visual info" << std::endl;
+ return;
+ }
+
// Get the context to share display lists with
GLXContext toShare = shared ? shared->m_context : NULL;
@@ -410,26 +615,13 @@ void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, co
if (!glXQueryVersion(m_display, &major, &minor))
err() << "Failed to query GLX version, limited to legacy context creation" << std::endl;
- // Make sure that extensions are initialized if this is not the shared context
- // The shared context is the context used to initialize the extensions
- if (shared)
- ensureExtensionsInit(m_display, DefaultScreen(m_display));
-
// Check if glXCreateContextAttribsARB is available (requires GLX 1.3 or greater)
bool hasCreateContextArb = (sfglx_ext_ARB_create_context == sfglx_LOAD_SUCCEEDED) && ((major > 1) || (minor >= 3));
- // Check if we need to use glXCreateContextAttribsARB
- bool needCreateContextArb = false;
-
- if (m_settings.attributeFlags)
- needCreateContextArb = true;
- else if (m_settings.majorVersion >= 3)
- needCreateContextArb = true;
-
- // Create the OpenGL context -- first try using glXCreateContextAttribsARB if we need to
- if (hasCreateContextArb && needCreateContextArb)
+ // Create the OpenGL context -- first try using glXCreateContextAttribsARB
+ if (hasCreateContextArb)
{
- // Get a GLXFBConfig that matches the the window's visual, for glXCreateContextAttribsARB
+ // Get a GLXFBConfig that matches the window's visual, for glXCreateContextAttribsARB
GLXFBConfig* config = NULL;
// We don't supply attributes to match against, since
@@ -457,27 +649,27 @@ void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, co
while (config && !m_context && m_settings.majorVersion)
{
+ std::vector<int> attributes;
+
+ // Check if the user requested a specific context version (anything > 1.1)
+ if ((m_settings.majorVersion > 1) || ((m_settings.majorVersion == 1) && (m_settings.minorVersion > 1)))
+ {
+ attributes.push_back(GLX_CONTEXT_MAJOR_VERSION_ARB);
+ attributes.push_back(m_settings.majorVersion);
+ attributes.push_back(GLX_CONTEXT_MINOR_VERSION_ARB);
+ attributes.push_back(m_settings.minorVersion);
+ }
+
// Check if setting the profile is supported
if (sfglx_ext_ARB_create_context_profile == sfglx_LOAD_SUCCEEDED)
{
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? GLX_CONTEXT_DEBUG_BIT_ARB : 0;
- // Create the context
- int attributes[] =
- {
- GLX_CONTEXT_MAJOR_VERSION_ARB, static_cast<int>(m_settings.majorVersion),
- GLX_CONTEXT_MINOR_VERSION_ARB, static_cast<int>(m_settings.minorVersion),
- GLX_CONTEXT_PROFILE_MASK_ARB, profile,
- GLX_CONTEXT_FLAGS_ARB, debug,
- 0, 0
- };
-
- // RAII GLX error handler (we simply ignore errors here)
- // On an error, glXCreateContextAttribsARB will return 0 anyway
- GlxErrorHandler handler(m_display);
-
- m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, attributes);
+ attributes.push_back(GLX_CONTEXT_PROFILE_MASK_ARB);
+ attributes.push_back(profile);
+ attributes.push_back(GLX_CONTEXT_FLAGS_ARB);
+ attributes.push_back(debug);
}
else
{
@@ -486,21 +678,18 @@ void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, co
<< "disabling comptibility and debug" << std::endl;
m_settings.attributeFlags = ContextSettings::Default;
+ }
- // Create the context
- int attributes[] =
- {
- GLX_CONTEXT_MAJOR_VERSION_ARB, static_cast<int>(m_settings.majorVersion),
- GLX_CONTEXT_MINOR_VERSION_ARB, static_cast<int>(m_settings.minorVersion),
- 0, 0
- };
+ // Append the terminating 0
+ attributes.push_back(0);
+ attributes.push_back(0);
- // RAII GLX error handler (we simply ignore errors here)
- // On an error, glXCreateContextAttribsARB will return 0 anyway
- GlxErrorHandler handler(m_display);
+ // RAII GLX error handler (we simply ignore errors here)
+ // On an error, glXCreateContextAttribsARB will return 0 anyway
+ GlxErrorHandler handler(m_display);
- m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, attributes);
- }
+ // Create the context
+ m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, &attributes[0]);
if (!m_context)
{
@@ -555,31 +744,7 @@ void GlxContext::createContext(GlxContext* shared, unsigned int bitsPerPixel, co
}
if (!m_context)
- {
err() << "Failed to create an OpenGL context for this window" << std::endl;
- }
- else
- {
- // Update the creation settings from the chosen format
- int depth, stencil, multiSampling, samples;
- glXGetConfig(m_display, visualInfo, GLX_DEPTH_SIZE, &depth);
- glXGetConfig(m_display, visualInfo, GLX_STENCIL_SIZE, &stencil);
-
- if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED)
- {
- glXGetConfig(m_display, visualInfo, GLX_SAMPLE_BUFFERS_ARB, &multiSampling);
- glXGetConfig(m_display, visualInfo, GLX_SAMPLES_ARB, &samples);
- }
- else
- {
- multiSampling = 0;
- samples = 0;
- }
-
- m_settings.depthBits = static_cast<unsigned int>(depth);
- m_settings.stencilBits = static_cast<unsigned int>(stencil);
- m_settings.antialiasingLevel = multiSampling ? samples : 0;
- }
// Free the visual info
XFree(visualInfo);
diff --git a/src/SFML/Window/Unix/GlxContext.hpp b/src/SFML/Window/Unix/GlxContext.hpp
index e1ad899..4a9444f 100644
--- a/src/SFML/Window/Unix/GlxContext.hpp
+++ b/src/SFML/Window/Unix/GlxContext.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -133,14 +133,45 @@ public:
private:
////////////////////////////////////////////////////////////
- /// \brief Create the context
+ /// \brief Update the context visual settings from XVisualInfo
+ ///
+ /// \param visualInfo XVisualInfo to update settings from
+ ///
+ ////////////////////////////////////////////////////////////
+ void updateSettingsFromVisualInfo(XVisualInfo* visualInfo);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Update the context visual settings from the window
+ ///
+ ////////////////////////////////////////////////////////////
+ void updateSettingsFromWindow();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Create the context's drawing surface
///
/// \param shared Context to share the new one with (can be NULL)
+ /// \param width Back buffer width, in pixels
+ /// \param height Back buffer height, in pixels
/// \param bitsPerPixel Pixel depth, in bits per pixel
- /// \param settings Creation parameters
///
////////////////////////////////////////////////////////////
- void createContext(GlxContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings);
+ void createSurface(GlxContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Create the context's drawing surface from an existing window
+ ///
+ /// \param window Window ID of the owning window
+ ///
+ ////////////////////////////////////////////////////////////
+ void createSurface(::Window window);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Create the context
+ ///
+ /// \param shared Context to share the new one with (can be NULL)
+ ///
+ ////////////////////////////////////////////////////////////
+ void createContext(GlxContext* shared);
////////////////////////////////////////////////////////////
// Member data
@@ -149,6 +180,7 @@ private:
::Window m_window; ///< Window to which the context is attached
xcb_connection_t* m_connection; ///< Pointer to the xcb connection
GLXContext m_context; ///< OpenGL context
+ GLXPbuffer m_pbuffer; ///< GLX pbuffer ID if one was created
bool m_ownsWindow; ///< Do we own the window associated to the context?
};
diff --git a/src/SFML/Window/Unix/GlxExtensions.cpp b/src/SFML/Window/Unix/GlxExtensions.cpp
index 029095c..e418e2e 100644
--- a/src/SFML/Window/Unix/GlxExtensions.cpp
+++ b/src/SFML/Window/Unix/GlxExtensions.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,6 +30,7 @@
#include <cstdlib>
#include <cstring>
#include <cstddef>
+#include <string>
static sf::GlFunctionPointer IntGetProcAddress(const char* name)
{
@@ -39,17 +40,21 @@ static sf::GlFunctionPointer IntGetProcAddress(const char* name)
int sfglx_ext_EXT_swap_control = sfglx_LOAD_FAILED;
int sfglx_ext_MESA_swap_control = sfglx_LOAD_FAILED;
int sfglx_ext_SGI_swap_control = sfglx_LOAD_FAILED;
+int sfglx_ext_EXT_framebuffer_sRGB = sfglx_LOAD_FAILED;
+int sfglx_ext_ARB_framebuffer_sRGB = sfglx_LOAD_FAILED;
int sfglx_ext_ARB_multisample = sfglx_LOAD_FAILED;
+int sfglx_ext_SGIX_pbuffer = sfglx_LOAD_FAILED;
int sfglx_ext_ARB_create_context = sfglx_LOAD_FAILED;
int sfglx_ext_ARB_create_context_profile = sfglx_LOAD_FAILED;
-void (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalEXT)(Display *, GLXDrawable, int) = NULL;
+void (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalEXT)(Display*, GLXDrawable, int) = NULL;
static int Load_EXT_swap_control(void)
{
int numFailed = 0;
- sf_ptrc_glXSwapIntervalEXT = (void (CODEGEN_FUNCPTR *)(Display *, GLXDrawable, int))IntGetProcAddress("glXSwapIntervalEXT");
- if(!sf_ptrc_glXSwapIntervalEXT) numFailed++;
+ sf_ptrc_glXSwapIntervalEXT = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, int)>(IntGetProcAddress("glXSwapIntervalEXT"));
+ if (!sf_ptrc_glXSwapIntervalEXT)
+ numFailed++;
return numFailed;
}
@@ -58,8 +63,9 @@ int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalMESA)(int) = NULL;
static int Load_MESA_swap_control(void)
{
int numFailed = 0;
- sf_ptrc_glXSwapIntervalMESA = (int (CODEGEN_FUNCPTR *)(int))IntGetProcAddress("glXSwapIntervalMESA");
- if(!sf_ptrc_glXSwapIntervalMESA) numFailed++;
+ sf_ptrc_glXSwapIntervalMESA = reinterpret_cast<int (CODEGEN_FUNCPTR*)(int)>(IntGetProcAddress("glXSwapIntervalMESA"));
+ if (!sf_ptrc_glXSwapIntervalMESA)
+ numFailed++;
return numFailed;
}
@@ -68,74 +74,110 @@ int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalSGI)(int) = NULL;
static int Load_SGI_swap_control(void)
{
int numFailed = 0;
- sf_ptrc_glXSwapIntervalSGI = (int (CODEGEN_FUNCPTR *)(int))IntGetProcAddress("glXSwapIntervalSGI");
- if(!sf_ptrc_glXSwapIntervalSGI) numFailed++;
+ sf_ptrc_glXSwapIntervalSGI = reinterpret_cast<int (CODEGEN_FUNCPTR *)(int)>(IntGetProcAddress("glXSwapIntervalSGI"));
+ if (!sf_ptrc_glXSwapIntervalSGI)
+ numFailed++;
return numFailed;
}
-GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *) = NULL;
+GLXPbufferSGIX (CODEGEN_FUNCPTR *sf_ptrc_glXCreateGLXPbufferSGIX)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*) = NULL;
+void (CODEGEN_FUNCPTR *sf_ptrc_glXDestroyGLXPbufferSGIX)(Display*, GLXPbufferSGIX) = NULL;
+void (CODEGEN_FUNCPTR *sf_ptrc_glXGetSelectedEventSGIX)(Display*, GLXDrawable, unsigned long*) = NULL;
+int (CODEGEN_FUNCPTR *sf_ptrc_glXQueryGLXPbufferSGIX)(Display*, GLXPbufferSGIX, int, unsigned int*) = NULL;
+void (CODEGEN_FUNCPTR *sf_ptrc_glXSelectEventSGIX)(Display*, GLXDrawable, unsigned long) = NULL;
+
+static int Load_SGIX_pbuffer(void)
+{
+ int numFailed = 0;
+ sf_ptrc_glXCreateGLXPbufferSGIX = reinterpret_cast<GLXPbufferSGIX (CODEGEN_FUNCPTR*)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*)>(IntGetProcAddress("glXCreateGLXPbufferSGIX"));
+ if (!sf_ptrc_glXCreateGLXPbufferSGIX)
+ numFailed++;
+ sf_ptrc_glXDestroyGLXPbufferSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXPbufferSGIX)>(IntGetProcAddress("glXDestroyGLXPbufferSGIX"));
+ if (!sf_ptrc_glXDestroyGLXPbufferSGIX)
+ numFailed++;
+ sf_ptrc_glXGetSelectedEventSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, unsigned long*)>(IntGetProcAddress("glXGetSelectedEventSGIX"));
+ if (!sf_ptrc_glXGetSelectedEventSGIX)
+ numFailed++;
+ sf_ptrc_glXQueryGLXPbufferSGIX = reinterpret_cast<int (CODEGEN_FUNCPTR*)(Display*, GLXPbufferSGIX, int, unsigned int*)>(IntGetProcAddress("glXQueryGLXPbufferSGIX"));
+ if (!sf_ptrc_glXQueryGLXPbufferSGIX)
+ numFailed++;
+ sf_ptrc_glXSelectEventSGIX = reinterpret_cast<void (CODEGEN_FUNCPTR*)(Display*, GLXDrawable, unsigned long)>(IntGetProcAddress("glXSelectEventSGIX"));
+ if (!sf_ptrc_glXSelectEventSGIX)
+ numFailed++;
+ return numFailed;
+}
+
+GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*) = NULL;
static int Load_ARB_create_context(void)
{
int numFailed = 0;
- sf_ptrc_glXCreateContextAttribsARB = (GLXContext (CODEGEN_FUNCPTR *)(Display *, GLXFBConfig, GLXContext, Bool, const int *))IntGetProcAddress("glXCreateContextAttribsARB");
- if(!sf_ptrc_glXCreateContextAttribsARB) numFailed++;
+ sf_ptrc_glXCreateContextAttribsARB = reinterpret_cast<GLXContext (CODEGEN_FUNCPTR*)(Display*, GLXFBConfig, GLXContext, Bool, const int*)>(IntGetProcAddress("glXCreateContextAttribsARB"));
+ if (!sf_ptrc_glXCreateContextAttribsARB)
+ numFailed++;
return numFailed;
}
typedef int (*PFN_LOADFUNCPOINTERS)(void);
typedef struct sfglx_StrToExtMap_s
{
- const char *extensionName;
- int *extensionVariable;
+ const char* extensionName;
+ int* extensionVariable;
PFN_LOADFUNCPOINTERS LoadExtension;
} sfglx_StrToExtMap;
-static sfglx_StrToExtMap ExtensionMap[6] = {
+static sfglx_StrToExtMap ExtensionMap[9] = {
{"GLX_EXT_swap_control", &sfglx_ext_EXT_swap_control, Load_EXT_swap_control},
{"GLX_MESA_swap_control", &sfglx_ext_MESA_swap_control, Load_MESA_swap_control},
{"GLX_SGI_swap_control", &sfglx_ext_SGI_swap_control, Load_SGI_swap_control},
+ {"GLX_EXT_framebuffer_sRGB", &sfglx_ext_EXT_framebuffer_sRGB, NULL},
+ {"GLX_ARB_framebuffer_sRGB", &sfglx_ext_ARB_framebuffer_sRGB, NULL},
{"GLX_ARB_multisample", &sfglx_ext_ARB_multisample, NULL},
+ {"GLX_SGIX_pbuffer", &sfglx_ext_SGIX_pbuffer, Load_SGIX_pbuffer},
{"GLX_ARB_create_context", &sfglx_ext_ARB_create_context, Load_ARB_create_context},
- {"GLX_ARB_create_context_profile", &sfglx_ext_ARB_create_context_profile, NULL},
+ {"GLX_ARB_create_context_profile", &sfglx_ext_ARB_create_context_profile, NULL}
};
-static int g_extensionMapSize = 6;
+static int g_extensionMapSize = 9;
+
-static sfglx_StrToExtMap *FindExtEntry(const char *extensionName)
+static sfglx_StrToExtMap* FindExtEntry(const char* extensionName)
{
- int loop;
- sfglx_StrToExtMap *currLoc = ExtensionMap;
- for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
+ sfglx_StrToExtMap* currLoc = ExtensionMap;
+ for (int loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
{
- if(strcmp(extensionName, currLoc->extensionName) == 0)
+ if (std::strcmp(extensionName, currLoc->extensionName) == 0)
return currLoc;
}
return NULL;
}
+
static void ClearExtensionVars(void)
{
sfglx_ext_EXT_swap_control = sfglx_LOAD_FAILED;
sfglx_ext_MESA_swap_control = sfglx_LOAD_FAILED;
sfglx_ext_SGI_swap_control = sfglx_LOAD_FAILED;
+ sfglx_ext_EXT_framebuffer_sRGB = sfglx_LOAD_FAILED;
+ sfglx_ext_ARB_framebuffer_sRGB = sfglx_LOAD_FAILED;
sfglx_ext_ARB_multisample = sfglx_LOAD_FAILED;
+ sfglx_ext_SGIX_pbuffer = sfglx_LOAD_FAILED;
sfglx_ext_ARB_create_context = sfglx_LOAD_FAILED;
sfglx_ext_ARB_create_context_profile = sfglx_LOAD_FAILED;
}
-static void LoadExtByName(const char *extensionName)
+static void LoadExtByName(const char* extensionName)
{
- sfglx_StrToExtMap *entry = NULL;
+ sfglx_StrToExtMap* entry = NULL;
entry = FindExtEntry(extensionName);
- if(entry)
+ if (entry)
{
- if(entry->LoadExtension)
+ if (entry->LoadExtension)
{
int numFailed = entry->LoadExtension();
- if(numFailed == 0)
+ if (numFailed == 0)
{
*(entry->extensionVariable) = sfglx_LOAD_SUCCEEDED;
}
@@ -152,46 +194,25 @@ static void LoadExtByName(const char *extensionName)
}
-static void ProcExtsFromExtString(const char *strExtList)
+static void ProcExtsFromExtString(const char* strExtList)
{
- size_t iExtListLen = strlen(strExtList);
- const char *strExtListEnd = strExtList + iExtListLen;
- const char *strCurrPos = strExtList;
- char strWorkBuff[256];
-
- while(*strCurrPos)
+ do
{
- /*Get the extension at our position.*/
- int iStrLen = 0;
- const char *strEndStr = strchr(strCurrPos, ' ');
- int iStop = 0;
- if(strEndStr == NULL)
- {
- strEndStr = strExtListEnd;
- iStop = 1;
- }
-
- iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
-
- if(iStrLen > 255)
- return;
+ const char* begin = strExtList;
- strncpy(strWorkBuff, strCurrPos, iStrLen);
- strWorkBuff[iStrLen] = '\0';
+ while ((*strExtList != ' ') && *strExtList)
+ strExtList++;
- LoadExtByName(strWorkBuff);
-
- strCurrPos = strEndStr + 1;
- if(iStop) break;
- }
+ LoadExtByName(std::string(begin, strExtList).c_str());
+ } while (*strExtList++);
}
-int sfglx_LoadFunctions(Display *display, int screen)
+
+int sfglx_LoadFunctions(Display* display, int screen)
{
ClearExtensionVars();
- ProcExtsFromExtString((const char *)glXQueryExtensionsString(display, screen));
+ ProcExtsFromExtString(reinterpret_cast<const char*>(glXQueryExtensionsString(display, screen)));
return sfglx_LOAD_SUCCEEDED;
}
-
diff --git a/src/SFML/Window/Unix/GlxExtensions.hpp b/src/SFML/Window/Unix/GlxExtensions.hpp
index 9e9a749..44c9165 100644
--- a/src/SFML/Window/Unix/GlxExtensions.hpp
+++ b/src/SFML/Window/Unix/GlxExtensions.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -36,7 +36,7 @@
#include <GL/glx.h>
#ifdef CODEGEN_FUNCPTR
#undef CODEGEN_FUNCPTR
-#endif /*CODEGEN_FUNCPTR*/
+#endif // CODEGEN_FUNCPTR
#define CODEGEN_FUNCPTR
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
@@ -58,21 +58,21 @@ typedef double GLdouble;
typedef double GLclampd;
#define GLvoid void
-#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/
+#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
-#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/
+#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glext.h, so must be protected */
+// This code block is duplicated in glext.h, so must be protected
#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GLX_OML_sync_control extension). */
+// Define int32_t, int64_t, and uint64_t types for UST/MSC
+// (as used in the GLX_OML_sync_control extension).
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <inttypes.h>
#elif defined(__sun__) || defined(__digital__)
@@ -84,8 +84,8 @@ typedef unsigned long int uint64_t;
#else
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
+#endif // __arch64__
+#endif // __STDC__
#elif defined( __VMS ) || defined(__sgi)
#include <inttypes.h>
#elif defined(__SCO__) || defined(__USLC__)
@@ -101,7 +101,7 @@ typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
-/* Fallback if nothing above works */
+// Fallback if nothing above works
#include <inttypes.h>
#endif
#endif
@@ -118,42 +118,75 @@ typedef unsigned __int64 uint64_t;
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
typedef XID GLXPbufferSGIX;
typedef struct {
- char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
+ char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
int networkId;
} GLXHyperpipeNetworkSGIX;
typedef struct {
- char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
+ char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
int channel;
unsigned int participationType;
int timeSlice;
} GLXHyperpipeConfigSGIX;
typedef struct {
- char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
+ char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
int destXOrigin, destYOrigin, destWidth, destHeight;
} GLXPipeRect;
typedef struct {
- char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
+ char pipeName[80]; // Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]
int XOrigin, YOrigin, maxHeight, maxWidth;
} GLXPipeRectLimits;
#ifdef __cplusplus
extern "C" {
-#endif /*__cplusplus*/
+#endif // __cplusplus
extern int sfglx_ext_EXT_swap_control;
extern int sfglx_ext_MESA_swap_control;
extern int sfglx_ext_SGI_swap_control;
+extern int sfglx_ext_EXT_framebuffer_sRGB;
+extern int sfglx_ext_ARB_framebuffer_sRGB;
extern int sfglx_ext_ARB_multisample;
+extern int sfglx_ext_SGIX_pbuffer;
extern int sfglx_ext_ARB_create_context;
extern int sfglx_ext_ARB_create_context_profile;
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
#define GLX_SWAP_INTERVAL_EXT 0x20F1
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2
+
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
+
#define GLX_SAMPLES_ARB 100001
#define GLX_SAMPLE_BUFFERS_ARB 100000
+#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080
+#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
+#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
+#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000
+#define GLX_DAMAGED_SGIX 0x8020
+#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
+#define GLX_EVENT_MASK_SGIX 0x801F
+#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
+#define GLX_HEIGHT_SGIX 0x801E
+#define GLX_LARGEST_PBUFFER_SGIX 0x801C
+#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017
+#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018
+#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016
+#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
+#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
+#define GLX_PBUFFER_BIT_SGIX 0x00000004
+#define GLX_PBUFFER_SGIX 0x8023
+#define GLX_PRESERVED_CONTENTS_SGIX 0x801B
+#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100
+#define GLX_SAVED_SGIX 0x8021
+#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040
+#define GLX_WIDTH_SGIX 0x801D
+#define GLX_WINDOW_SGIX 0x8022
+
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define GLX_CONTEXT_FLAGS_ARB 0x2094
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
@@ -168,7 +201,7 @@ extern int sfglx_ext_ARB_create_context_profile;
#define GLX_EXT_swap_control 1
extern void (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalEXT)(Display *, GLXDrawable, int);
#define glXSwapIntervalEXT sf_ptrc_glXSwapIntervalEXT
-#endif /*GLX_EXT_swap_control*/
+#endif // GLX_EXT_swap_control
// Declare entry point even if GLX header already provides glXSwapIntervalMESA
// We won't make use of an alias here
@@ -178,13 +211,27 @@ extern int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalMESA)(int);
#define GLX_SGI_swap_control 1
extern int (CODEGEN_FUNCPTR *sf_ptrc_glXSwapIntervalSGI)(int);
#define glXSwapIntervalSGI sf_ptrc_glXSwapIntervalSGI
-#endif /*GLX_SGI_swap_control*/
+#endif // GLX_SGI_swap_control
+
+#ifndef GLX_SGIX_pbuffer
+#define GLX_SGIX_pbuffer 1
+extern GLXPbufferSGIX (CODEGEN_FUNCPTR *sf_ptrc_glXCreateGLXPbufferSGIX)(Display*, GLXFBConfigSGIX, unsigned int, unsigned int, int*);
+#define glXCreateGLXPbufferSGIX sf_ptrc_glXCreateGLXPbufferSGIX
+extern void (CODEGEN_FUNCPTR *sf_ptrc_glXDestroyGLXPbufferSGIX)(Display*, GLXPbufferSGIX);
+#define glXDestroyGLXPbufferSGIX sf_ptrc_glXDestroyGLXPbufferSGIX
+extern void (CODEGEN_FUNCPTR *sf_ptrc_glXGetSelectedEventSGIX)(Display*, GLXDrawable, unsigned long*);
+#define glXGetSelectedEventSGIX sf_ptrc_glXGetSelectedEventSGIX
+extern int (CODEGEN_FUNCPTR *sf_ptrc_glXQueryGLXPbufferSGIX)(Display*, GLXPbufferSGIX, int, unsigned int*);
+#define glXQueryGLXPbufferSGIX sf_ptrc_glXQueryGLXPbufferSGIX
+extern void (CODEGEN_FUNCPTR *sf_ptrc_glXSelectEventSGIX)(Display*, GLXDrawable, unsigned long);
+#define glXSelectEventSGIX sf_ptrc_glXSelectEventSGIX
+#endif // GLX_SGIX_pbuffer
#ifndef GLX_ARB_create_context
#define GLX_ARB_create_context 1
-extern GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *);
+extern GLXContext (CODEGEN_FUNCPTR *sf_ptrc_glXCreateContextAttribsARB)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
#define glXCreateContextAttribsARB sf_ptrc_glXCreateContextAttribsARB
-#endif /*GLX_ARB_create_context*/
+#endif // GLX_ARB_create_context
enum sfglx_LoadStatus
@@ -198,6 +245,6 @@ int sfglx_LoadFunctions(Display *display, int screen);
#ifdef __cplusplus
}
-#endif /*__cplusplus*/
+#endif // __cplusplus
-#endif /* SF_POINTER_C_GENERATED_HEADER_GLXWIN_HPP */
+#endif // SF_POINTER_C_GENERATED_HEADER_GLXWIN_HPP
diff --git a/src/SFML/Window/Unix/GlxExtensions.txt b/src/SFML/Window/Unix/GlxExtensions.txt
index b6b06fa..9c8a641 100644
--- a/src/SFML/Window/Unix/GlxExtensions.txt
+++ b/src/SFML/Window/Unix/GlxExtensions.txt
@@ -1,11 +1,14 @@
// Created with:
-// https://bitbucket.org/Anteru/glloadgen-reloaded
-// Commit 20f19482b7a844d20b9785c3e3fd1f16419f6e0a
+// https://bitbucket.org/KhronosGroup/glloadgen
+// Commit d143d66ac90d538ed06f806188714861b8e8e2f9
// lua LoadGen.lua -style=pointer_c -spec=glX -indent=space -prefix=sf -extfile=GlxExtensions.txt GlxExtensions
EXT_swap_control
// MESA_swap_control
SGI_swap_control
+EXT_framebuffer_sRGB
+ARB_framebuffer_sRGB
GLX_ARB_multisample
+GLX_SGIX_pbuffer
GLX_ARB_create_context
-GLX_ARB_create_context_profile \ No newline at end of file
+GLX_ARB_create_context_profile
diff --git a/src/SFML/Window/Unix/InputImpl.cpp b/src/SFML/Window/Unix/InputImpl.cpp
index 53d92be..ad62cd5 100644
--- a/src/SFML/Window/Unix/InputImpl.cpp
+++ b/src/SFML/Window/Unix/InputImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/InputImpl.hpp b/src/SFML/Window/Unix/InputImpl.hpp
index 9425c3d..f61647d 100644
--- a/src/SFML/Window/Unix/InputImpl.hpp
+++ b/src/SFML/Window/Unix/InputImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/JoystickImpl.cpp b/src/SFML/Window/Unix/JoystickImpl.cpp
index d60075d..903d588 100644
--- a/src/SFML/Window/Unix/JoystickImpl.cpp
+++ b/src/SFML/Window/Unix/JoystickImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -440,6 +440,14 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
+JoystickImpl::JoystickImpl() :
+m_file(-1)
+{
+ std::fill(m_mapping, m_mapping + ABS_MAX + 1, 0);
+}
+
+
+////////////////////////////////////////////////////////////
void JoystickImpl::initialize()
{
udevContext = udev_new();
@@ -650,19 +658,23 @@ JoystickState JoystickImpl::JoystickImpl::update()
case JS_EVENT_AXIS:
{
float value = joyState.value * 100.f / 32767.f;
- switch (m_mapping[joyState.number])
+
+ if (joyState.number < ABS_MAX + 1)
{
- case ABS_X: m_state.axes[Joystick::X] = value; break;
- case ABS_Y: m_state.axes[Joystick::Y] = value; break;
- case ABS_Z:
- case ABS_THROTTLE: m_state.axes[Joystick::Z] = value; break;
- case ABS_RZ:
- case ABS_RUDDER: m_state.axes[Joystick::R] = value; break;
- case ABS_RX: m_state.axes[Joystick::U] = value; break;
- case ABS_RY: m_state.axes[Joystick::V] = value; break;
- case ABS_HAT0X: m_state.axes[Joystick::PovX] = value; break;
- case ABS_HAT0Y: m_state.axes[Joystick::PovY] = value; break;
- default: break;
+ switch (m_mapping[joyState.number])
+ {
+ case ABS_X: m_state.axes[Joystick::X] = value; break;
+ case ABS_Y: m_state.axes[Joystick::Y] = value; break;
+ case ABS_Z:
+ case ABS_THROTTLE: m_state.axes[Joystick::Z] = value; break;
+ case ABS_RZ:
+ case ABS_RUDDER: m_state.axes[Joystick::R] = value; break;
+ case ABS_RX: m_state.axes[Joystick::U] = value; break;
+ case ABS_RY: m_state.axes[Joystick::V] = value; break;
+ case ABS_HAT0X: m_state.axes[Joystick::PovX] = value; break;
+ case ABS_HAT0Y: m_state.axes[Joystick::PovY] = value; break;
+ default: break;
+ }
}
break;
}
diff --git a/src/SFML/Window/Unix/JoystickImpl.hpp b/src/SFML/Window/Unix/JoystickImpl.hpp
index 34fce2e..e454b03 100644
--- a/src/SFML/Window/Unix/JoystickImpl.hpp
+++ b/src/SFML/Window/Unix/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -45,6 +45,12 @@ class JoystickImpl
public:
////////////////////////////////////////////////////////////
+ /// \brief Constructor
+ ///
+ ////////////////////////////////////////////////////////////
+ JoystickImpl();
+
+ ////////////////////////////////////////////////////////////
/// \brief Perform the global initialization of the joystick module
///
////////////////////////////////////////////////////////////
diff --git a/src/SFML/Window/Unix/ScopedXcbPtr.hpp b/src/SFML/Window/Unix/ScopedXcbPtr.hpp
index 6c98065..f610d81 100644
--- a/src/SFML/Window/Unix/ScopedXcbPtr.hpp
+++ b/src/SFML/Window/Unix/ScopedXcbPtr.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/ScopedXcbPtr.inl b/src/SFML/Window/Unix/ScopedXcbPtr.inl
index 6683a1e..5869d91 100644
--- a/src/SFML/Window/Unix/ScopedXcbPtr.inl
+++ b/src/SFML/Window/Unix/ScopedXcbPtr.inl
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/SensorImpl.cpp b/src/SFML/Window/Unix/SensorImpl.cpp
index 144c6d7..fb8fce1 100644
--- a/src/SFML/Window/Unix/SensorImpl.cpp
+++ b/src/SFML/Window/Unix/SensorImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/SensorImpl.hpp b/src/SFML/Window/Unix/SensorImpl.hpp
index 49ced87..7006377 100644
--- a/src/SFML/Window/Unix/SensorImpl.hpp
+++ b/src/SFML/Window/Unix/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/VideoModeImpl.cpp b/src/SFML/Window/Unix/VideoModeImpl.cpp
index 9ee812f..f95d323 100644
--- a/src/SFML/Window/Unix/VideoModeImpl.cpp
+++ b/src/SFML/Window/Unix/VideoModeImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp
index 7aaf4e4..88176bf 100644
--- a/src/SFML/Window/Unix/WindowImplX11.cpp
+++ b/src/SFML/Window/Unix/WindowImplX11.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -34,6 +34,7 @@
#include <SFML/System/Err.hpp>
#include <SFML/System/Mutex.hpp>
#include <SFML/System/Lock.hpp>
+#include <SFML/System/Sleep.hpp>
#include <xcb/xcb_image.h>
#include <xcb/randr.h>
#include <X11/Xlibint.h>
@@ -69,7 +70,10 @@ namespace
XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_MOTION |
XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
- XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW;
+ XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
+ XCB_EVENT_MASK_VISIBILITY_CHANGE;
+
+ static const unsigned int maxTrialsCount = 5;
// Filter the events received by windows (only allow those matching a specific window)
Bool checkEvent(::Display*, XEvent* event, XPointer userData)
@@ -358,6 +362,7 @@ namespace priv
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(WindowHandle handle) :
m_window (0),
+m_screen (NULL),
m_inputMethod (NULL),
m_inputContext (NULL),
m_isExternal (true),
@@ -365,7 +370,9 @@ m_hiddenCursor (0),
m_keyRepeat (true),
m_previousSize (-1, -1),
m_useSizeHints (false),
-m_fullscreen (false)
+m_fullscreen (false),
+m_cursorGrabbed (false),
+m_windowMapped (false)
{
// Open a connection with the X server
m_display = OpenDisplay();
@@ -411,6 +418,7 @@ m_fullscreen (false)
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings) :
m_window (0),
+m_screen (NULL),
m_inputMethod (NULL),
m_inputContext (NULL),
m_isExternal (false),
@@ -418,7 +426,9 @@ m_hiddenCursor (0),
m_keyRepeat (true),
m_previousSize (-1, -1),
m_useSizeHints (false),
-m_fullscreen ((style & Style::Fullscreen) != 0)
+m_fullscreen ((style & Style::Fullscreen) != 0),
+m_cursorGrabbed (m_fullscreen),
+m_windowMapped (false)
{
// Open a connection with the X server
m_display = OpenDisplay();
@@ -732,7 +742,7 @@ void WindowImplX11::setTitle(const String& title)
err() << "Failed to set _NET_WM_NAME property" << std::endl;
}
- if (utf8StringType && netWmName)
+ if (utf8StringType && netWmIconName)
{
if (!changeWindowProperty(netWmIconName, utf8StringType, 8, utf8String.length(), utf8String.c_str()))
err() << "Failed to set _NET_WM_ICON_NAME property" << std::endl;
@@ -909,6 +919,13 @@ void WindowImplX11::setVisible(bool visible)
if (error)
err() << "Failed to change window visibility" << std::endl;
+
+ xcb_flush(m_connection);
+
+ // Before continuing, make sure the WM has
+ // internally marked the window as viewable
+ while (!m_windowMapped)
+ processEvents();
}
else
{
@@ -922,9 +939,14 @@ void WindowImplX11::setVisible(bool visible)
if (error)
err() << "Failed to change window visibility" << std::endl;
- }
- xcb_flush(m_connection);
+ xcb_flush(m_connection);
+
+ // Before continuing, make sure the WM has
+ // internally marked the window as unviewable
+ while (m_windowMapped)
+ processEvents();
+ }
}
@@ -951,6 +973,71 @@ void WindowImplX11::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void WindowImplX11::setMouseCursorGrabbed(bool grabbed)
+{
+ // This has no effect in fullscreen mode
+ if (m_fullscreen || (m_cursorGrabbed == grabbed))
+ return;
+
+ if (grabbed)
+ {
+ // Try multiple times to grab the cursor
+ for (unsigned int trial = 0; trial < maxTrialsCount; ++trial)
+ {
+ sf::priv::ScopedXcbPtr<xcb_generic_error_t> error(NULL);
+
+ sf::priv::ScopedXcbPtr<xcb_grab_pointer_reply_t> grabPointerReply(xcb_grab_pointer_reply(
+ m_connection,
+ xcb_grab_pointer(
+ m_connection,
+ true,
+ m_window,
+ XCB_NONE,
+ XCB_GRAB_MODE_ASYNC,
+ XCB_GRAB_MODE_ASYNC,
+ m_window,
+ XCB_NONE,
+ XCB_CURRENT_TIME
+ ),
+ &error
+ ));
+
+ if (!error && grabPointerReply && (grabPointerReply->status == XCB_GRAB_STATUS_SUCCESS))
+ {
+ m_cursorGrabbed = true;
+ break;
+ }
+
+ // The cursor grab failed, trying again after a small sleep
+ sf::sleep(sf::milliseconds(50));
+ }
+
+ if (!m_cursorGrabbed)
+ err() << "Failed to grab mouse cursor" << std::endl;
+ }
+ else
+ {
+ ScopedXcbPtr<xcb_generic_error_t> error(xcb_request_check(
+ m_connection,
+ xcb_ungrab_pointer_checked(
+ m_connection,
+ XCB_CURRENT_TIME
+ )
+ ));
+
+ if (!error)
+ {
+ m_cursorGrabbed = false;
+ }
+ else
+ {
+ err() << "Failed to ungrab mouse cursor" << std::endl;
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplX11::setKeyRepeatEnabled(bool enabled)
{
m_keyRepeat = enabled;
@@ -1604,7 +1691,7 @@ void WindowImplX11::cleanup()
////////////////////////////////////////////////////////////
-bool WindowImplX11::processEvent(XEvent windowEvent)
+bool WindowImplX11::processEvent(XEvent& windowEvent)
{
// This function implements a workaround to properly discard
// repeated key events when necessary. The problem is that the
@@ -1659,6 +1746,44 @@ bool WindowImplX11::processEvent(XEvent windowEvent)
if (m_inputContext)
XSetICFocus(m_inputContext);
+ // Grab cursor
+ if (m_cursorGrabbed)
+ {
+ // Try multiple times to grab the cursor
+ for (unsigned int trial = 0; trial < maxTrialsCount; ++trial)
+ {
+ sf::priv::ScopedXcbPtr<xcb_generic_error_t> error(NULL);
+
+ sf::priv::ScopedXcbPtr<xcb_grab_pointer_reply_t> grabPointerReply(xcb_grab_pointer_reply(
+ m_connection,
+ xcb_grab_pointer(
+ m_connection,
+ true,
+ m_window,
+ XCB_NONE,
+ XCB_GRAB_MODE_ASYNC,
+ XCB_GRAB_MODE_ASYNC,
+ m_window,
+ XCB_NONE,
+ XCB_CURRENT_TIME
+ ),
+ &error
+ ));
+
+ if (!error && grabPointerReply && (grabPointerReply->status == XCB_GRAB_STATUS_SUCCESS))
+ {
+ m_cursorGrabbed = true;
+ break;
+ }
+
+ // The cursor grab failed, trying again after a small sleep
+ sf::sleep(sf::milliseconds(50));
+ }
+
+ if (!m_cursorGrabbed)
+ err() << "Failed to grab mouse cursor" << std::endl;
+ }
+
Event event;
event.type = Event::GainedFocus;
pushEvent(event);
@@ -1701,6 +1826,21 @@ bool WindowImplX11::processEvent(XEvent windowEvent)
if (m_inputContext)
XUnsetICFocus(m_inputContext);
+ // Release cursor
+ if (m_cursorGrabbed)
+ {
+ ScopedXcbPtr<xcb_generic_error_t> error(xcb_request_check(
+ m_connection,
+ xcb_ungrab_pointer_checked(
+ m_connection,
+ XCB_CURRENT_TIME
+ )
+ ));
+
+ if (error)
+ err() << "Failed to ungrab mouse cursor" << std::endl;
+ }
+
Event event;
event.type = Event::LostFocus;
pushEvent(event);
@@ -1757,17 +1897,23 @@ bool WindowImplX11::processEvent(XEvent windowEvent)
// Key down event
case KeyPress:
{
- // Get the keysym of the key that has been pressed
- static XComposeStatus keyboard;
- char buffer[32];
- KeySym symbol;
- XLookupString(&windowEvent.xkey, buffer, sizeof(buffer), &symbol, &keyboard);
+ Keyboard::Key key = Keyboard::Unknown;
+
+ // Try each KeySym index (modifier group) until we get a match
+ for (int i = 0; i < 4; ++i)
+ {
+ // Get the SFML keyboard code from the keysym of the key that has been pressed
+ key = keysymToSF(XLookupKeysym(&windowEvent.xkey, i));
+
+ if (key != Keyboard::Unknown)
+ break;
+ }
// Fill the event parameters
// TODO: if modifiers are wrong, use XGetModifierMapping to retrieve the actual modifiers mapping
Event event;
event.type = Event::KeyPressed;
- event.key.code = keysymToSF(symbol);
+ event.key.code = key;
event.key.alt = windowEvent.xkey.state & Mod1Mask;
event.key.control = windowEvent.xkey.state & ControlMask;
event.key.shift = windowEvent.xkey.state & ShiftMask;
@@ -1826,15 +1972,22 @@ bool WindowImplX11::processEvent(XEvent windowEvent)
// Key up event
case KeyRelease:
{
- // Get the keysym of the key that has been pressed
- char buffer[32];
- KeySym symbol;
- XLookupString(&windowEvent.xkey, buffer, 32, &symbol, NULL);
+ Keyboard::Key key = Keyboard::Unknown;
+
+ // Try each KeySym index (modifier group) until we get a match
+ for (int i = 0; i < 4; ++i)
+ {
+ // Get the SFML keyboard code from the keysym of the key that has been released
+ key = keysymToSF(XLookupKeysym(&windowEvent.xkey, i));
+
+ if (key != Keyboard::Unknown)
+ break;
+ }
// Fill the event parameters
Event event;
event.type = Event::KeyReleased;
- event.key.code = keysymToSF(symbol);
+ event.key.code = key;
event.key.alt = windowEvent.xkey.state & Mod1Mask;
event.key.control = windowEvent.xkey.state & ControlMask;
event.key.shift = windowEvent.xkey.state & ShiftMask;
@@ -1962,16 +2115,33 @@ bool WindowImplX11::processEvent(XEvent windowEvent)
break;
}
- // Parent window changed
- case ReparentNotify:
+ // Window unmapped
+ case UnmapNotify:
{
- // Catch reparent events to properly apply fullscreen on
- // some "strange" window managers (like Awesome) which
- // seem to make use of temporary parents during mapping
- if (m_fullscreen)
- switchToFullscreen();
+ if (windowEvent.xunmap.window == m_window)
+ m_windowMapped = false;
+
+ break;
+ }
+
+ // Window visibility change
+ case VisibilityNotify:
+ {
+ // We prefer using VisibilityNotify over MapNotify because
+ // some window managers like awesome don't internally flag a
+ // window as viewable even after it is mapped but before it
+ // is visible leading to certain function calls failing with
+ // an unviewable error if called before VisibilityNotify arrives
+
+ // Empirical testing on most widely used window managers shows
+ // that mapping a window will always lead to a VisibilityNotify
+ // event that is not VisibilityFullyObscured
+ if (windowEvent.xvisibility.window == m_window)
+ {
+ if (windowEvent.xvisibility.state != VisibilityFullyObscured)
+ m_windowMapped = true;
+ }
- XSync(m_display, True); // Discard remaining events
break;
}
}
diff --git a/src/SFML/Window/Unix/WindowImplX11.hpp b/src/SFML/Window/Unix/WindowImplX11.hpp
index a717bfb..ea6f741 100644
--- a/src/SFML/Window/Unix/WindowImplX11.hpp
+++ b/src/SFML/Window/Unix/WindowImplX11.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -148,6 +148,14 @@ public:
virtual void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
@@ -301,7 +309,7 @@ private:
/// \return True if the event was processed, false if it was discarded
///
////////////////////////////////////////////////////////////
- bool processEvent(XEvent windowEvent);
+ bool processEvent(XEvent& windowEvent);
////////////////////////////////////////////////////////////
// Member data
@@ -318,7 +326,9 @@ private:
bool m_keyRepeat; ///< Is the KeyRepeat feature enabled?
Vector2i m_previousSize; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only)
bool m_useSizeHints; ///< Is the size of the window fixed with size hints?
- bool m_fullscreen; ///< Is window in fullscreen?
+ bool m_fullscreen; ///< Is the window in fullscreen?
+ bool m_cursorGrabbed; ///< Is the mouse cursor trapped?
+ bool m_windowMapped; ///< Has the window been mapped by the window manager?
};
} // namespace priv
diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp
index 8f3861d..2202d77 100644
--- a/src/SFML/Window/VideoMode.cpp
+++ b/src/SFML/Window/VideoMode.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/VideoModeImpl.hpp b/src/SFML/Window/VideoModeImpl.hpp
index cc992f9..f1a1b03 100644
--- a/src/SFML/Window/VideoModeImpl.hpp
+++ b/src/SFML/Window/VideoModeImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/InputImpl.cpp b/src/SFML/Window/Win32/InputImpl.cpp
index 6b1a472..8be35ec 100644
--- a/src/SFML/Window/Win32/InputImpl.cpp
+++ b/src/SFML/Window/Win32/InputImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/InputImpl.hpp b/src/SFML/Window/Win32/InputImpl.hpp
index 9f455f4..598ef62 100644
--- a/src/SFML/Window/Win32/InputImpl.hpp
+++ b/src/SFML/Window/Win32/InputImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/JoystickImpl.cpp b/src/SFML/Window/Win32/JoystickImpl.cpp
index ab40d5f..50cc819 100644
--- a/src/SFML/Window/Win32/JoystickImpl.cpp
+++ b/src/SFML/Window/Win32/JoystickImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/JoystickImpl.hpp b/src/SFML/Window/Win32/JoystickImpl.hpp
index ab0a724..591b0e8 100644
--- a/src/SFML/Window/Win32/JoystickImpl.hpp
+++ b/src/SFML/Window/Win32/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/SensorImpl.cpp b/src/SFML/Window/Win32/SensorImpl.cpp
index 144c6d7..fb8fce1 100644
--- a/src/SFML/Window/Win32/SensorImpl.cpp
+++ b/src/SFML/Window/Win32/SensorImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/SensorImpl.hpp b/src/SFML/Window/Win32/SensorImpl.hpp
index 666e5d2..8bea45b 100644
--- a/src/SFML/Window/Win32/SensorImpl.hpp
+++ b/src/SFML/Window/Win32/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/VideoModeImpl.cpp b/src/SFML/Window/Win32/VideoModeImpl.cpp
index 4b34a0f..90f522f 100644
--- a/src/SFML/Window/Win32/VideoModeImpl.cpp
+++ b/src/SFML/Window/Win32/VideoModeImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp
index c4e8b93..486946f 100644
--- a/src/SFML/Window/Win32/WglContext.cpp
+++ b/src/SFML/Window/Win32/WglContext.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -26,12 +26,13 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/WindowImpl.hpp> // included first to avoid a warning about macro redefinition
+#include <SFML/OpenGL.hpp> // included second to avoid an error in WglExtensions.hpp
#include <SFML/Window/Win32/WglContext.hpp>
-#include <SFML/Window/Win32/WglExtensions.hpp>
#include <SFML/System/Lock.hpp>
#include <SFML/System/Mutex.hpp>
#include <SFML/System/Err.hpp>
#include <sstream>
+#include <vector>
namespace sf
@@ -69,62 +70,75 @@ String getErrorString(DWORD errorCode)
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared) :
m_window (NULL),
+m_pbuffer (NULL),
m_deviceContext(NULL),
m_context (NULL),
-m_ownsWindow (true)
+m_ownsWindow (false)
{
- // Creating a dummy window is mandatory: we could create a memory DC but then
- // its pixel format wouldn't match the regular contexts' format, and thus
- // wglShareLists would always fail. Too bad...
+ // Save the creation settings
+ m_settings = ContextSettings();
+
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_deviceContext)
+ ensureExtensionsInit(shared->m_deviceContext);
- // Create a dummy window (disabled and hidden)
- m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
- ShowWindow(m_window, SW_HIDE);
- m_deviceContext = GetDC(m_window);
+ // Create the rendering surface (window or pbuffer if supported)
+ createSurface(shared, 1, 1, VideoMode::getDesktopMode().bitsPerPixel);
// Create the context
if (m_deviceContext)
- createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
+ createContext(shared);
}
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) :
m_window (NULL),
+m_pbuffer (NULL),
m_deviceContext(NULL),
m_context (NULL),
m_ownsWindow (false)
{
- // Get the owner window and its device context
- m_window = owner->getSystemHandle();
- m_deviceContext = GetDC(m_window);
+ // Save the creation settings
+ m_settings = settings;
+
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_deviceContext)
+ ensureExtensionsInit(shared->m_deviceContext);
+
+ // Create the rendering surface from the owner window
+ createSurface(owner->getSystemHandle(), bitsPerPixel);
// Create the context
if (m_deviceContext)
- createContext(shared, bitsPerPixel, settings);
+ createContext(shared);
}
////////////////////////////////////////////////////////////
WglContext::WglContext(WglContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) :
m_window (NULL),
+m_pbuffer (NULL),
m_deviceContext(NULL),
m_context (NULL),
-m_ownsWindow (true)
+m_ownsWindow (false)
{
- // The target of the context is a hidden window.
- // We can't create a memory DC (the resulting context wouldn't be compatible
- // with other contexts), and we don't add the extra complexity of P-Buffers;
- // we can still support them in the future if this solution is not good enough.
+ // Save the creation settings
+ m_settings = settings;
+
+ // Make sure that extensions are initialized if this is not the shared context
+ // The shared context is the context used to initialize the extensions
+ if (shared && shared->m_deviceContext)
+ ensureExtensionsInit(shared->m_deviceContext);
- // Create the hidden window
- m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
- ShowWindow(m_window, SW_HIDE);
- m_deviceContext = GetDC(m_window);
+ // Create the rendering surface (window or pbuffer if supported)
+ createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel);
// Create the context
if (m_deviceContext)
- createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, settings);
+ createContext(shared);
}
@@ -141,7 +155,17 @@ WglContext::~WglContext()
// Destroy the device context
if (m_deviceContext)
- ReleaseDC(m_window, m_deviceContext);
+ {
+ if (m_pbuffer)
+ {
+ wglReleasePbufferDCARB(m_pbuffer, m_deviceContext);
+ wglDestroyPbufferARB(m_pbuffer);
+ }
+ else
+ {
+ ReleaseDC(m_window, m_deviceContext);
+ }
+ }
// Destroy the window if we own it
if (m_window && m_ownsWindow)
@@ -217,7 +241,7 @@ void WglContext::setVerticalSyncEnabled(bool enabled)
////////////////////////////////////////////////////////////
-int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings)
+int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer)
{
// Let's find a suitable pixel format -- first try with wglChoosePixelFormatARB
int bestFormat = 0;
@@ -279,9 +303,40 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
}
}
+ int sRgbCapableValue = 0;
+ if ((sfwgl_ext_ARB_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED) || (sfwgl_ext_EXT_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED))
+ {
+ const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
+
+ if (!wglGetPixelFormatAttribivARB(deviceContext, formats[i], PFD_MAIN_PLANE, 1, &sRgbCapableAttribute, &sRgbCapableValue))
+ {
+ err() << "Failed to retrieve pixel format sRGB capability information: " << getErrorString(GetLastError()).toAnsiString() << std::endl;
+ break;
+ }
+ }
+
+ if (pbuffer)
+ {
+ const int pbufferAttributes[] =
+ {
+ WGL_DRAW_TO_PBUFFER_ARB
+ };
+
+ int pbufferValue = 0;
+
+ if (!wglGetPixelFormatAttribivARB(deviceContext, formats[i], PFD_MAIN_PLANE, 1, pbufferAttributes, &pbufferValue))
+ {
+ err() << "Failed to retrieve pixel format pbuffer information: " << getErrorString(GetLastError()).toAnsiString() << std::endl;
+ break;
+ }
+
+ if (pbufferValue != GL_TRUE)
+ continue;
+ }
+
// Evaluate the current configuration
int color = values[0] + values[1] + values[2] + values[3];
- int score = evaluateFormat(bitsPerPixel, settings, color, values[4], values[5], sampleValues[0] ? sampleValues[1] : 0, values[6] == WGL_FULL_ACCELERATION_ARB);
+ int score = evaluateFormat(bitsPerPixel, settings, color, values[4], values[5], sampleValues[0] ? sampleValues[1] : 0, values[6] == WGL_FULL_ACCELERATION_ARB, sRgbCapableValue == TRUE);
// Keep it if it's better than the current best
if (score < bestScore)
@@ -293,6 +348,10 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
}
}
+ // ChoosePixelFormat doesn't support pbuffers
+ if (pbuffer)
+ return bestFormat;
+
// Find a pixel format with ChoosePixelFormat, if wglChoosePixelFormatARB is not supported
if (bestFormat == 0)
{
@@ -318,17 +377,9 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix
////////////////////////////////////////////////////////////
-void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
+void WglContext::setDevicePixelFormat(unsigned int bitsPerPixel)
{
- // Save the creation settings
- m_settings = settings;
-
- // Make sure that extensions are initialized if this is not the shared context
- // The shared context is the context used to initialize the extensions
- if (shared)
- ensureExtensionsInit(m_deviceContext);
-
- int bestFormat = selectBestPixelFormat(m_deviceContext, bitsPerPixel, settings);
+ int bestFormat = selectBestPixelFormat(m_deviceContext, bitsPerPixel, m_settings);
if (bestFormat == 0)
{
@@ -343,12 +394,38 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
actualFormat.nVersion = 1;
DescribePixelFormat(m_deviceContext, bestFormat, sizeof(actualFormat), &actualFormat);
+ // Set the chosen pixel format
+ if (!SetPixelFormat(m_deviceContext, bestFormat, &actualFormat))
+ {
+ err() << "Failed to set pixel format for device context: " << getErrorString(GetLastError()).toAnsiString() << std::endl
+ << "Cannot create OpenGL context" << std::endl;
+ return;
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+void WglContext::updateSettingsFromPixelFormat()
+{
+ int format = GetPixelFormat(m_deviceContext);
+
+ PIXELFORMATDESCRIPTOR actualFormat;
+ actualFormat.nSize = sizeof(actualFormat);
+ actualFormat.nVersion = 1;
+ DescribePixelFormat(m_deviceContext, format, sizeof(actualFormat), &actualFormat);
+
+ if (format == 0)
+ {
+ err() << "Failed to get selected pixel format" << std::endl;
+ return;
+ }
+
if (sfwgl_ext_ARB_pixel_format == sfwgl_LOAD_SUCCEEDED)
{
const int attributes[] = {WGL_DEPTH_BITS_ARB, WGL_STENCIL_BITS_ARB};
int values[2];
- if (wglGetPixelFormatAttribivARB(m_deviceContext, bestFormat, PFD_MAIN_PLANE, 2, attributes, values))
+ if (wglGetPixelFormatAttribivARB(m_deviceContext, format, PFD_MAIN_PLANE, 2, attributes, values))
{
m_settings.depthBits = values[0];
m_settings.stencilBits = values[1];
@@ -365,7 +442,7 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
const int sampleAttributes[] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB};
int sampleValues[2];
- if (wglGetPixelFormatAttribivARB(m_deviceContext, bestFormat, PFD_MAIN_PLANE, 2, sampleAttributes, sampleValues))
+ if (wglGetPixelFormatAttribivARB(m_deviceContext, format, PFD_MAIN_PLANE, 2, sampleAttributes, sampleValues))
{
m_settings.antialiasingLevel = sampleValues[0] ? sampleValues[1] : 0;
}
@@ -379,6 +456,26 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
{
m_settings.antialiasingLevel = 0;
}
+
+ if ((sfwgl_ext_ARB_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED) || (sfwgl_ext_EXT_framebuffer_sRGB == sfwgl_LOAD_SUCCEEDED))
+ {
+ const int sRgbCapableAttribute = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
+ int sRgbCapableValue = 0;
+
+ if (wglGetPixelFormatAttribivARB(m_deviceContext, format, PFD_MAIN_PLANE, 1, &sRgbCapableAttribute, &sRgbCapableValue))
+ {
+ m_settings.sRgbCapable = (sRgbCapableValue == TRUE);
+ }
+ else
+ {
+ err() << "Failed to retrieve pixel format sRGB capability information: " << getErrorString(GetLastError()).toAnsiString() << std::endl;
+ m_settings.sRgbCapable = false;
+ }
+ }
+ else
+ {
+ m_settings.sRgbCapable = false;
+ }
}
else
{
@@ -386,15 +483,79 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
m_settings.stencilBits = actualFormat.cStencilBits;
m_settings.antialiasingLevel = 0;
}
+}
- // Set the chosen pixel format
- if (!SetPixelFormat(m_deviceContext, bestFormat, &actualFormat))
+
+////////////////////////////////////////////////////////////
+void WglContext::createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
+{
+ // Check if the shared context already exists and pbuffers are supported
+ if (shared && shared->m_deviceContext && (sfwgl_ext_ARB_pbuffer == sfwgl_LOAD_SUCCEEDED))
{
- err() << "Failed to set pixel format for device context: " << getErrorString(GetLastError()).toAnsiString() << std::endl
- << "Cannot create OpenGL context" << std::endl;
- return;
+ int bestFormat = selectBestPixelFormat(shared->m_deviceContext, bitsPerPixel, m_settings, true);
+
+ if (bestFormat > 0)
+ {
+ int attributes[] = {0, 0};
+
+ m_pbuffer = wglCreatePbufferARB(shared->m_deviceContext, bestFormat, width, height, attributes);
+
+ if (m_pbuffer)
+ {
+ m_window = shared->m_window;
+ m_deviceContext = wglGetPbufferDCARB(m_pbuffer);
+
+ if (!m_deviceContext)
+ {
+ wglDestroyPbufferARB(m_pbuffer);
+ m_pbuffer = NULL;
+ }
+ }
+ }
+ }
+
+ // If pbuffers are not available we use a hidden window as the off-screen surface to draw to
+ if (!m_deviceContext)
+ {
+ // We can't create a memory DC, the resulting context wouldn't be compatible
+ // with other contexts and thus wglShareLists would always fail
+
+ // Create the hidden window
+ m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, width, height, NULL, NULL, GetModuleHandle(NULL), NULL);
+ ShowWindow(m_window, SW_HIDE);
+ m_deviceContext = GetDC(m_window);
+
+ m_ownsWindow = true;
+
+ // Set the pixel format of the device context
+ setDevicePixelFormat(bitsPerPixel);
}
+ // Update context settings from the selected pixel format
+ updateSettingsFromPixelFormat();
+}
+
+
+////////////////////////////////////////////////////////////
+void WglContext::createSurface(HWND window, unsigned int bitsPerPixel)
+{
+ m_window = window;
+ m_deviceContext = GetDC(window);
+
+ // Set the pixel format of the device context
+ setDevicePixelFormat(bitsPerPixel);
+
+ // Update context settings from the selected pixel format
+ updateSettingsFromPixelFormat();
+}
+
+
+////////////////////////////////////////////////////////////
+void WglContext::createContext(WglContext* shared)
+{
+ // Get a working copy of the context settings
+ ContextSettings settings = m_settings;
+
// Get the context to share display lists with
HGLRC sharedContext = shared ? shared->m_context : NULL;
@@ -403,21 +564,27 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
{
if (sfwgl_ext_ARB_create_context == sfwgl_LOAD_SUCCEEDED)
{
+ std::vector<int> attributes;
+
+ // Check if the user requested a specific context version (anything > 1.1)
+ if ((m_settings.majorVersion > 1) || ((m_settings.majorVersion == 1) && (m_settings.minorVersion > 1)))
+ {
+ attributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
+ attributes.push_back(m_settings.majorVersion);
+ attributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
+ attributes.push_back(m_settings.minorVersion);
+ }
+
// Check if setting the profile is supported
if (sfwgl_ext_ARB_create_context_profile == sfwgl_LOAD_SUCCEEDED)
{
int profile = (m_settings.attributeFlags & ContextSettings::Core) ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
int debug = (m_settings.attributeFlags & ContextSettings::Debug) ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
- int attributes[] =
- {
- WGL_CONTEXT_MAJOR_VERSION_ARB, static_cast<int>(m_settings.majorVersion),
- WGL_CONTEXT_MINOR_VERSION_ARB, static_cast<int>(m_settings.minorVersion),
- WGL_CONTEXT_PROFILE_MASK_ARB, profile,
- WGL_CONTEXT_FLAGS_ARB, debug,
- 0, 0
- };
- m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, attributes);
+ attributes.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
+ attributes.push_back(profile);
+ attributes.push_back(WGL_CONTEXT_FLAGS_ARB);
+ attributes.push_back(debug);
}
else
{
@@ -426,15 +593,14 @@ void WglContext::createContext(WglContext* shared, unsigned int bitsPerPixel, co
<< "disabling comptibility and debug" << std::endl;
m_settings.attributeFlags = ContextSettings::Default;
-
- int attributes[] =
- {
- WGL_CONTEXT_MAJOR_VERSION_ARB, static_cast<int>(m_settings.majorVersion),
- WGL_CONTEXT_MINOR_VERSION_ARB, static_cast<int>(m_settings.minorVersion),
- 0, 0
- };
- m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, attributes);
}
+
+ // Append the terminating 0
+ attributes.push_back(0);
+ attributes.push_back(0);
+
+ // Create the context
+ m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, &attributes[0]);
}
else
{
diff --git a/src/SFML/Window/Win32/WglContext.hpp b/src/SFML/Window/Win32/WglContext.hpp
index 45070f6..ceecc2d 100644
--- a/src/SFML/Window/Win32/WglContext.hpp
+++ b/src/SFML/Window/Win32/WglContext.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -29,8 +29,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/GlContext.hpp>
-#include <SFML/OpenGL.hpp>
-#include <windows.h>
+#include <SFML/Window/Win32/WglExtensions.hpp>
namespace sf
@@ -124,31 +123,65 @@ public:
/// \param deviceContext Device context
/// \param bitsPerPixel Pixel depth, in bits per pixel
/// \param settings Requested context settings
+ /// \param pbuffer Whether the pixel format should support pbuffers
///
/// \return The best pixel format
///
////////////////////////////////////////////////////////////
- static int selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings);
+ static int selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPixel, const ContextSettings& settings, bool pbuffer = false);
private:
////////////////////////////////////////////////////////////
+ /// \brief Set the pixel format of the device context
+ ///
+ /// \param bitsPerPixel Pixel depth, in bits per pixel
+ ///
+ ////////////////////////////////////////////////////////////
+ void setDevicePixelFormat(unsigned int bitsPerPixel);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Update the context settings from the selected pixel format
+ ///
+ ////////////////////////////////////////////////////////////
+ void updateSettingsFromPixelFormat();
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Create the context's drawing surface
+ ///
+ /// \param shared Shared context (can be NULL)
+ /// \param width Back buffer width, in pixels
+ /// \param height Back buffer height, in pixels
+ /// \param bitsPerPixel Pixel depth, in bits per pixel
+ ///
+ ////////////////////////////////////////////////////////////
+ void createSurface(WglContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel);
+
+ ////////////////////////////////////////////////////////////
+ /// \brief Create the context's drawing surface from an existing window
+ ///
+ /// \param window Window handle of the owning window
+ /// \param bitsPerPixel Pixel depth, in bits per pixel
+ ///
+ ////////////////////////////////////////////////////////////
+ void createSurface(HWND window, unsigned int bitsPerPixel);
+
+ ////////////////////////////////////////////////////////////
/// \brief Create the context
///
- /// \param shared Context to share the new one with (can be NULL)
- /// \param bitsPerPixel Pixel depth, in bits per pixel
- /// \param settings Creation parameters
+ /// \param shared Context to share the new one with (can be NULL)
///
////////////////////////////////////////////////////////////
- void createContext(WglContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings);
+ void createContext(WglContext* shared);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
- HWND m_window; ///< Window to which the context is attached
- HDC m_deviceContext; ///< Device context associated to the context
- HGLRC m_context; ///< OpenGL context
- bool m_ownsWindow; ///< Do we own the target window?
+ HWND m_window; ///< Window to which the context is attached
+ HPBUFFERARB m_pbuffer; ///< Handle to a pbuffer if one was created
+ HDC m_deviceContext; ///< Device context associated to the context
+ HGLRC m_context; ///< OpenGL context
+ bool m_ownsWindow; ///< Do we own the target window?
};
} // namespace priv
diff --git a/src/SFML/Window/Win32/WglExtensions.cpp b/src/SFML/Window/Win32/WglExtensions.cpp
index 0d82b74..16cf473 100644
--- a/src/SFML/Window/Win32/WglExtensions.cpp
+++ b/src/SFML/Window/Win32/WglExtensions.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -30,6 +30,7 @@
#include <cstdlib>
#include <cstring>
#include <cstddef>
+#include <string>
static sf::GlFunctionPointer IntGetProcAddress(const char* name)
{
@@ -37,8 +38,11 @@ static sf::GlFunctionPointer IntGetProcAddress(const char* name)
}
int sfwgl_ext_EXT_swap_control = sfwgl_LOAD_FAILED;
+int sfwgl_ext_EXT_framebuffer_sRGB = sfwgl_LOAD_FAILED;
+int sfwgl_ext_ARB_framebuffer_sRGB = sfwgl_LOAD_FAILED;
int sfwgl_ext_ARB_multisample = sfwgl_LOAD_FAILED;
int sfwgl_ext_ARB_pixel_format = sfwgl_LOAD_FAILED;
+int sfwgl_ext_ARB_pbuffer = sfwgl_LOAD_FAILED;
int sfwgl_ext_ARB_create_context = sfwgl_LOAD_FAILED;
int sfwgl_ext_ARB_create_context_profile = sfwgl_LOAD_FAILED;
@@ -48,93 +52,133 @@ BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglSwapIntervalEXT)(int) = NULL;
static int Load_EXT_swap_control(void)
{
int numFailed = 0;
- sf_ptrc_wglGetSwapIntervalEXT = (int (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("wglGetSwapIntervalEXT");
- if(!sf_ptrc_wglGetSwapIntervalEXT) numFailed++;
- sf_ptrc_wglSwapIntervalEXT = (BOOL (CODEGEN_FUNCPTR *)(int))IntGetProcAddress("wglSwapIntervalEXT");
- if(!sf_ptrc_wglSwapIntervalEXT) numFailed++;
+ sf_ptrc_wglGetSwapIntervalEXT = reinterpret_cast<int (CODEGEN_FUNCPTR*)(void)>(IntGetProcAddress("wglGetSwapIntervalEXT"));
+ if (!sf_ptrc_wglGetSwapIntervalEXT)
+ numFailed++;
+ sf_ptrc_wglSwapIntervalEXT = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(int)>(IntGetProcAddress("wglSwapIntervalEXT"));
+ if (!sf_ptrc_wglSwapIntervalEXT)
+ numFailed++;
return numFailed;
}
-BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int *, const FLOAT *, UINT, int *, UINT *) = NULL;
-BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int *, FLOAT *) = NULL;
-BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int *, int *) = NULL;
+BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int*, const FLOAT*, UINT, int*, UINT*) = NULL;
+BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int*, FLOAT*) = NULL;
+BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int*, int*) = NULL;
static int Load_ARB_pixel_format(void)
{
int numFailed = 0;
- sf_ptrc_wglChoosePixelFormatARB = (BOOL (CODEGEN_FUNCPTR *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *))IntGetProcAddress("wglChoosePixelFormatARB");
- if(!sf_ptrc_wglChoosePixelFormatARB) numFailed++;
- sf_ptrc_wglGetPixelFormatAttribfvARB = (BOOL (CODEGEN_FUNCPTR *)(HDC, int, int, UINT, const int *, FLOAT *))IntGetProcAddress("wglGetPixelFormatAttribfvARB");
- if(!sf_ptrc_wglGetPixelFormatAttribfvARB) numFailed++;
- sf_ptrc_wglGetPixelFormatAttribivARB = (BOOL (CODEGEN_FUNCPTR *)(HDC, int, int, UINT, const int *, int *))IntGetProcAddress("wglGetPixelFormatAttribivARB");
- if(!sf_ptrc_wglGetPixelFormatAttribivARB) numFailed++;
+ sf_ptrc_wglChoosePixelFormatARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HDC, const int*, const FLOAT*, UINT, int*, UINT*)>(IntGetProcAddress("wglChoosePixelFormatARB"));
+ if (!sf_ptrc_wglChoosePixelFormatARB)
+ numFailed++;
+ sf_ptrc_wglGetPixelFormatAttribfvARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR *)(HDC, int, int, UINT, const int*, FLOAT*)>(IntGetProcAddress("wglGetPixelFormatAttribfvARB"));
+ if (!sf_ptrc_wglGetPixelFormatAttribfvARB)
+ numFailed++;
+ sf_ptrc_wglGetPixelFormatAttribivARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HDC, int, int, UINT, const int*, int*)>(IntGetProcAddress("wglGetPixelFormatAttribivARB"));
+ if (!sf_ptrc_wglGetPixelFormatAttribivARB)
+ numFailed++;
return numFailed;
}
-HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int *) = NULL;
+HPBUFFERARB (CODEGEN_FUNCPTR *sf_ptrc_wglCreatePbufferARB)(HDC, int, int, int, const int*) = NULL;
+BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglDestroyPbufferARB)(HPBUFFERARB) = NULL;
+HDC (CODEGEN_FUNCPTR *sf_ptrc_wglGetPbufferDCARB)(HPBUFFERARB) = NULL;
+BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglQueryPbufferARB)(HPBUFFERARB, int, int*) = NULL;
+int (CODEGEN_FUNCPTR *sf_ptrc_wglReleasePbufferDCARB)(HPBUFFERARB, HDC) = NULL;
+
+static int Load_ARB_pbuffer()
+{
+ int numFailed = 0;
+ sf_ptrc_wglCreatePbufferARB = reinterpret_cast<HPBUFFERARB (CODEGEN_FUNCPTR*)(HDC, int, int, int, const int*)>(IntGetProcAddress("wglCreatePbufferARB"));
+ if (!sf_ptrc_wglCreatePbufferARB)
+ numFailed++;
+ sf_ptrc_wglDestroyPbufferARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HPBUFFERARB)>(IntGetProcAddress("wglDestroyPbufferARB"));
+ if (!sf_ptrc_wglDestroyPbufferARB)
+ numFailed++;
+ sf_ptrc_wglGetPbufferDCARB = reinterpret_cast<HDC (CODEGEN_FUNCPTR*)(HPBUFFERARB)>(IntGetProcAddress("wglGetPbufferDCARB"));
+ if (!sf_ptrc_wglGetPbufferDCARB)
+ numFailed++;
+ sf_ptrc_wglQueryPbufferARB = reinterpret_cast<BOOL (CODEGEN_FUNCPTR*)(HPBUFFERARB, int, int*)>(IntGetProcAddress("wglQueryPbufferARB"));
+ if (!sf_ptrc_wglQueryPbufferARB)
+ numFailed++;
+ sf_ptrc_wglReleasePbufferDCARB = reinterpret_cast<int (CODEGEN_FUNCPTR*)(HPBUFFERARB, HDC)>(IntGetProcAddress("wglReleasePbufferDCARB"));
+ if (!sf_ptrc_wglReleasePbufferDCARB)
+ numFailed++;
+ return numFailed;
+}
+
+HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int*) = NULL;
static int Load_ARB_create_context(void)
{
int numFailed = 0;
- sf_ptrc_wglCreateContextAttribsARB = (HGLRC (CODEGEN_FUNCPTR *)(HDC, HGLRC, const int *))IntGetProcAddress("wglCreateContextAttribsARB");
- if(!sf_ptrc_wglCreateContextAttribsARB) numFailed++;
+ sf_ptrc_wglCreateContextAttribsARB = reinterpret_cast<HGLRC (CODEGEN_FUNCPTR*)(HDC, HGLRC, const int*)>(IntGetProcAddress("wglCreateContextAttribsARB"));
+ if (!sf_ptrc_wglCreateContextAttribsARB)
+ numFailed++;
return numFailed;
}
-static const char * (CODEGEN_FUNCPTR *sf_ptrc_wglGetExtensionsStringARB)(HDC) = NULL;
+static const char* (CODEGEN_FUNCPTR *sf_ptrc_wglGetExtensionsStringARB)(HDC) = NULL;
typedef int (*PFN_LOADFUNCPOINTERS)(void);
typedef struct sfwgl_StrToExtMap_s
{
- const char *extensionName;
- int *extensionVariable;
+ const char* extensionName;
+ int* extensionVariable;
PFN_LOADFUNCPOINTERS LoadExtension;
} sfwgl_StrToExtMap;
-static sfwgl_StrToExtMap ExtensionMap[5] = {
+static sfwgl_StrToExtMap ExtensionMap[8] = {
{"WGL_EXT_swap_control", &sfwgl_ext_EXT_swap_control, Load_EXT_swap_control},
+ {"WGL_EXT_framebuffer_sRGB", &sfwgl_ext_EXT_framebuffer_sRGB, NULL},
+ {"WGL_ARB_framebuffer_sRGB", &sfwgl_ext_ARB_framebuffer_sRGB, NULL},
{"WGL_ARB_multisample", &sfwgl_ext_ARB_multisample, NULL},
{"WGL_ARB_pixel_format", &sfwgl_ext_ARB_pixel_format, Load_ARB_pixel_format},
+ {"WGL_ARB_pbuffer", &sfwgl_ext_ARB_pbuffer, Load_ARB_pbuffer},
{"WGL_ARB_create_context", &sfwgl_ext_ARB_create_context, Load_ARB_create_context},
- {"WGL_ARB_create_context_profile", &sfwgl_ext_ARB_create_context_profile, NULL},
+ {"WGL_ARB_create_context_profile", &sfwgl_ext_ARB_create_context_profile, NULL}
};
-static int g_extensionMapSize = 5;
+static int g_extensionMapSize = 8;
-static sfwgl_StrToExtMap *FindExtEntry(const char *extensionName)
+
+static sfwgl_StrToExtMap* FindExtEntry(const char* extensionName)
{
- int loop;
- sfwgl_StrToExtMap *currLoc = ExtensionMap;
- for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
+ sfwgl_StrToExtMap* currLoc = ExtensionMap;
+ for (int loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc)
{
- if(strcmp(extensionName, currLoc->extensionName) == 0)
+ if (std::strcmp(extensionName, currLoc->extensionName) == 0)
return currLoc;
}
return NULL;
}
+
static void ClearExtensionVars(void)
{
sfwgl_ext_EXT_swap_control = sfwgl_LOAD_FAILED;
+ sfwgl_ext_EXT_framebuffer_sRGB = sfwgl_LOAD_FAILED;
+ sfwgl_ext_ARB_framebuffer_sRGB = sfwgl_LOAD_FAILED;
sfwgl_ext_ARB_multisample = sfwgl_LOAD_FAILED;
sfwgl_ext_ARB_pixel_format = sfwgl_LOAD_FAILED;
+ sfwgl_ext_ARB_pbuffer = sfwgl_LOAD_FAILED;
sfwgl_ext_ARB_create_context = sfwgl_LOAD_FAILED;
sfwgl_ext_ARB_create_context_profile = sfwgl_LOAD_FAILED;
}
-static void LoadExtByName(const char *extensionName)
+static void LoadExtByName(const char* extensionName)
{
- sfwgl_StrToExtMap *entry = NULL;
+ sfwgl_StrToExtMap* entry = NULL;
entry = FindExtEntry(extensionName);
- if(entry)
+ if (entry)
{
- if(entry->LoadExtension)
+ if (entry->LoadExtension)
{
int numFailed = entry->LoadExtension();
- if(numFailed == 0)
+ if (numFailed == 0)
{
*(entry->extensionVariable) = sfwgl_LOAD_SUCCEEDED;
}
@@ -151,48 +195,29 @@ static void LoadExtByName(const char *extensionName)
}
-static void ProcExtsFromExtString(const char *strExtList)
+static void ProcExtsFromExtString(const char* strExtList)
{
- size_t iExtListLen = strlen(strExtList);
- const char *strExtListEnd = strExtList + iExtListLen;
- const char *strCurrPos = strExtList;
- char strWorkBuff[256];
-
- while(*strCurrPos)
+ do
{
- /*Get the extension at our position.*/
- int iStrLen = 0;
- const char *strEndStr = strchr(strCurrPos, ' ');
- int iStop = 0;
- if(strEndStr == NULL)
- {
- strEndStr = strExtListEnd;
- iStop = 1;
- }
-
- iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos);
+ const char* begin = strExtList;
- if(iStrLen > 255)
- return;
+ while ((*strExtList != ' ') && *strExtList)
+ strExtList++;
- strncpy(strWorkBuff, strCurrPos, iStrLen);
- strWorkBuff[iStrLen] = '\0';
-
- LoadExtByName(strWorkBuff);
-
- strCurrPos = strEndStr + 1;
- if(iStop) break;
- }
+ LoadExtByName(std::string(begin, strExtList).c_str());
+ } while (*strExtList++);
}
+
int sfwgl_LoadFunctions(HDC hdc)
{
ClearExtensionVars();
- sf_ptrc_wglGetExtensionsStringARB = (const char * (CODEGEN_FUNCPTR *)(HDC))IntGetProcAddress("wglGetExtensionsStringARB");
- if(!sf_ptrc_wglGetExtensionsStringARB) return sfwgl_LOAD_FAILED;
+ sf_ptrc_wglGetExtensionsStringARB = reinterpret_cast<const char* (CODEGEN_FUNCPTR*)(HDC)>(IntGetProcAddress("wglGetExtensionsStringARB"));
+ if (!sf_ptrc_wglGetExtensionsStringARB)
+ return sfwgl_LOAD_FAILED;
- ProcExtsFromExtString((const char *)sf_ptrc_wglGetExtensionsStringARB(hdc));
+ ProcExtsFromExtString(reinterpret_cast<const char*>(sf_ptrc_wglGetExtensionsStringARB(hdc)));
return sfwgl_LOAD_SUCCEEDED;
}
diff --git a/src/SFML/Window/Win32/WglExtensions.hpp b/src/SFML/Window/Win32/WglExtensions.hpp
index 1b389c0..30d5253 100644
--- a/src/SFML/Window/Win32/WglExtensions.hpp
+++ b/src/SFML/Window/Win32/WglExtensions.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -41,7 +41,7 @@
#ifdef CODEGEN_FUNCPTR
#undef CODEGEN_FUNCPTR
-#endif /*CODEGEN_FUNCPTR*/
+#endif // CODEGEN_FUNCPTR
#define CODEGEN_FUNCPTR WINAPI
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
@@ -63,14 +63,14 @@ typedef double GLdouble;
typedef double GLclampd;
#define GLvoid void
-#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/
+#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
-#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/
+#endif // GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS
struct _GPU_DEVICE {
@@ -90,14 +90,21 @@ typedef struct _GPU_DEVICE *PGPU_DEVICE;
#ifdef __cplusplus
extern "C" {
-#endif /*__cplusplus*/
+#endif // __cplusplus
extern int sfwgl_ext_EXT_swap_control;
+extern int sfwgl_ext_EXT_framebuffer_sRGB;
+extern int sfwgl_ext_ARB_framebuffer_sRGB;
extern int sfwgl_ext_ARB_multisample;
extern int sfwgl_ext_ARB_pixel_format;
+extern int sfwgl_ext_ARB_pbuffer;
extern int sfwgl_ext_ARB_create_context;
extern int sfwgl_ext_ARB_create_context_profile;
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
+
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
+
#define WGL_SAMPLES_ARB 0x2042
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
@@ -151,6 +158,15 @@ extern int sfwgl_ext_ARB_create_context_profile;
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#define WGL_TYPE_RGBA_ARB 0x202B
+#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
+#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
+#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
+#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
+#define WGL_PBUFFER_HEIGHT_ARB 0x2035
+#define WGL_PBUFFER_LARGEST_ARB 0x2033
+#define WGL_PBUFFER_LOST_ARB 0x2036
+#define WGL_PBUFFER_WIDTH_ARB 0x2034
+
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
@@ -170,24 +186,38 @@ extern int (CODEGEN_FUNCPTR *sf_ptrc_wglGetSwapIntervalEXT)(void);
#define wglGetSwapIntervalEXT sf_ptrc_wglGetSwapIntervalEXT
extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglSwapIntervalEXT)(int);
#define wglSwapIntervalEXT sf_ptrc_wglSwapIntervalEXT
-#endif /*WGL_EXT_swap_control*/
+#endif // WGL_EXT_swap_control
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
-extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int *, const FLOAT *, UINT, int *, UINT *);
+extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglChoosePixelFormatARB)(HDC, const int*, const FLOAT*, UINT, int*, UINT*);
#define wglChoosePixelFormatARB sf_ptrc_wglChoosePixelFormatARB
-extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int *, FLOAT *);
+extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribfvARB)(HDC, int, int, UINT, const int*, FLOAT*);
#define wglGetPixelFormatAttribfvARB sf_ptrc_wglGetPixelFormatAttribfvARB
-extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int *, int *);
+extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglGetPixelFormatAttribivARB)(HDC, int, int, UINT, const int*, int*);
#define wglGetPixelFormatAttribivARB sf_ptrc_wglGetPixelFormatAttribivARB
-#endif /*WGL_ARB_pixel_format*/
+#endif // WGL_ARB_pixel_format
+
+#ifndef WGL_ARB_pbuffer
+#define WGL_ARB_pbuffer 1
+extern HPBUFFERARB (CODEGEN_FUNCPTR *sf_ptrc_wglCreatePbufferARB)(HDC, int, int, int, const int*);
+#define wglCreatePbufferARB sf_ptrc_wglCreatePbufferARB
+extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglDestroyPbufferARB)(HPBUFFERARB);
+#define wglDestroyPbufferARB sf_ptrc_wglDestroyPbufferARB
+extern HDC (CODEGEN_FUNCPTR *sf_ptrc_wglGetPbufferDCARB)(HPBUFFERARB);
+#define wglGetPbufferDCARB sf_ptrc_wglGetPbufferDCARB
+extern BOOL (CODEGEN_FUNCPTR *sf_ptrc_wglQueryPbufferARB)(HPBUFFERARB, int, int*);
+#define wglQueryPbufferARB sf_ptrc_wglQueryPbufferARB
+extern int (CODEGEN_FUNCPTR *sf_ptrc_wglReleasePbufferDCARB)(HPBUFFERARB, HDC);
+#define wglReleasePbufferDCARB sf_ptrc_wglReleasePbufferDCARB
+#endif // WGL_ARB_pbuffer
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
-extern HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int *);
+extern HGLRC (CODEGEN_FUNCPTR *sf_ptrc_wglCreateContextAttribsARB)(HDC, HGLRC, const int*);
#define wglCreateContextAttribsARB sf_ptrc_wglCreateContextAttribsARB
-#endif /*WGL_ARB_create_context*/
+#endif // WGL_ARB_create_context
enum sfwgl_LoadStatus
@@ -201,6 +231,6 @@ int sfwgl_LoadFunctions(HDC hdc);
#ifdef __cplusplus
}
-#endif /*__cplusplus*/
+#endif // __cplusplus
-#endif /* SF_POINTER_C_GENERATED_HEADER_WINDOWSGL_HPP */
+#endif // SF_POINTER_C_GENERATED_HEADER_WINDOWSGL_HPP
diff --git a/src/SFML/Window/Win32/WglExtensions.txt b/src/SFML/Window/Win32/WglExtensions.txt
index 99610a6..667c853 100644
--- a/src/SFML/Window/Win32/WglExtensions.txt
+++ b/src/SFML/Window/Win32/WglExtensions.txt
@@ -1,10 +1,13 @@
// Created with:
-// https://bitbucket.org/Anteru/glloadgen-reloaded
-// Commit 20f19482b7a844d20b9785c3e3fd1f16419f6e0a
+// https://bitbucket.org/KhronosGroup/glloadgen
+// Commit d143d66ac90d538ed06f806188714861b8e8e2f9
// lua LoadGen.lua -style=pointer_c -spec=wgl -indent=space -prefix=sf -extfile=WglExtensions.txt WglExtensions
EXT_swap_control
+EXT_framebuffer_sRGB
+ARB_framebuffer_sRGB
WGL_ARB_multisample
WGL_ARB_pixel_format
+WGL_ARB_pbuffer
WGL_ARB_create_context
WGL_ARB_create_context_profile \ No newline at end of file
diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp
index 8bf86ab..cc999f9 100644
--- a/src/SFML/Window/Win32/WindowImplWin32.cpp
+++ b/src/SFML/Window/Win32/WindowImplWin32.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -132,7 +132,9 @@ m_keyRepeatEnabled(true),
m_lastSize (0, 0),
m_resizing (false),
m_surrogate (0),
-m_mouseInside (false)
+m_mouseInside (false),
+m_fullscreen (false),
+m_cursorGrabbed (false)
{
// Set that this process is DPI aware and can handle DPI scaling
setProcessDpiAware();
@@ -156,7 +158,9 @@ m_keyRepeatEnabled(true),
m_lastSize (mode.width, mode.height),
m_resizing (false),
m_surrogate (0),
-m_mouseInside (false)
+m_mouseInside (false),
+m_fullscreen (style & Style::Fullscreen),
+m_cursorGrabbed (m_fullscreen)
{
// Set that this process is DPI aware and can handle DPI scaling
setProcessDpiAware();
@@ -187,8 +191,7 @@ m_mouseInside (false)
}
// In windowed mode, adjust width and height so that window will have the requested client area
- bool fullscreen = (style & Style::Fullscreen) != 0;
- if (!fullscreen)
+ if (!m_fullscreen)
{
RECT rectangle = {0, 0, width, height};
AdjustWindowRect(&rectangle, win32Style, false);
@@ -204,7 +207,7 @@ m_mouseInside (false)
setSize(Vector2u(mode.width, mode.height));
// Switch to fullscreen if requested
- if (fullscreen)
+ if (m_fullscreen)
switchToFullscreen(mode);
// Increment window count
@@ -277,6 +280,9 @@ Vector2i WindowImplWin32::getPosition() const
void WindowImplWin32::setPosition(const Vector2i& position)
{
SetWindowPos(m_handle, NULL, position.x, position.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+
+ if(m_cursorGrabbed)
+ grabCursor(true);
}
@@ -364,6 +370,14 @@ void WindowImplWin32::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void WindowImplWin32::setMouseCursorGrabbed(bool grabbed)
+{
+ m_cursorGrabbed = grabbed;
+ grabCursor(m_cursorGrabbed);
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplWin32::setKeyRepeatEnabled(bool enabled)
{
m_keyRepeatEnabled = enabled;
@@ -486,6 +500,23 @@ void WindowImplWin32::setTracking(bool track)
////////////////////////////////////////////////////////////
+void WindowImplWin32::grabCursor(bool grabbed)
+{
+ if (grabbed)
+ {
+ RECT rect;
+ GetClientRect(m_handle, &rect);
+ MapWindowPoints(m_handle, NULL, reinterpret_cast<LPPOINT>(&rect), 2);
+ ClipCursor(&rect);
+ }
+ else
+ {
+ ClipCursor(NULL);
+ }
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
// Don't process any message until window is created
@@ -536,6 +567,9 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
event.size.width = m_lastSize.x;
event.size.height = m_lastSize.y;
pushEvent(event);
+
+ // Restore/update cursor grabbing
+ grabCursor(m_cursorGrabbed);
}
break;
}
@@ -544,6 +578,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
case WM_ENTERSIZEMOVE:
{
m_resizing = true;
+ grabCursor(false);
break;
}
@@ -565,6 +600,9 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
event.size.height = m_lastSize.y;
pushEvent(event);
}
+
+ // Restore/update cursor grabbing
+ grabCursor(m_cursorGrabbed);
break;
}
@@ -582,6 +620,9 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
// Gain focus event
case WM_SETFOCUS:
{
+ // Restore cursor grabbing
+ grabCursor(m_cursorGrabbed);
+
Event event;
event.type = Event::GainedFocus;
pushEvent(event);
@@ -591,6 +632,9 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
// Lost focus event
case WM_KILLFOCUS:
{
+ // Ungrab the cursor
+ grabCursor(false);
+
Event event;
event.type = Event::LostFocus;
pushEvent(event);
diff --git a/src/SFML/Window/Win32/WindowImplWin32.hpp b/src/SFML/Window/Win32/WindowImplWin32.hpp
index fb5fe0f..d7ef4e0 100644
--- a/src/SFML/Window/Win32/WindowImplWin32.hpp
+++ b/src/SFML/Window/Win32/WindowImplWin32.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -146,6 +146,14 @@ public:
virtual void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
@@ -217,6 +225,19 @@ private:
void setTracking(bool track);
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor
+ ///
+ /// This is not to be confused with setMouseCursorGrabbed.
+ /// Here m_cursorGrabbed is not modified; it is used,
+ /// for example, to release the cursor when switching to
+ /// another application.
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ void grabCursor(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Convert a Win32 virtual key code to a SFML key code
///
/// \param key Virtual key code to convert
@@ -252,6 +273,8 @@ private:
bool m_resizing; ///< Is the window being resized?
Uint16 m_surrogate; ///< First half of the surrogate pair, in case we're receiving a Unicode character in two events
bool m_mouseInside; ///< Mouse is inside the window?
+ bool m_fullscreen; ///< Is the window fullscreen?
+ bool m_cursorGrabbed; ///< Is the mouse cursor trapped?
};
} // namespace priv
diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp
index a091325..70cb418 100644
--- a/src/SFML/Window/Window.cpp
+++ b/src/SFML/Window/Window.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -289,6 +289,14 @@ void Window::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void Window::setMouseCursorGrabbed(bool grabbed)
+{
+ if (m_impl)
+ m_impl->setMouseCursorGrabbed(grabbed);
+}
+
+
+////////////////////////////////////////////////////////////
void Window::setKeyRepeatEnabled(bool enabled)
{
if (m_impl)
diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp
index 679aaed..e7133e1 100644
--- a/src/SFML/Window/WindowImpl.cpp
+++ b/src/SFML/Window/WindowImpl.cpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp
index 1e07a0f..1243506 100644
--- a/src/SFML/Window/WindowImpl.hpp
+++ b/src/SFML/Window/WindowImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -187,6 +187,14 @@ public:
virtual void setMouseCursorVisible(bool visible) = 0;
////////////////////////////////////////////////////////////
+ /// \brief Grab or release the mouse cursor and keeps it from leaving
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed) = 0;
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
diff --git a/src/SFML/Window/iOS/EaglContext.hpp b/src/SFML/Window/iOS/EaglContext.hpp
index 1ad457f..a3c48ea 100644
--- a/src/SFML/Window/iOS/EaglContext.hpp
+++ b/src/SFML/Window/iOS/EaglContext.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/EaglContext.mm b/src/SFML/Window/iOS/EaglContext.mm
index 380c139..e033718 100644
--- a/src/SFML/Window/iOS/EaglContext.mm
+++ b/src/SFML/Window/iOS/EaglContext.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/InputImpl.hpp b/src/SFML/Window/iOS/InputImpl.hpp
index 43733cb..8c89dcb 100644
--- a/src/SFML/Window/iOS/InputImpl.hpp
+++ b/src/SFML/Window/iOS/InputImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/InputImpl.mm b/src/SFML/Window/iOS/InputImpl.mm
index b8dd103..c6cccaa 100644
--- a/src/SFML/Window/iOS/InputImpl.mm
+++ b/src/SFML/Window/iOS/InputImpl.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/JoystickImpl.hpp b/src/SFML/Window/iOS/JoystickImpl.hpp
index 59f31f2..47f8517 100644
--- a/src/SFML/Window/iOS/JoystickImpl.hpp
+++ b/src/SFML/Window/iOS/JoystickImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/JoystickImpl.mm b/src/SFML/Window/iOS/JoystickImpl.mm
index 6821e03..240c700 100644
--- a/src/SFML/Window/iOS/JoystickImpl.mm
+++ b/src/SFML/Window/iOS/JoystickImpl.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/ObjCType.hpp b/src/SFML/Window/iOS/ObjCType.hpp
index 5b111d5..17cb1b4 100644
--- a/src/SFML/Window/iOS/ObjCType.hpp
+++ b/src/SFML/Window/iOS/ObjCType.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFAppDelegate.hpp b/src/SFML/Window/iOS/SFAppDelegate.hpp
index cd20bfc..012e02e 100644
--- a/src/SFML/Window/iOS/SFAppDelegate.hpp
+++ b/src/SFML/Window/iOS/SFAppDelegate.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFAppDelegate.mm b/src/SFML/Window/iOS/SFAppDelegate.mm
index 5908b4e..3284b9a 100644
--- a/src/SFML/Window/iOS/SFAppDelegate.mm
+++ b/src/SFML/Window/iOS/SFAppDelegate.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFMain.hpp b/src/SFML/Window/iOS/SFMain.hpp
index f52857b..bcd3153 100644
--- a/src/SFML/Window/iOS/SFMain.hpp
+++ b/src/SFML/Window/iOS/SFMain.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFMain.mm b/src/SFML/Window/iOS/SFMain.mm
index 0e9d481..81b2452 100644
--- a/src/SFML/Window/iOS/SFMain.mm
+++ b/src/SFML/Window/iOS/SFMain.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFView.hpp b/src/SFML/Window/iOS/SFView.hpp
index 4804797..1066927 100644
--- a/src/SFML/Window/iOS/SFView.hpp
+++ b/src/SFML/Window/iOS/SFView.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFView.mm b/src/SFML/Window/iOS/SFView.mm
index b818749..efe8d3e 100644
--- a/src/SFML/Window/iOS/SFView.mm
+++ b/src/SFML/Window/iOS/SFView.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFViewController.hpp b/src/SFML/Window/iOS/SFViewController.hpp
index ecc8476..37a06aa 100644
--- a/src/SFML/Window/iOS/SFViewController.hpp
+++ b/src/SFML/Window/iOS/SFViewController.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SFViewController.mm b/src/SFML/Window/iOS/SFViewController.mm
index 0142297..a17f99c 100644
--- a/src/SFML/Window/iOS/SFViewController.mm
+++ b/src/SFML/Window/iOS/SFViewController.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SensorImpl.hpp b/src/SFML/Window/iOS/SensorImpl.hpp
index 0e3f211..cce8e44 100644
--- a/src/SFML/Window/iOS/SensorImpl.hpp
+++ b/src/SFML/Window/iOS/SensorImpl.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/SensorImpl.mm b/src/SFML/Window/iOS/SensorImpl.mm
index 96e4c7a..7801a8f 100644
--- a/src/SFML/Window/iOS/SensorImpl.mm
+++ b/src/SFML/Window/iOS/SensorImpl.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/VideoModeImpl.mm b/src/SFML/Window/iOS/VideoModeImpl.mm
index dd3d134..d054adf 100644
--- a/src/SFML/Window/iOS/VideoModeImpl.mm
+++ b/src/SFML/Window/iOS/VideoModeImpl.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
diff --git a/src/SFML/Window/iOS/WindowImplUIKit.hpp b/src/SFML/Window/iOS/WindowImplUIKit.hpp
index 53c066e..444672c 100644
--- a/src/SFML/Window/iOS/WindowImplUIKit.hpp
+++ b/src/SFML/Window/iOS/WindowImplUIKit.hpp
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -150,6 +150,14 @@ public:
virtual void setMouseCursorVisible(bool visible);
////////////////////////////////////////////////////////////
+ /// \brief Clips or releases the mouse cursor
+ ///
+ /// \param grabbed True to enable, false to disable
+ ///
+ ////////////////////////////////////////////////////////////
+ virtual void setMouseCursorGrabbed(bool grabbed);
+
+ ////////////////////////////////////////////////////////////
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
diff --git a/src/SFML/Window/iOS/WindowImplUIKit.mm b/src/SFML/Window/iOS/WindowImplUIKit.mm
index 3e7c833..3abfc10 100644
--- a/src/SFML/Window/iOS/WindowImplUIKit.mm
+++ b/src/SFML/Window/iOS/WindowImplUIKit.mm
@@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
+// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@@ -184,6 +184,13 @@ void WindowImplUIKit::setMouseCursorVisible(bool visible)
////////////////////////////////////////////////////////////
+void WindowImplUIKit::setMouseCursorGrabbed(bool grabbed)
+{
+ // Not applicable
+}
+
+
+////////////////////////////////////////////////////////////
void WindowImplUIKit::setKeyRepeatEnabled(bool enabled)
{
// Not applicable