Merge branch 'develop'

This commit is contained in:
Daniel Chappuis 2016-04-15 07:07:22 +02:00
commit c369eb97a8
1486 changed files with 394576 additions and 22240 deletions

4
.gitignore vendored
View File

@ -21,3 +21,7 @@
Icon?
ehthumbs.db
Thumbs.db
# vim swap files
#####################
*.*sw*

View File

@ -1,3 +1,9 @@
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "dDB6D746t1rfr8Evh9nFTu+35MN7UvHZf2RvVpYKFqRRsm2Kk4ET9B21JejZn2MaoYuzQ4Yw3TIXCErqOzFKwcET+2LC8SpA0GMp9eST6T0DtZquP1N/kRh704jN3cTuUo6R8xAxrw5w7g5ZFWREdRVnOHs6A0D3jEiMduBDXOGXuOHxCIARHbTvUxGxFTAh+EcNTgUp3Lq7pLlaTiFiJU20NumdrthFEnxk1ZN6t+mEk9ooG5jDvH//hs3sVrSGJIpbPQJioX1gL/xzgHJtwxG2upFmxm7C9FCwNo7z2zxQomOFyPQw9bZZGb46PPCJQsCJpw/j8QlCphxRKk5suwAGcoCP4zQXiygsXgoTIfkuTYEEEK7+9Gxkl9OaU5kcKKM7sradT7VQSqN9iAtcampA6ChsOPKFIgF1YbqpZrr9tkknFDvne3KraA4Zg8GSiebqXUNdsO1/enZkD+cGvidRDRTlJUHv4Osgr11maQ3uKG2T5QAs39qx0OK/Ctl77ppcZdQmDxFBW5Zu2McuawyGI2u3bCYg4fuFaMhsQ5cxiIp+wiqfMsr3LcX3Ut08fEGa8h2yE4aw7aGCXlLIPDcLLSGbsOSVlCblnlza2INi1VbwYqehT3DQvzP2rnNA+LFlRRIYupvV0heztgwalCOfJWinDQh9FuRRXMFFyfI="
language: cpp
os:
- linux
@ -5,18 +11,39 @@ os:
compiler:
- gcc
- clang
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- clang
coverity_scan:
project:
name: "DanielChappuis/reactphysics3d"
description: "Build submitted via Travis CI"
notification_email: chappuis.daniel@gmail.com
build_command_prepend: "mkdir build_directory; cd build_directory; cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug —DDOUBLE_PRECISION_ENABLED=False ../"
build_command: "make"
branch_pattern: develop
branches:
only:
- master
- develop
script:
- mkdir build_directory
- cd build_directory
# Build in debug mode with double precision
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug —DDOUBLE_PRECISION_ENABLED=True -DCOMPILE_TESTS=True ../
- make && make test
- make && make test ARGS="-V"
# Build in debug mode with single precision
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug —DDOUBLE_PRECISION_ENABLED=False -DCOMPILE_TESTS=True ../
- make && make test
- make && make test ARGS="-V"
# Build in release mode with double precision
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release —DDOUBLE_PRECISION_ENABLED=True -DCOMPILE_TESTS=True ../
- make && make test
- make && make test ARGS="-V"
# Build in release mode with single precision
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release —DDOUBLE_PRECISION_ENABLED=False -DCOMPILE_TESTS=True ../
- make && make test
- make && make test ARGS="-V"

View File

@ -1,8 +1,8 @@
# Minimum cmake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
# Project configuration
PROJECT(REACTPHYSICS3D)
PROJECT(REACTPHYSICS3D CXX)
# Build type
IF (NOT CMAKE_BUILD_TYPE)
@ -18,11 +18,26 @@ SET(OUR_EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")
ENABLE_TESTING()
# Options
OPTION(COMPILE_EXAMPLES "Select this if you want to build the examples" OFF)
OPTION(COMPILE_TESTBED "Select this if you want to build the testbed application" OFF)
OPTION(COMPILE_TESTS "Select this if you want to build the tests" OFF)
OPTION(PROFILING_ENABLED "Select this if you want to compile with enabled profiling" OFF)
OPTION(DOUBLE_PRECISION_ENABLED "Select this if you want to compile using double precision floating
values" OFF)
# Warning Compiler flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# C++11 flags
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSE()
message("The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
ENDIF()
ENDIF()
# Headers
INCLUDE_DIRECTORIES(src)
@ -49,6 +64,9 @@ SET (REACTPHYSICS3D_SOURCES
"src/collision/broadphase/BroadPhaseAlgorithm.cpp"
"src/collision/broadphase/DynamicAABBTree.h"
"src/collision/broadphase/DynamicAABBTree.cpp"
"src/collision/narrowphase/CollisionDispatch.h"
"src/collision/narrowphase/DefaultCollisionDispatch.h"
"src/collision/narrowphase/DefaultCollisionDispatch.cpp"
"src/collision/narrowphase/EPA/EdgeEPA.h"
"src/collision/narrowphase/EPA/EdgeEPA.cpp"
"src/collision/narrowphase/EPA/EPAAlgorithm.h"
@ -65,8 +83,14 @@ SET (REACTPHYSICS3D_SOURCES
"src/collision/narrowphase/NarrowPhaseAlgorithm.cpp"
"src/collision/narrowphase/SphereVsSphereAlgorithm.h"
"src/collision/narrowphase/SphereVsSphereAlgorithm.cpp"
"src/collision/narrowphase/ConcaveVsConvexAlgorithm.h"
"src/collision/narrowphase/ConcaveVsConvexAlgorithm.cpp"
"src/collision/shapes/AABB.h"
"src/collision/shapes/AABB.cpp"
"src/collision/shapes/ConvexShape.h"
"src/collision/shapes/ConvexShape.cpp"
"src/collision/shapes/ConcaveShape.h"
"src/collision/shapes/ConcaveShape.cpp"
"src/collision/shapes/BoxShape.h"
"src/collision/shapes/BoxShape.cpp"
"src/collision/shapes/CapsuleShape.h"
@ -81,12 +105,27 @@ SET (REACTPHYSICS3D_SOURCES
"src/collision/shapes/CylinderShape.cpp"
"src/collision/shapes/SphereShape.h"
"src/collision/shapes/SphereShape.cpp"
"src/collision/shapes/TriangleShape.h"
"src/collision/shapes/TriangleShape.cpp"
"src/collision/shapes/ConcaveMeshShape.h"
"src/collision/shapes/ConcaveMeshShape.cpp"
"src/collision/shapes/HeightFieldShape.h"
"src/collision/shapes/HeightFieldShape.cpp"
"src/collision/RaycastInfo.h"
"src/collision/RaycastInfo.cpp"
"src/collision/ProxyShape.h"
"src/collision/ProxyShape.cpp"
"src/collision/TriangleVertexArray.h"
"src/collision/TriangleVertexArray.cpp"
"src/collision/TriangleMesh.h"
"src/collision/TriangleMesh.cpp"
"src/collision/CollisionDetection.h"
"src/collision/CollisionDetection.cpp"
"src/collision/CollisionShapeInfo.h"
"src/collision/ContactManifold.h"
"src/collision/ContactManifold.cpp"
"src/collision/ContactManifoldSet.h"
"src/collision/ContactManifoldSet.cpp"
"src/constraint/BallAndSocketJoint.h"
"src/constraint/BallAndSocketJoint.cpp"
"src/constraint/ContactPoint.h"
@ -103,8 +142,6 @@ SET (REACTPHYSICS3D_SOURCES
"src/engine/CollisionWorld.cpp"
"src/engine/ConstraintSolver.h"
"src/engine/ConstraintSolver.cpp"
"src/engine/ContactManifold.h"
"src/engine/ContactManifold.cpp"
"src/engine/ContactSolver.h"
"src/engine/ContactSolver.cpp"
"src/engine/DynamicsWorld.h"
@ -123,6 +160,7 @@ SET (REACTPHYSICS3D_SOURCES
"src/engine/Timer.cpp"
"src/mathematics/mathematics.h"
"src/mathematics/mathematics_functions.h"
"src/mathematics/mathematics_functions.cpp"
"src/mathematics/Matrix2x2.h"
"src/mathematics/Matrix2x2.cpp"
"src/mathematics/Matrix3x3.h"
@ -142,12 +180,12 @@ SET (REACTPHYSICS3D_SOURCES
)
# Create the library
ADD_LIBRARY (reactphysics3d STATIC ${REACTPHYSICS3D_SOURCES})
ADD_LIBRARY(reactphysics3d STATIC ${REACTPHYSICS3D_SOURCES})
# If we need to compile the examples
IF(COMPILE_EXAMPLES)
add_subdirectory(examples/)
ENDIF(COMPILE_EXAMPLES)
# If we need to compile the testbed application
IF(COMPILE_TESTBED)
add_subdirectory(testbed/)
ENDIF(COMPILE_TESTBED)
# If we need to compile the tests
IF(COMPILE_TESTS)

View File

@ -1,5 +1,5 @@
ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/
Copyright (c) 2010-2013 Daniel Chappuis
Copyright (c) 2010-2016 Daniel Chappuis
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the

View File

@ -1,6 +1,5 @@
[![Travis Build Status](https://travis-ci.org/DanielChappuis/reactphysics3d.svg?branch=master)](https://travis-ci.org/DanielChappuis/reactphysics3d)
## ReactPhysics3D
ReactPhysics3D is an open source C++ physics engine library that can be used in 3D simulations and games.
@ -9,13 +8,15 @@ Website : [http://www.reactphysics3d.com](http://www.reactphysics3d.com)
Author : Daniel Chappuis
<img src="https://raw.githubusercontent.com/DanielChappuis/reactphysics3d/develop/documentation/UserManual/images/testbed.png" alt="Drawing" height="400" />
## Features
ReactPhysics3D has the following features :
- Rigid body dynamics
- Discrete collision detection
- Collision shapes (Sphere, Box, Cone, Cylinder, Capsule, Convex Mesh)
- Collision shapes (Sphere, Box, Cone, Cylinder, Capsule, Convex Mesh, static Concave Mesh, Height Field)
- Multiple collision shapes per body
- Broadphase collision detection (Dynamic AABB tree)
- Narrowphase collision detection (GJK/EPA)
@ -26,8 +27,9 @@ ReactPhysics3D has the following features :
- Sleeping technique for inactive bodies
- Integrated Profiler
- Multi-platform (Windows, Linux, Mac OS X)
- No dependencies (only OpenGL for the testbed application)
- Documentation (User manual and Doxygen API)
- Examples
- Testbed application with demo scenes
- Unit tests
## License

View File

@ -1 +1 @@
0.5.0
0.6.0

View File

@ -32,7 +32,7 @@ PROJECT_NAME = "ReactPhysics3D"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = "0.5.0"
PROJECT_NUMBER = "0.6.0"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -56,7 +56,7 @@
\begin{itemize}
\item Rigid body dynamics
\item Discrete collision detection
\item Collision shapes (Sphere, Box, Cone, Cylinder, Capsule, Convex Mesh)
\item Collision shapes (Sphere, Box, Cone, Cylinder, Capsule, Convex Mesh, Static Concave Mesh, Height Field)
\item Multiple collision shapes per body
\item Broadphase collision detection (Dynamic AABB tree)
\item Narrowphase collision detection (GJK/EPA)
@ -68,7 +68,7 @@
\item Integrated Profiler
\item Multi-platform (Windows, Linux, Mac OS X)
\item Documentation (User manual and Doxygen API)
\item Examples
\item Testbed application with demos
\item Unit tests
\end{itemize}
@ -87,10 +87,9 @@
If you have never used cmake before, you should read the page \url{http://www.cmake.org/cmake/help/runningcmake.html} as
it contains a lot of useful information. \\
Note that by default, the library is built in \emph{debugging} mode. In this mode, a lot of debugging information is compiled together with the code.
This might cause the application to run much slower that it should be in \emph{release} mode. Therefore, you should not forget to build the library in
\emph{release} mode when releasing your final application.
It is also possible to compile the testbed application using CMake. The testbed application contains different
demo scenes using the ReactPhysics3D library.
xs
\subsection{CMake using the command line (Linux and Mac OS X)}
Now, we will see how to build the ReactPhysics3D library using the CMake tool with the command line.
@ -101,7 +100,7 @@
\begin{sloppypar}
where \texttt{\textless path\_to\_library\_source\textgreater} must be replaced
by the path to the \texttt{reactphysics3d-0.5.0/} folder. It is the folder that
by the path to the \texttt{reactphysics3d-0.6.0/} folder. It is the folder that
contains the \texttt{CMakeLists.txt} file. Running this command will launch the CMake command line interface.
Hit the 'c' key to configure the project. There, you can also change some predefined variables (see section \ref{sec:cmakevariables} for more details)
and then, hit the 'c' key again. Once you have set all the values as you like, you can hit the 'g' key to generate the makefiles in the build directory
@ -118,9 +117,9 @@
You can also use the graphical user interface of CMake. To do this,
run the \texttt{cmake-gui} program. The program will ask you for the
source folder which is the \texttt{reactphysics3d-0.5.0/} folder of
source folder which is the \texttt{reactphysics3d-0.6.0/} folder of
the library. You will also have to select a folder where you want to
build the library and the examples. Select any empty folder that
build the library and the testbed application. Select any empty folder that
is on your system. Then, you can click on \texttt{Configure}. CMake will ask you to choose an IDE that is on
your system. For instance, you can select Visual Studio, Qt Creator, XCode, ... Then, you
can change the compilation options. See section \ref{sec:cmakevariables} to see what are the possible options.
@ -130,10 +129,6 @@
library, you should be able to open the project file that corresponds to your IDE and compile
the library. \\
If your want to run the examples within the Microsoft Visual Studio IDE, you need to make sure that in the
\emph{Debugging} section of the \emph{Configuration Properties} of the example projects, the \emph{Working Directory} is set to \texttt{\$(OutDir)}.
Otherwise, you might have problems to run the examples.
\subsection{CMake Variables}
\label{sec:cmakevariables}
@ -147,9 +142,9 @@
and therefore, it will run much faster. This mode must be used when you compile the final
release of you application.
\item[COMPILE\_EXAMPLES] If this variable is \texttt{ON}, the examples of the library will be compiled.
The examples use OpenGL for rendering. You will also need to have the GLEW library (\url{http://glew.sourceforge.net/})
to run them. Take a look at the section \ref{sec:examples} for more information about the examples.
\item[COMPILE\_TESTBED] If this variable is \texttt{ON}, the tesbed application of the library will be compiled.
The testbed application uses OpenGL for rendering.
Take a look at the section \ref{sec:testbed} for more information about the testbed application.
\item[COMPILE\_TESTS] If this variable is \texttt{ON}, the unit tests of the library will be compiled. You will then
be able to launch the tests to make sure that they are running fine on your system.
@ -173,8 +168,8 @@
the ReactPhysics3D header file with the line: \\
\begin{lstlisting}
// Include the ReactPhysics3D header file
#include "reactphysics3d.h"
// Include the ReactPhysics3D header file
#include "reactphysics3d.h"
\end{lstlisting}
\vspace{0.6cm}
@ -194,9 +189,9 @@
\texttt{rp3d}. Therefore, you need to include this namespace into your code with the following declaration: \\
\begin{lstlisting}
// Use the ReactPhysics3D namespace
using namespace reactphysics3d;
\end{lstlisting}
// Use the ReactPhysics3D namespace
using namespace reactphysics3d;
\end{lstlisting}
\vspace{0.6cm}
@ -228,7 +223,10 @@ rp3d::CollisionWorld world;
Do not forget to destroy the \texttt{CollisionWorld} instance at the end of your program in order to release the allocated memory. If the object has been created
statically, it will be destroyed automatically at the end of the scope in which it has been created. If the object has been created dynamically (using the \texttt{new}
operator), you need to destroy it with the \texttt{delete} operator.
operator), you need to destroy it with the \texttt{delete} operator. \\
When the \texttt{CollisionWorld} is destroyed, all the bodies that have been added into it and that have not been destroyed already will be destroyed.
Therefore, the pointers to the bodies of the world will become invalid after the existence of their \texttt{CollisionWorld}.
\section{Collision Bodies}
@ -286,8 +284,7 @@ body->setTransform(newTransform);
\begin{sloppypar}
In order to destroy a Collision Body from the world, you need to use the \texttt{CollisionWorld::destroyCollisionBody()} method. You need to use the pointer to the body you
want to destroy in argument. Note that after calling that method, the pointer will not be valid anymore and therefore, you should not use it. Note that you must
destroy all the bodies at the end of the simulation before you destroy the world. \\
want to destroy in argument. Note that after calling that method, the pointer will not be valid anymore and therefore, you should not use it. \\
\end{sloppypar}
Here is how to destroy a Collision Body: \\
@ -311,12 +308,8 @@ world.destroyCollisionBody(body);
\subsection{Creating the Dynamics World}
The first thing you have to do when you want to simulate the dynamics of rigid bodies in time is to create an instance
of the \texttt{DynamicsWorld}. You need to specify two parameters when constructing the world. The first one is the gravity acceleration vector (in $m / s^2$) in the
world and
the second one is the simulation time step (in seconds). Note that gravity is activated by default when you create the world. The time step is the fixed amount of time
used at each internal
physics tick. Note that multiple internal physics ticks can be taken at each frame. For real-time applications, a time step of $\frac{1}{60}$ seconds (60 Hz) is usually
used. Using a smaller time step makes the simulation more precise but also more expensive to compute. \\
of the \texttt{DynamicsWorld}. You need to specify the gravity acceleration vector (in $m / s^2$) in the world as parameter. Note that gravity is
activated by default when you create the world. \\
Here is how to create the Dynamics World: \\
@ -324,11 +317,8 @@ world.destroyCollisionBody(body);
// Gravity vector
rp3d::Vector3 gravity(0.0, -9.81, 0.0);
// Time step (in seconds)
rp3d::decimal timeStep = 1.0 / 60.0;
// Create the dynamics world
rp3d::DynamicsWorld world(gravity, timeStep);
rp3d::DynamicsWorld world(gravity);
\end{lstlisting}
\subsection{Customizing the Dynamics World}
@ -384,39 +374,67 @@ world.enableSleeping(false);
\subsection{Updating the Dynamics World}
The first thing you have to do to simulate the dynamics of your world is to start the simulation using the following method: \\
The \texttt{DynamicsWorld} is used to simulate physics through time. It has to be updated each time you want to simulate a step forward in time. Most of the time,
you want to update the world right before rendering a new frame in a real-time application. \\
To update the physics world, you need to use the \texttt{DynamicsWorld::update()} method. This method will perform collision detection and update the
position and orientation of the bodies and joints. After updating the world, you will be able to get the new position and orientation of your bodies for the next
frame to render. This method requires a \emph{timeStep} parameter. This is the amount of time you want to advance the physics simulation (in seconds). \\
The smaller the time step you pick, the more precise the simulation will be but it can also be more expensive to compute. For a real-time application, you
probably want a time step of at most $\frac{1}{60}$ seconds to
have at least a 60 Hz framerate. Most of the time, physics engines prefer to work with a constant time step. It means that you should always call
the \texttt{DynamicsWorld::update()} method with the same time step parameter. You do not want to use the time between two frames as your time step because it will
not be constant. \\
You can use the following technique. First, you choose a constant time step for the physics. Let say the time step is $\frac{1}{60}$ seconds. Then, at each frame,
you compute the time difference between the current frame and the previous one and you accumulate this difference in a variable called \emph{accumulator}. The accumulator
is initialized to zero at the beginning of your application and is updated at each frame. The idea is to divide the time in the accumulator in several constant time steps.
For instance, if your accumulator contains $0.145$ seconds, it means that we can take $8$ physics steps of $\frac{1}{60}$ seconds during the current frame. Note that
$0.012$ seconds will remain in the accumulator and will probably be used in the next frame. As you can see, multiple physics steps can be taken at each frame. It is
important to understand that each call to the \texttt{DynamicsWorld::update()} method is done using a constant time step that is not varying with the framerate. \\
Here is what the code looks like at each frame: \\
\begin{lstlisting}
// Start the simulation
world.start();
// Constant physics time step
const float timeStep = 1.0 / 60.0;
// Get the current system time
long double currentFrameTime = getCurrentSystemTime();
// Compute the time difference between the two frames
long double deltaTime = currentFrameTime - previousFrameTime;
// Update the previous time
previousFrameTime = currentFrameTime;
// Add the time difference in the accumulator
accumulator += mDeltaTime;
// While there is enough accumulated time to take
// one or several physics steps
while (accumulator >= timeStep) {
// Update the Dynamics world with a constant time step
dynamicsWorld->update(timeStep);
// Decrease the accumulated time
accumulator -= timeStep;
}
\end{lstlisting}
\vspace{0.6cm}
Then, each time you have to compute the next frame to render in your application, you need to update the state of the world. To do that, you simply need to call this method: \\
\begin{lstlisting}
// Update the world by taking a simulation step
world.update();
\end{lstlisting}
\vspace{0.6cm}
When the \texttt{DynamicsWorld::update()} method is called, collision detection is performed and the position and orientation of the bodies are updated accordingly.
After updating the world, you will be able to get the updated position and orientation of the bodies for the next frame. Make sure that you call
the \texttt{DynamicsWorld::start()} method before calling the \texttt{DynamicsWorld::update()} method. \\
You can also use the \texttt{DynamicsWorld::stop()} method to stop the simulation. You will then be able to start it again and continue updating it. \\
Note that you can get the elapsed time (in seconds) from the beginning of the physics simulation using the \texttt{DynamicsWorld::getPhysicsTime()} method.
This can be useful to
create some animations.
\subsection{Destroying the Dynamics World}
Do not forget to destroy the \texttt{DynamicsWorld} instance at the end of your program in order to release the allocated memory. If the object has been created statically, it will
automatically be destroyed at the end of the scope in which it has been created. If the object has been created dynamically (using the \texttt{new} operator), you need to destroy
it with the \texttt{delete} operator.
Do not forget to destroy the \texttt{DynamicsWorld} instance at the end of your program in order to release the allocated memory. If the object has been created
statically, it will automatically be destroyed at the end of the scope in which it has been created. If the object has been created dynamically (using the
\texttt{new} operator), you need to destroy it with the \texttt{delete} operator. \\
When the \texttt{DynamicsWorld} is destroyed, all the bodies and joints that have been added into it and that have not been destroyed already will be destroyed.
Therefore, the pointers to the bodies and joints of the world will become invalid after the existence of their \texttt{DynamicsWorld}.
\section{Rigid Bodies}
\label{sec:rigidbody}
@ -498,6 +516,11 @@ rigidBody->enableGravity(false);
another body. However, if the value is 1, the friction force will be high. You can change the friction coefficient of the material with the
\texttt{Material::setFrictionCoefficient()} method. \\
You can use the material to add rolling resistance to a rigid body. Rolling resistance can be used to stop
a rolling object on a flat surface for instance. You should use this only with SphereShape,
CapsuleShape, CylinderShape or ConeShape collision shapes. By default, rolling resistance is zero but you can
set a positive value using the \texttt{Material::setRollingResistance()} method to increase resistance. \\
Here is how to get the material of a rigid body and how to modify some of its properties : \\
\begin{lstlisting}
@ -849,13 +872,121 @@ for (unsigned int i=0; i<mesh.getNbFaces(); i++) {
collisionShape.setIsEdgesInformationUsed(true);
\end{lstlisting}
\subsection{Concave Mesh Shape}
\begin{figure}[h]
\centering
\includegraphics{concavemeshshape.png}
\label{fig:concaveshape}
\end{figure}
The \texttt{ConcaveMeshShape} class can be used for a static concave triangular mesh. It can be used to describe an environment for
instance. Note that it cannot be used with a dynamic body that is allowed to move. Moreover, make sure to use a \texttt{ConcaveMeshShape} only
when you are not able to use a convex shape and also try to limit the number of triangles of that mesh because collision detection
with \texttt{ConcaveMeshShape} is quite expensive compared to convex shapes. \\
In order to create a concave mesh shape, you need to supply a pointer to a \texttt{TriangleMesh}. A \texttt{TriangleMesh} is a class
that describes a mesh made of triangles. A \texttt{TriangleMesh} can contain several parts (submeshes). Each part is a set of
triangles represented by a \texttt{TriangleVertexArray} object. First, you need to create a \texttt{TriangleVertexArray}. A \texttt{TriangleVertexArray} represents
a continuous array of vertices and indexes for a triangular mesh. When you create a \texttt{TriangleVertexArray}, no data is copied
into the array. It only stores a pointer to the data. The goal is to allow the user to share vertices data between the physics engine and the rendering
part. Therefore, make sure that the data pointed by a \texttt{TriangleVertexArray} remains valid during the whole \texttt{TriangleVertexArray} life.
\\
The following example show how to create a \texttt{TriangleVertexArray}: \\
\begin{lstlisting}
const int nbVertices = 8;
const int nbTriangles = 12;
float vertices[3 * nbVertices] = ...;
int indices[3 * nbTriangles] = ...;
rp3d::TriangleVertexArray* triangleArray =
new rp3d::TriangleVertexArray(nbVertices, vertices, 3 * sizeof(float), nbTriangles,
indices, sizeof(int),
rp3d::TriangleVertexArray::VERTEX_FLOAT_TYPE,
rp3d::TriangleVertexArray::INDEX_INTEGER_TYPE);
\end{lstlisting}
\vspace{0.6cm}
Now that we have a \texttt{TriangleVertexArray}, we need to create a \texttt{TriangleMesh} and add the \texttt{TriangleVertexArray}
into it as a subpart. Once this is done, we can create the actual \texttt{ConcaveMeshShape} and add it to the body we want to
simulate as in the following example: \\
\begin{lstlisting}
rp3d::TriangleMesh triangleMesh;
// Add the triangle vertex array to the triangle mesh
triangleMesh.addSubpart(triangleArray);
// Create the concave mesh shape
ConcaveMesh* concaveMesh = new rp3d::ConcaveMeshShape(&triangleMesh);
\end{lstlisting}
\vspace{0.6cm}
Note that the \texttt{TriangleMesh} object also needs to exist during the whole life of the collision shape because its
data is not copied into the collision shape.
\subsection{Heightfield Shape}
\begin{figure}[h]
\centering
\includegraphics{heightfieldshape.png}
\label{fig:heightfieldshape}
\end{figure}
The \texttt{HeightFieldShape} is a collision shape that can be used to represent a static terrain for instance. You can
define a heightfield with a two dimensional grid that has a given height value at each point. \\
In order to create a \texttt{HeightFieldShape}, you need to have an array with all the height values of your field.
You can have height values of type int, float or double. You need to give the number of rows and columns of your two
dimensional grid. Note that the height values in your array must be organized such that the value at row
\texttt{indexRow} and column \texttt{indexColumn} is located at the following position in the array:
\begin{lstlisting}
heighFieldValues[indexRow * nbColumns + indexColumn]
\end{lstlisting}
\vspace{0.6cm}
Morevover, you need to provide the minimum and maximum height values of your height field. \\
Here is an example that shows how to create a \texttt{HeightFieldShape}: \\
\begin{lstlisting}
const int nbRows = 40;
const int nbColumns = 50;
float minHeight = 100;
float maxHeight = 500;
// Height values
float heightValues[nbRows * nbColumns] = ...;
// Create the heightfield collision shape
rp3d::HeightFieldShape = new rp3d::HeightFieldShape(nbColumns, nbRows, minHeight,
maxHeight, heightValues, rp3d::HeightFieldShape::HEIGHT_FLOAT_TYPE);
\end{lstlisting}
\vspace{0.6cm}
Note that the array of height values is not copied into the \texttt{HeightFieldShape}. Therefore, you need to make sure
it exists during the lifetime of the \texttt{HeightFieldShape} and you must not forget to release its memory when you
destroy the collision shape or at the end of your application. \\
When creating a \texttt{HeightFieldShape}, the origin of the shape will be at the center of its bounding volume.
Therefore, if you create a \texttt{HeightFieldShape} with a minimum height of 100 and a maximum height of 500, the
maximum coordinates of the shape on the Y axis will be 200 and the minimum coordinates will be -200.
\subsection{Adding a Collision Shape to a body - The Proxy Shape concept}
\begin{sloppypar}
Now that you know how to create a collision shape, we will see how to add it to a given body. \\
First, note that when you add a collision shape to a body, the collision shape object that you gave as a parameter
will be copied internally. Therefore, you can destroy the collision shape object right after it has been added to the body. \\
First note that when you add a collision shape to a body, the shape will not be copied internally. You only give a
pointer to the shape in parameter. The shape must exist during the whole lifetime of the body. This way, you can
create a collision shape and reuse it for multiple bodies. You are also responsible to destroy the shape at the
end when the bodies are not used anymore. \\
In order to add a collision shape to a body, you need to use the \texttt{CollisionBody::addCollisionShape()} method for a Collision Body and the
\texttt{RigidBody::addCollisionShape()} method for a Rigid Body. You will have to provide the collision shape transform in parameter. This is the
@ -866,8 +997,6 @@ collisionShape.setIsEdgesInformationUsed(true);
You can use the returned Proxy Shape to get or set parameters of the given collision shape in that particular body. This concept is also called \emph{fixture} in some
other physics engines. In ReactPhysics3D, a Proxy Shape is represented by the \texttt{ProxyShape} class. \\
When you create a collision shape, you can add it to multiple bodies. You do not need to create several times the same collision shape. \\
The following example shows how to add a sphere collision shape with a given mass to a rigid body and also how to remove it from the body using the Proxy Shape pointer. \\
\end{sloppypar}
@ -885,7 +1014,7 @@ rp3d::decimal mass = rp3d::decimal(4.0);
// Add the collision shape to the rigid body
rp3d::ProxyShape* proxyShape;
proxyShape = body->addCollisionShape(shape, transform, mass);
proxyShape = body->addCollisionShape(&shape, transform, mass);
// If you want to remove the collision shape from the body
// at some point, you need to use the proxy shape
@ -1432,48 +1561,142 @@ bool isHit = proxyShape->raycast(ray, raycastInfo);
\vspace{0.6cm}
\section{Examples}
\label{sec:examples}
\section{Testbed application}
\label{sec:testbed}
You can find some demos in the \texttt{examples/} folder of
the ReactPhysics3D library. Follow the instructions described in section \ref{sec:building} to
compile the examples. Note that OpenGL and the GLEW library are required to run those examples. Studying the examples is a
good way to understand how to use the ReactPhysics3D library. \\
\begin{figure}[h]
\centering
\includegraphics{testbed.png}
\label{fig:testbed}
\end{figure}
All the examples require some command line arguments to be able to run them. Do not forget to set them in your IDE (Visual Studio, XCode, \dots) or to
specify them when you run the example in command line. You can find the command line arguments to use for each example bellow.
The testbed application is a graphical interface where you can select and see some demo scenes using the
ReactPhysics3D library. \\
\subsection{Cubes}
Follow the instructions described in section \ref{sec:building} to
compile the testbed application. Note that OpenGL is required to compile it. \\
Command line arguments: shaders/ \\
The testbed application can be found in the \texttt{testbed/} folder of
the ReactPhysics3D library. Do not hesitate to take a look at the code of the demo scenes to better understand how
to use the library in your application. \\
In this example, you will see how to create a floor and some cubes using the Box Shape for collision detection. Because of gravity,
the cubes will fall down on the floor. After falling down, the cubes will come to rest and start sleeping (become inactive). In this demo,
the cubes are green when they are active and become red as they get inactive (sleeping).
The following subsections describe the demo scenes that can be found in the testbed application.
\subsection{Collision Shapes}
\subsection{Cubes Scene}
Command line arguments: shaders/ meshes/ \\
In this example, you will see how to create a floor (using the Box Shape) and some other bodies using the different collision shapes available
in the ReactPhysics3D library like Cylinders, Capsules, Spheres, Convex Meshes and Cones. Those bodies will fall down to the floor.
In this scene, you will see how to create a floor and some cubes using the Box Shape for collision detection. Because of gravity,
the cubes will fall down on the floor. After falling down, the cubes will come to rest and start sleeping (become inactive). In this scene,
the cubes will become red as they get inactive (sleeping).
\subsection{Joints}
Command line arguments: shaders/ \\
In this example, you will learn how to create different joints (Ball and Socket, Hinge, Slider, Fixed) into the dynamics world. You can also see how
In this scene, you will learn how to create different joints (Ball and Socket, Hinge, Slider, Fixed) into the dynamics world. You can also see how
to set the motor or limits of the joints.
\subsection{Raycast}
\subsection{Collision Shapes Scene}
Command line arguments: shaders/ meshes/ \\
In this scene, you will see how to create a floor (using the Box Shape) and some other bodies using the different collision shapes available
in the ReactPhysics3D library like Cylinders, Capsules, Spheres, Convex Meshes and Cones. Those bodies will fall down to the floor.
In this example, you will see how to use the ray casting methods of the library. Several rays are thrown against the different collision shapes.
It is possible to switch from a collision shape to another using the space key.
\subsection{Heightfield Scene}
In this scene, you will see how to use the Height field collision shape of the library. Several cubes will fall
down to the height field.
\subsection{Raycast Scene}
In this scene, you will see how to use the ray casting methods of the library. Several rays are thrown against the different collision shapes.
It is possible to switch from a collision shape to another using the spacebar key.
\subsection{Concave Mesh Scene}
In this scene, you will see how to use the static concave mesh collision shape of the library.
\section{Retrieving contacts}
There are several ways to get the contacts information (contact point, normal, penetration depth, \dots) from the \texttt{DynamicsWorld}. \\
\subsection{Contacts of a given rigid body}
If you are interested to retrieve all the contacts of a single rigid body, you can use the \texttt{RigidBody::getContactManifoldsList()} method. This method will
return a linked list with all the current contact manifolds of the body. A contact manifold can contains several contact points. \\
Here is an example showing how to get the contact points of a given rigid body: \\
\begin{lstlisting}
const ContactManifoldListElement* listElem;
// Get the head of the linked list of contact manifolds of the body
listElem = rigidbody->getContactManifoldsList();
// For each contact manifold of the body
for (; listElem != NULL; listElem = listElem->next) {
ContactManifold* manifold = listElem->contactManifold;
// For each contact point of the manifold
for (int i=0; i<manifold->getNbContactPoints(); i++) {
// Get the contact point
ContactPoint* point = manifold->getContactPoint(i);
// Get the world-space contact point on body 1
Vector3 pos = point->getWorldPointOnBody1();
// Get the world-space contact normal
Vector3 normal = point->getNormal();
}
}
\end{lstlisting}
\vspace{0.6cm}
Note that this technique to retrieve the contacts, if you use it between the \texttt{DynamicsWorld::update()} calls, will only give you the contacts are the end of
each frame. You will probably miss several contacts that have occured in the physics internal sub-steps. In section \ref{sec:receiving_feedback}, you will
see how to get all the contact occuring in the physis sub-steps of the engine. Also note that a contact manifold contains some persistent contact points that
have may have been there for several frames.
\subsection{All the contacts of the world}
If you want to retrieve all the contacts of any rigid body in the world, you can use the \texttt{DynamicsWorld::getContactsList()} method. This method will
a \texttt{std::vector} with the list of all the current contact manifolds of the world. A contact manifold may contain several contact points. \\
The following example shows how to get all the contacts of the world using this method: \\
\begin{lstlisting}
std::vector<ContactManifold*> manifolds;
// Get all the contacts of the world
manifolds = dynamicsWorld->getContactsList();
std::vector<ContactManifold*>::iterator it;
// For each contact manifold of the body
for (it = manifolds.begin(); it != manifolds.end(); ++it) {
ContactManifold* manifold = *it;
// For each contact point of the manifold
for (int i=0; i<manifold->getNbContactPoints(); i++) {
// Get the contact point
ContactPoint* point = manifold->getContactPoint(i);
// Get the world-space contact point on body 1
Vector3 pos = point->getWorldPointOnBody1();
// Get the world-space contact normal
Vector3 normal = point->getNormal();
}
}
\end{lstlisting}
\vspace{0.6cm}
Note that this technique to retrieve the contacts, if you use it between the \texttt{DynamicsWorld::update()} calls, will only give you the contacts are the end of
each frame. You will probably miss several contacts that have occured in the physics internal sub-steps. In section \ref{sec:receiving_feedback}, you will
see how to get all the contact occuring in the physis sub-steps of the engine. Also note that a contact manifold contains some persistent contact points that
have may have been there for several frames.
\section{Receiving Feedback}
\label{sec:receiving_feedback}
Sometimes, you want to receive notifications from the physics engine when a given event happens. The \texttt{EventListener} class can be used for that purpose. In order to use
it, you need to create a new class that inherits from the \texttt{EventListener} class and overrides some methods that will be called by the ReactPhysics3D library when some events
occur. You also need to register your class in the physics world using the \texttt{DynamicsWorld::setEventListener()} as in the following code: \\

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -10,7 +10,7 @@
\vskip 1.3cm
{\Huge \@title\par}%
\vskip 0.3cm
{\Large Version: 0.5.0\par}%
{\Large Version: 0.6.0\par}%
\vskip 0.3cm
{\Large \@author\par}%
\vskip 2cm

View File

@ -1,11 +0,0 @@
# Minimum cmake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Set a variable for the directory of the opengl-framework
SET(OPENGLFRAMEWORK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/common/opengl-framework")
ADD_SUBDIRECTORY(common/)
ADD_SUBDIRECTORY(cubes/)
ADD_SUBDIRECTORY(joints/)
ADD_SUBDIRECTORY(collisionshapes/)
ADD_SUBDIRECTORY(raycast/)

View File

@ -1,42 +0,0 @@
# Minimum cmake version required
cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(CollisionShapes)
# Where to build the executables
SET(EXECUTABLE_OUTPUT_PATH "${OUR_EXECUTABLE_OUTPUT_PATH}/collisionshapes")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
# Copy the shaders used for the demo into the build directory
FILE(COPY "${OPENGLFRAMEWORK_DIR}/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Copy the meshes used for the demo into the build directory
FILE(COPY "../common/meshes/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/meshes/")
# Headers
INCLUDE_DIRECTORIES("${OPENGLFRAMEWORK_DIR}/src/" "../common/glfw/include/" "../common/")
# Source files
SET(COLLISION_SHAPES_SOURCES
CollisionShapes.cpp
Scene.cpp
Scene.h
"../common/VisualContactPoint.cpp"
"../common/ConvexMesh.cpp"
"../common/Capsule.cpp"
"../common/Sphere.cpp"
"../common/Cylinder.cpp"
"../common/Cone.cpp"
"../common/Dumbbell.cpp"
"../common/Box.cpp"
"../common/Viewer.cpp"
)
# Create the executable
ADD_EXECUTABLE(collisionshapes ${COLLISION_SHAPES_SOURCES})
# Link with libraries
TARGET_LINK_LIBRARIES(collisionshapes reactphysics3d openglframework glfw ${GLFW_LIBRARIES})

View File

@ -1,152 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Scene.h"
#include "../common/Viewer.h"
// Declarations
void simulate();
void render();
void update();
void mouseButton(GLFWwindow* window, int button, int action, int mods);
void mouseMotion(GLFWwindow* window, double x, double y);
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
void scroll(GLFWwindow* window, double xAxis, double yAxis);
void init();
// Namespaces
using namespace openglframework;
// Global variables
Viewer* viewer;
Scene* scene;
// Main function
int main(int argc, char** argv) {
// Create and initialize the Viewer
viewer = new Viewer();
Vector2 windowsSize = Vector2(800, 600);
Vector2 windowsPosition = Vector2(100, 100);
viewer->init(argc, argv, "ReactPhysics3D Examples - Collision Shapes",
windowsSize, windowsPosition, true);
// If the shaders and meshes folders are not specified as an argument
if (argc < 3) {
std::cerr << "Error : You need to specify the shaders folder as the first argument"
<< " and the meshes folder as the second argument" << std::endl;
return 1;
}
// Get the path of the shaders folder
std::string shaderFolderPath(argv[1]);
std::string meshFolderPath(argv[2]);
// Register callback methods
viewer->registerUpdateFunction(update);
viewer->registerKeyboardCallback(keyboard);
viewer->registerMouseButtonCallback(mouseButton);
viewer->registerMouseCursorCallback(mouseMotion);
viewer->registerScrollingCallback(scroll);
// Create the scene
scene = new Scene(viewer, shaderFolderPath, meshFolderPath);
init();
viewer->startMainLoop();
delete viewer;
delete scene;
return 0;
}
// Update function that is called each frame
void update() {
// Take a simulation step
simulate();
// Render
render();
}
// Simulate function
void simulate() {
// Physics simulation
scene->simulate();
viewer->computeFPS();
}
// Initialization
void init() {
// Define the background color (black)
glClearColor(0.0, 0.0, 0.0, 1.0);
}
// Callback method to receive keyboard events
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
else if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) {
scene->pauseContinueSimulation();
}
}
// Callback method to receive scrolling events
void scroll(GLFWwindow* window, double xAxis, double yAxis) {
viewer->scrollingEvent(static_cast<float>(yAxis));
}
// Called when a mouse button event occurs
void mouseButton(GLFWwindow* window, int button, int action, int mods) {
viewer->mouseButtonEvent(button, action);
}
// Called when a mouse motion event occurs
void mouseMotion(GLFWwindow* window, double x, double y) {
viewer->mouseMotionEvent(x, y);
}
// Display the scene
void render() {
// Render the scene
scene->render();
// Display the FPS
viewer->displayGUI();
// Check the OpenGL errors
Viewer::checkOpenGLErrors();
}

View File

@ -1,444 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Scene.h"
// Namespaces
using namespace openglframework;
// Constructor
Scene::Scene(Viewer* viewer, const std::string& shaderFolderPath, const std::string& meshFolderPath)
: mViewer(viewer), mLight0(0),
mPhongShader(shaderFolderPath + "phong.vert",
shaderFolderPath +"phong.frag"), mIsRunning(false) {
// Move the light 0
mLight0.translateWorld(Vector3(50, 50, 50));
// Compute the radius and the center of the scene
float radiusScene = 30.0f;
openglframework::Vector3 center(0, 5, 0);
// Set the center of the scene
mViewer->setScenePosition(center, radiusScene);
// Gravity vector in the dynamics world
rp3d::Vector3 gravity(0, -9.81, 0);
// Time step for the physics simulation
rp3d::decimal timeStep = 1.0f / 60.0f;
// Create the dynamics world for the physics simulation
mDynamicsWorld = new rp3d::DynamicsWorld(gravity, timeStep);
// Set the number of iterations of the constraint solver
mDynamicsWorld->setNbIterationsVelocitySolver(15);
// Create the static data for the visual contact points
VisualContactPoint::createStaticData(meshFolderPath);
float radius = 3.0f;
for (int i=0; i<NB_COMPOUND_SHAPES; i++) {
// Position
float angle = i * 30.0f;
openglframework::Vector3 position(radius * cos(angle),
100 + i * (DUMBBELL_HEIGHT + 0.3f),
radius * sin(angle));
// Create a convex mesh and a corresponding rigid in the dynamics world
Dumbbell* dumbbell = new Dumbbell(position, mDynamicsWorld, meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = dumbbell->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the mesh the list of dumbbells in the scene
mDumbbells.push_back(dumbbell);
}
// Create all the boxes of the scene
for (int i=0; i<NB_BOXES; i++) {
// Position
float angle = i * 30.0f;
openglframework::Vector3 position(radius * cos(angle),
60 + i * (BOX_SIZE.y + 0.8f),
radius * sin(angle));
// Create a sphere and a corresponding rigid in the dynamics world
Box* box = new Box(BOX_SIZE, position , BOX_MASS, mDynamicsWorld);
// Change the material properties of the rigid body
rp3d::Material& material = box->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the sphere the list of sphere in the scene
mBoxes.push_back(box);
}
// Create all the spheres of the scene
for (int i=0; i<NB_CUBES; i++) {
// Position
float angle = i * 35.0f;
openglframework::Vector3 position(radius * cos(angle),
50 + i * (SPHERE_RADIUS + 0.8f),
radius * sin(angle));
// Create a sphere and a corresponding rigid in the dynamics world
Sphere* sphere = new Sphere(SPHERE_RADIUS, position , BOX_MASS, mDynamicsWorld,
meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = sphere->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the sphere the list of sphere in the scene
mSpheres.push_back(sphere);
}
// Create all the cones of the scene
for (int i=0; i<NB_CONES; i++) {
// Position
float angle = i * 50.0f;
openglframework::Vector3 position(radius * cos(angle),
35 + i * (CONE_HEIGHT + 0.3f),
radius * sin(angle));
// Create a cone and a corresponding rigid in the dynamics world
Cone* cone = new Cone(CONE_RADIUS, CONE_HEIGHT, position, CONE_MASS, mDynamicsWorld,
meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = cone->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the cone the list of sphere in the scene
mCones.push_back(cone);
}
// Create all the cylinders of the scene
for (int i=0; i<NB_CYLINDERS; i++) {
// Position
float angle = i * 35.0f;
openglframework::Vector3 position(radius * cos(angle),
25 + i * (CYLINDER_HEIGHT + 0.3f),
radius * sin(angle));
// Create a cylinder and a corresponding rigid in the dynamics world
Cylinder* cylinder = new Cylinder(CYLINDER_RADIUS, CYLINDER_HEIGHT, position ,
CYLINDER_MASS, mDynamicsWorld, meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = cylinder->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the cylinder the list of sphere in the scene
mCylinders.push_back(cylinder);
}
// Create all the capsules of the scene
for (int i=0; i<NB_CAPSULES; i++) {
// Position
float angle = i * 45.0f;
openglframework::Vector3 position(radius * cos(angle),
15 + i * (CAPSULE_HEIGHT + 0.3f),
radius * sin(angle));
// Create a cylinder and a corresponding rigid in the dynamics world
Capsule* capsule = new Capsule(CAPSULE_RADIUS, CAPSULE_HEIGHT, position ,
CAPSULE_MASS, mDynamicsWorld, meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = capsule->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the cylinder the list of sphere in the scene
mCapsules.push_back(capsule);
}
// Create all the convex meshes of the scene
for (int i=0; i<NB_MESHES; i++) {
// Position
float angle = i * 30.0f;
openglframework::Vector3 position(radius * cos(angle),
5 + i * (CAPSULE_HEIGHT + 0.3f),
radius * sin(angle));
// Create a convex mesh and a corresponding rigid in the dynamics world
ConvexMesh* mesh = new ConvexMesh(position, MESH_MASS, mDynamicsWorld, meshFolderPath);
// Change the material properties of the rigid body
rp3d::Material& material = mesh->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Add the mesh the list of sphere in the scene
mConvexMeshes.push_back(mesh);
}
// Create the floor
openglframework::Vector3 floorPosition(0, 0, 0);
mFloor = new Box(FLOOR_SIZE, floorPosition, FLOOR_MASS, mDynamicsWorld);
// The floor must be a static rigid body
mFloor->getRigidBody()->setType(rp3d::STATIC);
// Change the material properties of the rigid body
rp3d::Material& material = mFloor->getRigidBody()->getMaterial();
material.setBounciness(rp3d::decimal(0.2));
// Start the simulation
startSimulation();
}
// Destructor
Scene::~Scene() {
// Stop the physics simulation
stopSimulation();
// Destroy the shader
mPhongShader.destroy();
// Destroy all the boxes of the scene
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the box
delete (*it);
}
// Destroy all the sphere of the scene
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the sphere
delete (*it);
}
// Destroy all the cones of the scene
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the sphere
delete (*it);
}
// Destroy all the cylinders of the scene
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the sphere
delete (*it);
}
// Destroy all the capsules of the scene
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the sphere
delete (*it);
}
// Destroy all the convex meshes of the scene
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
it != mConvexMeshes.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the convex mesh
delete (*it);
}
// Destroy all the dumbbell of the scene
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
it != mDumbbells.end(); ++it) {
// Destroy the corresponding rigid body from the dynamics world
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
// Destroy the convex mesh
delete (*it);
}
// Destroy the rigid body of the floor
mDynamicsWorld->destroyRigidBody(mFloor->getRigidBody());
// Destroy the floor
delete mFloor;
// Destroy the dynamics world
delete mDynamicsWorld;
}
// Take a step for the simulation
void Scene::simulate() {
// If the physics simulation is running
if (mIsRunning) {
// Take a simulation step
mDynamicsWorld->update();
// Update the position and orientation of the boxes
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the sphere
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the cones
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the cylinders
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the capsules
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the convex meshes
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
it != mConvexMeshes.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
// Update the position and orientation of the dumbbells
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
it != mDumbbells.end(); ++it) {
// Update the transform used for the rendering
(*it)->updateTransform();
}
mFloor->updateTransform();
}
}
// Render the scene
void Scene::render() {
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_CULL_FACE);
// Get the world-space to camera-space matrix
const Camera& camera = mViewer->getCamera();
const openglframework::Matrix4 worldToCameraMatrix = camera.getTransformMatrix().getInverse();
// Bind the shader
mPhongShader.bind();
// Set the variables of the shader
mPhongShader.setMatrix4x4Uniform("projectionMatrix", camera.getProjectionMatrix());
mPhongShader.setVector3Uniform("light0PosCameraSpace", worldToCameraMatrix * mLight0.getOrigin());
mPhongShader.setVector3Uniform("lightAmbientColor", Vector3(0.3f, 0.3f, 0.3f));
const Color& diffColLight0 = mLight0.getDiffuseColor();
const Color& specColLight0 = mLight0.getSpecularColor();
mPhongShader.setVector3Uniform("light0DiffuseColor", Vector3(diffColLight0.r, diffColLight0.g, diffColLight0.b));
mPhongShader.setVector3Uniform("light0SpecularColor", Vector3(specColLight0.r, specColLight0.g, specColLight0.b));
mPhongShader.setFloatUniform("shininess", 200.0f);
// Render all the boxes of the scene
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the sphere of the scene
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the cones of the scene
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the cylinders of the scene
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the capsules of the scene
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the convex meshes of the scene
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
it != mConvexMeshes.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render all the dumbbells of the scene
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
it != mDumbbells.end(); ++it) {
(*it)->render(mPhongShader, worldToCameraMatrix);
}
// Render the floor
mFloor->render(mPhongShader, worldToCameraMatrix);
// Unbind the shader
mPhongShader.unbind();
}

View File

@ -1,131 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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 BOX_H
#define BOX_H
// Libraries
#include "openglframework.h"
#include "reactphysics3d.h"
// Structure VertexData
struct VertexData {
/// Vertex position
openglframework::Vector3 position;
/// Vertex normal
openglframework::Vector3 normal;
// Vertex color
openglframework::Color color;
};
// Class Box
class Box : public openglframework::Object3D {
private :
// -------------------- Attributes -------------------- //
/// Size of each side of the box
float mSize[3];
/// Rigid body used to simulate the dynamics of the box
rp3d::CollisionBody* mRigidBody;
/// Scaling matrix (applied to a cube to obtain the correct box dimensions)
openglframework::Matrix4 mScalingMatrix;
/// Vertex Buffer Object for the vertices data used to render the box with OpenGL
static openglframework::VertexBufferObject mVBOVertices;
/// Vertex Buffer Object for the indices used to render the box with OpenGL
static openglframework::VertexBufferObject mVBOIndices;
/// Vertex data for each vertex of the cube (used to render the box)
static VertexData mCubeVertices[8];
/// Indices of the cube (used to render the box)
static GLuint mCubeIndices[36];
/// True if the VBOs have already been created
static bool areVBOsCreated;
/// Main color of the box
openglframework::Color mColor;
// -------------------- Methods -------------------- //
/// Create a Vertex Buffer Object to render to box with OpenGL
static void createVBO();
public :
// -------------------- Methods -------------------- //
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
reactphysics3d::CollisionWorld* world);
/// Constructor
Box(const openglframework::Vector3& size, const openglframework::Vector3& position,
float mass, reactphysics3d::DynamicsWorld *world);
/// Destructor
~Box();
/// Return a pointer to the collision body of the box
reactphysics3d::CollisionBody* getCollisionBody();
/// Return a pointer to the rigid body of the box
reactphysics3d::RigidBody* getRigidBody();
/// Update the transform matrix of the box
void updateTransform();
/// Render the cube at the correct position and with the correct orientation
void render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix);
/// Set the color of the box
void setColor(const openglframework::Color& color);
};
// Return a pointer to the collision body of the box
inline rp3d::CollisionBody* Box::getCollisionBody() {
return mRigidBody;
}
// Return a pointer to the rigid body of the box
inline rp3d::RigidBody* Box::getRigidBody() {
return dynamic_cast<rp3d::RigidBody*>(mRigidBody);
}
// Set the color of the box
inline void Box::setColor(const openglframework::Color& color) {
mColor = color;
}
#endif

View File

@ -1,5 +0,0 @@
# Minimum cmake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
ADD_SUBDIRECTORY(opengl-framework/)
ADD_SUBDIRECTORY(glfw/)

View File

@ -1,218 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "ConvexMesh.h"
// Constructor
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position,
reactphysics3d::CollisionWorld* world,
const std::string& meshFolderPath)
: openglframework::Mesh() {
// Load the mesh from a file
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "convexmesh.obj", *this);
// Calculate the normals of the mesh
calculateNormals();
// Initialize the position where the sphere will be rendered
translateWorld(position);
// Convert the vertices array to the rp3d::decimal type
rp3d::decimal* vertices = new rp3d::decimal[3 * mVertices.size()];
for (int i=0; i < mVertices.size(); i++) {
vertices[3 * i] = static_cast<rp3d::decimal>(mVertices[i].x);
vertices[3 * i + 1] = static_cast<rp3d::decimal>(mVertices[i].y);
vertices[3 * i + 2] = static_cast<rp3d::decimal>(mVertices[i].z);
}
// Create the collision shape for the rigid body (convex mesh shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroyed right after calling RigidBody::addCollisionShape()
rp3d::ConvexMeshShape collisionShape(vertices, mVertices.size(), 3 * sizeof(rp3d::decimal));
delete[] vertices;
// Add the edges information of the mesh into the convex mesh collision shape.
// This is optional but it really speed up the convex mesh collision detection at the
// cost of some additional memory to store the edges inside the collision shape.
for (unsigned int i=0; i<getNbFaces(); i++) { // For each triangle face of the mesh
// Get the three vertex IDs of the vertices of the face
unsigned int v1 = getVertexIndexInFace(i, 0);
unsigned int v2 = getVertexIndexInFace(i, 1);
unsigned int v3 = getVertexIndexInFace(i, 2);
// Add the three edges into the collision shape
collisionShape.addEdge(v1, v2);
collisionShape.addEdge(v1, v3);
collisionShape.addEdge(v2, v3);
}
collisionShape.setIsEdgesInformationUsed(true);// Enable the fast collision detection with edges
// Initial position and orientation of the rigid body
rp3d::Vector3 initPosition(position.x, position.y, position.z);
rp3d::Quaternion initOrientation = rp3d::Quaternion::identity();
rp3d::Transform transform(initPosition, initOrientation);
// Create a rigid body corresponding to the sphere in the dynamics world
mRigidBody = world->createCollisionBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
mRigidBody->addCollisionShape(collisionShape, rp3d::Transform::identity());
}
// Constructor
ConvexMesh::ConvexMesh(const openglframework::Vector3 &position, float mass,
reactphysics3d::DynamicsWorld* dynamicsWorld,
const std::string& meshFolderPath)
: openglframework::Mesh() {
// Load the mesh from a file
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "convexmesh.obj", *this);
// Calculate the normals of the mesh
calculateNormals();
// Initialize the position where the sphere will be rendered
translateWorld(position);
// Convert the vertices array to the rp3d::decimal type
rp3d::decimal* vertices = new rp3d::decimal[3 * mVertices.size()];
for (int i=0; i < mVertices.size(); i++) {
vertices[3 * i] = static_cast<rp3d::decimal>(mVertices[i].x);
vertices[3 * i + 1] = static_cast<rp3d::decimal>(mVertices[i].y);
vertices[3 * i + 2] = static_cast<rp3d::decimal>(mVertices[i].z);
}
// Create the collision shape for the rigid body (convex mesh shape)
// ReactPhysics3D will clone this object to create an internal one. Therefore,
// it is OK if this object is destroyed right after calling RigidBody::addCollisionShape()
rp3d::ConvexMeshShape collisionShape(vertices, mVertices.size(), 3 * sizeof(rp3d::decimal));
delete[] vertices;
// Add the edges information of the mesh into the convex mesh collision shape.
// This is optional but it really speed up the convex mesh collision detection at the
// cost of some additional memory to store the edges inside the collision shape.
for (unsigned int i=0; i<getNbFaces(); i++) { // For each triangle face of the mesh
// Get the three vertex IDs of the vertices of the face
unsigned int v1 = getVertexIndexInFace(i, 0);
unsigned int v2 = getVertexIndexInFace(i, 1);
unsigned int v3 = getVertexIndexInFace(i, 2);
// Add the three edges into the collision shape
collisionShape.addEdge(v1, v2);
collisionShape.addEdge(v1, v3);
collisionShape.addEdge(v2, v3);
}
collisionShape.setIsEdgesInformationUsed(true);// Enable the fast collision detection with edges
// Initial position and orientation of the rigid body
rp3d::Vector3 initPosition(position.x, position.y, position.z);
rp3d::Quaternion initOrientation = rp3d::Quaternion::identity();
rp3d::Transform transform(initPosition, initOrientation);
// Create a rigid body corresponding to the sphere in the dynamics world
rp3d::RigidBody* body = dynamicsWorld->createRigidBody(transform);
// Add a collision shape to the body and specify the mass of the collision shape
body->addCollisionShape(collisionShape, rp3d::Transform::identity(), mass);
mRigidBody = body;
}
// Destructor
ConvexMesh::~ConvexMesh() {
// Destroy the mesh
destroy();
}
// Render the sphere at the correct position and with the correct orientation
void ConvexMesh::render(openglframework::Shader& shader,
const openglframework::Matrix4& worldToCameraMatrix) {
// Bind the shader
shader.bind();
// Set the model to camera matrix
const openglframework::Matrix4 localToCameraMatrix = worldToCameraMatrix * mTransformMatrix;
shader.setMatrix4x4Uniform("localToCameraMatrix", localToCameraMatrix);
// Set the normal matrix (inverse transpose of the 3x3 upper-left sub matrix of the
// model-view matrix)
const openglframework::Matrix3 normalMatrix =
localToCameraMatrix.getUpperLeft3x3Matrix().getInverse().getTranspose();
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if (hasTexture()) {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glVertexPointer(3, GL_FLOAT, 0, getVerticesPointer());
glNormalPointer(GL_FLOAT, 0, getNormalsPointer());
if(hasTexture()) {
glTexCoordPointer(2, GL_FLOAT, 0, getUVTextureCoordinatesPointer());
}
// For each part of the mesh
for (unsigned int i=0; i<getNbParts(); i++) {
glDrawElements(GL_TRIANGLES, getNbFaces(i) * 3,
GL_UNSIGNED_INT, getIndicesPointer());
}
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if (hasTexture()) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
// Unbind the shader
shader.unbind();
}
// Update the transform matrix of the sphere
void ConvexMesh::updateTransform() {
// Get the interpolated transform of the rigid body
rp3d::Transform transform = mRigidBody->getInterpolatedTransform();
// Compute the transform used for rendering the sphere
rp3d::decimal matrix[16];
transform.getOpenGLMatrix(matrix);
openglframework::Matrix4 newMatrix(matrix[0], matrix[4], matrix[8], matrix[12],
matrix[1], matrix[5], matrix[9], matrix[13],
matrix[2], matrix[6], matrix[10], matrix[14],
matrix[3], matrix[7], matrix[11], matrix[15]);
// Apply the scaling matrix to have the correct sphere dimensions
mTransformMatrix = newMatrix;
}

View File

@ -1,342 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Viewer.h"
#include "openglframework.h"
#include <iostream>
#include <cstdlib>
#include <sstream>
using namespace openglframework;
// Initialization of static variables
const float Viewer::SCROLL_SENSITIVITY = 0.02f;
// Constructor
Viewer::Viewer() : mFPS(0), mNbFrames(0), mPreviousTime(0) {
}
// Destructor
Viewer::~Viewer() {
// Destroy the window
glfwDestroyWindow(mWindow);
// Terminate GLFW
glfwTerminate();
}
// Initialize the viewer
void Viewer::init(int argc, char** argv, const std::string& windowsTitle,
const Vector2& windowsSize, const Vector2& windowsPosition,
bool isMultisamplingActive) {
mWindowTitle = windowsTitle;
// Set the GLFW error callback method
glfwSetErrorCallback(error_callback);
// Initialize the GLFW library
if (!glfwInit()) {
std::exit(EXIT_FAILURE);
}
// Active the multi-sampling by default
if (isMultisamplingActive) {
glfwWindowHint(GLFW_SAMPLES, 4);
}
// Create the GLFW window
mWindow = glfwCreateWindow(static_cast<int>(windowsSize.x),
static_cast<int>(windowsSize.y), mWindowTitle.c_str(), NULL, NULL);
if (!mWindow) {
glfwTerminate();
std::exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(mWindow);
// Disable Vertical Synchronization
glfwSwapInterval(0);
// Initialize the GLEW library
GLenum errorGLEW = glewInit();
if (errorGLEW != GLEW_OK) {
// Problem: glewInit failed, something is wrong
std::cerr << "GLEW Error : " << glewGetErrorString(errorGLEW) << std::endl;
assert(false);
std::exit(EXIT_FAILURE);
}
if (isMultisamplingActive) {
glEnable(GL_MULTISAMPLE);
}
}
// Set the dimension of the camera viewport
void Viewer::reshape() {
// Get the framebuffer dimension
int width, height;
glfwGetFramebufferSize(mWindow, &width, &height);
// Resize the viewport
mCamera.setDimensions(width, height);
glViewport(0, 0, width, height);
}
// Start the main loop where rendering occur
void Viewer::startMainLoop() {
// Loop until the user closes the window
while (!glfwWindowShouldClose(mWindow)) {
// Reshape the viewport
reshape();
// Call the update function
(*mUpdateFunctionPointer)();
// Swap front and back buffers
glfwSwapBuffers(mWindow);
// Poll for and process events
glfwPollEvents();
}
}
// Set the camera so that we can view the whole scene
void Viewer::resetCameraToViewAll() {
// Move the camera to the origin of the scene
mCamera.translateWorld(-mCamera.getOrigin());
// Move the camera to the center of the scene
mCamera.translateWorld(mCenterScene);
// Set the zoom of the camera so that the scene center is
// in negative view direction of the camera
mCamera.setZoom(1.0);
}
// Called when a mouse button event occurs
void Viewer::mouseButtonEvent(int button, int action) {
// Get the mouse cursor position
double x, y;
glfwGetCursorPos(mWindow, &x, &y);
// If the mouse button is pressed
if (action == GLFW_PRESS) {
mLastMouseX = x;
mLastMouseY = y;
mIsLastPointOnSphereValid = mapMouseCoordinatesToSphere(x, y, mLastPointOnSphere);
}
else { // If the mouse button is released
mIsLastPointOnSphereValid = false;
}
}
// Called when a mouse motion event occurs
void Viewer::mouseMotionEvent(double xMouse, double yMouse) {
int leftButtonState = glfwGetMouseButton(mWindow, GLFW_MOUSE_BUTTON_LEFT);
int rightButtonState = glfwGetMouseButton(mWindow, GLFW_MOUSE_BUTTON_RIGHT);
int middleButtonState = glfwGetMouseButton(mWindow, GLFW_MOUSE_BUTTON_MIDDLE);
int altKeyState = glfwGetKey(mWindow, GLFW_KEY_LEFT_ALT);
// Zoom
if (leftButtonState == GLFW_PRESS && altKeyState == GLFW_PRESS) {
// Get the window dimension
int width, height;
glfwGetWindowSize(mWindow, &width, &height);
float dy = static_cast<float>(yMouse - mLastMouseY);
float h = static_cast<float>(height);
// Zoom the camera
zoom(-dy / h);
}
// Translation
else if (middleButtonState == GLFW_PRESS || rightButtonState == GLFW_PRESS ||
(leftButtonState == GLFW_PRESS && altKeyState == GLFW_PRESS)) {
translate(xMouse, yMouse);
}
// Rotation
else if (leftButtonState == GLFW_PRESS) {
rotate(xMouse, yMouse);
}
// Remember the mouse position
mLastMouseX = xMouse;
mLastMouseY = yMouse;
mIsLastPointOnSphereValid = mapMouseCoordinatesToSphere(xMouse, yMouse, mLastPointOnSphere);
}
// Called when a scrolling event occurs
void Viewer::scrollingEvent(float scrollAxis) {
zoom(scrollAxis * SCROLL_SENSITIVITY);
}
// Map the mouse x,y coordinates to a point on a sphere
bool Viewer::mapMouseCoordinatesToSphere(double xMouse, double yMouse, Vector3& spherePoint) const {
// Get the window dimension
int width, height;
glfwGetWindowSize(mWindow, &width, &height);
if ((xMouse >= 0) && (xMouse <= width) && (yMouse >= 0) && (yMouse <= height)) {
float x = float(xMouse - 0.5f * width) / float(width);
float y = float(0.5f * height - yMouse) / float(height);
float sinx = sin(PI * x * 0.5f);
float siny = sin(PI * y * 0.5f);
float sinx2siny2 = sinx * sinx + siny * siny;
// Compute the point on the sphere
spherePoint.x = sinx;
spherePoint.y = siny;
spherePoint.z = (sinx2siny2 < 1.0) ? sqrt(1.0f - sinx2siny2) : 0.0f;
return true;
}
return false;
}
// Zoom the camera
void Viewer::zoom(float zoomDiff) {
// Zoom the camera
mCamera.setZoom(zoomDiff);
}
// Translate the camera
void Viewer::translate(int xMouse, int yMouse) {
float dx = static_cast<float>(xMouse - mLastMouseX);
float dy = static_cast<float>(yMouse - mLastMouseY);
// Translate the camera
mCamera.translateCamera(-dx / float(mCamera.getWidth()),
-dy / float(mCamera.getHeight()), mCenterScene);
}
// Rotate the camera
void Viewer::rotate(int xMouse, int yMouse) {
if (mIsLastPointOnSphereValid) {
Vector3 newPoint3D;
bool isNewPointOK = mapMouseCoordinatesToSphere(xMouse, yMouse, newPoint3D);
if (isNewPointOK) {
Vector3 axis = mLastPointOnSphere.cross(newPoint3D);
float cosAngle = mLastPointOnSphere.dot(newPoint3D);
float epsilon = std::numeric_limits<float>::epsilon();
if (fabs(cosAngle) < 1.0f && axis.length() > epsilon) {
axis.normalize();
float angle = 2.0f * acos(cosAngle);
// Rotate the camera around the center of the scene
mCamera.rotateAroundLocalPoint(axis, -angle, mCenterScene);
}
}
}
}
// Check the OpenGL errors
void Viewer::checkOpenGLErrors() {
GLenum glError;
// Get the OpenGL errors
glError = glGetError();
// While there are errors
while (glError != GL_NO_ERROR) {
// Get the error string
const GLubyte* stringError = gluErrorString(glError);
// Display the error
if (stringError)
std::cerr << "OpenGL Error #" << glError << "(" << gluErrorString(glError) << std::endl;
else
std::cerr << "OpenGL Error #" << glError << " (no message available)" << std::endl;
// Get the next error
glError = glGetError();
}
}
// Compute the FPS
void Viewer::computeFPS() {
mNbFrames++;
// Get the number of milliseconds since glutInit called
mCurrentTime = glfwGetTime();
// Calculate time passed
double timeInterval = mCurrentTime - mPreviousTime;
// Update the FPS counter each second
if(timeInterval > 1.0) {
// calculate the number of frames per second
mFPS = static_cast<double>(mNbFrames) / timeInterval;
// Set time
mPreviousTime = mCurrentTime;
// Reset frame count
mNbFrames = 0;
}
}
// GLFW error callback method
void Viewer::error_callback(int error, const char* description) {
fputs(description, stderr);
}
// Display the GUI
void Viewer::displayGUI() {
// Display the FPS
displayFPS();
}
// Display the FPS
void Viewer::displayFPS() {
std::stringstream ss;
ss << mFPS;
std::string fpsString = ss.str();
std::string windowTitle = mWindowTitle + " | FPS : " + fpsString;
glfwSetWindowTitle(mWindow, windowTitle.c_str());
}

View File

@ -1,208 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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 VIEWER_H
#define VIEWER_H
// Libraries
#include "openglframework.h"
#include <GLFW/glfw3.h>
// Class Viewer
class Viewer {
private :
// -------------------- Constants -------------------- //
static const float SCROLL_SENSITIVITY;
// -------------------- Attributes -------------------- //
/// GLFW window
GLFWwindow* mWindow;
/// Window title
std::string mWindowTitle;
/// Camera
openglframework::Camera mCamera;
/// Center of the scene
openglframework::Vector3 mCenterScene;
/// Last mouse coordinates on the windows
double mLastMouseX, mLastMouseY;
/// Last point computed on a sphere (for camera rotation)
openglframework::Vector3 mLastPointOnSphere;
/// True if the last point computed on a sphere (for camera rotation) is valid
bool mIsLastPointOnSphereValid;
/// Current number of frames per seconds
double mFPS;
/// Number of frames during the last second
int mNbFrames;
/// Current time for fps computation
double mCurrentTime;
/// Previous time for fps computation
double mPreviousTime;
/// Pointer to the update function
void (*mUpdateFunctionPointer)();
// -------------------- Methods -------------------- //
bool mapMouseCoordinatesToSphere(double xMouse, double yMouse, openglframework::Vector3& spherePoint) const;
public :
// -------------------- Methods -------------------- //
/// Constructor
Viewer();
/// Destructor
~Viewer();
// -------------------- Methods -------------------- //
/// Initialize the viewer
void init(int argc, char** argv, const std::string& windowsTitle,
const openglframework::Vector2& windowsSize,
const openglframework::Vector2& windowsPosition,
bool isMultisamplingActive = false);
/// Start the main loop where rendering occur
void startMainLoop();
/// Called when the windows is reshaped
void reshape();
/// Set the scene position (where the camera needs to look at)
void setScenePosition(const openglframework::Vector3& position, float sceneRadius);
/// Set the camera so that we can view the whole scene
void resetCameraToViewAll();
/// Zoom the camera
void zoom(float zoomDiff);
/// Translate the camera
void translate(int xMouse, int yMouse);
/// Rotate the camera
void rotate(int xMouse, int yMouse);
/// Get the camera
openglframework::Camera& getCamera();
/// Called when a GLUT mouse button event occurs
void mouseButtonEvent(int button, int action);
/// Called when a GLUT mouse motion event occurs
void mouseMotionEvent(double xMouse, double yMouse);
/// Called when a scrolling event occurs
void scrollingEvent(float scrollAxis);
/// Check the OpenGL errors
static void checkOpenGLErrors();
/// Display the FPS
void displayFPS();
/// Compute the FPS
void computeFPS();
/// Display the GUI
void displayGUI();
/// GLFW error callback method
static void error_callback(int error, const char* description);
/// Register the update function that has to be called each frame
void registerUpdateFunction(void (*updateFunctionPointer)());
/// Register a keyboard callback method
void registerKeyboardCallback(GLFWkeyfun method);
/// Register a mouse button callback method
void registerMouseButtonCallback(GLFWmousebuttonfun method);
/// Register a mouse cursor motion callback method
void registerMouseCursorCallback(GLFWcursorposfun method);
/// Register a scrolling cursor callback method
void registerScrollingCallback(GLFWscrollfun method);
};
// Set the scene position (where the camera needs to look at)
inline void Viewer::setScenePosition(const openglframework::Vector3& position, float sceneRadius) {
// Set the position and radius of the scene
mCenterScene = position;
mCamera.setSceneRadius(sceneRadius);
// Reset the camera position and zoom in order to view all the scene
resetCameraToViewAll();
}
// Get the camera
inline openglframework::Camera& Viewer::getCamera() {
return mCamera;
}
// Register the update function that has to be called each frame
inline void Viewer::registerUpdateFunction(void (*updateFunctionPointer)()) {
mUpdateFunctionPointer = updateFunctionPointer;
}
// Register a keyboard callback method
inline void Viewer::registerKeyboardCallback(GLFWkeyfun method) {
glfwSetKeyCallback(mWindow, method);
}
// Register a mouse button callback method
inline void Viewer::registerMouseButtonCallback(GLFWmousebuttonfun method) {
glfwSetMouseButtonCallback(mWindow, method);
}
// Register a mouse cursor motion callback method
inline void Viewer::registerMouseCursorCallback(GLFWcursorposfun method) {
glfwSetCursorPosCallback(mWindow, method);
}
// Register a scrolling cursor callback method
inline void Viewer::registerScrollingCallback(GLFWscrollfun method) {
glfwSetScrollCallback(mWindow, method);
}
#endif

View File

@ -1,115 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "VisualContactPoint.h"
// Initialization of static variables
int VisualContactPoint::mNbTotalPoints = 0;
bool VisualContactPoint::mIsMeshInitialized = false;
openglframework::Mesh VisualContactPoint::mMesh;
// Constructor
VisualContactPoint::VisualContactPoint(const openglframework::Vector3& position) {
assert(mIsMeshInitialized);
// Initialize the position where the sphere will be rendered
translateWorld(position);
}
// Destructor
VisualContactPoint::~VisualContactPoint() {
}
// Load and initialize the mesh for all the contact points
void VisualContactPoint::createStaticData(const std::string& meshFolderPath) {
if (!mIsMeshInitialized) {
// Load the mesh from a file
openglframework::MeshReaderWriter::loadMeshFromFile(meshFolderPath + "sphere.obj", mMesh);
// Calculate the normals of the mesh
mMesh.calculateNormals();
mMesh.scaleVertices(VISUAL_CONTACT_POINT_RADIUS);
mIsMeshInitialized = true;
}
}
// Destroy the mesh for the contact points
void VisualContactPoint::destroyStaticData() {
mMesh.destroy();
mIsMeshInitialized = false;
}
// Render the sphere at the correct position and with the correct orientation
void VisualContactPoint::render(openglframework::Shader& shader,
const openglframework::Matrix4& worldToCameraMatrix) {
// Bind the shader
shader.bind();
// Set the model to camera matrix
const openglframework::Matrix4 localToCameraMatrix = worldToCameraMatrix * mTransformMatrix;
shader.setMatrix4x4Uniform("localToCameraMatrix", localToCameraMatrix);
// Set the normal matrix (inverse transpose of the 3x3 upper-left sub matrix of the
// model-view matrix)
const openglframework::Matrix3 normalMatrix =
localToCameraMatrix.getUpperLeft3x3Matrix().getInverse().getTranspose();
shader.setMatrix3x3Uniform("normalMatrix", normalMatrix);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if (mMesh.hasTexture()) {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glVertexPointer(3, GL_FLOAT, 0, mMesh.getVerticesPointer());
glNormalPointer(GL_FLOAT, 0, mMesh.getNormalsPointer());
if(mMesh.hasTexture()) {
glTexCoordPointer(2, GL_FLOAT, 0, mMesh.getUVTextureCoordinatesPointer());
}
// For each part of the mesh
for (unsigned int i=0; i<mMesh.getNbParts(); i++) {
glDrawElements(GL_TRIANGLES, mMesh.getNbFaces(i) * 3,
GL_UNSIGNED_INT, mMesh.getIndicesPointer());
}
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if (mMesh.hasTexture()) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
// Unbind the shader
shader.unbind();
}

View File

@ -1,70 +0,0 @@
# External junk
.DS_Store
_ReSharper*
*.opensdf
*.sdf
*.dir
*.vcxproj*
*.sln
Win32
Debug
Release
# CMake files
Makefile
CMakeCache.txt
CMakeFiles
cmake_install.cmake
cmake_uninstall.cmake
# Generated files
docs/Doxyfile
docs/html
docs/warnings.txt
src/config.h
src/glfw3.pc
src/glfwConfig.cmake
src/glfwConfigVersion.cmake
# Compiled binaries
src/libglfw.so
src/libglfw.so.3
src/libglfw.so.3.0
src/libglfw.dylib
src/libglfw.dylib
src/libglfw.3.dylib
src/libglfw.3.0.dylib
src/libglfw3.a
src/glfw3.lib
src/glfw3.dll
src/glfw3dll.lib
src/glfw3dll.a
examples/*.app
examples/*.exe
examples/boing
examples/gears
examples/heightmap
examples/splitview
examples/simple
examples/wave
tests/*.app
tests/*.exe
tests/accuracy
tests/clipboard
tests/defaults
tests/events
tests/fsaa
tests/gamma
tests/glfwinfo
tests/iconify
tests/joysticks
tests/modes
tests/peter
tests/reopen
tests/sharing
tests/tearing
tests/threads
tests/title
tests/version
tests/windows

View File

@ -1,294 +0,0 @@
# GLFW
## Introduction
GLFW is a free, Open Source, multi-platform library for OpenGL and OpenGL ES
application development. It provides a simple, platform-independent API for
creating windows and contexts, reading input, handling events, etc.
Version 3.1 adds improved documentation, support for custom system cursors, file
drop events, main thread wake-up, window frame size retrieval, floating windows,
character input with modifier keys, single buffered windows, build improvements
and fixes for a large number of bugs.
If you are new to GLFW, you may find the
[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW
3 useful. If you have used GLFW 2 in the past, there is a
[transition guide](http://www.glfw.org/docs/latest/moving.html) for moving to
the GLFW 3 API.
Note that a number of source files have been added or renamed in 3.1, which may
require you to update any custom build files you have.
## Compiling GLFW
See the [Compiling GLFW](http://www.glfw.org/docs/latest/compile.html) guide in
the GLFW documentation.
## Using GLFW
See the
[Building programs that use GLFW](http://www.glfw.org/docs/latest/build.html)
guide in the GLFW documentation.
## Reporting bugs
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please always include the name and version of the OS where the bug occurs and
the version of GLFW used. If you have cloned it, include the commit ID used.
If it's a build issue, please also include the build log and the name and
version of your development environment.
If it's a context creation issue, please also include the make and model of your
graphics card and the version of your driver.
This will help both us and other people experiencing the same bug.
## Dependencies
GLFW bundles a number of dependencies in the `deps/` directory.
- [Khronos extension headers](https://www.opengl.org/registry/) for API
extension symbols used by GLFW
- [getopt\_port](https://github.com/kimgr/getopt_port/) for examples
with command-line options
- [TinyCThread](https://github.com/tinycthread/tinycthread) for threaded
examples
- An OpenGL 3.2 core loader generated by
[glad](https://github.com/Dav1dde/glad) for examples using modern OpenGL
## Changelog
- Added `GLFWcursor` custom system cursor handle
- Added `glfwCreateCursor`, `glfwCreateStandardCursor`, `glfwDestroyCursor` and
`glfwSetCursor` for managing system cursor images
- Added `GLFWimage` struct for passing 32-bit RGBA images
- Added monitor and adapter identifier access to native API
- Added `glfwSetDropCallback` and `GLFWdropfun` for receiving dropped files
- Added `glfwPostEmptyEvent` for allowing secondary threads to cause
`glfwWaitEvents` to return
- Added `empty` test program for verifying posting of empty events
- Added `glfwSetCharModsCallback` for receiving character events with modifiers
- Added `glfwGetWindowFrameSize` for retrieving the size of the frame around
the client area of a window
- Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows
automatically iconify (and restore the previous video mode) on focus loss
- Added `GLFW_DONT_CARE` for indicating that any value is acceptable
- Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering
- Added `GLFW_CONTEXT_RELEASE_BEHAVIOR` and values
`GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` and
`GLFW_RELEASE_BEHAVIOR_NONE` for `GL_KHR_context_flush_control` support
- Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header
- Added `GLFW_FLOATING` for creating always-on-top windowed mode windows
- Added `GLFW_FOCUSED` window hint for controlling initial input focus
- Added *partial and experimental* support for Wayland
- Added *partial and experimental* support for Mir
- Changed the window state attributes (focused, iconified and visible) to query
the system directly
- Changed the default of `GLFW_REFRESH_RATE` to `GLFW_DONT_CARE` to maintain
the default behavior
- Changed static library to build as position independent code for easier use
from the Rust language
- Changed `glfwGetCursorPos` to query the system directly for all cursor modes
except captured mode
- Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even
when a debug context had not been requested
- Bugfix: The particles example was not linked against the threading library
- Bugfix: The cursor was not positioned over newly created full screen windows
- Bugfix: The queried cursor position was not always up-to-date
- Bugfix: `glfwExtensionSupported` always failed for OpenGL ES 3.0 and later if
the library was compiled for OpenGL ES
- [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full
resolution on Retina displays
- [Cocoa] Made content view subclass of `NSOpenGLView`
- [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen
recorders to fail
- [Cocoa] Bugfix: Some Core Foundation objects were leaked during joystick
enumeration and termination
- [Cocoa] Bugfix: One copy of each display name string was leaked
- [Cocoa] Bugfix: Monitor enumeration caused a segfault if no `NSScreen` was
found for a given `CGDisplay`
- [Cocoa] Bugfix: Modifier key events were lost if the corresponding modifier
bit field was unchanged
- [Cocoa] Bugfix: Joystick enumeration took hundreds of ms on some systems
- [Cocoa] Bugfix: The cursor was hidden when the user resized a GLFW window
- [Cocoa] Bugfix: The 10.10 Yosemite OpenGL 4.1 profile token was not used
- [Cocoa] Bugfix: The generic software OpenGL renderer could be selected under
certain conditions
- [Cocoa] Bugfix: The virtual cursor jumped unpredictably when entering
disabled cursor mode
- [Win32] Enabled generation of pkg-config file for MinGW
- [Win32] Removed option to require explicitly linking against `winmm.dll`
- [Win32] Bugfix: Failure to load winmm or its functions was not reported to
the error callback
- [Win32] Bugfix: Some keys were reported based on the current layout instead
of their physical location
- [Win32] Bugfix: Maximized hidden windows were restored by `glfwShowWindow`
- [Win32] Bugfix: Context re-creation was not triggered by sRGB hint
- [Win32] Bugfix: Full screen windows were incorrectly sized and placed on some
systems
- [Win32] Bugfix: Gamma ramp functions acted on entire desktop instead of the
specified monitor
- [Win32] Bugfix: The wrong incorrect physical size was returned for
non-primary monitors
- [Win32] Bugfix: X-axis scroll offsets were inverted
- [Win32] Bugfix: The Optimus HPG forcing variable was not correctly exported
- [Win32] Bugfix: The iconified window state attribute was not always updated
- [Win32] Bugfix: Previously focused windows with disabled cursor mode and that
had been iconified by Win+D were not visible when restored
- [Win32] Bugfix: The virtual cursor jumped unpredictably when entering
disabled cursor mode
- [X11] Added run-time support for systems lacking the XKB extension
- [X11] Made GLX 1.3 the minimum supported version
- [X11] Replaced `XRRGetScreenResources` with `XRRGetScreenResourcesCurrent`
for monitor property retrieval
- [X11] Bugfix: The case of finding no usable CRTCs was not detected
- [X11] Bugfix: Detection of broken Nvidia RandR gamma support did not verify
that at least one CRTC was present
- [X11] Bugfix: A stale `_NET_SUPPORTING_WM_CHECK` root window property would
cause an uncaught `BadWindow` error
- [X11] Bugfix: No check was made for the presence of GLX 1.3 when
`GLX_SGIX_fbconfig` was unavailable
- [X11] Bugfix: The message type of ICCCM protocol events was not checked
- [X11] Bugfix: `glfwDestroyWindow` did not flush the output buffer
- [X11] Bugfix: Window frame interactions were reported as focus events
- [X11] Bugfix: Workaround for legacy Compiz caused flickering during resize
- [X11] Bugfix: The name pointer of joysticks were not cleared on disconnection
- [X11] Bugfix: Video mode resolutions and monitor physical sizes were not
corrected for rotated CRTCs
- [X11] Bugfix: Unicode character input ignored dead keys
- [X11] Bugfix: X-axis scroll offsets were inverted
- [X11] Bugfix: Full screen override redirect windows were not always
positioned over the specified monitor
- [X11] Bugfix: Character input did not work for the default `"C"` locale
- [X11] Bugfix: Joysticks connected after `glfwInit` were not detected
(temporary inotify solution until proper libudev solution)
## Contact
The official website for GLFW is [glfw.org](http://www.glfw.org/). There you
can find the latest version of GLFW, as well as news, documentation and other
information about the project.
If you have questions related to the use of GLFW, we have a
[support forum](https://sourceforge.net/p/glfw/discussion/247562/), and the IRC
channel `#glfw` on [Freenode](http://freenode.net/).
If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
Finally, if you're interested in helping out with the development of GLFW or
porting it to your favorite platform, we have an occasionally active
[developer's mailing list](https://lists.stacken.kth.se/mailman/listinfo/glfw-dev),
or you could join us on `#glfw`.
## Acknowledgements
GLFW exists because people around the world donated their time and lent their
skills.
- Bobyshev Alexander
- artblanc
- arturo
- Matt Arsenault
- Keith Bauer
- John Bartholomew
- Niklas Behrens
- Niklas Bergström
- Doug Binks
- blanco
- Martin Capitanio
- Lambert Clara
- Andrew Corrigan
- Noel Cower
- Jarrod Davis
- Olivier Delannoy
- Paul R. Deppe
- Michael Dickens
- Jonathan Dummer
- Ralph Eastwood
- Michael Fogleman
- Gerald Franz
- GeO4d
- Marcus Geelnard
- Eloi Marín Gratacós
- Stefan Gustavson
- Sylvain Hellegouarch
- Matthew Henry
- heromyth
- Lucas Hinderberger
- Paul Holden
- Toni Jovanoski
- Arseny Kapoulkine
- Osman Keskin
- Cameron King
- Peter Knut
- Robin Leffmann
- Glenn Lewis
- Shane Liesegang
- Дмитри Малышев
- Martins Mozeiko
- Tristam MacDonald
- Hans Mackowiak
- Kyle McDonald
- David Medlock
- Jonathan Mercier
- Marcel Metz
- Kenneth Miller
- Bruce Mitchener
- Jack Moffitt
- Jeff Molofee
- Jon Morton
- Pierre Moulon
- Julian Møller
- Kamil Nowakowski
- Ozzy
- Andri Pálsson
- Peoro
- Braden Pellett
- Arturo J. Pérez
- Cyril Pichard
- Pieroman
- Jorge Rodriguez
- Ed Ropple
- Riku Salminen
- Brandon Schaefer
- Sebastian Schuberth
- Matt Sealey
- SephiRok
- Steve Sexton
- Systemcluster
- Dmitri Shuralyov
- Daniel Skorupski
- Bradley Smith
- Julian Squires
- Johannes Stein
- Justin Stoecker
- Nathan Sweet
- TTK-Bandit
- Sergey Tikhomirov
- Samuli Tuomola
- urraka
- Jari Vetoniemi
- Ricardo Vieira
- Simon Voordouw
- Torsten Walluhn
- Patrick Walton
- Jay Weisskopf
- Frank Wille
- yuriks
- Santi Zupancic
- Jonas Ådahl
- Lasse Öörni
- All the unmentioned and anonymous contributors in the GLFW community, for bug
reports, patches, feedback, testing and encouragement

View File

@ -1,5 +0,0 @@
add_custom_target(docs ALL ${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY ${GLFW_BINARY_DIR}/docs
COMMENT "Generating HTML documentation" VERBATIM)

File diff suppressed because it is too large Load Diff

View File

@ -1,303 +0,0 @@
/*!
@page build Building applications
@tableofcontents
This is about compiling and linking applications that use GLFW. For information on
how to write such applications, start with the [introductory tutorial](@ref quick).
For information on how to compile the GLFW library itself, see the @ref compile
guide.
This is not a tutorial on compilation or linking. It assumes basic
understanding of how to compile and link a C program as well as how to use the
specific compiler of your chosen development environment. The compilation
and linking process should be explained in your C programming material and in
the documentation for your development environment.
@section build_include Including the GLFW header file
In the source files of your application where you use OpenGL or GLFW, you should
include the GLFW header file, i.e.:
@code
#include <GLFW/glfw3.h>
@endcode
The GLFW header declares the GLFW API and by default also includes the OpenGL
header of your development environment, which in turn defines all the constants,
types and function prototypes of the OpenGL API.
The GLFW header also defines everything necessary for your OpenGL header to
function. For example, under Windows you are normally required to include
`windows.h` before the OpenGL header, which would pollute your code namespace
with the entire Win32 API.
Instead, the GLFW header takes care of this for you, not by including
`windows.h`, but by duplicating only the very few necessary parts of it. It
does this only when needed, so if `windows.h` _is_ included, the GLFW header
does not try to redefine those symbols. The reverse is not true, i.e.
`windows.h` cannot cope if any of its symbols have already been defined.
In other words:
- Do _not_ include the OpenGL headers yourself, as GLFW does this for you
- Do _not_ include `windows.h` or other platform-specific headers unless you
plan on using those APIs directly
- If you _do_ need to include such headers, do it _before_ including
the GLFW header and it will handle this
If you are using an OpenGL extension loading library such as
[glad](https://github.com/Dav1dde/glad), the extension loader header should
either be included _before_ the GLFW one, or the `GLFW_INCLUDE_NONE` macro
(described below) should be defined.
@subsection build_macros GLFW header option macros
These macros may be defined before the inclusion of the GLFW header and affect
its behavior.
`GLFW_DLL` is required on Windows when using the GLFW DLL, to tell the compiler
that the GLFW functions are defined in a DLL.
The following macros control which OpenGL or OpenGL ES API header is included.
`GLFW_INCLUDE_GLCOREARB` makes the GLFW header include the modern
`GL/glcorearb.h` header (`OpenGL/gl3.h` on OS X) instead of the regular OpenGL
header.
`GLFW_INCLUDE_ES1` makes the GLFW header include the OpenGL ES 1.x `GLES/gl.h`
header instead of the regular OpenGL header.
`GLFW_INCLUDE_ES2` makes the GLFW header include the OpenGL ES 2.0 `GLES2/gl2.h`
header instead of the regular OpenGL header.
`GLFW_INCLUDE_ES3` makes the GLFW header include the OpenGL ES 3.0 `GLES3/gl3.h`
header instead of the regular OpenGL header.
`GLFW_INCLUDE_ES31` makes the GLFW header include the OpenGL ES 3.1 `GLES3/gl31.h`
header instead of the regular OpenGL header.
`GLFW_INCLUDE_NONE` makes the GLFW header not include any OpenGL or OpenGL ES API
header. This is useful in combination with an extension loading library.
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
header (`OpenGL/gl.h` on OS X) is included.
`GLFW_INCLUDE_GLEXT` makes the GLFW header include the appropriate extension
header for the OpenGL or OpenGL ES header selected above after and _in addition
to_ that header.
`GLFW_INCLUDE_GLU` makes the header include the GLU header _in addition to_ the
header selected above. This should only be used with the standard OpenGL header
and only for legacy code. GLU has been deprecated and should not be used in new
code.
@note GLFW does not provide any of the API headers mentioned above. They must
be provided by your development environment or your OpenGL or OpenGL ES SDK.
@section build_link Link with the right libraries
GLFW is essentially a wrapper of various platform-specific APIs and therefore
needs to link against many different system libraries. If you are using GLFW as
a shared library / dynamic library / DLL then it takes care of these links.
However, if you are using GLFW as a static library then your executable will
need to link against these libraries.
On Windows and OS X, the list of system libraries is static and can be
hard-coded into your build environment. See the section for your development
environment below. On Linux and other Unix-like operating systems, the list
varies but can be retrieved in various ways as described below.
A good general introduction to linking is
[Beginner's Guide to Linkers](http://www.lurklurk.org/linkers/linkers.html) by
David Drysdale.
@subsection build_link_win32 With MinGW or Visual C++ on Windows
The static version of the GLFW library is named `glfw3`. When using this
version, it is also necessary to link with some libraries that GLFW uses.
When linking an application under Windows that uses the static version of GLFW,
you must link with `opengl32`. On some versions of MinGW, you must also
explicitly link with `gdi32`, while other versions of MinGW include it in the
set of default libraries along with other dependencies like `user32` and
`kernel32`. If you are using GLU, you must also link with `glu32`.
The link library for the GLFW DLL is named `glfw3dll`. When compiling an
application that uses the DLL version of GLFW, you need to define the `GLFW_DLL`
macro _before_ any inclusion of the GLFW header. This can be done either with
a compiler switch or by defining it in your source code.
An application using the GLFW DLL does not need to link against any of its
dependencies, but you still have to link against `opengl32` if your application
uses OpenGL and `glu32` if it uses GLU.
@subsection build_link_cmake_source With CMake and GLFW source
With just a few changes to your `CMakeLists.txt` you can have the GLFW source
tree built along with your application.
Firstly, add the root directory of the GLFW source tree to your project. This
will add the `glfw` target and the necessary cache variables to your project.
@code{.cmake}
add_subdirectory(path/to/glfw)
@endcode
To be able to include the GLFW header from your code, you need to tell the
compiler where to find it.
@code{.cmake}
include_directories(path/to/glfw/include)
@endcode
Once GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable
contains all link-time dependencies of GLFW as it is currently configured. To
link against GLFW, link against them and the `glfw` target.
@code{.cmake}
target_link_libraries(myapp glfw ${GLFW_LIBRARIES})
@endcode
Note that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it. If
your application needs GLU, you can add it to the list of dependencies with the
`OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW
CMake files look for OpenGL.
@code{.cmake}
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})
@endcode
@subsection build_link_cmake_pkgconfig With CMake on Unix and installed GLFW binaries
CMake can import settings from pkg-config, which GLFW supports. When you
installed GLFW, the pkg-config file `glfw3.pc` was installed along with it.
First you need to find the PkgConfig package. If this fails, you may need to
install the pkg-config package for your distribution.
@code{.cmake}
find_package(PkgConfig REQUIRED)
@endcode
This creates the CMake commands to find pkg-config packages. Then you need to
find the GLFW package.
@code{.cmake}
pkg_search_module(GLFW REQUIRED glfw3)
@endcode
This creates the CMake variables you need to use GLFW. To be able to include
the GLFW header, you need to tell your compiler where it is.
@code{.cmake}
include_directories(${GLFW_INCLUDE_DIRS})
@endcode
You also need to link against the correct libraries. If you are using the
shared library version of GLFW, use the `GLFW_LIBRARIES` variable.
@code{.cmake}
target_link_libraries(simple ${GLFW_LIBRARIES})
@endcode
If you are using the static library version of GLFW, use the
`GLFW_STATIC_LIBRARIES` variable instead.
@code{.cmake}
target_link_libraries(simple ${GLFW_STATIC_LIBRARIES})
@endcode
@subsection build_link_pkgconfig With pkg-config on OS X or other Unix
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
and the `glfw3.pc` pkf-config file is generated when the GLFW library is built
and is installed along with it. A pkg-config file describes all necessary
compile-time and link-time flags and dependencies needed to use a library. When
they are updated or if they differ between systems, you will get the correct
ones automatically.
A typical compile and link command-line when using the static version of the
GLFW library may look like this:
@code{.sh}
cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3`
@endcode
If you are using the shared version of the GLFW library, simply omit the
`--static` flag.
@code{.sh}
cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`
@endcode
You can also use the `glfw3.pc` file without installing it first, by using the
`PKG_CONFIG_PATH` environment variable.
@code{.sh}
env PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`
@endcode
The dependencies do not include GLU, as GLFW does not need it. On OS X, GLU is
built into the OpenGL framework, so if you need GLU you don't need to do
anything extra. If you need GLU and are using Linux or BSD, you should add the
`glu` pkg-config module.
@code{.sh}
cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu`
@endcode
If you are using the static version of the GLFW library, make sure you don't link statically against GLU.
@code{.sh}
cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --static --libs glfw3` `pkg-config --libs glu`
@endcode
@subsection build_link_xcode With Xcode on OS X
If you are using the dynamic library version of GLFW, simply add it to the
project dependencies.
If you are using the static library version of GLFW, add it and the Cocoa,
OpenGL, IOKit, CoreVideo and Carbon frameworks to the project as dependencies.
They can all be found in `/System/Library/Frameworks`.
@note GLFW needs the Carbon framework only to access the current keyboard layout
via the Text Input Source Services. This is one of the non-deprecated parts of
the Carbon API and the only way to access this information on OS X.
@subsection build_link_osx With command-line on OS X
It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when
building from the command line on OS X. That way you will get any new
dependencies added automatically. If you still wish to build manually, you need
to add the required frameworks and libraries to your command-line yourself using
the `-l` and `-framework` switches.
If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:
@code{.sh}
cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
@endcode
If you are using the static library, named `libglfw3.a`, substitute `-lglfw3`
for `-lglfw`.
Note that you do not add the `.framework` extension to a framework when linking
against it from the command-line.
The OpenGL framework contains both the OpenGL and GLU APIs, so there is nothing
special to do when using GLU. Also note that even though your machine may have
`libGL`-style OpenGL libraries, they are for use with the X Window System and
will _not_ work with the OS X native version of GLFW.
*/

View File

@ -1,179 +0,0 @@
/*!
@page compat Standards conformance
@tableofcontents
This guide describes the various API extensions used by this version of GLFW.
It lists what are essentially implementation details, but which are nonetheless
vital knowledge for developers intending to deploy their applications on a wide
range of machines.
The information in this guide is not a part of GLFW API, but merely
preconditions for some parts of the library to function on a given machine. Any
part of this information may change in future versions of GLFW and that will not
be considered a breaking API change.
@section compat_x11 X11 extensions, protocols and IPC standards
As GLFW uses Xlib directly, without any intervening toolkit
library, it has sole responsibility for interacting well with the many and
varied window managers in use on Unix-like systems. In order for applications
and window managers to work well together, a number of standards and
conventions have been developed that regulate behavior outside the scope of the
X11 API; most importantly the
[Inter-Client Communication Conventions Manual](http://www.tronche.com/gui/x/icccm/)
(ICCCM) and
[Extended Window Manager Hints](http://standards.freedesktop.org/wm-spec/wm-spec-latest.html)
(EWMH) standards.
GLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows.
If the running window manager does not support this property, the
`GLFW_DECORATED` hint will have no effect.
GLFW uses the ICCCM `WM_DELETE_WINDOW` protocol to intercept the user
attempting to close the GLFW window. If the running window manager does not
support this protocol, the close callback will never be called.
GLFW uses the EWMH `_NET_WM_PING` protocol, allowing the window manager notify
the user when the application has stopped responding, i.e. when it has ceased to
process events. If the running window manager does not support this protocol,
the user will not be notified if the application locks up.
GLFW uses the EWMH `_NET_WM_STATE_FULLSCREEN` window state to tell the window
manager to make the GLFW window full screen. If the running window manager does
not support this state, full screen windows may not work properly. GLFW has
a fallback code path in case this state is unavailable, but every window manager
behaves slightly differently in this regard.
GLFW uses the EWMH `_NET_WM_BYPASS_COMPOSITOR` window property to tell a
compositing window manager to un-redirect full screen GLFW windows. If the
running window manager uses compositing but does not support this property then
additional copying may be performed for each buffer swap of full screen windows.
GLFW uses the
[clipboard manager protocol](http://www.freedesktop.org/wiki/ClipboardManager/)
to push a clipboard string (i.e. selection) owned by a GLFW window about to be
destroyed to the clipboard manager. If there is no running clipboard manager,
the clipboard string will be unavailable once the window has been destroyed.
GLFW uses the
[X drag-and-drop protocol](http://www.freedesktop.org/wiki/Specifications/XDND/)
to provide file drop events. If the application originating the drag does not
support this protocol, drag and drop will not work.
GLFW uses the XInput 2 extension to provide sub-pixel cursor motion events. If
the running X server does not support this version of this extension, cursor
motion will be snapped to the pixel grid.
GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the
running X server does not support this version of this extension, multi-monitor
support will not function and only a single, desktop-spanning monitor will be
reported.
GLFW uses the XRandR 1.3 and Xf86vidmode extensions to provide gamma ramp
support. If the running X server does not support either or both of these
extensions, gamma ramp support will not function.
GLFW uses the Xkb extension and detectable auto-repeat to provide keyboard
input. If the running X server does not support this extension, a non-Xkb
fallback path is used.
@section compat_glx GLX extensions
The GLX API is the default API used to create OpenGL contexts on Unix-like
systems using the X Window System.
GLFW uses the GLX 1.3 `GLXFBConfig` functions to enumerate and select framebuffer pixel
formats. If GLX 1.3 is not supported, @ref glfwInit will fail.
GLFW uses the `GLX_MESA_swap_control,` `GLX_EXT_swap_control` and
`GLX_SGI_swap_control` extensions to provide vertical retrace synchronization
(or _vsync_), in that order of preference. Where none of these extension are
available, calling @ref glfwSwapInterval will have no effect.
GLFW uses the `GLX_ARB_multisample` extension to create contexts with
multisampling anti-aliasing. Where this extension is unavailable, the
`GLFW_SAMPLES` hint will have no effect.
GLFW uses the `GLX_ARB_create_context` extension when available, even when
creating OpenGL contexts of version 2.1 and below. Where this extension is
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
`GLFW_OPENGL_FORWARD_COMPAT` hints to `GL_TRUE` will cause @ref
glfwCreateWindow to fail.
GLFW uses the `GLX_ARB_create_context_profile` extension to provide support for
context profiles. Where this extension is unavailable, setting the
`GLFW_OPENGL_PROFILE` hint to anything but `GLFW_OPENGL_ANY_PROFILE`, or setting
`GLFW_CLIENT_API` to anything but `GLFW_OPENGL_API` will cause @ref
glfwCreateWindow to fail.
GLFW uses the `GLX_ARB_context_flush_control` extension to provide control over
whether a context is flushed when it is released (made non-current). Where this
extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no
effect and the context will always be flushed when released.
@section compat_wgl WGL extensions
The WGL API is used to create OpenGL contexts on Microsoft Windows and other
implementations of the Win32 API, such as Wine.
GLFW uses either the `WGL_EXT_extension_string` or the
`WGL_ARB_extension_string` extension to check for the presence of all other WGL
extensions listed below. If both are available, the EXT one is preferred. If
neither is available, no other extensions are used and many GLFW features
related to context creation will have no effect or cause errors when used.
GLFW uses the `WGL_EXT_swap_control` extension to provide vertical retrace
synchronization (or _vsync_). Where this extension is unavailable, calling @ref
glfwSwapInterval will have no effect.
GLFW uses the `WGL_ARB_pixel_format` and `WGL_ARB_multisample` extensions to
create contexts with multisampling anti-aliasing. Where these extensions are
unavailable, the `GLFW_SAMPLES` hint will have no effect.
GLFW uses the `WGL_ARB_create_context` extension when available, even when
creating OpenGL contexts of version 2.1 and below. Where this extension is
unavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`
hints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint
will have no effect, and setting the `GLFW_OPENGL_PROFILE` or
`GLFW_OPENGL_FORWARD_COMPAT` hints to `GL_TRUE` will cause @ref
glfwCreateWindow to fail.
GLFW uses the `WGL_ARB_create_context_profile` extension to provide support for
context profiles. Where this extension is unavailable, setting the
`GLFW_OPENGL_PROFILE` hint to anything but `GLFW_OPENGL_ANY_PROFILE` will cause
@ref glfwCreateWindow to fail.
GLFW uses the `WGL_ARB_context_flush_control` extension to provide control over
whether a context is flushed when it is released (made non-current). Where this
extension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no
effect and the context will always be flushed when released.
@section compat_osx OpenGL 3.2 and later on OS X
Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then
only forward-compatible, core profile contexts are supported. Support for
OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible,
core profile contexts. There is also still no mechanism for requesting debug
contexts. Versions of Mac OS X earlier than 10.7 support at most OpenGL
version 2.1.
Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
given version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to
`GL_TRUE` and the `GLFW_OPENGL_PROFILE` hint must be set to
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts and the
`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.
Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1,
setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to
a non-default value will cause @ref glfwCreateWindow to fail and the
`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.
*/

View File

@ -1,315 +0,0 @@
/*!
@page compile Compiling GLFW
@tableofcontents
This is about compiling the GLFW library itself. For information on how to
build applications that use GLFW, see the @ref build guide.
@section compile_cmake Using CMake
GLFW uses [CMake](http://www.cmake.org/) to generate project files or makefiles
for a particular development environment. If you are on a Unix-like system such
as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or
Homebrew, you can simply install its CMake package. If not, you can download
installers for Windows and OS X from the [CMake website](http://www.cmake.org/).
@note CMake only generates project files or makefiles. It does not compile the
actual GLFW library. To compile GLFW, first generate these files and then use
them in your chosen development environment to compile the actual GLFW library.
@subsection compile_deps Dependencies
Once you have installed CMake, make sure that all other dependencies are
available. On some platforms, GLFW needs a few additional packages to be
installed. See the section for your chosen platform and development environment
below.
@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows
The Microsoft Platform SDK that is installed along with Visual C++ already
contains all the necessary headers, link libraries and tools except for CMake.
Move on to @ref compile_generate.
@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows
Both the MinGW and the MinGW-w64 packages already contain all the necessary
headers, link libraries and tools except for CMake. Move on to @ref
compile_generate.
@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation
Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For
example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages
for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives
like Ubuntu have the `mingw-w64` package for both.
GLFW has CMake toolchain files in the `CMake/` directory that allow for easy
cross-compilation of Windows binaries. To use these files you need to add a
special parameter when generating the project files or makefiles:
@code{.sh}
cmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .
@endcode
The exact toolchain file to use depends on the prefix used by the MinGW or
MinGW-w64 binaries on your system. You can usually see this in the /usr
directory. For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages
have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct
invocation would be:
@code{.sh}
cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .
@endcode
For more details see the article
[CMake Cross Compiling](http://www.paraview.org/Wiki/CMake_Cross_Compiling) on
the CMake wiki.
Once you have this set up, move on to @ref compile_generate.
@subsubsection compile_deps_xcode Dependencies for Xcode on OS X
Xcode comes with all necessary tools except for CMake. The required headers
and libraries are included in the core OS X frameworks. Xcode can be downloaded
from the Mac App Store or from the ADC Member Center.
Once you have Xcode installed, move on to @ref compile_generate.
@subsubsection compile_deps_x11 Dependencies for Linux and X11
To compile GLFW for X11, you need to have the X11 and OpenGL header packages
installed, as well as the basic development tools like GCC and make. For
example, on Ubuntu and other distributions based on Debian GNU/Linux, you need
to install the `xorg-dev` and `libglu1-mesa-dev` packages. The former pulls in
all X.org header packages and the latter pulls in the Mesa OpenGL and GLU
packages. GLFW itself doesn't need or use GLU, but some of the examples do.
Note that using header files and libraries from Mesa during compilation
_will not_ tie your binaries to the Mesa implementation of OpenGL.
Once you have installed the necessary packages, move on to @ref
compile_generate.
@subsection compile_generate Generating build files with CMake
Once you have all necessary dependencies it is time to generate the project
files or makefiles for your development environment. CMake needs to know two
paths for this: the path to the _root_ directory of the GLFW source tree (i.e.
_not_ the `src` subdirectory) and the target path for the generated files and
compiled binaries. If these are the same, it is called an in-tree build,
otherwise it is called an out-of-tree build.
One of several advantages of out-of-tree builds is that you can generate files
and compile for different development environments using a single source tree.
@note This section is about generating the project files or makefiles necessary
to compile the GLFW library, not about compiling the actual library.
@subsubsection compile_generate_cli Generating files with the CMake command-line tool
To make an in-tree build, enter the _root_ directory of the GLFW source tree
(i.e. _not_ the `src` subdirectory) and run CMake. The current directory is
used as target path, while the path provided as an argument is used to find the
source tree.
@code{.sh}
cd <glfw-root-dir>
cmake .
@endcode
To make an out-of-tree build, make another directory, enter it and run CMake
with the (relative or absolute) path to the root of the source tree as an
argument.
@code{.sh}
cd <glfw-root-dir>
mkdir build
cd build
cmake ..
@endcode
Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile.
@subsubsection compile_generate_gui Generating files with the CMake GUI
If you are using the GUI version, choose the root of the GLFW source tree as
source location and the same directory or another, empty directory as the
destination for binaries. Choose _Configure_, change any options you wish to,
_Configure_ again to let the changes take effect and then _Generate_.
Once you have generated the project files or makefiles for your chosen
development environment, move on to @ref compile_compile.
@subsection compile_compile Compiling the library
You should now have all required dependencies and the project files or makefiles
necessary to compile GLFW. Go ahead and compile the actual GLFW library with
these files, as you would with any other project.
Once the GLFW library is compiled, you are ready to build your applications,
linking it to the GLFW library. See the @ref build guide for more information.
@subsection compile_options CMake options
The CMake files for GLFW provide a number of options, although not all are
available on all supported platforms. Some of these are de facto standards
among projects using CMake and so have no `GLFW_` prefix.
If you are using the GUI version of CMake, these are listed and can be changed
from there. If you are using the command-line version, use the `ccmake` tool.
Some package systems like Ubuntu and other distributions based on Debian
GNU/Linux have this tool in a separate `cmake-curses-gui` package.
@subsubsection compile_options_shared Shared CMake options
`BUILD_SHARED_LIBS` determines whether GLFW is built as a static
library or as a DLL / shared library / dynamic library.
`LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed. If it
is empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`. If it is set to
`64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`.
`GLFW_CLIENT_LIBRARY` determines which client API library to use. If set to
`opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x
library is used, or if set to `glesv2` the OpenGL ES 2.0 library is used. The
selected library and its header files must be present on the system for this to
work.
`GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built
along with the library.
`GLFW_BUILD_TESTS` determines whether the GLFW test programs are
built along with the library.
`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with
the library.
@subsubsection compile_options_osx OS X specific CMake options
`GLFW_USE_CHDIR` determines whether `glfwInit` changes the current
directory of bundled applications to the `Contents/Resources` directory.
`GLFW_USE_MENUBAR` determines whether the first call to
`glfwCreateWindow` sets up a minimal menu bar.
`GLFW_USE_RETINA` determines whether windows will use the full resolution of
Retina displays.
`GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.
@subsubsection compile_options_win32 Windows specific CMake options
`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the
static library version of the Visual C++ runtime library. If set to `ON`, the
DLL version of the Visual C++ library is used. It is recommended to set this to
`ON`, as this keeps the executable smaller and benefits from security and bug
fix updates of the Visual C++ runtime.
`GLFW_USE_DWM_SWAP_INTERVAL` determines whether the swap interval is set even
when DWM compositing is enabled. If this is `ON`, the swap interval is set even
if DWM is enabled. It is recommended to set this to `OFF`, as doing otherwise
can lead to severe jitter.
`GLFW_USE_OPTIMUS_HPG` determines whether to export the `NvOptimusEnablement`
symbol, which forces the use of the high-performance GPU on Nvidia Optimus
systems. This symbol needs to be exported by the EXE to be detected by the
driver, so the override will not work if GLFW is built as a DLL. See _Enabling
High Performance Graphics Rendering on Optimus Systems_ for more details.
@subsubsection compile_options_egl EGL specific CMake options
`GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific
context creation API. Note that EGL is not yet provided on all supported
platforms.
@section compile_manual Compiling GLFW manually
If you wish to compile GLFW without its CMake build environment then you will
have to do at least some of the platform detection yourself. GLFW needs
a number of configuration macros to be defined in order to know what it's being
compiled for and has many optional, platform-specific ones for various features.
When building with CMake, the `glfw_config.h` configuration header is generated
based on the current platform and CMake options. The GLFW CMake environment
defines `_GLFW_USE_CONFIG_H`, which causes this header to be included by
`internal.h`. Without this macro, GLFW will expect the necessary configuration
macros to be defined on the command-line.
Three macros _must_ be defined when compiling GLFW: one selecting the window
creation API, one selecting the context creation API and one client library.
Exactly one of each kind must be defined for GLFW to compile and link.
The window creation API is used to create windows, handle input, monitors, gamma
ramps and clipboard. The options are:
- `_GLFW_COCOA` to use the Cocoa frameworks
- `_GLFW_WIN32` to use the Win32 API
- `_GLFW_X11` to use the X Window System
- `_GLFW_WAYLAND` to use the Wayland API (experimental and incomplete)
- `_GLFW_MIR` to use the Mir API (experimental and incomplete)
The context creation API is used to enumerate pixel formats / framebuffer
configurations and to create contexts. The options are:
- `_GLFW_NSGL` to use the Cocoa OpenGL framework
- `_GLFW_WGL` to use the Win32 WGL API
- `_GLFW_GLX` to use the X11 GLX API
- `_GLFW_EGL` to use the EGL API
Wayland and Mir both require the EGL backend.
The client library is the one providing the OpenGL or OpenGL ES API, which is
used by GLFW to probe the created context. This is not the same thing as the
client API, as many desktop OpenGL client libraries now expose the OpenGL ES API
through extensions. The options are:
- `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or
OpenGL.framework)
- `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental)
- `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental)
Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL,
as the other context creation APIs do not interface with OpenGL ES client
libraries.
If you are building GLFW as a shared library / dynamic library / DLL then you
must also define `_GLFW_BUILD_DLL`. Otherwise, you may not define it.
If you are using the X11 window creation API then you _must_ also select an entry
point retrieval mechanism.
- `_GLFW_HAS_GLXGETPROCADDRESS` to use `glXGetProcAddress` (recommended)
- `_GLFW_HAS_GLXGETPROCADDRESSARB` to use `glXGetProcAddressARB` (legacy)
- `_GLFW_HAS_GLXGETPROCADDRESSEXT` to use `glXGetProcAddressEXT` (legacy)
- `_GLFW_HAS_DLOPEN` to do manual retrieval with `dlopen` (fallback)
If you are using the Cocoa window creation API, the following options are
available:
- `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the
application bundle during @ref glfwInit (recommended)
- `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window
is created (recommended)
- `_GLFW_USE_RETINA` to have windows use the full resolution of Retina displays
(recommended)
*/

View File

@ -1,329 +0,0 @@
/*!
@page context Context guide
@tableofcontents
This guide introduces the OpenGL and OpenGL ES context related functions of
GLFW. There are also guides for the other areas of the GLFW API.
- @ref intro
- @ref window
- @ref monitor
- @ref input
@section context_object Context objects
A window object encapsulates both a top-level window and an OpenGL or OpenGL ES
context. It is created with @ref glfwCreateWindow and destroyed with @ref
glfwDestroyWindow or @ref glfwTerminate. See @ref window_creation for more
information.
As the window and context are inseparably linked, the window object also serves
as the context handle.
To test the creation of various kinds of contexts and see their properties, run
the `glfwinfo` test program.
@subsection context_hints Context creation hints
There are a number of hints, specified using @ref glfwWindowHint, related to
what kind of context is created. See
[context related hints](@ref window_hints_ctx) in the window guide.
@subsection context_sharing Context object sharing
When creating a window and its OpenGL or OpenGL ES context with @ref
glfwCreateWindow, you can specify another window whose context the new one
should share its objects (textures, vertex and element buffers, etc.) with.
@code
GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window);
@endcode
Object sharing is implemented by the operating system and graphics driver. On
platforms where it is possible to choose which types of objects are shared, GLFW
requests that all types are shared.
See the relevant chapter of the [OpenGL](https://www.opengl.org/registry/) or
[OpenGL ES](http://www.khronos.org/opengles/) reference documents for more
information. The name and number of this chapter unfortunately varies between
versions and APIs, but has at times been named _Shared Objects and Multiple
Contexts_.
GLFW comes with a simple object sharing test program called `sharing`.
@subsection context_offscreen Offscreen contexts
GLFW doesn't support creating contexts without an associated window. However,
contexts with hidden windows can be created with the
[GLFW_VISIBLE](@ref window_hints_wnd) window hint.
@code
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL);
@endcode
The window never needs to be shown and its context can be used as a plain
offscreen context. Depending on the window manager, the size of a hidden
window's framebuffer may not be usable or modifiable, so framebuffer
objects are recommended for rendering with such contexts.
__OS X:__ The first time a window is created the menu bar is populated with
common commands like Hide, Quit and About. This is not desirable for example
when writing a command-line only application. The menu bar setup can be
disabled with a [compile-time option](@ref compile_options_osx).
@section context_current Current context
Before you can make OpenGL or OpenGL ES calls, you need to have a current
context of the correct type. A context can only be current for a single thread
at a time, and a thread can only have a single context current at a time.
The context of a window is made current with @ref glfwMakeContextCurrent.
@code
glfwMakeContextCurrent(window);
@endcode
The window of the current context is returned by @ref glfwGetCurrentContext.
@code
GLFWwindow* window = glfwGetCurrentContext();
@endcode
The following GLFW functions require a context to be current. Calling any these
functions without a current context will generate a @ref GLFW_NO_CURRENT_CONTEXT
error.
- @ref glfwSwapInterval
- @ref glfwExtensionSupported
- @ref glfwGetProcAddress
@section context_swap Buffer swapping
Buffer swapping is part of the window and framebuffer, not the context. See
@ref buffer_swap.
@section context_glext OpenGL and OpenGL ES extensions
One of the benefits of OpenGL and OpenGL ES are their extensibility.
Hardware vendors may include extensions in their implementations that extend the
API before that functionality is included in a new version of the OpenGL or
OpenGL ES specification, and some extensions are never included and remain
as extensions until they become obsolete.
An extension is defined by:
- An extension name (e.g. `GL_ARB_debug_output`)
- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`)
- New OpenGL functions (e.g. `glGetDebugMessageLogARB`)
Note the `ARB` affix, which stands for Architecture Review Board and is used
for official extensions. The extension above was created by the ARB, but there
are many different affixes, like `NV` for Nvidia and `AMD` for, well, AMD. Any
group may also use the generic `EXT` affix. Lists of extensions, together with
their specifications, can be found at the
[OpenGL Registry](http://www.opengl.org/registry/) and
[OpenGL ES Registry](https://www.khronos.org/registry/gles/).
@subsection context_glext_auto Loading extension with a loader library
An extension loader library is the easiest and best way to access both OpenGL and
OpenGL ES extensions and modern versions of the core OpenGL or OpenGL ES APIs.
They will take care of all the details of declaring and loading everything you
need. One such library is [glad](https://github.com/Dav1dde/glad) and there are
several others.
The following example will use glad but all extension loader libraries work
similarly.
First you need to generate the source files using the glad Python script. This
example generates a loader for any version of OpenGL, which is the default for
both GLFW and glad, but loaders for OpenGL ES, as well as loaders for specific
API versions and extension sets can be generated. The generated files are
written to the `output` directory.
@code{.sh}
python main.py --generator c --no-loader --out-path output
@endcode
The `--no-loader` option is added because GLFW already provides a function for
loading OpenGL and OpenGL ES function pointers and glad can call this instead of
having to implement its own. There are several other command-line options as
well. See the glad documentation for details.
Add the generated `output/src/glad.c`, `output/include/glad/glad.h` and
`output/include/KHR/khrplatform.h` files to your build. Then you need to
include the glad header file, which will replace the OpenGL header of your
development environment. By including the glad header before the GLFW header,
it suppresses the development environment's OpenGL or OpenGL ES header.
@code
#include <glad/glad.h>
#include <GLFW/glfw3.h>
@endcode
Finally you need to initialize glad once you have a suitable current context.
@code
window = glfwCreateWindow(640, 480, "My Window", NULL, NULL);
if (!window)
{
...
}
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
@endcode
Once glad has been loaded, you have access to all OpenGL core and extension
functions supported by both the context you created and the glad loader you
generated and you are ready to start rendering.
You can specify a minimum required OpenGL or OpenGL ES version with
[context hints](@ref window_hints_ctx). If your needs are more complex, you can
check the actual OpenGL or OpenGL ES version with
[context attributes](@ref window_attribs_ctx), or you can check whether
a specific version is supported by the current context with the
`GLAD_GL_VERSION_x_x` booleans.
@code
if (GLAD_GL_VERSION_3_2)
{
// Call OpenGL 3.2+ specific code
}
@endcode
To check whether a specific extension is supported, use the `GLAD_GL_xxx`
booleans.
@code
if (GLAD_GL_ARB_debug_output)
{
// Use GL_ARB_debug_output
}
@endcode
@subsection context_glext_manual Loading extensions manually
__Do not use this technique__ unless it is absolutely necessary. An
[extension loader library](@ref context_glext_auto) will save you a ton of
tedious, repetitive, error prone work.
To use a certain extension, you must first check whether the context supports
that extension and then, if it introduces new functions, retrieve the pointers
to those functions. GLFW provides @ref glfwExtensionSupported and @ref
glfwGetProcAddress for manual loading of extensions and new API functions.
This section will demonstrate manual loading of OpenGL extensions. The loading
of OpenGL ES extensions is identical except for the name of the extension header.
@subsubsection context_glext_header The glext.h header
The `glext.h` extension header is a continually updated file that defines the
interfaces for all OpenGL extensions. The latest version of this can always be
found at the [OpenGL Registry](http://www.opengl.org/registry/). There are also
extension headers for the various versions of OpenGL ES at the
[OpenGL ES Registry](https://www.khronos.org/registry/gles/). It it strongly
recommended that you use your own copy of the extension header, as the one
included in your development environment may be several years out of date and
may not include the extensions you wish to use.
The header defines function pointer types for all functions of all extensions it
supports. These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for
`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer
to function) and `PROC` (procedure) are added to the ends.
To include the extension header, define [GLFW_INCLUDE_GLEXT](@ref build_macros)
before including the GLFW header.
@code
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
@endcode
@subsubsection context_glext_string Checking for extensions
A given machine may not actually support the extension (it may have older
drivers or a graphics card that lacks the necessary hardware features), so it
is necessary to check at run-time whether the context supports the extension.
This is done with @ref glfwExtensionSupported.
@code
if (glfwExtensionSupported("GL_ARB_debug_output"))
{
// The extension is supported by the current context
}
@endcode
The argument is a null terminated ASCII string with the extension name. If the
extension is supported, @ref glfwExtensionSupported returns `GL_TRUE`, otherwise
it returns `GL_FALSE`.
@subsubsection context_glext_proc Fetching function pointers
Many extensions, though not all, require the use of new OpenGL functions.
These functions often do not have entry points in the client API libraries of
your operating system, making it necessary to fetch them at run time. You can
retrieve pointers to these functions with @ref glfwGetProcAddress.
@code
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress("glGetDebugMessageLogARB");
@endcode
In general, you should avoid giving the function pointer variables the (exact)
same name as the function, as this may confuse your linker. Instead, you can
use a different prefix, like above, or some other naming scheme.
Now that all the pieces have been introduced, here is what they might look like
when used together.
@code
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#define glGetDebugMessageLogARB pfnGetDebugMessageLog
PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog;
// Flag indicating whether the extension is supported
int has_ARB_debug_output = 0;
void load_extensions(void)
{
if (glfwExtensionSupported("GL_ARB_debug_output"))
{
pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC) glfwGetProcAddress("glGetDebugMessageLogARB");
if (pfnGetDebugMessageLog)
{
// Both the extension name and the function pointer are present
has_ARB_debug_output = 1;
}
}
}
void some_function(void)
{
if (has_ARB_debug_output)
{
// Now the extension function can be called as usual
glGetDebugMessageLogARB(...);
}
}
@endcode
*/

File diff suppressed because one or more lines are too long

View File

@ -1,370 +0,0 @@
// NOTE: Please use this file to perform modifications on default style sheets.
//
// You need to install a few Ruby gems to generate extra.css from this file:
// gem install less therubyracer
//
// Run this command to regenerate extra.css after you're finished with changes:
// lessc --compress extra.less > extra.css
//
// Alternatively you can use online services to regenerate extra.css.
// Default text color for page contents
@default-text-color: hsl(0,0%,30%);
// Page header, footer, table rows, inline codes and definition lists
@header-footer-background-color: hsl(0,0%,95%);
// Page header, footer links and navigation bar background
@header-footer-link-color: hsl(0,0%,40%);
// Doxygen navigation bar links
@navbar-link-color: @header-footer-background-color;
// Page content background color
@content-background-color: hsl(0,0%,100%);
// Bold, italic, h1, h2, ... and table of contents
@heading-color: hsl(0,0%,10%);
// Function, enum and macro definition separator
@def-separator-color: @header-footer-background-color;
// Base color hue
@base-hue: 24;
// Default color used for links
@default-link-color: hsl(@base-hue,100%,50%);
// Doxygen navigation bar active tab
@tab-text-color: hsl(0,0%,100%);
@tab-background-color1: @default-link-color;
@tab-background-color2: lighten(spin(@tab-background-color1, 10), 10%);
// Table borders
@default-border-color: @default-link-color;
// Table header
@table-text-color: @tab-text-color;
@table-background-color1: @tab-background-color1;
@table-background-color2: @tab-background-color2;
// Table of contents, data structure index and prototypes
@toc-background-color1: hsl(0,0%,90%);
@toc-background-color2: lighten(@toc-background-color1, 5%);
// Function prototype parameters color
@prototype-param-color: darken(@default-link-color, 25%);
// Message box color: note, pre, post and invariant
@box-note-color: hsl(103,80%,85%);
// Message box color: warning and attention
@box-warning-color: hsl(34,80%,85%);
// Message box color: deprecated and bug
@box-bug-color: hsl(333,80%,85%);
// Message box color: todo and test
@box-todo-color: hsl(200,80%,85%);
// Message box helper function
.message-box(@base-color) {
background:linear-gradient(to bottom,lighten(@base-color, 5%) 0%,@base-color 100%);
box-shadow:inset 0 0 32px darken(@base-color, 5%);
color:darken(@base-color, 67%);
border:2px solid desaturate(darken(@base-color, 10%), 20%);
}
#navrow1,#navrow2,#navrow3,#navrow4,.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code {
background:none;
}
#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,hr,.memSeparator {
border:none;
}
.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.reflist dt a.el,.levels span,.directory .levels span {
text-shadow:none;
}
.memdoc,dl.reflist dd {
box-shadow:none;
}
div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code {
padding:0;
}
#nav-path,.directory .levels,span.lineno {
display:none;
}
html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code {
background:@header-footer-background-color;
}
body {
color:@default-text-color;
}
h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {
color:@heading-color;
border-bottom:none;
}
h1 {
padding-top:0.5em;
font-size:180%;
}
h2 {
padding-top:0.5em;
margin-bottom:0;
font-size:140%;
}
h3 {
padding-top:0.5em;
margin-bottom:0;
font-size:110%;
}
.glfwheader {
font-size:16px;
height:64px;
max-width:920px;
min-width:800px;
padding:0 32px;
margin:0 auto;
}
#glfwhome {
line-height:64px;
padding-right:48px;
color:@header-footer-link-color;
font-size:2.5em;
background:url("http://www.glfw.org/css/arrow.png") no-repeat right;
}
.glfwnavbar {
list-style-type:none;
margin:0 auto;
float:right;
}
#glfwhome,.glfwnavbar li {
float:left;
}
.glfwnavbar a,.glfwnavbar a:visited {
line-height:64px;
margin-left:2em;
display:block;
color:@header-footer-link-color;
}
#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {
transition:.35s ease;
}
#titlearea,.footer {
color:@header-footer-link-color;
}
address.footer {
text-align:center;
padding:2em;
margin-top:3em;
}
#top {
background:@header-footer-link-color;
}
#navrow1,#navrow2,#navrow3,#navrow4 {
max-width:920px;
min-width:800px;
margin:0 auto;
font-size:13px;
}
.tablist {
height:36px;
display:block;
position:relative;
}
.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a {
color:@navbar-link-color;
}
.tablist li.current a {
background:linear-gradient(to bottom,@tab-background-color2 0%,@tab-background-color1 100%);
box-shadow:inset 0 0 32px @tab-background-color1;
text-shadow:0 -1px 1px darken(@tab-background-color1, 15%);
color:@tab-text-color;
}
.contents {
min-height:590px;
}
div.contents,div.header {
max-width:920px;
margin:0 auto;
padding:0 32px;
background:@content-background-color none;
}
table.doxtable th,dl.reflist dt {
background:linear-gradient(to bottom,@table-background-color2 0%,@table-background-color1 100%);
box-shadow:inset 0 0 32px @table-background-color1;
text-shadow:0 -1px 1px darken(@table-background-color1, 15%);
color:@table-text-color;
}
dl.reflist dt a.el {
color:@default-link-color;
padding:.2em;
border-radius:4px;
background-color:lighten(@default-link-color, 40%);
}
div.toc {
float:none;
width:auto;
}
div.toc h3 {
font-size:1.17em;
}
div.toc ul {
padding-left:1.5em;
}
div.toc li {
font-size:1em;
padding-left:0;
list-style-type:disc;
}
div.toc,.memproto,div.qindex,div.ah {
background:linear-gradient(to bottom,@toc-background-color2 0%,@toc-background-color1 100%);
box-shadow:inset 0 0 32px @toc-background-color1;
text-shadow:0 1px 1px lighten(@toc-background-color2, 10%);
color:@heading-color;
border:2px solid @toc-background-color1;
border-radius:4px;
}
.paramname {
color:@prototype-param-color;
}
dl.reflist dt {
border:2px solid @default-border-color;
border-top-left-radius:4px;
border-top-right-radius:4px;
border-bottom:none;
}
dl.reflist dd {
border:2px solid @default-border-color;
border-bottom-right-radius:4px;
border-bottom-left-radius:4px;
border-top:none;
}
table.doxtable {
border-collapse:inherit;
border-spacing:0;
border:2px solid @default-border-color;
border-radius:4px;
}
a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,.tablist a:hover,span.lineno a:hover {
color:@default-link-color;
text-decoration:none;
}
div.directory {
border-collapse:inherit;
border-spacing:0;
border:2px solid @default-border-color;
border-radius:4px;
}
hr,.memSeparator {
height:2px;
background:linear-gradient(to right,@def-separator-color 0%,darken(@def-separator-color, 10%) 50%,@def-separator-color 100%);
}
dl.note,dl.pre,dl.post,dl.invariant {
.message-box(@box-note-color);
}
dl.warning,dl.attention {
.message-box(@box-warning-color);
}
dl.deprecated,dl.bug {
.message-box(@box-bug-color);
}
dl.todo,dl.test {
.message-box(@box-todo-color);
}
dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {
border-radius:4px;
padding:1em;
text-shadow:0 1px 1px hsl(0,0%,100%);
margin:1em 0;
}
.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited {
color:inherit;
}
div.line {
line-height:inherit;
}
div.fragment,pre.fragment {
background:hsl(0,0%,95%);
border-radius:4px;
border:none;
padding:1em;
overflow:auto;
border-left:4px solid hsl(0,0%,80%);
margin:1em 0;
}
.lineno a,.lineno a:visited,.line,pre.fragment {
color:@default-text-color;
}
span.preprocessor,span.comment {
color:hsl(193,100%,30%);
}
a.code,a.code:visited {
color:hsl(18,100%,45%);
}
span.keyword,span.keywordtype,span.keywordflow {
color:darken(@default-text-color, 5%);
font-weight:bold;
}
span.stringliteral {
color:hsl(261,100%,30%);
}
code {
padding:.1em;
border-radius:4px;
}

View File

@ -1,7 +0,0 @@
<address class="footer">
<p>
Last update on $date for $projectname $projectnumber
</p>
</address>
</body>
</html>

View File

@ -1,34 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<div class="glfwheader">
<a href="http://www.glfw.org/" id="glfwhome">GLFW</a>
<ul class="glfwnavbar">
<li><a href="http://www.glfw.org/documentation.html">Documentation</a></li>
<li><a href="http://www.glfw.org/download.html">Download</a></li>
<li><a href="http://www.glfw.org/media.html">Media</a></li>
<li><a href="http://www.glfw.org/community.html">Community</a></li>
</ul>
</div>
</div>
<!--END TITLEAREA-->
<!-- end header part -->

View File

@ -1,588 +0,0 @@
/*!
@page input Input guide
@tableofcontents
This guide introduces the input related functions of GLFW. There are also
guides for the other areas of GLFW.
- @ref intro
- @ref window
- @ref context
- @ref monitor
GLFW provides many kinds of input. While some can only be polled, like time, or
only received via callbacks, like scrolling, there are those that provide both
callbacks and polling. Where a callback is provided, that is the recommended
way to receive that kind of input. The more you can use callbacks the less time
your users' machines will need to spend polling.
All input callbacks receive a window handle. By using the
[window user pointer](@ref window_userptr), you can access non-global structures
or objects from your callbacks.
To get a better feel for how the various events callbacks behave, run the
`events` test program. It register every callback supported by GLFW and prints
out all arguments provided for every event, along with time and sequence
information.
@section events Event processing
GLFW needs to communicate regularly with the window system both in order to
receive events and to show that the application hasn't locked up. Event
processing must be done regularly while you have visible windows and is normally
done each frame after [buffer swapping](@ref buffer_swap).
There are two functions for processing pending events. @ref glfwPollEvents,
processes only those events that have already been received and then returns
immediately.
@code
glfwPollEvents();
@endcode
This is the best choice when rendering continually, like most games do.
If you only need to update the contents of the window when you receive new
input, @ref glfwWaitEvents is a better choice.
@code
glfwWaitEvents();
@endcode
It puts the thread to sleep until at least one event has been received and then
processes all received events. This saves a great deal of CPU cycles and is
useful for, for example, editing tools. There must be at least one GLFW window
for this function to sleep.
If the main thread is sleeping in @ref glfwWaitEvents, you can wake it from
another thread by posting an empty event to the event queue with @ref
glfwPostEmptyEvent.
@code
glfwPostEmptyEvent();
@endcode
Do not assume that callbacks will _only_ be called through either of the above
functions. While it is necessary to process events in the event queue, some
window systems will send some events directly to the application, which in turn
causes callbacks to be called outside of regular event processing.
@section input_keyboard Keyboard input
GLFW divides keyboard input into two categories; key events and character
events. Key events relate to actual physical keyboard keys, whereas character
events relate to the Unicode code points generated by pressing some of them.
Keys and characters do not map 1:1. A single key press may produce several
characters, and a single character may require several keys to produce. This
may not be the case on your machine, but your users are likely not all using the
same keyboard layout, input method or even operating system as you.
@subsection input_key Key input
If you wish to be notified when a physical key is pressed or released or when it
repeats, set a key callback.
@code
glfwSetKeyCallback(window, key_callback);
@endcode
The callback function receives the [keyboard key](@ref keys), platform-specific
scancode, key action and [modifier bits](@ref mods).
@code
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_E && action == GLFW_PRESS)
activate_airship();
}
@endcode
The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. The key
will be `GLFW_KEY_UNKNOWN` if GLFW lacks a key token for it. These keys still
have unique, if platform-specific scancodes.
The scancode is unique for every key but is platform-specific, so a scancode
will map to different keys on different platforms.
The key will be `GLFW_KEY_UNKNOWN` for special keys like _E-mail_ or _Play_ that
don't have a key token. Those keys will still have unique, if platform-specific
scancodes.
Key states for [named keys](@ref keys) are also saved in per-window state arrays
that can be polled with @ref glfwGetKey.
@code
int state = glfwGetKey(window, GLFW_KEY_E);
if (state == GLFW_PRESS)
activate_airship();
@endcode
The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.
This function only returns cached key event state. It does not poll the
system for the current state of the key.
Whenever you poll state, you risk missing the state change you are looking for.
If a pressed key is released again before you poll its state, you will have
missed the key press. The recommended solution for this is to use a
key callback, but there is also the `GLFW_STICKY_KEYS` input mode.
@code
glfwSetInputMode(window, GLFW_STICKY_KEYS, 1);
@endcode
When sticky keys mode is enabled, the pollable state of a key will remain
`GLFW_PRESS` until the state of that key is polled with @ref glfwGetKey. Once
it has been polled, if a key release event had been processed in the meantime,
the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.
The `GLFW_KEY_LAST` constant holds the highest value of any
[named key](@ref keys).
@subsection input_char Text input
GLFW supports text input in the form of a stream of
[Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the
operating system text input system. Unlike key input, text input obeys keyboard
layouts and modifier keys and supports composing characters using
[dead keys](https://en.wikipedia.org/wiki/Dead_key). Once received, you can
encode the code points into
[UTF-8](https://en.wikipedia.org/wiki/UTF-8) or any other encoding you prefer.
Because an `unsigned int` is 32 bits long on all platforms supported by GLFW,
you can treat the code point argument as native endian
[UTF-32](https://en.wikipedia.org/wiki/UTF-32).
There are two callbacks for receiving Unicode code points. If you wish to
offer regular text input, set a character callback.
@code
glfwSetCharCallback(window, character_callback);
@endcode
The callback function receives Unicode code points for key events that would
have led to regular text input and generally behaves as a standard text field on
that platform.
@code
void character_callback(GLFWwindow* window, unsigned int codepoint)
{
}
@endcode
If you wish to receive even those Unicode code points generated with modifier
key combinations that a plain text field would ignore, or just want to know
exactly what modifier keys were used, set a character with modifiers callback.
@code
glfwSetCharModsCallback(window, charmods_callback);
@endcode
The callback function receives Unicode code points and
[modifier bits](@ref mods).
@code
void charmods_callback(GLFWwindow* window, unsigned int codepoint, int mods)
{
}
@endcode
@section input_mouse Mouse input
Mouse input comes in many forms, including cursor motion, button presses and
scrolling offsets. The cursor appearance can also be changed, either to
a custom image or a standard cursor shape from the system theme.
@subsection cursor_pos Cursor position
If you wish to be notified when the cursor moves over the window, set a cursor
position callback.
@code
glfwSetCursorPosCallback(window, cursor_pos_callback);
@endcode
The callback functions receives the cursor position. On platforms that provide
it, the full sub-pixel cursor position is passed on.
@code
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
{
}
@endcode
The cursor position is also saved per-window and can be polled with @ref
glfwGetCursorPos.
@code
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
@endcode
@subsection cursor_mode Cursor modes
The `GLFW_CURSOR` input mode provides several cursor modes for special forms of
mouse motion input. By default, the cursor mode is `GLFW_CURSOR_NORMAL`,
meaning the regular arrow cursor (or another cursor set with @ref glfwSetCursor)
is used and cursor motion is not limited.
If you wish to implement mouse motion based camera controls or other input
schemes that require unlimited mouse movement, set the cursor mode to
`GLFW_CURSOR_DISABLED`.
@code
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
@endcode
This will hide the cursor and lock it to the specified window. GLFW will then
take care of all the details of cursor re-centering and offset calculation and
providing the application with a virtual cursor position. This virtual position
is provided normally via both the cursor position callback and through polling.
@note You should not implement your own version of this functionality using
other features of GLFW. It is not supported and will not work as robustly as
`GLFW_CURSOR_DISABLED`.
If you just wish the cursor to become hidden when it is over a window, set
the cursor mode to `GLFW_CURSOR_HIDDEN`.
@code
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
@endcode
This mode puts no limit on the motion of the cursor.
To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL`
cursor mode.
@code
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
@endcode
@subsection cursor_object Cursor objects
GLFW supports creating both custom and system theme cursor images, encapsulated
as @ref GLFWcursor objects. They are created with @ref glfwCreateCursor or @ref
glfwCreateStandardCursor and destroyed with @ref glfwDestroyCursor, or @ref
glfwTerminate, if any remain.
@subsubsection cursor_custom Custom cursor creation
A custom cursor is created with @ref glfwCreateCursor, which returns a handle to
the created cursor object. For example, this creates a 16x16 white square
cursor with the hot-spot in the upper-left corner:
@code
unsigned char pixels[16 * 16 * 4];
memset(pixels, 0xff, sizeof(pixels));
GLFWimage image;
image.width = 16;
image.height = 16;
image.pixels = pixels;
GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0);
@endcode
If cursor creation fails, `NULL` will be returned, so it is necessary to check
the return value.
The image data is 32-bit RGBA, i.e. eight bits per channel. The pixels are
arranged canonically as sequential rows, starting from the top-left corner.
@subsubsection cursor_standard Standard cursor creation
A cursor with a [standard shape](@ref shapes) from the current system cursor
theme can be can be created with @ref glfwCreateStandardCursor.
@code
GLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
@endcode
These cursor objects behave in the exact same way as those created with @ref
glfwCreateCursor except that the system cursor theme provides the actual image.
@subsubsection cursor_destruction Cursor destruction
When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor.
@code
glfwDestroyCursor(cursor);
@endcode
Cursor destruction always succeeds. All cursors remaining when @ref
glfwTerminate is called are destroyed as well.
@subsubsection cursor_set Cursor setting
A cursor can be set as current for a window with @ref glfwSetCursor.
@code
glfwSetCursor(window, cursor);
@endcode
Once set, the cursor image will be used as long as the system cursor is over the
client area of the window and the [cursor mode](@ref cursor_mode) is set
to `GLFW_CURSOR_NORMAL`.
A single cursor may be set for any number of windows.
To remove a cursor from a window, set the cursor of that window to `NULL`.
@code
glfwSetCursor(window, NULL);
@endcode
When a cursor is destroyed, it is removed from any window where it is set. This
does not affect the cursor modes of those windows.
@subsection cursor_enter Cursor enter/leave events
If you wish to be notified when the cursor enters or leaves the client area of
a window, set a cursor enter/leave callback.
@code
glfwSetCursorEnterCallback(window, cursor_enter_callback);
@endcode
The callback function receives the new classification of the cursor.
@code
void cursor_enter_callback(GLFWwindow* window, int entered)
{
if (entered)
{
// The cursor entered the client area of the window
}
else
{
// The cursor left the client area of the window
}
}
@endcode
@subsection input_mouse_button Mouse button input
If you wish to be notified when a mouse button is pressed or released, set
a mouse button callback.
@code
glfwSetMouseButtonCallback(window, mouse_button_callback);
@endcode
The callback function receives the [mouse button](@ref buttons), button action
and [modifier bits](@ref mods).
@code
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS)
popup_menu();
}
@endcode
The action is one of `GLFW_PRESS` or `GLFW_RELEASE`.
Mouse button states for [named buttons](@ref buttons) are also saved in
per-window state arrays that can be polled with @ref glfwGetMouseButton.
@code
int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
if (state == GLFW_PRESS)
upgrade_cow();
@endcode
The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.
This function only returns cached mouse button event state. It does not poll
the system for the current state of the mouse button.
Whenever you poll state, you risk missing the state change you are looking for.
If a pressed mouse button is released again before you poll its state, you will have
missed the button press. The recommended solution for this is to use a
mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS`
input mode.
@code
glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, 1);
@endcode
When sticky mouse buttons mode is enabled, the pollable state of a mouse button
will remain `GLFW_PRESS` until the state of that button is polled with @ref
glfwGetMouseButton. Once it has been polled, if a mouse button release event
had been processed in the meantime, the state will reset to `GLFW_RELEASE`,
otherwise it will remain `GLFW_PRESS`.
The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any
[named button](@ref buttons).
@subsection scrolling Scroll input
If you wish to be notified when the user scrolls, whether with a mouse wheel or
touchpad gesture, set a scroll callback.
@code
glfwSetScrollCallback(window, scroll_callback);
@endcode
The callback function receives two-dimensional scroll offsets.
@code
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
}
@endcode
A simple mouse wheel, being vertical, provides offsets along the Y-axis.
@section joystick Joystick input
The joystick functions expose connected joysticks and controllers, with both
referred to as joysticks. It supports up to sixteen joysticks, ranging from
`GLFW_JOYSTICK_1`, `GLFW_JOYSTICK_2` up to `GLFW_JOYSTICK_LAST`. You can test
whether a [joystick](@ref joysticks) is present with @ref glfwJoystickPresent.
@code
int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
@endcode
When GLFW is initialized, detected joysticks are added to to the beginning of
the array, starting with `GLFW_JOYSTICK_1`. Once a joystick is detected, it
keeps its assigned index until it is disconnected, so as joysticks are connected
and disconnected, they will become spread out.
Joystick state is updated as needed when a joystick function is called and does
not require a window to be created or @ref glfwPollEvents or @ref glfwWaitEvents
to be called.
@subsection joystick_axis Joystick axis states
The positions of all axes of a joystick are returned by @ref
glfwGetJoystickAxes. See the reference documentation for the lifetime of the
returned array.
@code
int count;
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &count);
@endcode
Each element in the returned array is a value between -1.0 and 1.0.
@subsection joystick_button Joystick button states
The states of all buttons of a joystick are returned by @ref
glfwGetJoystickButtons. See the reference documentation for the lifetime of the
returned array.
@code
int count;
const unsigned char* axes = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &count);
@endcode
Each element in the returned array is either `GLFW_PRESS` or `GLFW_RELEASE`.
@subsection joystick_name Joystick name
The human-readable, UTF-8 encoded name of a joystick is returned by @ref
glfwGetJoystickName. See the reference documentation for the lifetime of the
returned string.
@code
const char* name = glfwGetJoystickName(GLFW_JOYSTICK_1);
@endcode
Joystick names are not guaranteed to be unique. Two joysticks of the same model
and make may have the same name. Only the [joystick token](@ref joysticks) is
guaranteed to be unique, and only until that joystick is disconnected.
@section time Time input
GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
@code
double seconds = glfwGetTime();
@endcode
It returns the number of seconds since the timer was started when the library
was initialized with @ref glfwInit. The platform-specific time sources used
usually have micro- or nanosecond resolution.
You can modify the reference time with @ref glfwSetTime.
@code
glfwSetTime(4.0);
@endcode
This sets the timer to the specified time, in seconds.
@section clipboard Clipboard input and output
If the system clipboard contains a UTF-8 encoded string or if it can be
converted to one, you can retrieve it with @ref glfwGetClipboardString. See the
reference documentation for the lifetime of the returned string.
@code
const char* clipboard = glfwGetClipboardString(window);
@endcode
The contents of the system clipboard can be set to a UTF-8 encoded string with
@ref glfwSetClipboardString.
@code
glfwSetClipboardString(window, "A string with words in it");
@endcode
The clipboard functions take a window handle argument because some window
systems require a window to communicate with the system clipboard. Any valid
window may be used.
@section path_drop Path drop input
If you wish to receive the paths of files and/or directories dropped on
a window, set a file drop callback.
@code
glfwSetDropCallback(window, drop_callback);
@endcode
The callback function receives an array of paths encoded as UTF-8.
@code
void drop_callback(GLFWwindow* window, int count, const char** paths)
{
int i;
for (i = 0; i < count; i++)
handle_dropped_file(paths[i]);
}
@endcode
The path array and its strings are only valid until the file drop callback
returns, as they may have been generated specifically for that event. You need
to make a deep copy of the array if you want to keep the paths.
*/

View File

@ -1,116 +0,0 @@
/*!
@page internals Internal structure
@tableofcontents
There are several interfaces inside GLFW. Each interface has its own area of
responsibility and its own naming conventions.
@section internals_public Public interface
The most well-known is the public interface, described in the glfw3.h header
file. This is implemented in source files shared by all platforms and these
files contain no platform-specific code. This code usually ends up calling the
platform and internal interfaces to do the actual work.
The public interface uses the OpenGL naming conventions except with GLFW and
glfw instead of GL and gl. For struct members, where OpenGL sets no precedent,
it use headless camel case.
Examples: @ref glfwCreateWindow, @ref GLFWwindow, @ref GLFWvidmode.redBits,
`GLFW_RED_BITS`
@section internals_native Native interface
The [native interface](@ref native) is a small set of publicly available
but platform-specific functions, described in the glfw3native.h header file and
used to gain access to the underlying window, context and (on some platforms)
display handles used by the platform interface.
The function names of the native interface are similar to those of the public
interface, but embeds the name of the interface that the returned handle is
from.
Examples: @ref glfwGetX11Window, @ref glfwGetWGLContext
@section internals_internal Internal interface
The internal interface consists of utility functions used by all other
interfaces. It is shared code implemented in the same shared source files as
the public and event interfaces. The internal interface is described in the
internal.h header file.
The internal interface is in charge of GLFW's global data, which it stores in
a `_GLFWlibrary` struct named `_glfw`.
The internal interface uses the same style as the public interface, except all
global names have a leading underscore.
Examples: @ref _glfwIsValidContextConfig, @ref _GLFWwindow, `_glfw.currentRamp`
@section internals_platform Platform interface
The platform interface implements all platform-specific operations as a service
to the public interface. This includes event processing. The platform
interface is never directly called by application code and never directly calls
application-provided callbacks. It is also prohibited from modifying the
platform-independent part of the internal structs. Instead, it calls the event
interface when events interesting to GLFW are received.
The platform interface mirrors those parts of the public interface that needs to
perform platform-specific operations on some or all platforms. The are also
named the same except that the glfw function prefix is replaced by
_glfwPlatform.
Examples: @ref _glfwPlatformCreateWindow
The platform interface also defines structs that contain platform-specific
global and per-object state. Their names mirror those of the internal
interface, except that an interface-specific suffix is added.
Examples: `_GLFWwindowX11`, `_GLFWcontextWGL`
These structs are incorporated as members into the internal interface structs
using special macros that name them after the specific interface used. This
prevents shared code from accidentally using these members.
Examples: `window.win32.handle`, `_glfw.x11.display`
@section internals_event Event interface
The event interface is implemented in the same shared source files as the public
interface and is responsible for delivering the events it receives to the
application, either via callbacks, via window state changes or both.
The function names of the event interface use a `_glfwInput` prefix and the
ObjectEvent pattern.
Examples: @ref _glfwInputWindowFocus, @ref _glfwInputCursorMotion
@section internals_static Static functions
Static functions may be used by any interface and have no prefixes or suffixes.
These use headless camel case.
Examples: `clearScrollOffsets`
@section internals_config Configuration macros
GLFW uses a number of configuration macros to select at compile time which
interfaces and code paths to use. They are defined in the glfw_config.h header file,
which is generated from the `glfw_config.h.in` file by CMake.
Configuration macros the same style as tokens in the public interface, except
with a leading underscore.
Examples: `_GLFW_HAS_GLXGETPROCADDRESS`
*/

View File

@ -1,347 +0,0 @@
/*!
@page intro Introduction to the API
@tableofcontents
This guide introduces the basic concepts of GLFW and describes initialization,
error handling and API guarantees and limitations. For a broad but shallow
tutorial, see @ref quick instead. There are also guides for the other areas of
GLFW.
- @ref window
- @ref context
- @ref monitor
- @ref input
@section intro_init Initialization and termination
Before most GLFW functions may be called, the library must be initialized.
This initialization checks what features are available on the machine,
enumerates monitors and joysticks, initializes the timer and performs any
required platform-specific initialization.
Only the following functions may be called before the library has been
successfully initialized, and only from the main thread.
- @ref glfwGetVersion
- @ref glfwGetVersionString
- @ref glfwSetErrorCallback
- @ref glfwInit
- @ref glfwTerminate
Calling any other function before that time will cause a @ref
GLFW_NOT_INITIALIZED error.
@subsection intro_init_init Initializing GLFW
The library is initialized with @ref glfwInit, which returns `GL_FALSE` if an
error occurred.
@code
if (!glfwInit())
{
// Handle initialization failure
}
@endcode
If any part of initialization fails, all remaining bits are terminated as if
@ref glfwTerminate was called. The library only needs to be initialized once
and additional calls to an already initialized library will simply return
`GL_TRUE` immediately.
Once the library has been successfully initialized, it should be terminated
before the application exits.
@subsection intro_init_terminate Terminating GLFW
Before your application exits, you should terminate the GLFW library if it has
been initialized. This is done with @ref glfwTerminate.
@code
glfwTerminate();
@endcode
This will destroy any remaining window, monitor and cursor objects, restore any
modified gamma ramps, re-enable the screensaver if it had been disabled and free
any resources allocated by GLFW.
Once the library is terminated, it is as if it had never been initialized and
you will need to initialize it again before being able to use GLFW. If the
library was not initialized or had already been terminated, it return
immediately.
@section error_handling Error handling
Some GLFW functions have return values that indicate an error, but this is often
not very helpful when trying to figure out _why_ the error occurred. Some
functions also return otherwise valid values on error. Finally, far from all
GLFW functions have return values.
This is where the error callback comes in. This callback is called whenever an
error occurs. It is set with @ref glfwSetErrorCallback, a function that may be
called regardless of whether GLFW is initialized.
@code
glfwSetErrorCallback(error_callback);
@endcode
The error callback receives a human-readable description of the error and (when
possible) its cause. The description encoded as UTF-8. The callback is also
provided with an [error code](@ref errors).
@code
void error_callback(int error, const char* description)
{
puts(description);
}
@endcode
The error code indicates the general category of the error. Some error codes,
such as @ref GLFW_NOT_INITIALIZED has only a single meaning, whereas others like
@ref GLFW_PLATFORM_ERROR are used for many different errors.
The description string is only valid until the error callback returns, as it may
have been generated specifically for that error. This lets GLFW provide much
more specific error descriptions but means you must make a copy if you want to
keep the description string.
@section coordinate_systems Coordinate systems
GLFW has two primary coordinate systems: the _virtual screen_ and the window
_client area_ or _content area_. Both use the same unit: _virtual screen
coordinates_, or just _screen coordinates_, which don't necessarily correspond
to pixels.
<img src="spaces.svg" width="90%" />
Both the virtual screen and the client area coordinate systems have the X-axis
pointing to the right and the Y-axis pointing down.
Window and monitor positions are specified as the position of the upper-left
corners of their content areas relative to the virtual screen, while cursor
positions are specified relative to a window's client area.
Because the origin of the window's client area coordinate system is also the
point from which the window position is specified, you can translate client area
coordinates to the virtual screen by adding the window position. The window
frame, when present, extends out from the client area but does not affect the
window position.
Almost all positions and sizes in GLFW are measured in screen coordinates
relative to one of the two origins above. This includes cursor positions,
window positions and sizes, window frame sizes, monitor positions and video mode
resolutions.
Two exceptions are the [monitor physical size](@ref monitor_size), which is
measured in millimetres, and [framebuffer size](@ref window_fbsize), which is
measured in pixels.
Pixels and screen coordinates may map 1:1 on your machine, but they won't on
every other machine, for example on a Mac with a Retina display. The ratio
between screen coordinates and pixels may also change at run-time depending on
which monitor the window is currently considered to be on.
@section guarantees_limitations Guarantees and limitations
This section describes the conditions under which GLFW can be expected to
function, barring bugs in the operating system or drivers. Use of GLFW outside
of these limits may work on some platforms, or on some machines, or some of the
time, or on some versions of GLFW, but it may break at any time and this will
not be considered a bug.
@subsection lifetime Pointer lifetimes
GLFW will never free any pointer you provide to it and you must never free any
pointer it provides to you.
Many GLFW functions return pointers to dynamically allocated structures, strings
or arrays, and some callbacks are provided with strings or arrays. These are
always managed by GLFW and should never be freed by the application. The
lifetime of these pointers is documented for each GLFW function and callback.
If you need to keep this data, you must copy it before its lifetime expires.
Many GLFW functions accept pointers to structures or strings allocated by the
application. These are never freed by GLFW and are always the responsibility of
the application. If GLFW needs to keep the data in these structures or strings,
it is copied before the function returns.
Pointer lifetimes are guaranteed not to be shortened in future minor or patch
releases.
@subsection reentrancy Reentrancy
GLFW event processing and object creation and destruction are not reentrant.
This means that the following functions may not be called from any callback
function:
- @ref glfwCreateWindow
- @ref glfwDestroyWindow
- @ref glfwCreateCursor
- @ref glfwCreateStandardCursor
- @ref glfwDestroyCursor
- @ref glfwPollEvents
- @ref glfwWaitEvents
- @ref glfwTerminate
These functions may be made reentrant in future minor or patch releases, but
functions not on this list will not be made non-reentrant.
@subsection thread_safety Thread safety
Most GLFW functions may only be called from the main thread, but some may be
called from any thread. However, no GLFW function may be called from any other
thread until GLFW has been successfully initialized on the main thread,
including functions that may called before initialization.
The reference documentation for every GLFW function states whether it is limited
to the main thread.
The following categories of functions are and will remain limited to the main
thread due to the limitations of one or several platforms:
- Initialization and termination
- Event processing
- Creation and destruction of window, context and cursor objects
Because event processing must be performed on the main thread, all callbacks
except for the error callback will only be called on that thread. The error
callback may be called on any thread, as any GLFW function may generate errors.
The posting of empty events may be done from any thread. The window user
pointer and close flag may also be accessed and modified from any thread, but
this is not synchronized by GLFW. The following window related functions may
be called from any thread:
- @ref glfwPostEmptyEvent
- @ref glfwGetWindowUserPointer
- @ref glfwSetWindowUserPointer
- @ref glfwWindowShouldClose
- @ref glfwSetWindowShouldClose
Rendering may be done on any thread. The following context related functions
may be called from any thread:
- @ref glfwMakeContextCurrent
- @ref glfwGetCurrentContext
- @ref glfwSwapBuffers
- @ref glfwSwapInterval
- @ref glfwExtensionSupported
- @ref glfwGetProcAddress
The timer may be accessed from any thread, but this is not synchronized by GLFW.
The following timer related functions may be called from any thread:
- @ref glfwGetTime
Library version information may be queried from any thread. The following
version related functions may be called from any thread:
- @ref glfwGetVersion
- @ref glfwGetVersionString
GLFW uses no synchronization objects internally except for thread-local storage
to keep track of the current context for each thread. Synchronization is left
to the application.
Functions that may currently be called from any thread will always remain so,
but functions that are currently limited to the main may be updated to allow
calls from any thread in future releases.
@subsection compatibility Version compatibility
GLFW guarantees binary backward compatibility with earlier minor versions of the
API. This means that you can drop in a newer version of the GLFW DLL / shared
library / dynamic library and existing applications will continue to run.
Once a function or constant has been added, the signature of that function or
value of that constant will remain unchanged until the next major version of
GLFW. No compatibility of any kind is guaranteed between major versions.
Undocumented behavior, i.e. behavior that is not described in the documentation,
may change at any time until it is documented.
If the reference documentation and the implementation differ, the reference
documentation is correct and the implementation will be fixed in the next
release.
@subsection event_order Event order
The order of arrival of related events is not guaranteed to be consistent
across platforms. The exception is synthetic key and mouse button release
events, which are always delivered after the window defocus event.
@section intro_version Version management
GLFW provides mechanisms for identifying what version of GLFW your application
was compiled against as well as what version it is currently running against.
If you are loading GLFW dynamically (not just linking dynamically), you can use
this to verify that the library binary is compatible with your application.
@subsection intro_version_compile Compile-time version
The compile-time version of GLFW is provided by the GLFW header with the
`GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros.
@code
printf("Compiled against GLFW %i.%i.%i\n",
GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION);
@endcode
@subsection intro_version_runtime Run-time version
The run-time version can be retrieved with @ref glfwGetVersion, a function that
may be called regardless of whether GLFW is initialized.
@code
int major, minor, revision;
glfwGetVersion(&major, &minor, &revision);
printf("Running against GLFW %i.%i.%i\n", major, minor, revision);
@endcode
@subsection intro_version_string Version string
GLFW 3 also provides a compile-time generated version string that describes the
version, platform, compiler and any platform-specific compile-time options.
This is primarily intended for submitting bug reports, to allow developers to
see which code paths are enabled in a binary.
The version string is returned by @ref glfwGetVersionString, a function that may
be called regardless of whether GLFW is initialized.
__Do not use the version string__ to parse the GLFW library version. The @ref
glfwGetVersion function already provides the version of the running library
binary.
The format of the string is as follows:
- The version of GLFW
- The name of the window system API
- The name of the context creation API
- Any additional options or APIs
For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
back ends, the version string may look something like this:
@code
3.0.0 Win32 WGL MinGW
@endcode
*/

View File

@ -1,47 +0,0 @@
/*!
@mainpage notitle
@section main_intro Introduction
__GLFW__ is a free, Open Source, multi-platform library for creating windows
with OpenGL or OpenGL ES contexts and receiving many kinds of input. It is easy
to integrate into existing applications and does not lay claim to the main loop.
See @ref news_31 for release highlights or the
[version history](http://www.glfw.org/changelog.html) for details.
@ref quick is a guide for those new to GLFW. It takes you through how to write
a small but complete program. For people coming from GLFW 2, the @ref moving
guide explains what has changed and how to update existing code to use the new
API.
There are guides for each of the various areas of the API.
- @ref intro initialization, error handling and high-level design
- @ref window creating and working with windows and framebuffers
- @ref context working with OpenGL and OpenGL ES contexts
- @ref monitor enumerating and working with monitors and video modes
- @ref input receiving events, polling and processing input
Once you have written a program, see the @ref compile and @ref build guides.
The [reference documentation](modules.html) provides more detailed information
about specific functions.
There is a section on @ref guarantees_limitations for pointer lifetimes,
reentrancy, thread safety, event order and backward and forward compatibility.
The @ref rift fills in the gaps for how to use LibOVR with GLFW.
The [FAQ](http://www.glfw.org/faq.html) answers many common questions about the
design, implementation and use of GLFW.
Finally, the @ref compat guide explains what APIs, standards and protocols GLFW
uses and what happens when they are not present on a given machine.
This documentation was generated with Doxygen. The sources for it are available
in both the [source distribution](http://www.glfw.org/download.html) and
[GitHub repository](https://github.com/glfw/glfw).
*/

View File

@ -1,204 +0,0 @@
/*!
@page monitor Monitor guide
@tableofcontents
This guide introduces the monitor related functions of GLFW. There are also
guides for the other areas of GLFW.
- @ref intro
- @ref window
- @ref context
- @ref input
@section monitor_object Monitor objects
A monitor object represents a currently connected monitor and is represented as
a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type
@ref GLFWmonitor. Monitor objects cannot be created or destroyed by the
application and retain their addresses until the monitors they represent are
disconnected or until the library is [terminated](@ref intro_init_terminate).
Each monitor has a current video mode, a list of supported video modes,
a virtual position, a human-readable name, an estimated physical size and
a gamma ramp. One of the monitors is the primary monitor.
The virtual position of a monitor is in
[screen coordinates](@ref coordinate_systems) and, together with the current
video mode, describes the viewports that the connected monitors provide into the
virtual desktop that spans them.
To see how GLFW views your monitor setup and its available video modes, run the
`modes` test program.
@subsection monitor_monitors Retrieving monitors
The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's
preferred monitor and is usually the one with global UI elements like task bar
or menu bar.
@code
GLFWmonitor* primary = glfwGetPrimaryMonitor();
@endcode
You can retrieve all currently connected monitors with @ref glfwGetMonitors.
See the reference documentation for the lifetime of the returned array.
@code
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
@endcode
The primary monitor is always the first monitor in the returned array, but other
monitors may be moved to a different index when a monitor is connected or
disconnected.
@subsection monitor_event Monitor configuration changes
If you wish to be notified when a monitor is connected or disconnected, set
a monitor callback.
@code
glfwSetMonitorCallback(monitor_callback);
@endcode
The callback function receives the handle for the monitor that has been
connected or disconnected and a monitor action.
@code
void monitor_callback(GLFWmonitor* monitor, int event)
{
}
@endcode
The action is one of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
@section monitor_properties Monitor properties
Each monitor has a current video mode, a list of supported video modes,
a virtual position, a human-readable name, an estimated physical size and
a gamma ramp.
@subsection monitor_modes Video modes
GLFW generally does a good job selecting a suitable video mode when you create
a full screen window, but it is sometimes useful to know exactly which video
modes are supported.
Video modes are represented as @ref GLFWvidmode structures. You can get an
array of the video modes supported by a monitor with @ref glfwGetVideoModes.
See the reference documentation for the lifetime of the returned array.
@code
int count;
GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
@endcode
To get the current video mode of a monitor call @ref glfwGetVideoMode. See the
reference documentation for the lifetime of the returned pointer.
@code
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@endcode
The resolution of a video mode is specified in
[screen coordinates](@ref coordinate_systems), not pixels.
@subsection monitor_size Physical size
The physical size of a monitor in millimetres, or an estimation of it, can be
retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its
current _resolution_, i.e. the width and height of its current
[video mode](@ref monitor_modes).
@code
int widthMM, heightMM;
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
@endcode
This can, for example, be used together with the current video mode to calculate
the DPI of a monitor.
@code
const double dpi = mode->width / (widthMM / 25.4);
@endcode
@subsection monitor_pos Virtual position
The position of the monitor on the virtual desktop, in
[screen coordinates](@ref coordinate_systems), can be retrieved with @ref
glfwGetMonitorPos.
@code
int xpos, ypos;
glfwGetMonitorPos(monitor, &xpos, &ypos);
@endcode
@subsection monitor_name Human-readable name
The human-readable, UTF-8 encoded name of a monitor is returned by @ref
glfwGetMonitorName. See the reference documentation for the lifetime of the
returned string.
@code
const char* name = glfwGetMonitorName(monitor);
@endcode
Monitor names are not guaranteed to be unique. Two monitors of the same model
and make may have the same name. Only the monitor handle is guaranteed to be
unique, and only until that monitor is disconnected.
@subsection monitor_gamma Gamma ramp
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
a monitor handle and a pointer to a @ref GLFWgammaramp structure.
@code
GLFWgammaramp ramp;
unsigned short red[256], green[256], blue[256];
ramp.size = 256;
ramp.red = red;
ramp.green = green;
ramp.blue = blue;
for (i = 0; i < ramp.size; i++)
{
// Fill out gamma ramp arrays as desired
}
glfwSetGammaRamp(monitor, &ramp);
@endcode
The gamma ramp data is copied before the function returns, so there is no need
to keep it around once the ramp has been set.
@note It is recommended to use gamma ramps of size 256, as that is the size
supported by all graphics cards on all platforms.
The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See
the reference documentation for the lifetime of the returned structure.
@code
const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);
@endcode
If you wish to set a regular gamma ramp, you can have GLFW calculate it for you
from the desired exponent with @ref glfwSetGamma, which in turn calls @ref
glfwSetGammaRamp with the resulting ramp.
@code
glfwSetGamma(monitor, 1.0);
@endcode
*/

View File

@ -1,494 +0,0 @@
/*!
@page moving Moving from GLFW 2 to 3
@tableofcontents
This is a transition guide for moving from GLFW 2 to 3. It describes what has
changed or been removed, but does _not_ include
[new features](@ref news) unless they are required when moving an existing code
base onto the new API. For example, the new multi-monitor functions are
required to create full screen windows with GLFW 3.
@section moving_removed Changed and removed features
@subsection moving_renamed_files Renamed library and header file
The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to
avoid collisions with the headers of other major versions. Similarly, the GLFW
3 library is named `glfw3,` except when it's installed as a shared library on
Unix-like systems, where it uses the
[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`.
@par Old syntax
@code
#include <GL/glfw.h>
@endcode
@par New syntax
@code
#include <GLFW/glfw3.h>
@endcode
@subsection moving_threads Removal of threading functions
The threading functions have been removed, including the per-thread sleep
function. They were fairly primitive, under-used, poorly integrated and took
time away from the focus of GLFW (i.e. context, input and window). There are
better threading libraries available and native threading support is available
in both [C++11](http://en.cppreference.com/w/cpp/thread) and
[C11](http://en.cppreference.com/w/c/thread), both of which are gaining
traction.
If you wish to use the C++11 or C11 facilities but your compiler doesn't yet
support them, see the
[TinyThread++](https://gitorious.org/tinythread/tinythreadpp) and
[TinyCThread](https://github.com/tinycthread/tinycthread) projects created by
the original author of GLFW. These libraries implement a usable subset of the
threading APIs in C++11 and C11, and in fact some GLFW 3 test programs use
TinyCThread.
However, GLFW 3 has better support for _use from multiple threads_ than GLFW
2 had. Contexts can be made current on any thread, although only a single
thread at a time, and the documentation explicitly states which functions may be
used from any thread and which may only be used from the main thread.
@par Removed functions
`glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`,
`glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`,
`glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`,
`glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`.
@subsection moving_image Removal of image and texture loading
The image and texture loading functions have been removed. They only supported
the Targa image format, making them mostly useful for beginner level examples.
To become of sufficiently high quality to warrant keeping them in GLFW 3, they
would need not only to support other formats, but also modern extensions to
OpenGL texturing. This would either add a number of external
dependencies (libjpeg, libpng, etc.), or force GLFW to ship with inline versions
of these libraries.
As there already are libraries doing this, it is unnecessary both to duplicate
the work and to tie the duplicate to GLFW. The resulting library would also be
platform-independent, as both OpenGL and stdio are available wherever GLFW is.
@par Removed functions
`glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`,
`glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`.
@subsection moving_stdcall Removal of GLFWCALL macro
The `GLFWCALL` macro, which made callback functions use
[__stdcall](http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows,
has been removed. GLFW is written in C, not Pascal. Removing this macro means
there's one less thing for application programmers to remember, i.e. the
requirement to mark all callback functions with `GLFWCALL`. It also simplifies
the creation of DLLs and DLL link libraries, as there's no need to explicitly
disable `@n` entry point suffixes.
@par Old syntax
@code
void GLFWCALL callback_function(...);
@endcode
@par New syntax
@code
void callback_function(...);
@endcode
@subsection moving_window_handles Window handle parameters
Because GLFW 3 supports multiple windows, window handle parameters have been
added to all window-related GLFW functions and callbacks. The handle of
a newly created window is returned by @ref glfwCreateWindow (formerly
`glfwOpenWindow`). Window handles are pointers to the
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow.
@par Old syntax
@code
glfwSetWindowTitle("New Window Title");
@endcode
@par New syntax
@code
glfwSetWindowTitle(window, "New Window Title");
@endcode
@subsection moving_monitor Explicit monitor selection
GLFW 3 provides support for multiple monitors. To request a full screen mode window,
instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the
window to use. The @ref glfwGetPrimaryMonitor function returns the monitor that
GLFW 2 would have selected, but there are many other
[monitor functions](@ref monitor). Monitor handles are pointers to the
[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor.
@par Old basic full screen
@code
glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN);
@endcode
@par New basic full screen
@code
window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL);
@endcode
@note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned
into [window hints](@ref window_hints), but as they have been given
[sane defaults](@ref window_hints_values) you rarely need to set these hints.
@subsection moving_autopoll Removal of automatic event polling
GLFW 3 does not automatically poll for events in @ref glfwSwapBuffers, meaning
you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. Unlike
buffer swap, which acts on a single window, the event processing functions act
on all windows at once.
@par Old basic main loop
@code
while (...)
{
// Process input
// Render output
glfwSwapBuffers();
}
@endcode
@par New basic main loop
@code
while (...)
{
// Process input
// Render output
glfwSwapBuffers(window);
glfwPollEvents();
}
@endcode
@subsection moving_context Explicit context management
Each GLFW 3 window has its own OpenGL context and only you, the application
programmer, can know which context should be current on which thread at any
given time. Therefore, GLFW 3 leaves that decision to you.
This means that you need to call @ref glfwMakeContextCurrent after creating
a window before you can call any OpenGL functions.
@subsection moving_hidpi Separation of window and framebuffer sizes
Window positions and sizes now use screen coordinates, which may not be the same
as pixels on machines with high-DPI monitors. This is important as OpenGL uses
pixels, not screen coordinates. For example, the rectangle specified with
`glViewport` needs to use pixels. Therefore, framebuffer size functions have
been added. You can retrieve the size of the framebuffer of a window with @ref
glfwGetFramebufferSize function. A framebuffer size callback has also been
added, which can be set with @ref glfwSetFramebufferSizeCallback.
@par Old basic viewport setup
@code
glfwGetWindowSize(&width, &height);
glViewport(0, 0, width, height);
@endcode
@par New basic viewport setup
@code
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
@endcode
@subsection moving_window_close Window closing changes
The `GLFW_OPENED` window parameter has been removed. As long as the window has
not been destroyed, whether through @ref glfwDestroyWindow or @ref
glfwTerminate, the window is "open".
A user attempting to close a window is now just an event like any other. Unlike
GLFW 2, windows and contexts created with GLFW 3 will never be destroyed unless
you choose them to be. Each window now has a close flag that is set to
`GL_TRUE` when the user attempts to close that window. By default, nothing else
happens and the window stays visible. It is then up to you to either destroy
the window, take some other action or simply ignore the request.
You can query the close flag at any time with @ref glfwWindowShouldClose and set
it at any time with @ref glfwSetWindowShouldClose.
@par Old basic main loop
@code
while (glfwGetWindowParam(GLFW_OPENED))
{
...
}
@endcode
@par New basic main loop
@code
while (!glfwWindowShouldClose(window))
{
...
}
@endcode
The close callback no longer returns a value. Instead, it is called after the
close flag has been set so it can override its value, if it chooses to, before
event processing completes. You may however not call @ref glfwDestroyWindow
from the close callback (or any other window related callback).
@par Old syntax
@code
int GLFWCALL window_close_callback(void);
@endcode
@par New syntax
@code
void window_close_callback(GLFWwindow* window);
@endcode
@note GLFW never clears the close flag to `GL_FALSE`, meaning you can use it
for other reasons to close the window as well, for example the user choosing
Quit from an in-game menu.
@subsection moving_hints Persistent window hints
The `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint.
Window hints are no longer reset to their default values on window creation, but
instead retain their values until modified by @ref glfwWindowHint or @ref
glfwDefaultWindowHints, or until the library is terminated and re-initialized.
@subsection moving_video_modes Video mode enumeration
Video mode enumeration is now per-monitor. The @ref glfwGetVideoModes function
now returns all available modes for a specific monitor instead of requiring you
to guess how large an array you need. The `glfwGetDesktopMode` function, which
had poorly defined behavior, has been replaced by @ref glfwGetVideoMode, which
returns the current mode of a monitor.
@subsection moving_char_up Removal of character actions
The action parameter of the [character callback](@ref GLFWcharfun) has been
removed. This was an artefact of the origin of GLFW, i.e. being developed in
English by a Swede. However, many keyboard layouts require more than one key to
produce characters with diacritical marks. Even the Swedish keyboard layout
requires this for uncommon cases like ü.
@par Old syntax
@code
void GLFWCALL character_callback(int character, int action);
@endcode
@par New syntax
@code
void character_callback(GLFWwindow* window, int character);
@endcode
@subsection moving_cursorpos Cursor position changes
The `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos,
`glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref
glfwSetCursorPosCallback.
The cursor position is now `double` instead of `int`, both for the direct
functions and for the callback. Some platforms can provide sub-pixel cursor
movement and this data is now passed on to the application where available. On
platforms where this is not provided, the decimal part is zero.
GLFW 3 only allows you to position the cursor within a window using @ref
glfwSetCursorPos (formerly `glfwSetMousePos`) when that window is active.
Unless the window is active, the function fails silently.
@subsection moving_wheel Wheel position replaced by scroll offsets
The `glfwGetMouseWheel` function has been removed. Scrolling is the input of
offsets and has no absolute position. The mouse wheel callback has been
replaced by a [scroll callback](@ref GLFWscrollfun) that receives
two-dimensional floating point scroll offsets. This allows you to receive
precise scroll data from for example modern touchpads.
@par Old syntax
@code
void GLFWCALL mouse_wheel_callback(int position);
@endcode
@par New syntax
@code
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
@endcode
@par Removed functions
`glfwGetMouseWheel`
@subsection moving_repeat Key repeat action
The `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled
for both keys and characters. A new key action, `GLFW_REPEAT`, has been added
to allow the [key callback](@ref GLFWkeyfun) to distinguish an initial key press
from a repeat. Note that @ref glfwGetKey still returns only `GLFW_PRESS` or
`GLFW_RELEASE`.
@subsection moving_keys Physical key input
GLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to
the values generated by the current keyboard layout. The tokens are named
according to the values they would have using the standard US layout, but this
is only a convenience, as most programmers are assumed to know that layout.
This means that (for example) `GLFW_KEY_LEFT_BRACKET` is always a single key and
is the same key in the same place regardless of what keyboard layouts the users
of your program has.
The key input facility was never meant for text input, although using it that
way worked slightly better in GLFW 2. If you were using it to input text, you
should be using the character callback instead, on both GLFW 2 and 3. This will
give you the characters being input, as opposed to the keys being pressed.
GLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of
having to remember whether to check for `'a'` or `'A'`, you now check for
`GLFW_KEY_A`.
@subsection moving_joystick Joystick function changes
The `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes.
The `glfwGetJoystickParam` function and the `GLFW_PRESENT`, `GLFW_AXES` and
`GLFW_BUTTONS` tokens have been replaced by the @ref glfwJoystickPresent
function as well as axis and button counts returned by the @ref
glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions.
@subsection moving_mbcs Win32 MBCS support
The Win32 port of GLFW 3 will not compile in
[MBCS mode](http://msdn.microsoft.com/en-us/library/5z097dxa.aspx).
However, because the use of the Unicode version of the Win32 API doesn't affect
the process as a whole, but only those windows created using it, it's perfectly
possible to call MBCS functions from other parts of the same application.
Therefore, even if an application using GLFW has MBCS mode code, there's no need
for GLFW itself to support it.
@subsection moving_windows Support for versions of Windows older than XP
All explicit support for version of Windows older than XP has been removed.
There is no code that actively prevents GLFW 3 from running on these earlier
versions, but it uses Win32 functions that those versions lack.
Windows XP was released in 2001, and by now (January 2015) it has not only
replaced almost all earlier versions of Windows, but is itself rapidly being
replaced by Windows 7 and 8. The MSDN library doesn't even provide
documentation for version older than Windows 2000, making it difficult to
maintain compatibility with these versions even if it was deemed worth the
effort.
The Win32 API has also not stood still, and GLFW 3 uses many functions only
present on Windows XP or later. Even supporting an OS as new as XP (new
from the perspective of GLFW 2, which still supports Windows 95) requires
runtime checking for a number of functions that are present only on modern
version of Windows.
@subsection moving_syskeys Capture of system-wide hotkeys
The ability to disable and capture system-wide hotkeys like Alt+Tab has been
removed. Modern applications, whether they're games, scientific visualisations
or something else, are nowadays expected to be good desktop citizens and allow
these hotkeys to function even when running in full screen mode.
@subsection moving_terminate Automatic termination
GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization,
because `exit` calls registered functions from the calling thread and while it
is permitted to call `exit` from any thread, @ref glfwTerminate may only be
called from the main thread.
To release all resources allocated by GLFW, you should call @ref glfwTerminate
yourself, from the main thread, before the program terminates. Note that this
destroys all windows not already destroyed with @ref glfwDestroyWindow,
invalidating any window handles you may still have.
@subsection moving_glu GLU header inclusion
GLFW 3 does not by default include the GLU header and GLU itself has been
deprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group). __New
projects should avoid using GLU__, but if you need to compile legacy code that
has been moved to GLFW 3, you can request that the GLFW header includes it by
defining `GLFW_INCLUDE_GLU` before the inclusion of the GLFW header.
@par Old syntax
@code
#include <GL/glfw.h>
@endcode
@par New syntax
@code
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
@endcode
@section moving_tables Name change tables
@subsection moving_renamed_functions Renamed functions
| GLFW 2 | GLFW 3 | Notes |
| --------------------------- | ----------------------------- | ----- |
| `glfwOpenWindow` | @ref glfwCreateWindow | All channel bit depths are now hints
| `glfwCloseWindow` | @ref glfwDestroyWindow | |
| `glfwOpenWindowHint` | @ref glfwWindowHint | Now accepts all `GLFW_*_BITS` tokens |
| `glfwEnable` | @ref glfwSetInputMode | |
| `glfwDisable` | @ref glfwSetInputMode | |
| `glfwGetMousePos` | @ref glfwGetCursorPos | |
| `glfwSetMousePos` | @ref glfwSetCursorPos | |
| `glfwSetMousePosCallback` | @ref glfwSetCursorPosCallback | |
| `glfwSetMouseWheelCallback` | @ref glfwSetScrollCallback | Accepts two-dimensional scroll offsets as doubles |
| `glfwGetJoystickPos` | @ref glfwGetJoystickAxes | |
| `glfwGetWindowParam` | @ref glfwGetWindowAttrib | |
| `glfwGetGLVersion` | @ref glfwGetWindowAttrib | Use `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and `GLFW_CONTEXT_REVISION` |
| `glfwGetDesktopMode` | @ref glfwGetVideoMode | Returns the current mode of a monitor |
| `glfwGetJoystickParam` | @ref glfwJoystickPresent | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons |
@subsection moving_renamed_tokens Renamed tokens
| GLFW 2 | GLFW 3 | Notes |
| --------------------------- | ---------------------------- | ----- |
| `GLFW_OPENGL_VERSION_MAJOR` | `GLFW_CONTEXT_VERSION_MAJOR` | Renamed as it applies to OpenGL ES as well |
| `GLFW_OPENGL_VERSION_MINOR` | `GLFW_CONTEXT_VERSION_MINOR` | Renamed as it applies to OpenGL ES as well |
| `GLFW_FSAA_SAMPLES` | `GLFW_SAMPLES` | Renamed to match the OpenGL API |
| `GLFW_ACTIVE` | `GLFW_FOCUSED` | Renamed to match the window focus callback |
| `GLFW_WINDOW_NO_RESIZE` | `GLFW_RESIZABLE` | The default has been inverted |
| `GLFW_MOUSE_CURSOR` | `GLFW_CURSOR` | Used with @ref glfwSetInputMode |
| `GLFW_KEY_ESC` | `GLFW_KEY_ESCAPE` | |
| `GLFW_KEY_DEL` | `GLFW_KEY_DELETE` | |
| `GLFW_KEY_PAGEUP` | `GLFW_KEY_PAGE_UP` | |
| `GLFW_KEY_PAGEDOWN` | `GLFW_KEY_PAGE_DOWN` | |
| `GLFW_KEY_KP_NUM_LOCK` | `GLFW_KEY_NUM_LOCK` | |
| `GLFW_KEY_LCTRL` | `GLFW_KEY_LEFT_CONTROL` | |
| `GLFW_KEY_LSHIFT` | `GLFW_KEY_LEFT_SHIFT` | |
| `GLFW_KEY_LALT` | `GLFW_KEY_LEFT_ALT` | |
| `GLFW_KEY_LSUPER` | `GLFW_KEY_LEFT_SUPER` | |
| `GLFW_KEY_RCTRL` | `GLFW_KEY_RIGHT_CONTROL` | |
| `GLFW_KEY_RSHIFT` | `GLFW_KEY_RIGHT_SHIFT` | |
| `GLFW_KEY_RALT` | `GLFW_KEY_RIGHT_ALT` | |
| `GLFW_KEY_RSUPER` | `GLFW_KEY_RIGHT_SUPER` | |
*/

View File

@ -1,292 +0,0 @@
/*!
@page news New features
@section news_31 New features in 3.1
These are the release highlights. For a full list of changes see the
[version history](http://www.glfw.org/changelog.html).
@subsection news_31_cursor Custom mouse cursor images
GLFW now supports creating and setting both custom cursor images and standard
cursor shapes. They are created with @ref glfwCreateCursor or @ref
glfwCreateStandardCursor, set with @ref glfwSetCursor and destroyed with @ref
glfwDestroyCursor.
@see @ref cursor_object
@subsection news_31_drop Path drop event
GLFW now provides a callback for receiving the paths of files and directories
dropped onto GLFW windows. The callback is set with @ref glfwSetDropCallback.
@see @ref path_drop
@subsection news_31_emptyevent Main thread wake-up
GLFW now provides the @ref glfwPostEmptyEvent function for posting an empty
event from another thread to the main thread event queue, causing @ref
glfwWaitEvents to return.
@see @ref events
@subsection news_31_framesize Window frame size query
GLFW now supports querying the size, on each side, of the frame around the
client area of a window, with @ref glfwGetWindowFrameSize.
@see [Window size](@ref window_size)
@subsection news_31_autoiconify Simultaneous multi-monitor rendering
GLFW now supports disabling auto-iconification of full screen windows with
the [GLFW_AUTO_ICONIFY](@ref window_hints_wnd) window hint. This is intended
for people building multi-monitor installations, where you need windows to stay
in full screen despite losing input focus.
@subsection news_31_floating Floating windows
GLFW now supports floating windows, also called topmost or always on top, for
easier debugging with the [GLFW_FLOATING](@ref window_hints_wnd) window hint.
@subsection news_31_focused Initially unfocused windows
GLFW now supports preventing a windowed mode window from gaining input focus on
creation, with the [GLFW_FOCUSED](@ref window_hints_wnd) window hint.
@subsection news_31_direct Direct access for window attributes and cursor position
GLFW now queries the window input focus, visibility and iconification attributes
and the cursor position directly instead of returning cached data.
@subsection news_31_libovr Better interoperability with Oculus Rift
GLFW now provides native access functions for the OS level handles corresponding
to monitor objects, as well as a [brief guide](@ref rift). It is also regularly
tested for compatibility with the latest version of LibOVR (0.4.4 on release).
@subsection news_31_charmods Character with modifiers callback
GLFW now provides a callback for character events with modifier key bits. The
callback is set with @ref glfwSetCharModsCallback. Unlike the regular character
callback, this will report character events that will not result in a character
being input, for example if the Control key is held down.
@see @ref input_char
@subsection news_31_single Single buffered framebuffers
GLFW now supports the creation of single buffered windows, with the
[GLFW_DOUBLEBUFFER](@ref window_hints_fb) window hint.
@subsection news_31_glext Macro for including extension header
GLFW now includes the extension header appropriate for the chosen OpenGL or
OpenGL ES header when [GLFW_INCLUDE_GLEXT](@ref build_macros) is defined. GLFW
does not provide these headers. They must be provided by your development
environment or your OpenGL or OpenGL ES SDK.
@subsection news_31_release Context release behaviors
GLFW now supports controlling whether the pipeline is flushed when a context is
made non-current, with the
[GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint, provided the
machine supports the `GL_KHR_context_flush_control` extension.
@subsection news_31_wayland (Experimental) Wayland support
GLFW now has an _experimental_ Wayland display protocol backend that can be
selected on Linux with a CMake option.
@subsection news_31_mir (Experimental) Mir support
GLFW now has an _experimental_ Mir display server backend that can be selected
on Linux with a CMake option.
@section news_30 New features in 3.0
These are the release highlights. For a full list of changes see the
[version history](http://www.glfw.org/changelog.html).
@subsection news_30_cmake CMake build system
GLFW now uses the CMake build system instead of the various makefiles and
project files used by earlier versions. CMake is available for all platforms
supported by GLFW, is present in most package systems and can generate
makefiles and/or project files for most popular development environments.
For more information on how to use CMake, see the
[CMake manual](http://cmake.org/cmake/help/documentation.html).
@subsection news_30_multiwnd Multi-window support
GLFW now supports the creation of multiple windows, each with their own OpenGL
or OpenGL ES context, and all window functions now take a window handle. Event
callbacks are now per-window and are provided with the handle of the window that
received the event. The @ref glfwMakeContextCurrent function has been added to
select which context is current on a given thread.
@subsection news_30_multimon Multi-monitor support
GLFW now explicitly supports multiple monitors. They can be enumerated with
@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref
glfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize,
and specified at window creation to make the newly created window full screen on
that specific monitor.
@subsection news_30_unicode Unicode support
All string arguments to GLFW functions and all strings returned by GLFW now use
the UTF-8 encoding. This includes the window title, error string, clipboard
text, monitor and joystick names as well as the extension function arguments (as
ASCII is a subset of UTF-8).
@subsection news_30_clipboard Clipboard text I/O
GLFW now supports reading and writing plain text to and from the system
clipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString
functions.
@subsection news_30_gamma Gamma ramp support
GLFW now supports setting and reading back the gamma ramp of monitors, with the
@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions. There is also @ref
glfwSetGamma, which generates a ramp from a gamma value and then sets it.
@subsection news_30_gles OpenGL ES support
GLFW now supports the creation of OpenGL ES contexts, by setting the
`GLFW_CLIENT_API` window hint to `GLFW_OPENGL_ES_API`, where creation of such
contexts are supported. Note that GLFW _does not implement_ OpenGL ES, so your
driver must provide support in a way usable by GLFW. Modern Nvidia and Intel
drivers support creation of OpenGL ES context using the GLX and WGL APIs, while
AMD provides an EGL implementation instead.
@subsection news_30_egl (Experimental) EGL support
GLFW now has an experimental EGL context creation back end that can be selected
through CMake options.
@subsection news_30_hidpi High-DPI support
GLFW now supports high-DPI monitors on both Windows and OS X, giving windows full
resolution framebuffers where other UI elements are scaled up. To achieve this,
@ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been
added. These work with pixels, while the rest of the GLFW API works with screen
coordinates. This is important as OpenGL uses pixels, not screen coordinates.
@subsection news_30_error Error callback
GLFW now has an error callback, which can provide your application with much
more detailed diagnostics than was previously possible. The callback is passed
an error code and a description string.
@subsection news_30_wndptr Per-window user pointer
Each window now has a user-defined pointer, retrieved with @ref
glfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it
easier to integrate GLFW into C++ code.
@subsection news_30_iconifyfun Window iconification callback
Each window now has a callback for iconification and restoration events,
which is set with @ref glfwSetWindowIconifyCallback.
@subsection news_30_wndposfun Window position callback
Each window now has a callback for position events, which is set with @ref
glfwSetWindowPosCallback.
@subsection news_30_wndpos Window position query
The position of a window can now be retrieved using @ref glfwGetWindowPos.
@subsection news_30_focusfun Window focus callback
Each windows now has a callback for focus events, which is set with @ref
glfwSetWindowFocusCallback.
@subsection news_30_enterleave Cursor enter/leave callback
Each window now has a callback for when the mouse cursor enters or leaves its
client area, which is set with @ref glfwSetCursorEnterCallback.
@subsection news_30_wndtitle Initial window title
The title of a window is now specified at creation time, as one of the arguments
to @ref glfwCreateWindow.
@subsection news_30_hidden Hidden windows
Windows can now be hidden with @ref glfwHideWindow, shown using @ref
glfwShowWindow and created initially hidden with the `GLFW_VISIBLE` window hint.
This allows for off-screen rendering in a way compatible with most drivers, as
well as moving a window to a specific position before showing it.
@subsection news_30_undecorated Undecorated windows
Windowed mode windows can now be created without decorations, i.e. things like
a frame, a title bar, with the `GLFW_DECORATED` window hint. This allows for
the creation of things like splash screens.
@subsection news_30_keymods Modifier key bit masks
[Modifier key bit mask](@ref mods) parameters have been added to the
[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks.
@subsection news_30_scancode Platform-specific scancodes
A scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys
that don't have a [key token](@ref keys) still get passed on with the key
parameter set to `GLFW_KEY_UNKNOWN`. These scancodes will vary between machines
and are intended to be used for key bindings.
@subsection news_30_jsname Joystick names
The name of a joystick can now be retrieved using @ref glfwGetJoystickName.
@subsection news_30_doxygen Doxygen documentation
You are reading it.
*/

View File

@ -1,328 +0,0 @@
/*!
@page quick Getting started
@tableofcontents
This guide takes you through writing a simple application using GLFW 3. The
application will create a window and OpenGL context, render a rotating triangle
and exit when the user closes the window or presses Escape. This guide will
introduce a few of the most commonly used functions, but there are many more.
This guide assumes no experience with earlier versions of GLFW. If you
have used GLFW 2 in the past, read the @ref moving guide, as some functions
behave differently in GLFW 3.
@section quick_steps Step by step
@subsection quick_include Including the GLFW header
In the source files of your application where you use OpenGL or GLFW, you need
to include the GLFW 3 header file.
@code
#include <GLFW/glfw3.h>
@endcode
This defines all the constants, types and function prototypes of the GLFW API.
It also includes the OpenGL header, and defines all the constants and types
necessary for it to work on your platform.
For example, under Windows you are normally required to include `windows.h`
before including `GL/gl.h`. This would make your source file tied to Windows
and pollute your code's namespace with the whole Win32 API.
Instead, the GLFW header takes care of this for you, not by including
`windows.h`, but rather by itself duplicating only the necessary parts of it.
It does this only where needed, so if `windows.h` _is_ included, the GLFW header
does not try to redefine those symbols.
In other words:
- Do _not_ include the OpenGL headers yourself, as GLFW does this for you
- Do _not_ include `windows.h` or other platform-specific headers unless
you plan on using those APIs directly
- If you _do_ need to include such headers, do it _before_ including the
GLFW one and it will detect this
Starting with version 3.0, the GLU header `glu.h` is no longer included by
default. If you wish to include it, define `GLFW_INCLUDE_GLU` before the
inclusion of the GLFW header.
@code
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
@endcode
@subsection quick_init_term Initializing and terminating GLFW
Before you can use most GLFW functions, the library must be initialized. On
successful initialization, `GL_TRUE` is returned. If an error occurred,
`GL_FALSE` is returned.
@code
if (!glfwInit())
exit(EXIT_FAILURE);
@endcode
When you are done using GLFW, typically just before the application exits, you
need to terminate GLFW.
@code
glfwTerminate();
@endcode
This destroys any remaining windows and releases any other resources allocated by
GLFW. After this call, you must initialize GLFW again before using any GLFW
functions that require it.
@subsection quick_capture_error Setting an error callback
Most events are reported through callbacks, whether it's a key being pressed,
a GLFW window being moved, or an error occurring. Callbacks are simply
C functions (or C++ static methods) that are called by GLFW with arguments
describing the event.
In case a GLFW function fails, an error is reported to the GLFW error callback.
You can receive these reports with an error callback. This function must have
the signature below. This simple error callback just prints the error
description to `stderr`.
@code
void error_callback(int error, const char* description)
{
fputs(description, stderr);
}
@endcode
Callback functions must be set, so GLFW knows to call them. The function to set
the error callback is one of the few GLFW functions that may be called before
initialization, which lets you be notified of errors both during and after
initialization.
@code
glfwSetErrorCallback(error_callback);
@endcode
@subsection quick_create_window Creating a window and context
The window and its OpenGL context are created with a single call, which returns
a handle to the created combined window and context object. For example, this
creates a 640 by 480 windowed mode window with an OpenGL context:
@code
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
@endcode
If window or context creation fails, `NULL` will be returned, so it is necessary
to check the return value.
@code
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
@endcode
The window handle is passed to all window related functions and is provided to
along to all window related callbacks, so they can tell which window received
the event.
When a window is no longer needed, destroy it.
@code
glfwDestroyWindow(window);
@endcode
Once this function is called, no more events will be delivered for that window
and its handle becomes invalid.
@subsection quick_context_current Making the OpenGL context current
Before you can use the OpenGL API, you must have a current OpenGL context.
@code
glfwMakeContextCurrent(window);
@endcode
The context will remain current until you make another context current or until
the window owning the current context is destroyed.
@subsection quick_window_close Checking the window close flag
Each window has a flag indicating whether the window should be closed.
When the user attempts to close the window, either by pressing the close widget
in the title bar or using a key combination like Alt+F4, this flag is set to 1.
Note that __the window isn't actually closed__, so you are expected to monitor
this flag and either destroy the window or give some kind of feedback to the
user.
@code
while (!glfwWindowShouldClose(window))
{
// Keep running
}
@endcode
You can be notified when the user is attempting to close the window by setting
a close callback with @ref glfwSetWindowCloseCallback. The callback will be
called immediately after the close flag has been set.
You can also set it yourself with @ref glfwSetWindowShouldClose. This can be
useful if you want to interpret other kinds of input as closing the window, like
for example pressing the escape key.
@subsection quick_key_input Receiving input events
Each window has a large number of callbacks that can be set to receive all the
various kinds of events. To receive key press and release events, create a key
callback function.
@code
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
@endcode
The key callback, like other window related callbacks, are set per-window.
@code
glfwSetKeyCallback(window, key_callback);
@endcode
In order for event callbacks to be called when events occur, you need to process
events as described below.
@subsection quick_render Rendering with OpenGL
Once you have a current OpenGL context, you can use OpenGL normally. In this
tutorial, a multi-colored rotating triangle will be rendered. The framebuffer
size needs to be retrieved for `glViewport`.
@code
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
@endcode
You can also set a framebuffer size callback using @ref
glfwSetFramebufferSizeCallback and call `glViewport` from there.
@subsection quick_timer Reading the timer
To create smooth animation, a time source is needed. GLFW provides a timer that
returns the number of seconds since initialization. The time source used is the
most accurate on each platform and generally has micro- or nanosecond
resolution.
@code
double time = glfwGetTime();
@endcode
@subsection quick_swap_buffers Swapping buffers
GLFW windows by default use double buffering. That means that each window has
two rendering buffers; a front buffer and a back buffer. The front buffer is
the one being displayed and the back buffer the one you render to.
When the entire frame has been rendered, the buffers need to be swapped with one
another, so the back buffer becomes the front buffer and vice versa.
@code
glfwSwapBuffers(window);
@endcode
The swap interval indicates how many frames to wait until swapping the buffers,
commonly known as _vsync_. By default, the swap interval is zero, meaning
buffer swapping will occur immediately. On fast machines, many of those frames
will never be seen, as the screen is still only updated typically 60-75 times
per second, so this wastes a lot of CPU and GPU cycles.
Also, because the buffers will be swapped in the middle the screen update,
leading to [screen tearing](https://en.wikipedia.org/wiki/Screen_tearing).
For these reasons, applications will typically want to set the swap interval to
one. It can be set to higher values, but this is usually not recommended,
because of the input latency it leads to.
@code
glfwSwapInterval(1);
@endcode
This function acts on the current context and will fail unless a context is
current.
@subsection quick_process_events Processing events
GLFW needs to communicate regularly with the window system both in order to
receive events and to show that the application hasn't locked up. Event
processing must be done regularly while you have visible windows and is normally
done each frame after buffer swapping.
There are two methods for processing pending events; polling and waiting. This
example will use event polling, which processes only those events that have
already been received and then returns immediately.
@code
glfwPollEvents();
@endcode
This is the best choice when rendering continually, like most games do. If
instead you only need to update your rendering once you have received new input,
@ref glfwWaitEvents is a better choice. It waits until at least one event has
been received, putting the thread to sleep in the meantime, and then processes
all received events. This saves a great deal of CPU cycles and is useful for,
for example, many kinds of editing tools.
@section quick_example Putting it together
Now that you know how to initialize GLFW, create a window and poll for
keyboard input, it's possible to create a simple program.
@snippet simple.c code
This program creates a 640 by 480 windowed mode window and starts a loop that
clears the screen, renders a triangle and processes events until the user either
presses Escape or closes the window.
This program uses only a few of the many functions GLFW provides. There are
guides for each of the areas covered by GLFW. Each guide will introduce all the
functions for that category.
- @ref intro
- @ref window
- @ref context
- @ref monitor
- @ref input
@section quick_build Compiling and linking the program
The complete program above can be found in the source distribution as
`examples/simple.c` and is compiled along with all other examples when you
build GLFW. That is, if you have compiled GLFW then you have already built this
as `simple.exe` on Windows, `simple` on Linux or `simple.app` on OS X.
This tutorial ends here. Once you have written a program that uses GLFW, you
will need to compile and link it. How to do that depends on the development
environment you are using and is best explained by the documentation for that
environment. To learn about the details that are specific to GLFW, see
@ref build.
*/

View File

@ -1,199 +0,0 @@
/*!
@page rift Oculus Rift guide
@tableofcontents
This guide is intended to fill in the gaps between the
[Oculus PC SDK documentation](https://developer.oculus.com/documentation/) and
the rest of the GLFW documentation and is not a replacement for either. It
requires you to use [native access](@ref native) and assumes a certain level of
proficiency with LibOVR, platform specific APIs and your chosen development
environment.
While GLFW has no explicit support for LibOVR, it is tested with and tries to
interoperate well with it.
@note Because of the speed of development of the Oculus SDK, this guide may
become outdated before the next release. If this is a local copy of the
documentation, you may want to check the GLFW website for updates. This
revision of the guide is written against version 0.4.4 of the SDK.
@section rift_include Including the LibOVR and GLFW header files
Both the OpenGL LibOVR header and the GLFW native header need macros telling
them what OS you are building for. Because LibOVR only supports three major
desktop platforms, this can be solved with canonical predefined macros.
@code
#if defined(_WIN32)
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#define OVR_OS_WIN32
#elif defined(__APPLE__)
#define GLFW_EXPOSE_NATIVE_COCOA
#define GLFW_EXPOSE_NATIVE_NSGL
#define OVR_OS_MAC
#elif defined(__linux__)
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
#define OVR_OS_LINUX
#endif
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <OVR_CAPI_GL.h>
@endcode
Both the GLFW and LibOVR headers by default attempt to include the standard
OpenGL `GL/gl.h` header (`OpenGL/gl.h` on OS X). If you wish to use a different
standard header or an [extension loading library](@ref context_glext_auto),
include that header before these.
@section rift_init Initializing LibOVR and GLFW
LibOVR needs to be initialized before GLFW. This means calling at least
`ovr_Initialize`, `ovrHmd_Create` and `ovrHmd_ConfigureTracking` before @ref
glfwInit. Similarly, LibOVR must be shut down after GLFW. This means calling
`ovrHmd_Destroy` and `ovr_Shutdown` after @ref glfwTerminate.
@section rift_direct Direct HMD mode
Direct HMD mode is the recommended display mode for new applications, but the
Oculus Rift runtime currently (January 2015) only supports this mode on Windows.
In direct mode the HMD is not detectable as a GLFW monitor.
@subsection rift_direct_create Creating a window and context
If the HMD is in direct mode you can use either a full screen or a windowed mode
window, but full screen is only recommended if there is a monitor that supports
the resolution of the HMD. Due to limitations in LibOVR, the size of the client
area of the window must equal the resolution of the HMD.
If the resolution of the HMD is much larger than the regular monitor, the window
may be resized by the window manager on creation. One way to avoid this is to
make it undecorated with the [GLFW_DECORATED](@ref window_hints_wnd) window
hint.
@subsection rift_direct_attach Attaching the window to the HMD
Once you have created the window and context, you need to attach the native
handle of the GLFW window to the HMD.
@code
ovrHmd_AttachToWindow(hmd, glfwGetWin32Window(window), NULL, NULL);
@endcode
@section rift_extend Extend Desktop mode
Extend desktop mode is a legacy display mode, but is still (January 2015) the
only available mode on OS X and Linux, as well as on Windows machines that for
technical reasons do not yet support direct HMD mode.
@subsection rift_extend_detect Detecting a HMD with GLFW
If the HMD is in extend desktop mode you can deduce which GLFW monitor it
corresponds to and create a full screen window on that monitor.
On Windows, the native display device name of a GLFW monitor corresponds to the
display device name of the detected HMD as stored, in the `DisplayDeviceName`
member of `ovrHmdDesc`.
On OS X, the native display ID of a GLFW monitor corresponds to the display ID
of the detected HMD, as stored in the `DisplayId` member of `ovrHmdDesc`.
At the time of writing (January 2015), the Oculus SDK does not support detecting
which monitor corresponds to the HMD in any sane fashion, but as long as the HMD
is set up and rotated properly it can be found via the screen position and
resolution provided by LibOVR. This method may instead find another monitor
that is mirroring the HMD, but this only matters if you intend to change its
video mode.
@code
int i, count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
for (i = 0; i < count; i++)
{
#if defined(_WIN32)
if (strcmp(glfwGetWin32Monitor(monitors[i]), hmd->DisplayDeviceName) == 0)
return monitors[i];
#elif defined(__APPLE__)
if (glfwGetCocoaMonitor(monitors[i]) == hmd->DisplayId)
return monitors[i];
#elif defined(__linux__)
int xpos, ypos;
const GLFWvidmode* mode = glfwGetVideoMode(monitors[i]);
glfwGetMonitorPos(monitors[i], &xpos, &ypos);
if (hmd->WindowsPos.x == xpos &&
hmd->WindowsPos.y == ypos &&
hmd->Resolution.w == mode->width &&
hmd->Resolution.h == mode->height)
{
return monitors[i];
}
#endif
}
@endcode
@subsection rift_extend_create Creating a window and context
The window is created as a regular full screen window on the found monitor. It
is usually a good idea to create a
[windowed full screen](@ref window_windowed_full_screen) window, as the HMD will
very likely already be set to the correct video mode. However, in extend
desktop mode it behaves like a regular monitor and any supported video mode can
be requested.
If other monitors are mirroring the HMD and you request a different video mode,
all monitors in the mirroring set will get the new video mode.
@section rift_render Rendering to the HMD
@subsection rift_render_sdk SDK distortion rendering
If you wish to use SDK distortion rendering you will need some information from
GLFW to configure the renderer. Below are the parts of the `ovrGLConfig` union
that need to be filled with from GLFW. Note that there are other fields that
also need to be filled for `ovrHmd_ConfigureRendering` to succeed.
Before configuring SDK distortion rendering you should make your context
current.
@code
int width, height;
union ovrGLConfig config;
glfwGetFramebufferSize(window, &width, &height);
config.OGL.Header.BackBufferSize.w = width;
config.OGL.Header.BackBufferSize.h = height;
#if defined(_WIN32)
config.OGL.Window = glfwGetWin32Window(window);
#elif defined(__APPLE__)
#elif defined(__linux__)
config.OGL.Disp = glfwGetX11Display();
#endif
@endcode
When using SDK distortion rendering you should not swap the buffers yourself, as
the HMD is updated by `ovrHmd_EndFrame`.
@subsection rift_render_custom Client distortion rendering
With client distortion rendering you are in full control of the contents of the
HMD and should render and swap the buffers normally.
*/

View File

@ -1,872 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="688.48718"
height="327.98221"
id="svg2"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="spaces.svg">
<defs
id="defs4">
<marker
inkscape:stockid="Arrow2Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lend"
style="overflow:visible;">
<path
id="path3888"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) rotate(180) translate(1,0)" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.5611424"
inkscape:cx="344.24359"
inkscape:cy="163.9911"
inkscape:document-units="px"
inkscape:current-layer="svg2"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1021"
inkscape:window-x="0"
inkscape:window-y="30"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
units="px"
showborder="false"
inkscape:showpageshadow="false" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-12.627039,-339.86462)">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#0000ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:3,3;stroke-dashoffset:0"
id="rect2985"
width="687.36469"
height="326.85971"
x="13.188287"
y="340.42587"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<rect
style="fill:#f3fff3;fill-opacity:1;stroke:#00b800;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3757"
width="318.05698"
height="277.04684"
x="38.315689"
y="366.05841"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<rect
style="fill:#f3fff3;fill-opacity:1;stroke:#00b800;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3767"
width="319.01456"
height="198.09369"
x="356.36722"
y="366.01291"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<g
style="font-size:12px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text3769">
<path
d="m 365.3732,374.63632 0,2.73926 1.24023,0 c 0.45898,0 0.8138,-0.11881 1.06446,-0.35645 0.25064,-0.23762 0.37597,-0.57616 0.37597,-1.01562 0,-0.43619 -0.12533,-0.77311 -0.37597,-1.01074 -0.25066,-0.23763 -0.60548,-0.35644 -1.06446,-0.35645 l -1.24023,0 m -0.98633,-0.81054 2.22656,0 c 0.81706,0 1.43392,0.18555 1.85059,0.55664 0.41992,0.36784 0.62988,0.9082 0.62988,1.62109 0,0.7194 -0.20996,1.26302 -0.62988,1.63086 -0.41667,0.36784 -1.03353,0.55176 -1.85059,0.55176 l -1.24023,0 0,2.92968 -0.98633,0 0,-7.29003"
style="font-size:10px"
id="path3281" />
<path
d="m 373.37613,376.48691 c -0.10092,-0.0586 -0.21159,-0.10091 -0.33203,-0.12696 -0.11719,-0.0293 -0.2474,-0.0439 -0.39063,-0.0439 -0.50781,0 -0.89844,0.16602 -1.17187,0.49805 -0.27019,0.32878 -0.40528,0.80241 -0.40528,1.42089 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0147 0.0749,0.007 0.15788,0.0179 0.24903,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3283" />
<path
d="m 374.32828,375.64706 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3285" />
<path
d="m 381.35953,376.69687 c 0.2246,-0.40364 0.49316,-0.70149 0.80566,-0.89356 0.3125,-0.19205 0.68033,-0.28808 1.10352,-0.28808 0.56965,0 1.0091,0.2002 1.31836,0.60058 0.30923,0.39714 0.46385,0.96355 0.46386,1.69922 l 0,3.30078 -0.90332,0 0,-3.27148 c 0,-0.52408 -0.0928,-0.91308 -0.27832,-1.16699 -0.18555,-0.2539 -0.46875,-0.38086 -0.84961,-0.38086 -0.4655,0 -0.83334,0.15463 -1.10351,0.46387 -0.27019,0.30924 -0.40528,0.73079 -0.40528,1.26464 l 0,3.09082 -0.90332,0 0,-3.27148 c 0,-0.52734 -0.0928,-0.91634 -0.27832,-1.16699 -0.18555,-0.2539 -0.472,-0.38086 -0.85937,-0.38086 -0.45899,0 -0.82357,0.15625 -1.09375,0.46875 -0.27019,0.30925 -0.40528,0.72917 -0.40527,1.25976 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.20507,-0.33528 0.45084,-0.58267 0.7373,-0.74218 0.28646,-0.1595 0.62662,-0.23926 1.02051,-0.23926 0.39713,0 0.73404,0.10092 1.01074,0.30273 0.27994,0.20183 0.48665,0.4948 0.62012,0.87891"
style="font-size:10px"
id="path3287" />
<path
d="m 389.33316,378.36679 c -0.72591,0 -1.22884,0.083 -1.50879,0.24902 -0.27995,0.16602 -0.41992,0.44923 -0.41992,0.84961 0,0.31902 0.10416,0.57292 0.3125,0.76172 0.21159,0.18555 0.49804,0.27832 0.85937,0.27832 0.49805,0 0.89681,-0.17578 1.19629,-0.52734 0.30273,-0.35482 0.4541,-0.82519 0.45411,-1.41113 l 0,-0.2002 -0.89356,0 m 1.79199,-0.37109 0,3.12011 -0.89843,0 0,-0.83007 c -0.20509,0.33203 -0.46062,0.5778 -0.76661,0.7373 -0.30599,0.15625 -0.68034,0.23438 -1.12304,0.23438 -0.5599,0 -1.00586,-0.15625 -1.33789,-0.46875 -0.32878,-0.31576 -0.49317,-0.73731 -0.49317,-1.26465 0,-0.61523 0.20508,-1.0791 0.61524,-1.3916 0.41341,-0.3125 1.02864,-0.46875 1.8457,-0.46875 l 1.25977,0 0,-0.0879 c -10e-6,-0.41341 -0.13673,-0.73242 -0.41016,-0.95704 -0.27019,-0.22786 -0.65105,-0.34179 -1.14258,-0.34179 -0.3125,0 -0.61686,0.0374 -0.91309,0.1123 -0.29622,0.0749 -0.58105,0.18718 -0.85449,0.33692 l 0,-0.83008 c 0.32878,-0.12695 0.64779,-0.22135 0.95703,-0.28321 0.30925,-0.0651 0.61035,-0.0977 0.90332,-0.0977 0.79102,0 1.38184,0.20508 1.77247,0.61523 0.39062,0.41016 0.58593,1.03191 0.58593,1.86524"
style="font-size:10px"
id="path3289" />
<path
d="m 396.14957,376.48691 c -0.10092,-0.0586 -0.2116,-0.10091 -0.33203,-0.12696 -0.1172,-0.0293 -0.2474,-0.0439 -0.39063,-0.0439 -0.50781,0 -0.89844,0.16602 -1.17187,0.49805 -0.27019,0.32878 -0.40528,0.80241 -0.40528,1.42089 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0147 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3291" />
<path
d="m 399.37711,381.62363 c -0.25391,0.65104 -0.50131,1.07584 -0.74219,1.27441 -0.24089,0.19857 -0.56315,0.29785 -0.9668,0.29785 l -0.71777,0 0,-0.75195 0.52734,0 c 0.2474,0 0.43945,-0.0586 0.57617,-0.17578 0.13672,-0.11719 0.28809,-0.39388 0.45411,-0.83008 l 0.16113,-0.41016 -2.21192,-5.38086 0.95215,0 1.70899,4.27735 1.70898,-4.27735 0.95215,0 -2.40234,5.97657"
style="font-size:10px"
id="path3293" />
<path
d="m 410.46109,376.69687 c 0.2246,-0.40364 0.49316,-0.70149 0.80566,-0.89356 0.3125,-0.19205 0.68034,-0.28808 1.10352,-0.28808 0.56965,0 1.00911,0.2002 1.31836,0.60058 0.30924,0.39714 0.46386,0.96355 0.46387,1.69922 l 0,3.30078 -0.90332,0 0,-3.27148 c -1e-5,-0.52408 -0.0928,-0.91308 -0.27832,-1.16699 -0.18556,-0.2539 -0.46876,-0.38086 -0.84961,-0.38086 -0.4655,0 -0.83334,0.15463 -1.10352,0.46387 -0.27019,0.30924 -0.40528,0.73079 -0.40527,1.26464 l 0,3.09082 -0.90332,0 0,-3.27148 c -10e-6,-0.52734 -0.0928,-0.91634 -0.27832,-1.16699 -0.18555,-0.2539 -0.47201,-0.38086 -0.85938,-0.38086 -0.45899,0 -0.82357,0.15625 -1.09375,0.46875 -0.27018,0.30925 -0.40527,0.72917 -0.40527,1.25976 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.20507,-0.33528 0.45084,-0.58267 0.7373,-0.74218 0.28646,-0.1595 0.62663,-0.23926 1.02051,-0.23926 0.39713,0 0.73405,0.10092 1.01074,0.30273 0.27995,0.20183 0.48665,0.4948 0.62012,0.87891"
style="font-size:10px"
id="path3295" />
<path
d="m 418.06851,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85775,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41991,-0.89192 0.41992,-1.54297 -10e-6,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65919,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44597,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.06119,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3297" />
<path
d="m 426.60855,377.81503 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51757 -0.10091,-0.90494 -0.30273,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.9082,-0.38574 -0.48503,0 -0.86752,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41993,0.73079 -0.41993,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29297,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19532 1.42578,0.58594 0.32226,0.38737 0.4834,0.95866 0.4834,1.71386"
style="font-size:10px"
id="path3299" />
<path
d="m 428.41031,375.64706 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3301" />
<path
d="m 432.07242,374.09433 0,1.55273 1.85058,0 0,0.69825 -1.85058,0 0,2.96875 c 0,0.44596 0.0602,0.73242 0.18066,0.85937 0.1237,0.12696 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17187,-0.12858 -1.43554,-0.38574 -0.26368,-0.26041 -0.39551,-0.73242 -0.39551,-1.41601 l 0,-2.96875 -0.65918,0 0,-0.69825 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3303" />
<path
d="m 437.22867,376.27695 c -0.48178,0 -0.86263,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13834,1.17025 0.41504,1.54785 0.27994,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85774,-0.1888 1.13769,-0.56641 0.27995,-0.3776 0.41992,-0.89192 0.41993,-1.54297 -1e-5,-0.64778 -0.13998,-1.16048 -0.41993,-1.53808 -0.27995,-0.38086 -0.65918,-0.57129 -1.13769,-0.57129 m 0,-0.76172 c 0.78124,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66894,2.10937 0,0.89519 -0.22298,1.59831 -0.66894,2.10938 -0.44597,0.50781 -1.05958,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66407,-1.21419 -0.66407,-2.10938 0,-0.89843 0.22136,-1.60156 0.66407,-2.10937 0.44596,-0.50781 1.06119,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3305" />
<path
d="m 444.39175,376.48691 c -0.10091,-0.0586 -0.21159,-0.10091 -0.33203,-0.12696 -0.11719,-0.0293 -0.2474,-0.0439 -0.39062,-0.0439 -0.50782,0 -0.89844,0.16602 -1.17188,0.49805 -0.27018,0.32878 -0.40527,0.80241 -0.40527,1.42089 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.7373,-0.7373 0.30274,-0.16276 0.67057,-0.24414 1.10352,-0.24414 0.0618,0 0.1302,0.005 0.20508,0.0147 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3307" />
<path
d="m 449.39664,380.2955 0,2.90039 -0.90332,0 0,-7.54883 0.90332,0 0,0.83008 c 0.1888,-0.32551 0.42643,-0.5664 0.71289,-0.72265 0.28971,-0.1595 0.63476,-0.23926 1.03515,-0.23926 0.66406,0 1.2028,0.26368 1.61621,0.79101 0.41667,0.52735 0.625,1.22071 0.625,2.08008 0,0.85938 -0.20833,1.55274 -0.625,2.08008 -0.41341,0.52734 -0.95215,0.79102 -1.61621,0.79102 -0.40039,0 -0.74544,-0.0781 -1.03515,-0.23438 -0.28646,-0.1595 -0.52409,-0.40202 -0.71289,-0.72754 m 3.05664,-1.90918 c -1e-5,-0.6608 -0.13673,-1.17838 -0.41016,-1.55273 -0.27019,-0.3776 -0.64291,-0.5664 -1.11816,-0.56641 -0.47527,1e-5 -0.84961,0.18881 -1.12305,0.56641 -0.27018,0.37435 -0.40527,0.89193 -0.40527,1.55273 0,0.66081 0.13509,1.18002 0.40527,1.55762 0.27344,0.37435 0.64778,0.56152 1.12305,0.56152 0.47525,0 0.84797,-0.18717 1.11816,-0.56152 0.27343,-0.3776 0.41015,-0.89681 0.41016,-1.55762"
style="font-size:10px"
id="path3309" />
<path
d="m 456.99429,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14257,0.5664 -0.27995,0.37436 -0.41993,0.88868 -0.41993,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56153 0.47852,0 0.85775,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41992,-0.89192 0.41992,-1.54297 0,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65918,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39486,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -10e-6,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44596,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.7845,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.0612,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3311" />
<path
d="m 464.47476,375.8082 0,0.84961 c -0.25391,-0.13021 -0.51758,-0.22786 -0.79101,-0.29297 -0.27344,-0.0651 -0.55665,-0.0976 -0.84961,-0.0977 -0.44597,1e-5 -0.78126,0.0684 -1.00586,0.20508 -0.22136,0.13672 -0.33204,0.3418 -0.33203,0.61523 -10e-6,0.20834 0.0798,0.37273 0.23925,0.49317 0.15951,0.11719 0.48015,0.22949 0.96192,0.33691 l 0.30762,0.0684 c 0.63801,0.13672 1.09049,0.33041 1.35742,0.58106 0.27017,0.24739 0.40527,0.59407 0.40527,1.04004 0,0.50781 -0.20183,0.90983 -0.60547,1.20605 -0.40039,0.29622 -0.95215,0.44434 -1.65527,0.44434 -0.29297,0 -0.59896,-0.0293 -0.91797,-0.0879 -0.31576,-0.0553 -0.64942,-0.13998 -1.00098,-0.25391 l 0,-0.92774 c 0.33203,0.17253 0.65918,0.30274 0.98145,0.39063 0.32226,0.0846 0.64127,0.12695 0.95703,0.12695 0.42317,0 0.74869,-0.0716 0.97656,-0.21484 0.22786,-0.14648 0.3418,-0.35156 0.3418,-0.61524 0,-0.24413 -0.083,-0.43131 -0.24902,-0.56152 -0.16277,-0.13021 -0.52247,-0.25553 -1.07911,-0.37598 l -0.3125,-0.0732 c -0.55664,-0.11718 -0.95866,-0.29622 -1.20605,-0.53711 -0.2474,-0.24413 -0.37109,-0.57779 -0.37109,-1.00097 0,-0.51432 0.18229,-0.91146 0.54687,-1.19141 0.36458,-0.27994 0.88216,-0.41992 1.55274,-0.41992 0.33202,0 0.64452,0.0244 0.9375,0.0732 0.29296,0.0488 0.56314,0.12208 0.81054,0.21973"
style="font-size:10px"
id="path3313" />
<path
d="m 466.20328,375.64706 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3315" />
<path
d="m 469.86539,374.09433 0,1.55273 1.85058,0 0,0.69825 -1.85058,0 0,2.96875 c 0,0.44596 0.0602,0.73242 0.18066,0.85937 0.1237,0.12696 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26041 -0.3955,-0.73242 -0.3955,-1.41601 l 0,-2.96875 -0.65918,0 0,-0.69825 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3317" />
<path
d="m 472.9025,375.64706 0.89843,0 0,5.46875 -0.89843,0 0,-5.46875 m 0,-2.1289 0.89843,0 0,1.13769 -0.89843,0 0,-1.13769"
style="font-size:10px"
id="path3319" />
<path
d="m 477.79507,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14257,0.5664 -0.27995,0.37436 -0.41993,0.88868 -0.41993,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66244,0.56153 1.14746,0.56153 0.47852,0 0.85775,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41992,-0.89192 0.41992,-1.54297 0,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65918,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39486,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44596,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.7845,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.0612,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3321" />
<path
d="m 486.33511,377.81503 0,3.30078 -0.89843,0 0,-3.27148 c -1e-5,-0.51757 -0.10092,-0.90494 -0.30274,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.9082,-0.38574 -0.48503,0 -0.86752,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41993,0.73079 -0.41992,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75683,-0.7373 0.29297,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19532 1.42579,0.58594 0.32226,0.38737 0.48339,0.95866 0.48339,1.71386"
style="font-size:10px"
id="path3323" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00b800;fill-opacity:1;stroke:none;font-family:Sans"
id="text3773">
<path
d="m 242.85294,625.22699 0,1.1543 c -0.44923,-0.21484 -0.87306,-0.375 -1.27149,-0.48047 -0.39844,-0.10546 -0.78321,-0.1582 -1.1543,-0.15821 -0.64453,10e-6 -1.14258,0.12501 -1.49414,0.375 -0.34765,0.25001 -0.52148,0.60548 -0.52148,1.06641 0,0.38673 0.11523,0.67969 0.3457,0.87891 0.23438,0.19532 0.67578,0.35352 1.32422,0.47461 l 0.71485,0.14648 c 0.8828,0.16797 1.53319,0.46485 1.95117,0.89063 0.42187,0.42187 0.6328,0.98828 0.63281,1.69921 -1e-5,0.84766 -0.28516,1.49024 -0.85547,1.92774 -0.56641,0.4375 -1.39844,0.65625 -2.49609,0.65625 -0.41407,0 -0.85547,-0.0469 -1.32422,-0.14063 -0.46485,-0.0937 -0.94727,-0.23242 -1.44727,-0.41601 l 0,-1.21875 c 0.48047,0.26953 0.95117,0.47266 1.41211,0.60937 0.46094,0.13672 0.91406,0.20508 1.35938,0.20508 0.67577,0 1.19726,-0.13281 1.56445,-0.39844 0.36718,-0.26562 0.55078,-0.64453 0.55078,-1.13671 0,-0.42969 -0.13282,-0.76563 -0.39844,-1.00782 -0.26172,-0.24218 -0.69336,-0.42382 -1.29492,-0.54492 l -0.7207,-0.14062 c -0.88282,-0.17578 -1.52149,-0.45117 -1.91602,-0.82618 -0.39453,-0.37499 -0.59179,-0.89647 -0.59179,-1.56445 0,-0.77343 0.27148,-1.3828 0.81445,-1.82812 0.54687,-0.44531 1.29882,-0.66796 2.25586,-0.66797 0.41015,10e-6 0.82812,0.0371 1.25391,0.11133 0.42577,0.0742 0.86132,0.18555 1.30664,0.33398"
style=""
id="path3355" />
<path
d="m 250.79239,630.13715 0,0.52734 -4.95703,0 c 0.0469,0.74219 0.26953,1.3086 0.66797,1.69922 0.40234,0.38672 0.96093,0.58008 1.67578,0.58008 0.41406,0 0.81445,-0.0508 1.20117,-0.15235 0.39062,-0.10156 0.77734,-0.2539 1.16016,-0.45703 l 0,1.01953 c -0.38673,0.16407 -0.78321,0.28907 -1.18946,0.375 -0.40625,0.0859 -0.81836,0.12891 -1.23633,0.12891 -1.04687,0 -1.87695,-0.30469 -2.49023,-0.91406 -0.60938,-0.60938 -0.91406,-1.43359 -0.91406,-2.47266 0,-1.07421 0.28906,-1.92578 0.86719,-2.55469 0.58202,-0.6328 1.36523,-0.94921 2.3496,-0.94922 0.88281,10e-6 1.58008,0.28517 2.0918,0.85547 0.51562,0.56641 0.77343,1.3379 0.77344,2.31446 m -1.07813,-0.31641 c -0.008,-0.58984 -0.17383,-1.06054 -0.49804,-1.41211 -0.32032,-0.35156 -0.7461,-0.52734 -1.27735,-0.52734 -0.60156,0 -1.08398,0.16992 -1.44726,0.50976 -0.35938,0.33985 -0.56641,0.81837 -0.6211,1.43555 l 3.84375,-0.006"
style=""
id="path3357" />
<path
d="m 257.28458,627.37738 0,1.00781 c -0.3047,-0.16796 -0.61134,-0.29296 -0.91993,-0.375 -0.30469,-0.0859 -0.61328,-0.1289 -0.92578,-0.1289 -0.69922,0 -1.24219,0.22266 -1.6289,0.66797 -0.38672,0.44141 -0.58008,1.0625 -0.58008,1.86328 0,0.80078 0.19336,1.42383 0.58008,1.86914 0.38671,0.4414 0.92968,0.66211 1.6289,0.66211 0.3125,0 0.62109,-0.041 0.92578,-0.12305 0.30859,-0.0859 0.61523,-0.21289 0.91993,-0.38086 l 0,0.99609 c -0.30079,0.14063 -0.61329,0.2461 -0.9375,0.31641 -0.32032,0.0703 -0.66212,0.10547 -1.02539,0.10547 -0.98829,0 -1.77344,-0.31055 -2.35547,-0.93164 -0.58204,-0.62109 -0.87305,-1.45898 -0.87305,-2.51367 0,-1.07031 0.29297,-1.91211 0.87891,-2.52539 0.58984,-0.61328 1.39648,-0.91992 2.41992,-0.91993 0.33203,10e-6 0.65624,0.0352 0.97265,0.10547 0.31641,0.0664 0.62305,0.16798 0.91993,0.30469"
style=""
id="path3359" />
<path
d="m 261.71426,627.88129 c -0.57812,0 -1.03515,0.22656 -1.37109,0.67968 -0.33594,0.44923 -0.50391,1.06641 -0.50391,1.85157 0,0.78516 0.16602,1.4043 0.49805,1.85742 0.33594,0.44922 0.79492,0.67383 1.37695,0.67383 0.57422,0 1.0293,-0.22656 1.36524,-0.67969 0.33593,-0.45312 0.5039,-1.07031 0.5039,-1.85156 0,-0.77734 -0.16797,-1.39258 -0.5039,-1.84571 -0.33594,-0.45702 -0.79102,-0.68554 -1.36524,-0.68554 m 0,-0.91407 c 0.9375,10e-6 1.67383,0.3047 2.20899,0.91407 0.53515,0.60938 0.80273,1.45313 0.80273,2.53125 0,1.07422 -0.26758,1.91797 -0.80273,2.53125 -0.53516,0.60937 -1.27149,0.91406 -2.20899,0.91406 -0.94141,0 -1.67969,-0.30469 -2.21484,-0.91406 -0.53125,-0.61328 -0.79688,-1.45703 -0.79687,-2.53125 -10e-6,-1.07812 0.26562,-1.92187 0.79687,-2.53125 0.53515,-0.60937 1.27343,-0.91406 2.21484,-0.91407"
style=""
id="path3361" />
<path
d="m 271.96231,629.72699 0,3.96094 -1.07812,0 0,-3.92578 c -10e-6,-0.62109 -0.1211,-1.08594 -0.36329,-1.39454 -0.24219,-0.30858 -0.60547,-0.46288 -1.08984,-0.46289 -0.58203,10e-6 -1.04102,0.18556 -1.37695,0.55664 -0.33594,0.3711 -0.50391,0.87696 -0.50391,1.51758 l 0,3.70899 -1.08398,0 0,-6.5625 1.08398,0 0,1.01953 c 0.25781,-0.39453 0.56055,-0.68945 0.9082,-0.88477 0.35156,-0.1953 0.75586,-0.29296 1.2129,-0.29297 0.7539,10e-6 1.32421,0.23439 1.71093,0.70313 0.38672,0.46485 0.58007,1.15039 0.58008,2.05664"
style=""
id="path3363" />
<path
d="m 278.44278,628.12152 0,-3.55078 1.07812,0 0,9.11719 -1.07812,0 0,-0.98438 c -0.22657,0.39063 -0.51368,0.68164 -0.86133,0.87305 -0.34375,0.1875 -0.75781,0.28125 -1.24219,0.28125 -0.79297,0 -1.43945,-0.31641 -1.93945,-0.94922 -0.49609,-0.63281 -0.74414,-1.46484 -0.74414,-2.49609 0,-1.03125 0.24805,-1.86328 0.74414,-2.4961 0.5,-0.6328 1.14648,-0.94921 1.93945,-0.94922 0.48438,10e-6 0.89844,0.0957 1.24219,0.28711 0.34765,0.18751 0.63476,0.47657 0.86133,0.86719 m -3.67383,2.29102 c 0,0.79297 0.16211,1.41601 0.48633,1.86914 0.32812,0.44922 0.77734,0.67383 1.34766,0.67383 0.5703,0 1.01952,-0.22461 1.34765,-0.67383 0.32812,-0.45313 0.49218,-1.07617 0.49219,-1.86914 -1e-5,-0.79297 -0.16407,-1.41406 -0.49219,-1.86328 -0.32813,-0.45312 -0.77735,-0.67969 -1.34765,-0.67969 -0.57032,0 -1.01954,0.22657 -1.34766,0.67969 -0.32422,0.44922 -0.48633,1.07031 -0.48633,1.86328"
style=""
id="path3365" />
<path
d="m 284.72403,630.3891 c -0.8711,0 -1.47461,0.0996 -1.81055,0.29883 -0.33594,0.19922 -0.50391,0.53906 -0.5039,1.01953 -1e-5,0.38281 0.12499,0.6875 0.375,0.91406 0.2539,0.22266 0.59765,0.33399 1.03125,0.33399 0.59765,0 1.07616,-0.21094 1.43554,-0.63282 0.36328,-0.42578 0.54492,-0.99023 0.54493,-1.69336 l 0,-0.24023 -1.07227,0 m 2.15039,-0.44531 0,3.74414 -1.07812,0 0,-0.9961 c -0.2461,0.39844 -0.55274,0.69336 -0.91993,0.88477 -0.36719,0.1875 -0.81641,0.28125 -1.34765,0.28125 -0.67188,0 -1.20704,-0.1875 -1.60547,-0.5625 -0.39453,-0.37891 -0.5918,-0.88477 -0.5918,-1.51758 0,-0.73828 0.24609,-1.29492 0.73828,-1.66992 0.49609,-0.375 1.23437,-0.5625 2.21485,-0.5625 l 1.51172,0 0,-0.10547 c -10e-6,-0.49609 -0.16407,-0.8789 -0.49219,-1.14844 -0.32423,-0.27343 -0.78126,-0.41015 -1.3711,-0.41015 -0.375,0 -0.74023,0.0449 -1.0957,0.13476 -0.35547,0.0899 -0.69727,0.22462 -1.02539,0.4043 l 0,-0.99609 c 0.39453,-0.15234 0.77734,-0.26562 1.14844,-0.33985 0.37109,-0.0781 0.73242,-0.11718 1.08398,-0.11719 0.94922,10e-6 1.6582,0.2461 2.12696,0.73829 0.46874,0.49219 0.70311,1.23828 0.70312,2.23828"
style=""
id="path3367" />
<path
d="m 292.90372,628.13324 c -0.1211,-0.0703 -0.25391,-0.12109 -0.39844,-0.15234 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,10e-6 -1.07813,0.19923 -1.40625,0.59766 -0.32422,0.39453 -0.48633,0.96289 -0.48633,1.70508 l 0,3.45703 -1.08398,0 0,-6.5625 1.08398,0 0,1.01953 c 0.22656,-0.39843 0.52148,-0.69335 0.88477,-0.88477 0.36327,-0.1953 0.80468,-0.29296 1.32422,-0.29297 0.0742,10e-6 0.15624,0.006 0.24609,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10742"
style=""
id="path3369" />
<path
d="m 296.77676,634.2973 c -0.30469,0.78125 -0.60156,1.29102 -0.89062,1.5293 -0.28907,0.23828 -0.67578,0.35742 -1.16016,0.35742 l -0.86133,0 0,-0.90234 0.63282,0 c 0.29687,0 0.52734,-0.0703 0.6914,-0.21094 0.16406,-0.14063 0.3457,-0.47266 0.54493,-0.99609 l 0.19335,-0.49219 -2.65429,-6.45703 1.14258,0 2.05078,5.13281 2.05078,-5.13281 1.14258,0 -2.88282,7.17187"
style=""
id="path3371" />
<path
d="m 305.01505,624.93988 1.76367,0 2.23242,5.95313 2.24414,-5.95313 1.76367,0 0,8.74805 -1.1543,0 0,-7.68164 -2.25585,6 -1.18946,0 -2.25586,-6 0,7.68164 -1.14843,0 0,-8.74805"
style=""
id="path3373" />
<path
d="m 317.87051,627.88129 c -0.57812,0 -1.03515,0.22656 -1.37109,0.67968 -0.33594,0.44923 -0.50391,1.06641 -0.50391,1.85157 0,0.78516 0.16602,1.4043 0.49805,1.85742 0.33594,0.44922 0.79492,0.67383 1.37695,0.67383 0.57422,0 1.0293,-0.22656 1.36524,-0.67969 0.33593,-0.45312 0.5039,-1.07031 0.5039,-1.85156 0,-0.77734 -0.16797,-1.39258 -0.5039,-1.84571 -0.33594,-0.45702 -0.79102,-0.68554 -1.36524,-0.68554 m 0,-0.91407 c 0.9375,10e-6 1.67383,0.3047 2.20899,0.91407 0.53515,0.60938 0.80273,1.45313 0.80273,2.53125 0,1.07422 -0.26758,1.91797 -0.80273,2.53125 -0.53516,0.60937 -1.27149,0.91406 -2.20899,0.91406 -0.94141,0 -1.67969,-0.30469 -2.21484,-0.91406 -0.53125,-0.61328 -0.79688,-1.45703 -0.79687,-2.53125 -10e-6,-1.07812 0.26562,-1.92187 0.79687,-2.53125 0.53515,-0.60937 1.27343,-0.91406 2.21484,-0.91407"
style=""
id="path3375" />
<path
d="m 328.11856,629.72699 0,3.96094 -1.07812,0 0,-3.92578 c -10e-6,-0.62109 -0.1211,-1.08594 -0.36329,-1.39454 -0.24219,-0.30858 -0.60547,-0.46288 -1.08984,-0.46289 -0.58203,10e-6 -1.04102,0.18556 -1.37695,0.55664 -0.33594,0.3711 -0.50391,0.87696 -0.50391,1.51758 l 0,3.70899 -1.08398,0 0,-6.5625 1.08398,0 0,1.01953 c 0.25781,-0.39453 0.56055,-0.68945 0.9082,-0.88477 0.35156,-0.1953 0.75586,-0.29296 1.2129,-0.29297 0.7539,10e-6 1.32421,0.23439 1.71093,0.70313 0.38672,0.46485 0.58007,1.15039 0.58008,2.05664"
style=""
id="path3377" />
<path
d="m 330.28067,627.12543 1.07813,0 0,6.5625 -1.07813,0 0,-6.5625 m 0,-2.55469 1.07813,0 0,1.36523 -1.07813,0 0,-1.36523"
style=""
id="path3379" />
<path
d="m 334.6752,625.26215 0,1.86328 2.2207,0 0,0.83789 -2.2207,0 0,3.5625 c 0,0.53516 0.0723,0.87891 0.2168,1.03125 0.14843,0.15234 0.44726,0.22851 0.89648,0.22851 l 1.10742,0 0,0.90235 -1.10742,0 c -0.83203,0 -1.40625,-0.1543 -1.72265,-0.46289 -0.31641,-0.3125 -0.47461,-0.87891 -0.47461,-1.69922 l 0,-3.5625 -0.79102,0 0,-0.83789 0.79102,0 0,-1.86328 1.08398,0"
style=""
id="path3381" />
<path
d="m 340.8627,627.88129 c -0.57813,0 -1.03516,0.22656 -1.37109,0.67968 -0.33594,0.44923 -0.50391,1.06641 -0.50391,1.85157 0,0.78516 0.16602,1.4043 0.49805,1.85742 0.33593,0.44922 0.79492,0.67383 1.37695,0.67383 0.57422,0 1.02929,-0.22656 1.36524,-0.67969 0.33593,-0.45312 0.5039,-1.07031 0.5039,-1.85156 0,-0.77734 -0.16797,-1.39258 -0.5039,-1.84571 -0.33595,-0.45702 -0.79102,-0.68554 -1.36524,-0.68554 m 0,-0.91407 c 0.9375,10e-6 1.67382,0.3047 2.20899,0.91407 0.53515,0.60938 0.80272,1.45313 0.80273,2.53125 -10e-6,1.07422 -0.26758,1.91797 -0.80273,2.53125 -0.53517,0.60937 -1.27149,0.91406 -2.20899,0.91406 -0.94141,0 -1.67969,-0.30469 -2.21484,-0.91406 -0.53125,-0.61328 -0.79688,-1.45703 -0.79688,-2.53125 0,-1.07812 0.26563,-1.92187 0.79688,-2.53125 0.53515,-0.60937 1.27343,-0.91406 2.21484,-0.91407"
style=""
id="path3383" />
<path
d="m 349.4584,628.13324 c -0.12109,-0.0703 -0.25391,-0.12109 -0.39843,-0.15234 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,10e-6 -1.07813,0.19923 -1.40625,0.59766 -0.32422,0.39453 -0.48633,0.96289 -0.48633,1.70508 l 0,3.45703 -1.08399,0 0,-6.5625 1.08399,0 0,1.01953 c 0.22656,-0.39843 0.52148,-0.69335 0.88476,-0.88477 0.36328,-0.1953 0.80469,-0.29296 1.32422,-0.29297 0.0742,10e-6 0.15625,0.006 0.2461,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10742"
style=""
id="path3385" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#00b800;fill-opacity:1;stroke:none;font-family:Sans"
id="text3777">
<path
d="m 575.27002,547.52673 0,3.28711 1.48828,0 c 0.55078,10e-6 0.97656,-0.14257 1.27734,-0.42773 0.30078,-0.28515 0.45117,-0.6914 0.45118,-1.21875 -10e-6,-0.52343 -0.1504,-0.92773 -0.45118,-1.21289 -0.30078,-0.28515 -0.72656,-0.42773 -1.27734,-0.42774 l -1.48828,0 m -1.18359,-0.97265 2.67187,0 c 0.98046,10e-6 1.7207,0.22266 2.2207,0.66797 0.5039,0.44141 0.75586,1.08985 0.75586,1.94531 0,0.86328 -0.25196,1.51563 -0.75586,1.95703 -0.5,0.44141 -1.24024,0.66211 -2.2207,0.66211 l -1.48828,0 0,3.51562 -1.18359,0 0,-8.74804"
style=""
id="path3326" />
<path
d="m 584.87354,549.74744 c -0.1211,-0.0703 -0.25392,-0.12109 -0.39844,-0.15235 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,0 -1.07813,0.19922 -1.40625,0.59765 -0.32422,0.39454 -0.48633,0.9629 -0.48633,1.70508 l 0,3.45703 -1.08398,0 0,-6.5625 1.08398,0 0,1.01954 c 0.22656,-0.39844 0.52148,-0.69336 0.88477,-0.88477 0.36327,-0.19531 0.80468,-0.29296 1.32421,-0.29297 0.0742,10e-6 0.15625,0.006 0.2461,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10743"
style=""
id="path3328" />
<path
d="m 586.01611,548.73962 1.07813,0 0,6.5625 -1.07813,0 0,-6.5625 m 0,-2.55468 1.07813,0 0,1.36523 -1.07813,0 0,-1.36523"
style=""
id="path3330" />
<path
d="m 594.45361,549.99939 c 0.26953,-0.48437 0.59179,-0.84179 0.9668,-1.07227 0.37499,-0.23046 0.8164,-0.34569 1.32422,-0.3457 0.68358,10e-6 1.21093,0.24024 1.58203,0.7207 0.37108,0.47657 0.55663,1.15626 0.55664,2.03907 l 0,3.96093 -1.08398,0 0,-3.92578 c -10e-6,-0.6289 -0.11134,-1.0957 -0.33399,-1.40039 -0.22266,-0.30468 -0.56251,-0.45702 -1.01953,-0.45703 -0.5586,10e-6 -1.00001,0.18555 -1.32422,0.55664 -0.32422,0.3711 -0.48633,0.87696 -0.48633,1.51758 l 0,3.70898 -1.08398,0 0,-3.92578 c -1e-5,-0.63281 -0.11133,-1.0996 -0.33398,-1.40039 -0.22267,-0.30468 -0.56642,-0.45702 -1.03125,-0.45703 -0.55079,10e-6 -0.98829,0.18751 -1.3125,0.5625 -0.32423,0.3711 -0.48634,0.87501 -0.48633,1.51172 l 0,3.70898 -1.08399,0 0,-6.5625 1.08399,0 0,1.01954 c 0.24609,-0.40234 0.54101,-0.69922 0.88476,-0.89063 0.34375,-0.1914 0.75195,-0.2871 1.22461,-0.28711 0.47656,10e-6 0.88086,0.1211 1.21289,0.36328 0.33593,0.2422 0.58398,0.59376 0.74414,1.05469"
style=""
id="path3332" />
<path
d="m 604.02197,552.0033 c -0.87109,0 -1.47461,0.0996 -1.81054,0.29882 -0.33594,0.19923 -0.50391,0.53907 -0.50391,1.01954 0,0.38281 0.125,0.6875 0.375,0.91406 0.2539,0.22265 0.59765,0.33398 1.03125,0.33398 0.59765,0 1.07617,-0.21093 1.43555,-0.63281 0.36327,-0.42578 0.54491,-0.99023 0.54492,-1.69336 l 0,-0.24023 -1.07227,0 m 2.15039,-0.44532 0,3.74414 -1.07812,0 0,-0.99609 c -0.2461,0.39844 -0.55274,0.69336 -0.91992,0.88477 -0.36719,0.1875 -0.81641,0.28125 -1.34766,0.28125 -0.67188,0 -1.20703,-0.1875 -1.60547,-0.5625 -0.39453,-0.37891 -0.5918,-0.88477 -0.5918,-1.51758 0,-0.73828 0.2461,-1.29492 0.73829,-1.66992 0.49609,-0.375 1.23437,-0.5625 2.21484,-0.5625 l 1.51172,0 0,-0.10547 c -10e-6,-0.49609 -0.16407,-0.8789 -0.49219,-1.14844 -0.32422,-0.27343 -0.78125,-0.41015 -1.37109,-0.41016 -0.37501,10e-6 -0.74024,0.0449 -1.09571,0.13477 -0.35547,0.0898 -0.69726,0.22461 -1.02539,0.4043 l 0,-0.9961 c 0.39453,-0.15234 0.77735,-0.26562 1.14844,-0.33984 0.37109,-0.0781 0.73242,-0.11718 1.08399,-0.11719 0.94921,10e-6 1.65819,0.2461 2.12695,0.73828 0.46874,0.4922 0.70312,1.23829 0.70312,2.23828"
style=""
id="path3334" />
<path
d="m 612.20166,549.74744 c -0.1211,-0.0703 -0.25391,-0.12109 -0.39844,-0.15235 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,0 -1.07813,0.19922 -1.40625,0.59765 -0.32422,0.39454 -0.48633,0.9629 -0.48633,1.70508 l 0,3.45703 -1.08398,0 0,-6.5625 1.08398,0 0,1.01954 c 0.22656,-0.39844 0.52149,-0.69336 0.88477,-0.88477 0.36328,-0.19531 0.80468,-0.29296 1.32422,-0.29297 0.0742,10e-6 0.15624,0.006 0.24609,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10743"
style=""
id="path3336" />
<path
d="m 616.07471,555.9115 c -0.30469,0.78125 -0.60157,1.29101 -0.89063,1.5293 -0.28906,0.23827 -0.67578,0.35742 -1.16015,0.35742 l -0.86133,0 0,-0.90235 0.63281,0 c 0.29687,0 0.52734,-0.0703 0.69141,-0.21093 0.16406,-0.14063 0.3457,-0.47266 0.54492,-0.9961 l 0.19336,-0.49218 -2.6543,-6.45704 1.14258,0 2.05078,5.13282 2.05078,-5.13282 1.14258,0 -2.88281,7.17188"
style=""
id="path3338" />
<path
d="m 624.31299,546.55408 1.76367,0 2.23242,5.95312 2.24414,-5.95312 1.76367,0 0,8.74804 -1.15429,0 0,-7.68164 -2.25586,6 -1.18945,0 -2.25586,-6 0,7.68164 -1.14844,0 0,-8.74804"
style=""
id="path3340" />
<path
d="m 637.16846,549.49548 c -0.57813,10e-6 -1.03516,0.22657 -1.3711,0.67969 -0.33594,0.44922 -0.5039,1.06641 -0.5039,1.85156 0,0.78516 0.16601,1.4043 0.49804,1.85743 0.33594,0.44921 0.79492,0.67382 1.37696,0.67382 0.57421,0 1.02929,-0.22656 1.36523,-0.67968 0.33593,-0.45313 0.5039,-1.07031 0.50391,-1.85157 -10e-6,-0.77734 -0.16798,-1.39257 -0.50391,-1.8457 -0.33594,-0.45703 -0.79102,-0.68554 -1.36523,-0.68555 m 0,-0.91406 c 0.93749,10e-6 1.67382,0.30469 2.20898,0.91406 0.53515,0.60938 0.80273,1.45313 0.80274,2.53125 -10e-6,1.07422 -0.26759,1.91797 -0.80274,2.53125 -0.53516,0.60938 -1.27149,0.91407 -2.20898,0.91407 -0.94141,0 -1.67969,-0.30469 -2.21485,-0.91407 -0.53125,-0.61328 -0.79687,-1.45703 -0.79687,-2.53125 0,-1.07812 0.26562,-1.92187 0.79687,-2.53125 0.53516,-0.60937 1.27344,-0.91405 2.21485,-0.91406"
style=""
id="path3342" />
<path
d="m 647.4165,551.34119 0,3.96093 -1.07812,0 0,-3.92578 c -10e-6,-0.62109 -0.1211,-1.08593 -0.36328,-1.39453 -0.24219,-0.30859 -0.60548,-0.46288 -1.08985,-0.46289 -0.58203,10e-6 -1.04101,0.18555 -1.37695,0.55664 -0.33594,0.3711 -0.50391,0.87696 -0.50391,1.51758 l 0,3.70898 -1.08398,0 0,-6.5625 1.08398,0 0,1.01954 c 0.25781,-0.39453 0.56055,-0.68945 0.90821,-0.88477 0.35156,-0.19531 0.75585,-0.29296 1.21289,-0.29297 0.7539,10e-6 1.32421,0.23438 1.71094,0.70313 0.38671,0.46485 0.58007,1.15039 0.58007,2.05664"
style=""
id="path3344" />
<path
d="m 649.57861,548.73962 1.07813,0 0,6.5625 -1.07813,0 0,-6.5625 m 0,-2.55468 1.07813,0 0,1.36523 -1.07813,0 0,-1.36523"
style=""
id="path3346" />
<path
d="m 653.97314,546.87634 0,1.86328 2.22071,0 0,0.83789 -2.22071,0 0,3.5625 c 0,0.53516 0.0723,0.87891 0.2168,1.03125 0.14844,0.15235 0.44726,0.22852 0.89649,0.22852 l 1.10742,0 0,0.90234 -1.10742,0 c -0.83204,0 -1.40626,-0.15429 -1.72266,-0.46289 -0.31641,-0.3125 -0.47461,-0.8789 -0.47461,-1.69922 l 0,-3.5625 -0.79102,0 0,-0.83789 0.79102,0 0,-1.86328 1.08398,0"
style=""
id="path3348" />
<path
d="m 660.16064,549.49548 c -0.57812,10e-6 -1.03515,0.22657 -1.37109,0.67969 -0.33594,0.44922 -0.50391,1.06641 -0.50391,1.85156 0,0.78516 0.16602,1.4043 0.49805,1.85743 0.33594,0.44921 0.79492,0.67382 1.37695,0.67382 0.57422,0 1.0293,-0.22656 1.36524,-0.67968 0.33593,-0.45313 0.5039,-1.07031 0.50391,-1.85157 -1e-5,-0.77734 -0.16798,-1.39257 -0.50391,-1.8457 -0.33594,-0.45703 -0.79102,-0.68554 -1.36524,-0.68555 m 0,-0.91406 c 0.9375,10e-6 1.67383,0.30469 2.20899,0.91406 0.53515,0.60938 0.80273,1.45313 0.80273,2.53125 0,1.07422 -0.26758,1.91797 -0.80273,2.53125 -0.53516,0.60938 -1.27149,0.91407 -2.20899,0.91407 -0.9414,0 -1.67968,-0.30469 -2.21484,-0.91407 -0.53125,-0.61328 -0.79687,-1.45703 -0.79687,-2.53125 0,-1.07812 0.26562,-1.92187 0.79687,-2.53125 0.53516,-0.60937 1.27344,-0.91405 2.21484,-0.91406"
style=""
id="path3350" />
<path
d="m 668.75635,549.74744 c -0.1211,-0.0703 -0.25391,-0.12109 -0.39844,-0.15235 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,0 -1.07813,0.19922 -1.40625,0.59765 -0.32422,0.39454 -0.48633,0.9629 -0.48633,1.70508 l 0,3.45703 -1.08398,0 0,-6.5625 1.08398,0 0,1.01954 c 0.22656,-0.39844 0.52148,-0.69336 0.88477,-0.88477 0.36328,-0.19531 0.80468,-0.29296 1.32422,-0.29297 0.0742,10e-6 0.15624,0.006 0.24609,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10743"
style=""
id="path3352" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;font-family:Sans"
id="text3781">
<path
d="m 612.64136,657.77118 -3.33985,-8.74805 1.23633,0 2.77149,7.36524 2.77734,-7.36524 1.23047,0 -3.33399,8.74805 -1.34179,0"
style=""
id="path3401" />
<path
d="m 618.28394,651.20868 1.07812,0 0,6.5625 -1.07812,0 0,-6.5625 m 0,-2.55469 1.07812,0 0,1.36524 -1.07812,0 0,-1.36524"
style=""
id="path3403" />
<path
d="m 625.41479,652.21649 c -0.12109,-0.0703 -0.25391,-0.12109 -0.39843,-0.15234 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,1e-5 -1.07813,0.19923 -1.40625,0.59766 -0.32422,0.39454 -0.48633,0.96289 -0.48633,1.70508 l 0,3.45703 -1.08399,0 0,-6.5625 1.08399,0 0,1.01953 c 0.22656,-0.39843 0.52148,-0.69335 0.88476,-0.88477 0.36328,-0.1953 0.80469,-0.29296 1.32422,-0.29296 0.0742,0 0.15625,0.006 0.2461,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10742"
style=""
id="path3405" />
<path
d="m 627.62378,649.3454 0,1.86328 2.2207,0 0,0.83789 -2.2207,0 0,3.5625 c 0,0.53516 0.0723,0.87891 0.2168,1.03125 0.14843,0.15234 0.44726,0.22852 0.89648,0.22852 l 1.10742,0 0,0.90234 -1.10742,0 c -0.83203,0 -1.40625,-0.1543 -1.72266,-0.46289 -0.3164,-0.3125 -0.47461,-0.87891 -0.47461,-1.69922 l 0,-3.5625 -0.79101,0 0,-0.83789 0.79101,0 0,-1.86328 1.08399,0"
style=""
id="path3407" />
<path
d="m 631.15698,655.18134 0,-3.97266 1.07813,0 0,3.93164 c 0,0.6211 0.12109,1.08789 0.36328,1.40039 0.24218,0.3086 0.60546,0.46289 1.08984,0.46289 0.58203,0 1.04101,-0.18554 1.37696,-0.55664 0.33983,-0.37109 0.50976,-0.87695 0.50976,-1.51758 l 0,-3.7207 1.07813,0 0,6.5625 -1.07813,0 0,-1.00781 c -0.26172,0.39843 -0.56641,0.69531 -0.91406,0.89062 -0.34376,0.19141 -0.74415,0.28711 -1.20117,0.28711 -0.75391,0 -1.32618,-0.23437 -1.7168,-0.70312 -0.39063,-0.46875 -0.58594,-1.1543 -0.58594,-2.05664 m 2.71289,-4.13086 0,0"
style=""
id="path3409" />
<path
d="m 641.86792,654.47235 c -0.8711,0 -1.47461,0.0996 -1.81055,0.29883 -0.33594,0.19922 -0.50391,0.53906 -0.5039,1.01953 -10e-6,0.38281 0.12499,0.6875 0.375,0.91406 0.2539,0.22266 0.59765,0.33399 1.03125,0.33399 0.59765,0 1.07616,-0.21094 1.43554,-0.63282 0.36328,-0.42577 0.54492,-0.99023 0.54493,-1.69335 l 0,-0.24024 -1.07227,0 m 2.15039,-0.44531 0,3.74414 -1.07812,0 0,-0.99609 c -0.2461,0.39843 -0.55274,0.69336 -0.91993,0.88476 -0.36719,0.1875 -0.81641,0.28125 -1.34765,0.28125 -0.67188,0 -1.20704,-0.1875 -1.60547,-0.5625 -0.39453,-0.3789 -0.5918,-0.88476 -0.5918,-1.51758 0,-0.73828 0.24609,-1.29492 0.73828,-1.66992 0.49609,-0.37499 1.23438,-0.56249 2.21485,-0.5625 l 1.51172,0 0,-0.10547 c -10e-6,-0.49609 -0.16407,-0.8789 -0.49219,-1.14844 -0.32423,-0.27343 -0.78126,-0.41015 -1.3711,-0.41015 -0.375,0 -0.74023,0.0449 -1.0957,0.13476 -0.35547,0.0899 -0.69727,0.22462 -1.02539,0.4043 l 0,-0.99609 c 0.39453,-0.15234 0.77734,-0.26562 1.14844,-0.33985 0.37109,-0.0781 0.73242,-0.11718 1.08398,-0.11718 0.94922,0 1.6582,0.2461 2.12696,0.73828 0.46874,0.49219 0.70311,1.23828 0.70312,2.23828"
style=""
id="path3411" />
<path
d="m 646.24487,648.65399 1.07813,0 0,9.11719 -1.07813,0 0,-9.11719"
style=""
id="path3413" />
<path
d="m 658.68433,649.31024 0,1.1543 c -0.44923,-0.21484 -0.87306,-0.37499 -1.27149,-0.48047 -0.39844,-0.10546 -0.78321,-0.1582 -1.1543,-0.1582 -0.64453,0 -1.14258,0.125 -1.49414,0.375 -0.34765,0.25 -0.52148,0.60547 -0.52148,1.0664 0,0.38673 0.11523,0.6797 0.3457,0.87891 0.23438,0.19532 0.67578,0.35352 1.32422,0.47461 l 0.71485,0.14648 c 0.8828,0.16798 1.53319,0.46485 1.95117,0.89063 0.42187,0.42188 0.6328,0.98828 0.63281,1.69922 -10e-6,0.84765 -0.28516,1.49023 -0.85547,1.92773 -0.56641,0.4375 -1.39844,0.65625 -2.49609,0.65625 -0.41407,0 -0.85547,-0.0469 -1.32422,-0.14062 -0.46485,-0.0937 -0.94727,-0.23243 -1.44727,-0.41602 l 0,-1.21875 c 0.48047,0.26953 0.95117,0.47266 1.41211,0.60938 0.46094,0.13672 0.91406,0.20507 1.35938,0.20507 0.67577,0 1.19726,-0.13281 1.56445,-0.39843 0.36718,-0.26563 0.55078,-0.64453 0.55078,-1.13672 0,-0.42969 -0.13282,-0.76562 -0.39844,-1.00782 -0.26172,-0.24218 -0.69336,-0.42382 -1.29492,-0.54492 l -0.7207,-0.14062 c -0.88282,-0.17578 -1.52149,-0.45117 -1.91602,-0.82617 -0.39453,-0.375 -0.59179,-0.89648 -0.59179,-1.56446 0,-0.77343 0.27148,-1.3828 0.81445,-1.82812 0.54687,-0.44531 1.29883,-0.66796 2.25586,-0.66797 0.41015,1e-5 0.82812,0.0371 1.25391,0.11133 0.42577,0.0742 0.86132,0.18555 1.30664,0.33398"
style=""
id="path3415" />
<path
d="m 665.73315,651.46063 0,1.00781 c -0.30469,-0.16796 -0.61133,-0.29296 -0.91992,-0.375 -0.30469,-0.0859 -0.61328,-0.1289 -0.92578,-0.1289 -0.69922,0 -1.24219,0.22266 -1.62891,0.66797 -0.38672,0.44141 -0.58008,1.0625 -0.58007,1.86328 -10e-6,0.80078 0.19335,1.42383 0.58007,1.86914 0.38672,0.44141 0.92969,0.66211 1.62891,0.66211 0.3125,0 0.62109,-0.041 0.92578,-0.12305 0.30859,-0.0859 0.61523,-0.21289 0.91992,-0.38086 l 0,0.9961 c -0.30078,0.14062 -0.61328,0.24609 -0.9375,0.3164 -0.32031,0.0703 -0.66211,0.10547 -1.02539,0.10547 -0.98828,0 -1.77344,-0.31055 -2.35547,-0.93164 -0.58203,-0.62109 -0.87304,-1.45898 -0.87304,-2.51367 0,-1.07031 0.29297,-1.91211 0.8789,-2.52539 0.58985,-0.61328 1.39649,-0.91992 2.41993,-0.91992 0.33202,0 0.65624,0.0352 0.97265,0.10546 0.3164,0.0664 0.62304,0.16798 0.91992,0.30469"
style=""
id="path3417" />
<path
d="m 671.42261,652.21649 c -0.1211,-0.0703 -0.25391,-0.12109 -0.39844,-0.15234 -0.14063,-0.0352 -0.29688,-0.0527 -0.46875,-0.0527 -0.60938,1e-5 -1.07813,0.19923 -1.40625,0.59766 -0.32422,0.39454 -0.48633,0.96289 -0.48633,1.70508 l 0,3.45703 -1.08398,0 0,-6.5625 1.08398,0 0,1.01953 c 0.22656,-0.39843 0.52148,-0.69335 0.88477,-0.88477 0.36328,-0.1953 0.80468,-0.29296 1.32422,-0.29296 0.0742,0 0.15624,0.006 0.24609,0.0176 0.0898,0.008 0.18945,0.0215 0.29883,0.041 l 0.006,1.10742"
style=""
id="path3419" />
<path
d="m 677.92065,654.2204 0,0.52734 -4.95703,0 c 0.0469,0.74219 0.26953,1.3086 0.66797,1.69922 0.40234,0.38672 0.96094,0.58008 1.67578,0.58008 0.41406,0 0.81445,-0.0508 1.20117,-0.15235 0.39062,-0.10156 0.77734,-0.2539 1.16016,-0.45703 l 0,1.01953 c -0.38672,0.16407 -0.78321,0.28907 -1.18945,0.375 -0.40626,0.0859 -0.81837,0.12891 -1.23633,0.12891 -1.04688,0 -1.87696,-0.30469 -2.49023,-0.91406 -0.60938,-0.60938 -0.91407,-1.43359 -0.91407,-2.47266 0,-1.07421 0.28906,-1.92577 0.86719,-2.55469 0.58203,-0.6328 1.36523,-0.94921 2.34961,-0.94921 0.88281,0 1.58007,0.28516 2.0918,0.85546 0.51562,0.56642 0.77343,1.3379 0.77343,2.31446 m -1.07812,-0.31641 c -0.008,-0.58984 -0.17383,-1.06054 -0.49805,-1.41211 -0.32031,-0.35155 -0.7461,-0.52734 -1.27734,-0.52734 -0.60157,0 -1.08399,0.16993 -1.44727,0.50976 -0.35937,0.33985 -0.56641,0.81837 -0.62109,1.43555 l 3.84375,-0.006"
style=""
id="path3421" />
<path
d="m 685.30347,654.2204 0,0.52734 -4.95703,0 c 0.0469,0.74219 0.26952,1.3086 0.66796,1.69922 0.40235,0.38672 0.96094,0.58008 1.67579,0.58008 0.41405,0 0.81444,-0.0508 1.20117,-0.15235 0.39062,-0.10156 0.77734,-0.2539 1.16015,-0.45703 l 0,1.01953 c -0.38672,0.16407 -0.78321,0.28907 -1.18945,0.375 -0.40625,0.0859 -0.81836,0.12891 -1.23633,0.12891 -1.04688,0 -1.87695,-0.30469 -2.49023,-0.91406 -0.60938,-0.60938 -0.91407,-1.43359 -0.91406,-2.47266 -10e-6,-1.07421 0.28906,-1.92577 0.86718,-2.55469 0.58203,-0.6328 1.36523,-0.94921 2.34961,-0.94921 0.88281,0 1.58008,0.28516 2.0918,0.85546 0.51562,0.56642 0.77343,1.3379 0.77344,2.31446 m -1.07813,-0.31641 c -0.008,-0.58984 -0.17383,-1.06054 -0.49805,-1.41211 -0.32031,-0.35155 -0.74609,-0.52734 -1.27734,-0.52734 -0.60156,0 -1.08399,0.16993 -1.44726,0.50976 -0.35938,0.33985 -0.56641,0.81837 -0.6211,1.43555 l 3.84375,-0.006"
style=""
id="path3423" />
<path
d="m 692.52808,653.81024 0,3.96094 -1.07813,0 0,-3.92578 c 0,-0.62109 -0.1211,-1.08593 -0.36328,-1.39453 -0.24219,-0.30859 -0.60547,-0.46289 -1.08984,-0.46289 -0.58204,0 -1.04102,0.18555 -1.37696,0.55664 -0.33594,0.3711 -0.50391,0.87695 -0.5039,1.51757 l 0,3.70899 -1.08399,0 0,-6.5625 1.08399,0 0,1.01953 c 0.25781,-0.39452 0.56054,-0.68945 0.9082,-0.88477 0.35156,-0.1953 0.75586,-0.29296 1.21289,-0.29296 0.7539,0 1.32421,0.23438 1.71094,0.70312 0.38671,0.46485 0.58007,1.1504 0.58008,2.05664"
style=""
id="path3425" />
</g>
<rect
style="fill:#b8b8b8;fill-opacity:1;stroke:#b8b8b8;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect5577"
width="173.25098"
height="141.43118"
x="157.75581"
y="436.97159" />
<rect
style="fill:#ededed;fill-opacity:1;stroke:#ededed;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3789"
width="168.99611"
height="136.87178"
x="159.87543"
y="439.39697"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#454545;fill-opacity:1;stroke:none;font-family:Sans"
id="text3791">
<path
d="m 274.28683,558.98682 1.19532,0 1.83984,7.39453 1.83399,-7.39453 1.33007,0 1.83985,7.39453 1.83398,-7.39453 1.20117,0 -2.19726,8.74804 -1.48828,0 -1.84571,-7.59375 -1.86328,7.59375 -1.48828,0 -2.19141,-8.74804"
style=""
id="path3388" />
<path
d="m 286.62082,561.17236 1.07812,0 0,6.5625 -1.07812,0 0,-6.5625 m 0,-2.55468 1.07812,0 0,1.36523 -1.07812,0 0,-1.36523"
style=""
id="path3390" />
<path
d="m 295.40402,563.77393 0,3.96093 -1.07812,0 0,-3.92578 c -10e-6,-0.62109 -0.1211,-1.08593 -0.36328,-1.39453 -0.2422,-0.30859 -0.60548,-0.46288 -1.08985,-0.46289 -0.58203,1e-5 -1.04102,0.18555 -1.37695,0.55664 -0.33594,0.3711 -0.50391,0.87696 -0.50391,1.51758 l 0,3.70898 -1.08398,0 0,-6.5625 1.08398,0 0,1.01953 c 0.25781,-0.39452 0.56055,-0.68944 0.90821,-0.88476 0.35156,-0.19531 0.75585,-0.29296 1.21289,-0.29297 0.7539,1e-5 1.32421,0.23438 1.71093,0.70313 0.38672,0.46484 0.58008,1.15039 0.58008,2.05664"
style=""
id="path3392" />
<path
d="m 301.88449,562.16846 0,-3.55078 1.07813,0 0,9.11718 -1.07813,0 0,-0.98437 c -0.22657,0.39062 -0.51368,0.68164 -0.86133,0.87305 -0.34375,0.1875 -0.75781,0.28124 -1.24218,0.28125 -0.79298,-1e-5 -1.43946,-0.31641 -1.93946,-0.94922 -0.49609,-0.63281 -0.74414,-1.46485 -0.74414,-2.4961 0,-1.03124 0.24805,-1.86327 0.74414,-2.49609 0.5,-0.63281 1.14648,-0.94921 1.93946,-0.94922 0.48437,1e-5 0.89843,0.0957 1.24218,0.28711 0.34765,0.18751 0.63476,0.47657 0.86133,0.86719 m -3.67383,2.29101 c 0,0.79297 0.16211,1.41602 0.48633,1.86914 0.32812,0.44922 0.77734,0.67383 1.34766,0.67383 0.57031,0 1.01952,-0.22461 1.34765,-0.67383 0.32812,-0.45312 0.49219,-1.07617 0.49219,-1.86914 0,-0.79296 -0.16407,-1.41406 -0.49219,-1.86328 -0.32813,-0.45312 -0.77734,-0.67968 -1.34765,-0.67969 -0.57032,10e-6 -1.01954,0.22657 -1.34766,0.67969 -0.32422,0.44922 -0.48633,1.07032 -0.48633,1.86328"
style=""
id="path3394" />
<path
d="m 307.72629,561.92822 c -0.57813,10e-6 -1.03516,0.22657 -1.3711,0.67969 -0.33594,0.44922 -0.5039,1.06641 -0.5039,1.85156 0,0.78516 0.16601,1.4043 0.49804,1.85742 0.33594,0.44922 0.79492,0.67383 1.37696,0.67383 0.57421,0 1.02929,-0.22656 1.36523,-0.67968 0.33593,-0.45313 0.5039,-1.07031 0.50391,-1.85157 -1e-5,-0.77734 -0.16798,-1.39257 -0.50391,-1.8457 -0.33594,-0.45703 -0.79102,-0.68554 -1.36523,-0.68555 m 0,-0.91406 c 0.93749,1e-5 1.67382,0.30469 2.20898,0.91406 0.53515,0.60938 0.80273,1.45313 0.80274,2.53125 -10e-6,1.07422 -0.26759,1.91797 -0.80274,2.53125 -0.53516,0.60938 -1.27149,0.91406 -2.20898,0.91407 -0.94141,-1e-5 -1.67969,-0.30469 -2.21485,-0.91407 -0.53125,-0.61328 -0.79687,-1.45703 -0.79687,-2.53125 0,-1.07812 0.26562,-1.92187 0.79687,-2.53125 0.53516,-0.60937 1.27344,-0.91405 2.21485,-0.91406"
style=""
id="path3396" />
<path
d="m 311.8923,561.17236 1.07813,0 1.34765,5.1211 1.3418,-5.1211 1.27149,0 1.34765,5.1211 1.3418,-5.1211 1.07812,0 -1.71679,6.5625 -1.27149,0 -1.41211,-5.3789 -1.41797,5.3789 -1.27148,0 -1.7168,-6.5625"
style=""
id="path3398" />
</g>
<rect
y="439.39581"
x="159.87428"
height="8.8251209"
width="168.99841"
id="rect3795"
style="fill:#7b7bff;fill-opacity:1;stroke:#7b7bff;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<path
sodipodi:type="arc"
style="fill:#000000;fill-opacity:1;stroke:none"
id="path3797"
sodipodi:cx="352.54324"
sodipodi:cy="373.03461"
sodipodi:rx="2.5253813"
sodipodi:ry="2.5253813"
d="m 355.06862,373.03461 c 0,1.39473 -1.13065,2.52538 -2.52538,2.52538 -1.39473,0 -2.52538,-1.13065 -2.52538,-2.52538 0,-1.39473 1.13065,-2.52538 2.52538,-2.52538 1.39473,0 2.52538,1.13065 2.52538,2.52538 z"
transform="matrix(0.66107369,0,0,0.66107369,123.32145,119.41326)"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<path
transform="matrix(0.66107369,0,0,0.66107369,-194.73594,119.44704)"
d="m 355.06862,373.03461 c 0,1.39473 -1.13065,2.52538 -2.52538,2.52538 -1.39473,0 -2.52538,-1.13065 -2.52538,-2.52538 0,-1.39473 1.13065,-2.52538 2.52538,-2.52538 1.39473,0 2.52538,1.13065 2.52538,2.52538 z"
sodipodi:ry="2.5253813"
sodipodi:rx="2.5253813"
sodipodi:cy="373.03461"
sodipodi:cx="352.54324"
id="path3799"
style="fill:#000000;fill-opacity:1;stroke:none"
sodipodi:type="arc"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<path
sodipodi:type="arc"
style="fill:#000000;fill-opacity:1;stroke:none"
id="path3801"
sodipodi:cx="352.54324"
sodipodi:cy="373.03461"
sodipodi:rx="2.5253813"
sodipodi:ry="2.5253813"
d="m 355.06862,373.03461 c 0,1.39473 -1.13065,2.52538 -2.52538,2.52538 -1.39473,0 -2.52538,-1.13065 -2.52538,-2.52538 0,-1.39473 1.13065,-2.52538 2.52538,-2.52538 1.39473,0 2.52538,1.13065 2.52538,2.52538 z"
transform="matrix(0.66107369,0,0,0.66107369,-73.218648,201.61091)"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113" />
<text
xml:space="preserve"
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="21.213203"
y="340.20465"
id="text3803"
sodipodi:linespacing="125%"
inkscape:export-filename="/home/elmindreda/projects/glfw/glfw/docs/spaces.png"
inkscape:export-xdpi="109.89113"
inkscape:export-ydpi="109.89113"><tspan
sodipodi:role="line"
id="tspan3805"
x="21.213203"
y="340.20465" /></text>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text3807">
<path
d="m 71.179893,455.55557 0.996094,0 1.533203,6.16211 1.528321,-6.16211 1.108398,0 1.533203,6.16211 1.528321,-6.16211 1.000976,0 -1.831055,7.29004 -1.240234,0 -1.538086,-6.32812 -1.552734,6.32812 -1.240235,0 -1.826172,-7.29004"
style="font-size:10px"
id="path3164" />
<path
d="m 81.458214,457.37686 0.898437,0 0,5.46875 -0.898437,0 0,-5.46875 m 0,-2.1289 0.898437,0 0,1.13769 -0.898437,0 0,-1.13769"
style="font-size:10px"
id="path3166" />
<path
d="m 88.77755,459.54483 0,3.30078 -0.898438,0 0,-3.27148 c -4e-6,-0.51758 -0.100916,-0.90495 -0.302734,-1.16211 -0.201827,-0.25716 -0.504561,-0.38574 -0.908203,-0.38574 -0.485029,0 -0.867516,0.15462 -1.147461,0.46386 -0.27995,0.30925 -0.419924,0.7308 -0.419922,1.26465 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.214842,-0.32877 0.46712,-0.57454 0.756836,-0.7373 0.292966,-0.16276 0.629879,-0.24414 1.010742,-0.24414 0.628251,0 1.103511,0.19531 1.425781,0.58593 0.322261,0.38738 0.483393,0.95867 0.483399,1.71387"
style="font-size:10px"
id="path3168" />
<path
d="m 94.17794,458.20694 0,-2.95898 0.898438,0 0,7.59765 -0.898438,0 0,-0.82031 c -0.188806,0.32552 -0.428064,0.56803 -0.717773,0.72754 -0.286462,0.15625 -0.631514,0.23437 -1.035156,0.23437 -0.66081,0 -1.199546,-0.26367 -1.616211,-0.79101 -0.413412,-0.52735 -0.620118,-1.2207 -0.620117,-2.08008 -10e-7,-0.85937 0.206705,-1.55273 0.620117,-2.08008 0.416665,-0.52734 0.955401,-0.79101 1.616211,-0.79101 0.403642,0 0.748694,0.0797 1.035156,0.23925 0.289709,0.15626 0.528967,0.39714 0.717773,0.72266 m -3.061523,1.90918 c -2e-6,0.66081 0.135089,1.18001 0.405273,1.55762 0.273436,0.37435 0.647784,0.56152 1.123047,0.56152 0.475257,0 0.849606,-0.18717 1.123047,-0.56152 0.273433,-0.37761 0.410152,-0.89681 0.410156,-1.55762 -4e-6,-0.6608 -0.136723,-1.17838 -0.410156,-1.55273 -0.273441,-0.3776 -0.64779,-0.56641 -1.123047,-0.56641 -0.475263,0 -0.849611,0.18881 -1.123047,0.56641 -0.270184,0.37435 -0.405275,0.89193 -0.405273,1.55273"
style="font-size:10px"
id="path3170" />
<path
d="m 99.046104,458.00674 c -0.481773,1e-5 -0.862632,0.18881 -1.142578,0.56641 -0.279949,0.37435 -0.419923,0.88868 -0.419922,1.54297 -10e-7,0.6543 0.138345,1.17025 0.415039,1.54785 0.279946,0.37435 0.662433,0.56153 1.147461,0.56152 0.478513,1e-5 0.857744,-0.1888 1.137696,-0.5664 0.27994,-0.3776 0.41992,-0.89193 0.41992,-1.54297 0,-0.64778 -0.13998,-1.16048 -0.41992,-1.53809 -0.279952,-0.38085 -0.659183,-0.57128 -1.137696,-0.57129 m 0,-0.76171 c 0.781247,0 1.394856,0.25391 1.840816,0.76171 0.44596,0.50782 0.66894,1.21095 0.66895,2.10938 -1e-5,0.89518 -0.22299,1.59831 -0.66895,2.10937 -0.44596,0.50782 -1.059569,0.76172 -1.840816,0.76172 -0.784507,0 -1.399741,-0.2539 -1.845703,-0.76172 -0.442709,-0.51106 -0.664063,-1.21419 -0.664062,-2.10937 -10e-7,-0.89843 0.221353,-1.60156 0.664062,-2.10938 0.445962,-0.5078 1.061196,-0.76171 1.845703,-0.76171"
style="font-size:10px"
id="path3172" />
<path
d="m 102.51778,457.37686 0.89844,0 1.12305,4.26758 1.11816,-4.26758 1.05957,0 1.12305,4.26758 1.11816,-4.26758 0.89844,0 -1.43066,5.46875 -1.05957,0 -1.17676,-4.48242 -1.18164,4.48242 -1.05957,0 -1.43067,-5.46875"
style="font-size:10px"
id="path3174" />
<path
d="m 115.27657,462.0253 0,2.90039 -0.90332,0 0,-7.54883 0.90332,0 0,0.83008 c 0.1888,-0.32552 0.42643,-0.5664 0.71289,-0.72266 0.28971,-0.1595 0.63477,-0.23925 1.03516,-0.23925 0.66406,0 1.20279,0.26367 1.61621,0.79101 0.41666,0.52735 0.625,1.22071 0.625,2.08008 0,0.85938 -0.20834,1.55273 -0.625,2.08008 -0.41342,0.52734 -0.95215,0.79101 -1.61621,0.79101 -0.40039,0 -0.74545,-0.0781 -1.03516,-0.23437 -0.28646,-0.15951 -0.52409,-0.40202 -0.71289,-0.72754 m 3.05664,-1.90918 c 0,-0.6608 -0.13672,-1.17838 -0.41015,-1.55273 -0.27019,-0.3776 -0.64291,-0.56641 -1.11817,-0.56641 -0.47526,0 -0.84961,0.18881 -1.12304,0.56641 -0.27019,0.37435 -0.40528,0.89193 -0.40528,1.55273 0,0.66081 0.13509,1.18001 0.40528,1.55762 0.27343,0.37435 0.64778,0.56152 1.12304,0.56152 0.47526,0 0.84798,-0.18717 1.11817,-0.56152 0.27343,-0.37761 0.41015,-0.89681 0.41015,-1.55762"
style="font-size:10px"
id="path3176" />
<path
d="m 122.87423,458.00674 c -0.48177,1e-5 -0.86263,0.18881 -1.14258,0.56641 -0.27995,0.37435 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13834,1.17025 0.41504,1.54785 0.27994,0.37435 0.66243,0.56153 1.14746,0.56152 0.47851,1e-5 0.85774,-0.1888 1.13769,-0.5664 0.27995,-0.3776 0.41992,-0.89193 0.41993,-1.54297 -1e-5,-0.64778 -0.13998,-1.16048 -0.41993,-1.53809 -0.27995,-0.38085 -0.65918,-0.57128 -1.13769,-0.57129 m 0,-0.76171 c 0.78125,0 1.39485,0.25391 1.84082,0.76171 0.44596,0.50782 0.66894,1.21095 0.66895,2.10938 -1e-5,0.89518 -0.22299,1.59831 -0.66895,2.10937 -0.44597,0.50782 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.2539 -1.8457,-0.76172 -0.44271,-0.51106 -0.66407,-1.21419 -0.66407,-2.10937 0,-0.89843 0.22136,-1.60156 0.66407,-2.10938 0.44596,-0.5078 1.06119,-0.76171 1.8457,-0.76171"
style="font-size:10px"
id="path3178" />
<path
d="m 130.3547,457.53799 0,0.84961 c -0.25391,-0.1302 -0.51758,-0.22786 -0.79102,-0.29296 -0.27344,-0.0651 -0.55664,-0.0977 -0.84961,-0.0977 -0.44596,0 -0.78125,0.0684 -1.00586,0.20508 -0.22135,0.13672 -0.33203,0.3418 -0.33203,0.61523 0,0.20834 0.0797,0.37273 0.23926,0.49317 0.1595,0.11719 0.48014,0.22949 0.96191,0.33691 l 0.30762,0.0684 c 0.63802,0.13672 1.09049,0.33041 1.35742,0.58105 0.27018,0.2474 0.40527,0.59408 0.40528,1.04004 -1e-5,0.50782 -0.20183,0.90983 -0.60547,1.20606 -0.4004,0.29622 -0.95215,0.44433 -1.65528,0.44433 -0.29297,0 -0.59896,-0.0293 -0.91796,-0.0879 -0.31576,-0.0553 -0.64942,-0.13997 -1.00098,-0.2539 l 0,-0.92774 c 0.33203,0.17253 0.65918,0.30274 0.98144,0.39063 0.32227,0.0846 0.64128,0.12695 0.95704,0.12695 0.42317,0 0.74869,-0.0716 0.97656,-0.21484 0.22786,-0.14649 0.34179,-0.35157 0.3418,-0.61524 -1e-5,-0.24414 -0.083,-0.43131 -0.24903,-0.56152 -0.16276,-0.13021 -0.52246,-0.25553 -1.0791,-0.37598 l -0.3125,-0.0732 c -0.55664,-0.11719 -0.95866,-0.29622 -1.20605,-0.53711 -0.2474,-0.24414 -0.3711,-0.5778 -0.3711,-1.00098 0,-0.51431 0.18229,-0.91145 0.54688,-1.1914 0.36458,-0.27994 0.88216,-0.41992 1.55273,-0.41992 0.33203,0 0.64453,0.0244 0.9375,0.0732 0.29297,0.0488 0.56315,0.12207 0.81055,0.21972"
style="font-size:10px"
id="path3180" />
<path
d="m 132.08321,457.37686 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3182" />
<path
d="m 135.74532,455.82413 0,1.55273 1.85059,0 0,0.69824 -1.85059,0 0,2.96875 c 0,0.44597 0.0602,0.73243 0.18067,0.85938 0.12369,0.12695 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26042 -0.39551,-0.73242 -0.39551,-1.41602 l 0,-2.96875 -0.65918,0 0,-0.69824 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3184" />
<path
d="m 138.78243,457.37686 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3186" />
<path
d="m 143.67501,458.00674 c -0.48177,1e-5 -0.86263,0.18881 -1.14258,0.56641 -0.27995,0.37435 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56152 0.47851,1e-5 0.85774,-0.1888 1.1377,-0.5664 0.27994,-0.3776 0.41991,-0.89193 0.41992,-1.54297 -1e-5,-0.64778 -0.13998,-1.16048 -0.41992,-1.53809 -0.27996,-0.38085 -0.65919,-0.57128 -1.1377,-0.57129 m 0,-0.76171 c 0.78125,0 1.39485,0.25391 1.84082,0.76171 0.44596,0.50782 0.66894,1.21095 0.66895,2.10938 -1e-5,0.89518 -0.22299,1.59831 -0.66895,2.10937 -0.44597,0.50782 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.2539 -1.8457,-0.76172 -0.44271,-0.51106 -0.66407,-1.21419 -0.66406,-2.10937 -10e-6,-0.89843 0.22135,-1.60156 0.66406,-2.10938 0.44596,-0.5078 1.06119,-0.76171 1.8457,-0.76171"
style="font-size:10px"
id="path3188" />
<path
d="m 152.21505,459.54483 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51758 -0.10091,-0.90495 -0.30273,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.90821,-0.38574 -0.48502,0 -0.86751,0.15462 -1.14746,0.46386 -0.27995,0.30925 -0.41992,0.7308 -0.41992,1.26465 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29296,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19531 1.42578,0.58593 0.32226,0.38738 0.48339,0.95867 0.4834,1.71387"
style="font-size:10px"
id="path3190" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text3817">
<path
d="m 49.798271,374.06503 0,0.96192 c -0.374354,-0.17903 -0.727544,-0.3125 -1.05957,-0.40039 -0.332035,-0.0879 -0.652673,-0.13183 -0.961914,-0.13184 -0.537112,1e-5 -0.952151,0.10417 -1.245117,0.3125 -0.289716,0.20834 -0.434572,0.50456 -0.434571,0.88867 -10e-7,0.32227 0.09603,0.56641 0.288086,0.73242 0.195311,0.16277 0.563149,0.2946 1.103516,0.39551 l 0.595703,0.12207 c 0.735673,0.13998 1.277664,0.38738 1.625977,0.74219 0.351556,0.35157 0.527338,0.82357 0.527343,1.41602 -5e-6,0.70638 -0.237635,1.24186 -0.71289,1.60644 -0.47201,0.36458 -1.165369,0.54688 -2.080078,0.54688 -0.345055,0 -0.712893,-0.0391 -1.103516,-0.11719 -0.387371,-0.0781 -0.789389,-0.19369 -1.206055,-0.34668 l 0,-1.01563 c 0.40039,0.22461 0.792642,0.39388 1.176758,0.50782 0.384112,0.11393 0.761716,0.1709 1.132813,0.17089 0.563147,10e-6 0.997717,-0.11067 1.30371,-0.33203 0.305985,-0.22135 0.45898,-0.5371 0.458985,-0.94726 -5e-6,-0.35807 -0.110682,-0.63802 -0.332031,-0.83985 -0.218104,-0.20182 -0.577804,-0.35318 -1.079102,-0.4541 l -0.600586,-0.11719 c -0.735679,-0.14648 -1.267905,-0.37597 -1.59668,-0.68847 -0.328776,-0.3125 -0.493164,-0.74707 -0.493164,-1.30371 0,-0.64453 0.226236,-1.15234 0.678711,-1.52344 0.455728,-0.37109 1.082355,-0.55663 1.879883,-0.55664 0.341793,10e-6 0.6901,0.0309 1.044922,0.0928 0.354813,0.0619 0.717768,0.15463 1.088867,0.27832"
style="font-size:10px"
id="path3193" />
<path
d="m 56.414482,378.15683 0,0.43945 -4.130859,0 c 0.03906,0.61849 0.224607,1.0905 0.55664,1.41602 0.335284,0.32226 0.800779,0.4834 1.396485,0.4834 0.345048,0 0.678707,-0.0423 1.000976,-0.12696 0.325516,-0.0846 0.647782,-0.21158 0.966797,-0.38086 l 0,0.84961 c -0.322271,0.13672 -0.652674,0.24089 -0.991211,0.3125 -0.338546,0.0716 -0.68197,0.10743 -1.030273,0.10743 -0.872399,0 -1.56413,-0.25391 -2.075196,-0.76172 -0.507813,-0.50781 -0.761719,-1.19466 -0.761718,-2.06055 -10e-7,-0.89518 0.240884,-1.60481 0.722656,-2.12891 0.485024,-0.52733 1.137693,-0.79101 1.958008,-0.79101 0.735673,0 1.316727,0.23763 1.743164,0.71289 0.429682,0.47201 0.644525,1.11491 0.644531,1.92871 m -0.898437,-0.26367 c -0.0065,-0.49153 -0.144862,-0.88379 -0.415039,-1.17676 -0.266932,-0.29296 -0.621749,-0.43945 -1.064454,-0.43945 -0.501304,0 -0.903322,0.1416 -1.206054,0.4248 -0.299481,0.28321 -0.472007,0.68197 -0.517578,1.19629 l 3.203125,-0.005"
style="font-size:10px"
id="path3195" />
<path
d="m 61.824638,375.85703 0,0.83984 c -0.253911,-0.13997 -0.509444,-0.24414 -0.766601,-0.3125 -0.25391,-0.0716 -0.511072,-0.10742 -0.771485,-0.10742 -0.582685,0 -1.035158,0.18555 -1.357421,0.55664 -0.322268,0.36784 -0.4834,0.88542 -0.483399,1.55273 -10e-7,0.66732 0.161131,1.18653 0.483399,1.55762 0.322263,0.36784 0.774736,0.55176 1.357421,0.55176 0.260413,0 0.517575,-0.0342 0.771485,-0.10254 0.257157,-0.0716 0.51269,-0.17741 0.766601,-0.31738 l 0,0.83007 c -0.250655,0.11719 -0.511072,0.20508 -0.78125,0.26368 -0.266931,0.0586 -0.551761,0.0879 -0.854492,0.0879 -0.82357,0 -1.477866,-0.25879 -1.96289,-0.77637 -0.485027,-0.51758 -0.72754,-1.21582 -0.72754,-2.09473 0,-0.89192 0.24414,-1.59342 0.732422,-2.10449 0.491535,-0.51106 1.163735,-0.7666 2.016602,-0.7666 0.276689,0 0.546871,0.0293 0.810547,0.0879 0.263667,0.0553 0.519201,0.13998 0.766601,0.25391"
style="font-size:10px"
id="path3197" />
<path
d="m 65.516045,376.27695 c -0.481774,0 -0.862633,0.1888 -1.142579,0.5664 -0.279949,0.37436 -0.419923,0.88868 -0.419921,1.54297 -2e-6,0.6543 0.138344,1.17025 0.415039,1.54785 0.279945,0.37435 0.662432,0.56153 1.147461,0.56153 0.478512,0 0.857743,-0.1888 1.137695,-0.56641 0.279943,-0.3776 0.419917,-0.89192 0.419922,-1.54297 -5e-6,-0.64778 -0.139979,-1.16048 -0.419922,-1.53808 -0.279952,-0.38086 -0.659183,-0.57129 -1.137695,-0.57129 m 0,-0.76172 c 0.781246,0 1.394852,0.25391 1.84082,0.76172 0.445958,0.50781 0.66894,1.21094 0.668945,2.10937 -5e-6,0.89519 -0.222987,1.59831 -0.668945,2.10938 -0.445968,0.50781 -1.059574,0.76172 -1.84082,0.76172 -0.784508,0 -1.399742,-0.25391 -1.845704,-0.76172 -0.442709,-0.51107 -0.664063,-1.21419 -0.664062,-2.10938 -10e-7,-0.89843 0.221353,-1.60156 0.664062,-2.10937 0.445962,-0.50781 1.061196,-0.76172 1.845704,-0.76172"
style="font-size:10px"
id="path3199" />
<path
d="m 74.056084,377.81503 0,3.30078 -0.898438,0 0,-3.27148 c -4e-6,-0.51757 -0.100916,-0.90494 -0.302734,-1.16211 -0.201827,-0.25716 -0.504561,-0.38574 -0.908203,-0.38574 -0.485029,0 -0.867516,0.15463 -1.147461,0.46387 -0.27995,0.30924 -0.419924,0.73079 -0.419922,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.214842,-0.32877 0.46712,-0.57454 0.756836,-0.7373 0.292966,-0.16276 0.629879,-0.24414 1.010742,-0.24414 0.628251,0 1.103511,0.19532 1.425781,0.58594 0.322261,0.38737 0.483393,0.95866 0.483399,1.71386"
style="font-size:10px"
id="path3201" />
<path
d="m 79.456474,376.47714 0,-2.95898 0.898438,0 0,7.59765 -0.898438,0 0,-0.82031 c -0.188806,0.32552 -0.428064,0.56804 -0.717773,0.72754 -0.286462,0.15625 -0.631514,0.23438 -1.035156,0.23438 -0.66081,0 -1.199546,-0.26368 -1.616211,-0.79102 -0.413413,-0.52734 -0.620118,-1.2207 -0.620118,-2.08008 0,-0.85937 0.206705,-1.55273 0.620118,-2.08008 0.416665,-0.52733 0.955401,-0.79101 1.616211,-0.79101 0.403642,0 0.748694,0.0798 1.035156,0.23926 0.289709,0.15625 0.528967,0.39714 0.717773,0.72265 m -3.061523,1.90918 c -2e-6,0.66081 0.135089,1.18002 0.405273,1.55762 0.273436,0.37435 0.647784,0.56152 1.123047,0.56152 0.475257,0 0.849606,-0.18717 1.123047,-0.56152 0.273433,-0.3776 0.410152,-0.89681 0.410156,-1.55762 -4e-6,-0.6608 -0.136723,-1.17838 -0.410156,-1.55273 -0.273441,-0.3776 -0.64779,-0.5664 -1.123047,-0.56641 -0.475263,1e-5 -0.849611,0.18881 -1.123047,0.56641 -0.270184,0.37435 -0.405275,0.89193 -0.405273,1.55273"
style="font-size:10px"
id="path3203" />
<path
d="m 84.690849,378.36679 c -0.725914,0 -1.228843,0.083 -1.508789,0.24902 -0.279949,0.16602 -0.419923,0.44923 -0.419922,0.84961 -10e-7,0.31902 0.104165,0.57292 0.3125,0.76172 0.211587,0.18555 0.498045,0.27832 0.859375,0.27832 0.498044,0 0.896807,-0.17578 1.196289,-0.52734 0.302731,-0.35482 0.454098,-0.82519 0.454102,-1.41113 l 0,-0.2002 -0.893555,0 m 1.791992,-0.37109 0,3.12011 -0.898437,0 0,-0.83007 c -0.205082,0.33203 -0.460616,0.5778 -0.766602,0.7373 -0.305992,0.15625 -0.680341,0.23438 -1.123046,0.23438 -0.559898,0 -1.005861,-0.15625 -1.337891,-0.46875 -0.328777,-0.31576 -0.493165,-0.73731 -0.493164,-1.26465 -1e-6,-0.61523 0.205077,-1.0791 0.615234,-1.3916 0.41341,-0.3125 1.028644,-0.46875 1.845703,-0.46875 l 1.259766,0 0,-0.0879 c -4e-6,-0.41341 -0.136723,-0.73242 -0.410156,-0.95704 -0.270186,-0.22786 -0.651045,-0.34179 -1.142578,-0.34179 -0.312503,0 -0.616865,0.0374 -0.913086,0.1123 -0.296226,0.0749 -0.581056,0.18718 -0.854493,0.33692 l 0,-0.83008 c 0.328775,-0.12695 0.647785,-0.22135 0.957032,-0.28321 0.309242,-0.0651 0.610349,-0.0977 0.90332,-0.0977 0.791012,0 1.381832,0.20508 1.772461,0.61523 0.39062,0.41016 0.585932,1.03191 0.585937,1.86524"
style="font-size:10px"
id="path3205" />
<path
d="m 91.507256,376.48691 c -0.100916,-0.0586 -0.211593,-0.10091 -0.332032,-0.12696 -0.117191,-0.0293 -0.247399,-0.0439 -0.390625,-0.0439 -0.507815,0 -0.89844,0.16602 -1.171875,0.49805 -0.270184,0.32878 -0.405275,0.80241 -0.405273,1.42089 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.434568,-0.57779 0.737305,-0.7373 0.302731,-0.16276 0.670569,-0.24414 1.103515,-0.24414 0.06185,0 0.130205,0.005 0.205078,0.0147 0.07487,0.007 0.157874,0.0179 0.249024,0.0342 l 0.0049,0.92285"
style="font-size:10px"
id="path3207" />
<path
d="m 94.734795,381.62363 c -0.25391,0.65104 -0.501305,1.07584 -0.742188,1.27441 -0.240888,0.19857 -0.563153,0.29785 -0.966797,0.29785 l -0.717773,0 0,-0.75195 0.527344,0 c 0.247394,0 0.439451,-0.0586 0.576171,-0.17578 0.136717,-0.11719 0.288084,-0.39388 0.454102,-0.83008 l 0.161133,-0.41016 -2.211914,-5.38086 0.952148,0 1.708985,4.27735 1.708984,-4.27735 0.952148,0 -2.402343,5.97657"
style="font-size:10px"
id="path3209" />
<path
d="m 105.81878,376.69687 c 0.2246,-0.40364 0.49316,-0.70149 0.80566,-0.89356 0.3125,-0.19205 0.68033,-0.28808 1.10352,-0.28808 0.56965,0 1.00911,0.2002 1.31836,0.60058 0.30923,0.39714 0.46386,0.96355 0.46387,1.69922 l 0,3.30078 -0.90333,0 0,-3.27148 c 0,-0.52408 -0.0928,-0.91308 -0.27832,-1.16699 -0.18555,-0.2539 -0.46875,-0.38086 -0.8496,-0.38086 -0.46551,0 -0.83334,0.15463 -1.10352,0.46387 -0.27019,0.30924 -0.40528,0.73079 -0.40527,1.26464 l 0,3.09082 -0.90332,0 0,-3.27148 c -10e-6,-0.52734 -0.0928,-0.91634 -0.27832,-1.16699 -0.18556,-0.2539 -0.47201,-0.38086 -0.85938,-0.38086 -0.45899,0 -0.82357,0.15625 -1.09375,0.46875 -0.27018,0.30925 -0.40527,0.72917 -0.40527,1.25976 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.20507,-0.33528 0.45084,-0.58267 0.7373,-0.74218 0.28646,-0.1595 0.62663,-0.23926 1.02051,-0.23926 0.39713,0 0.73404,0.10092 1.01074,0.30273 0.27994,0.20183 0.48665,0.4948 0.62012,0.87891"
style="font-size:10px"
id="path3211" />
<path
d="m 113.4262,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85774,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41991,-0.89192 0.41992,-1.54297 -10e-6,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27996,-0.38086 -0.65919,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44597,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66407,-1.21419 -0.66406,-2.10938 -10e-6,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.06119,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3213" />
<path
d="m 121.96624,377.81503 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51757 -0.10091,-0.90494 -0.30273,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.90821,-0.38574 -0.48502,0 -0.86751,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41992,0.73079 -0.41992,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29296,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19532 1.42578,0.58594 0.32226,0.38737 0.48339,0.95866 0.4834,1.71386"
style="font-size:10px"
id="path3215" />
<path
d="m 123.768,375.64706 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3217" />
<path
d="m 127.43011,374.09433 0,1.55273 1.85058,0 0,0.69825 -1.85058,0 0,2.96875 c 0,0.44596 0.0602,0.73242 0.18066,0.85937 0.1237,0.12696 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26041 -0.3955,-0.73242 -0.3955,-1.41601 l 0,-2.96875 -0.65918,0 0,-0.69825 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3219" />
<path
d="m 132.58636,376.27695 c -0.48178,0 -0.86264,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13834,1.17025 0.41504,1.54785 0.27994,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85774,-0.1888 1.13769,-0.56641 0.27995,-0.3776 0.41992,-0.89192 0.41992,-1.54297 0,-0.64778 -0.13997,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65918,-0.57129 -1.13769,-0.57129 m 0,-0.76172 c 0.78124,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66894,2.10937 0,0.89519 -0.22298,1.59831 -0.66894,2.10938 -0.44597,0.50781 -1.05958,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.84571,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44597,-0.50781 1.0612,-0.76172 1.84571,-0.76172"
style="font-size:10px"
id="path3221" />
<path
d="m 139.74944,376.48691 c -0.10091,-0.0586 -0.21159,-0.10091 -0.33203,-0.12696 -0.11719,-0.0293 -0.2474,-0.0439 -0.39062,-0.0439 -0.50782,0 -0.89844,0.16602 -1.17188,0.49805 -0.27018,0.32878 -0.40527,0.80241 -0.40527,1.42089 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.7373,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10352,-0.24414 0.0618,0 0.1302,0.005 0.20508,0.0147 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3223" />
<path
d="m 144.75433,380.2955 0,2.90039 -0.90332,0 0,-7.54883 0.90332,0 0,0.83008 c 0.1888,-0.32551 0.42643,-0.5664 0.71289,-0.72265 0.28971,-0.1595 0.63476,-0.23926 1.03515,-0.23926 0.66406,0 1.2028,0.26368 1.61621,0.79101 0.41666,0.52735 0.625,1.22071 0.625,2.08008 0,0.85938 -0.20834,1.55274 -0.625,2.08008 -0.41341,0.52734 -0.95215,0.79102 -1.61621,0.79102 -0.40039,0 -0.74544,-0.0781 -1.03515,-0.23438 -0.28646,-0.1595 -0.52409,-0.40202 -0.71289,-0.72754 m 3.05664,-1.90918 c -1e-5,-0.6608 -0.13673,-1.17838 -0.41016,-1.55273 -0.27019,-0.3776 -0.64291,-0.5664 -1.11816,-0.56641 -0.47527,1e-5 -0.84962,0.18881 -1.12305,0.56641 -0.27018,0.37435 -0.40528,0.89193 -0.40527,1.55273 -1e-5,0.66081 0.13509,1.18002 0.40527,1.55762 0.27343,0.37435 0.64778,0.56152 1.12305,0.56152 0.47525,0 0.84797,-0.18717 1.11816,-0.56152 0.27343,-0.3776 0.41015,-0.89681 0.41016,-1.55762"
style="font-size:10px"
id="path3225" />
<path
d="m 152.35198,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85775,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41991,-0.89192 0.41992,-1.54297 -1e-5,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65919,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44597,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.06119,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3227" />
<path
d="m 159.83245,375.8082 0,0.84961 c -0.25391,-0.13021 -0.51758,-0.22786 -0.79101,-0.29297 -0.27345,-0.0651 -0.55665,-0.0976 -0.84961,-0.0977 -0.44597,1e-5 -0.78126,0.0684 -1.00586,0.20508 -0.22136,0.13672 -0.33204,0.3418 -0.33203,0.61523 -1e-5,0.20834 0.0798,0.37273 0.23925,0.49317 0.15951,0.11719 0.48014,0.22949 0.96192,0.33691 l 0.30761,0.0684 c 0.63802,0.13672 1.0905,0.33041 1.35743,0.58106 0.27017,0.24739 0.40526,0.59407 0.40527,1.04004 -1e-5,0.50781 -0.20183,0.90983 -0.60547,1.20605 -0.40039,0.29622 -0.95215,0.44434 -1.65527,0.44434 -0.29297,0 -0.59896,-0.0293 -0.91797,-0.0879 -0.31576,-0.0553 -0.64942,-0.13998 -1.00098,-0.25391 l 0,-0.92774 c 0.33203,0.17253 0.65918,0.30274 0.98145,0.39063 0.32226,0.0846 0.64127,0.12695 0.95703,0.12695 0.42317,0 0.74869,-0.0716 0.97656,-0.21484 0.22786,-0.14648 0.34179,-0.35156 0.3418,-0.61524 -1e-5,-0.24413 -0.083,-0.43131 -0.24903,-0.56152 -0.16276,-0.13021 -0.52246,-0.25553 -1.0791,-0.37598 l -0.3125,-0.0732 c -0.55664,-0.11718 -0.95866,-0.29622 -1.20605,-0.53711 -0.2474,-0.24413 -0.3711,-0.57779 -0.3711,-1.00097 0,-0.51432 0.1823,-0.91146 0.54688,-1.19141 0.36458,-0.27994 0.88216,-0.41992 1.55273,-0.41992 0.33203,0 0.64453,0.0244 0.9375,0.0732 0.29297,0.0488 0.56315,0.12208 0.81055,0.21973"
style="font-size:10px"
id="path3229" />
<path
d="m 161.56097,375.64706 0.89843,0 0,5.46875 -0.89843,0 0,-5.46875 m 0,-2.1289 0.89843,0 0,1.13769 -0.89843,0 0,-1.13769"
style="font-size:10px"
id="path3231" />
<path
d="m 165.22308,374.09433 0,1.55273 1.85058,0 0,0.69825 -1.85058,0 0,2.96875 c -1e-5,0.44596 0.0602,0.73242 0.18066,0.85937 0.1237,0.12696 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26041 -0.39551,-0.73242 -0.3955,-1.41601 l 0,-2.96875 -0.65918,0 0,-0.69825 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3233" />
<path
d="m 168.26019,375.64706 0.89843,0 0,5.46875 -0.89843,0 0,-5.46875 m 0,-2.1289 0.89843,0 0,1.13769 -0.89843,0 0,-1.13769"
style="font-size:10px"
id="path3235" />
<path
d="m 173.15276,376.27695 c -0.48177,0 -0.86263,0.1888 -1.14257,0.5664 -0.27995,0.37436 -0.41993,0.88868 -0.41993,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56153 0.47852,0 0.85775,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41992,-0.89192 0.41992,-1.54297 0,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27995,-0.38086 -0.65918,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39486,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44596,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.7845,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66406,-1.21419 -0.66406,-2.10938 0,-0.89843 0.22135,-1.60156 0.66406,-2.10937 0.44596,-0.50781 1.0612,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3237" />
<path
d="m 181.6928,377.81503 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51757 -0.10091,-0.90494 -0.30273,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.9082,-0.38574 -0.48503,0 -0.86752,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41993,0.73079 -0.41993,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21485,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29297,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19532 1.42578,0.58594 0.32226,0.38737 0.4834,0.95866 0.4834,1.71386"
style="font-size:10px"
id="path3239" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text3826">
<path
d="m 172.22728,456.1171 0,1.04004 c -0.33204,-0.30924 -0.68686,-0.54036 -1.06445,-0.69336 -0.37436,-0.15299 -0.77312,-0.22949 -1.19629,-0.2295 -0.83334,10e-6 -1.47136,0.25554 -1.91407,0.76661 -0.44271,0.50781 -0.66406,1.24349 -0.66406,2.20703 0,0.96029 0.22135,1.69596 0.66406,2.20703 0.44271,0.50781 1.08073,0.76172 1.91407,0.76172 0.42317,0 0.82193,-0.0765 1.19629,-0.2295 0.37759,-0.15299 0.73241,-0.38411 1.06445,-0.69336 l 0,1.03028 c -0.34506,0.23437 -0.71127,0.41015 -1.09863,0.52734 -0.38412,0.11719 -0.79102,0.17578 -1.22071,0.17578 -1.10351,0 -1.97265,-0.33691 -2.60742,-1.01074 -0.63476,-0.67708 -0.95215,-1.59993 -0.95215,-2.76855 0,-1.17187 0.31739,-2.09472 0.95215,-2.76856 0.63477,-0.67707 1.50391,-1.01562 2.60742,-1.01562 0.4362,0 0.84635,0.0586 1.23047,0.17578 0.38737,0.11394 0.75032,0.28646 1.08887,0.51758"
style="font-size:10px"
id="path3108" />
<path
d="m 173.72142,455.24796 0.89844,0 0,7.59765 -0.89844,0 0,-7.59765"
style="font-size:10px"
id="path3110" />
<path
d="m 176.49486,457.37686 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3112" />
<path
d="m 183.94603,459.88663 0,0.43945 -4.13086,0 c 0.0391,0.61849 0.22461,1.0905 0.55664,1.41602 0.33528,0.32226 0.80078,0.4834 1.39649,0.48339 0.34504,1e-5 0.6787,-0.0423 1.00097,-0.12695 0.32552,-0.0846 0.64778,-0.21159 0.9668,-0.38086 l 0,0.84961 c -0.32227,0.13672 -0.65268,0.24089 -0.99121,0.3125 -0.33855,0.0716 -0.68197,0.10742 -1.03028,0.10742 -0.87239,0 -1.56413,-0.2539 -2.07519,-0.76172 -0.50781,-0.50781 -0.76172,-1.19466 -0.76172,-2.06054 0,-0.89518 0.24088,-1.60482 0.72266,-2.12891 0.48502,-0.52734 1.13769,-0.79101 1.958,-0.79101 0.73568,0 1.31673,0.23763 1.74317,0.71289 0.42968,0.47201 0.64452,1.11491 0.64453,1.92871 m -0.89844,-0.26367 c -0.007,-0.49154 -0.14486,-0.88379 -0.41504,-1.17676 -0.26693,-0.29297 -0.62175,-0.43945 -1.06445,-0.43946 -0.5013,1e-5 -0.90332,0.14161 -1.20605,0.42481 -0.29949,0.28321 -0.47201,0.68197 -0.51758,1.19629 l 3.20312,-0.005"
style="font-size:10px"
id="path3114" />
<path
d="m 189.96654,459.54483 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51758 -0.10092,-0.90495 -0.30273,-1.16211 -0.20183,-0.25716 -0.50457,-0.38574 -0.90821,-0.38574 -0.48503,0 -0.86751,0.15462 -1.14746,0.46386 -0.27995,0.30925 -0.41992,0.7308 -0.41992,1.26465 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29296,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19531 1.42578,0.58593 0.32226,0.38738 0.48339,0.95867 0.4834,1.71387"
style="font-size:10px"
id="path3116" />
<path
d="m 192.65697,455.82413 0,1.55273 1.85058,0 0,0.69824 -1.85058,0 0,2.96875 c 0,0.44597 0.0602,0.73243 0.18066,0.85938 0.1237,0.12695 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26042 -0.3955,-0.73242 -0.3955,-1.41602 l 0,-2.96875 -0.65918,0 0,-0.69824 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3118" />
<path
d="m 201.36302,460.09659 c -0.72591,0 -1.22884,0.083 -1.50879,0.24902 -0.27995,0.16602 -0.41992,0.44922 -0.41992,0.84961 0,0.31901 0.10417,0.57292 0.3125,0.76172 0.21159,0.18555 0.49805,0.27832 0.85938,0.27832 0.49804,0 0.8968,-0.17578 1.19628,-0.52734 0.30274,-0.35482 0.4541,-0.8252 0.45411,-1.41114 l 0,-0.20019 -0.89356,0 m 1.79199,-0.3711 0,3.12012 -0.89843,0 0,-0.83008 c -0.20509,0.33204 -0.46062,0.5778 -0.76661,0.73731 -0.30599,0.15625 -0.68034,0.23437 -1.12304,0.23437 -0.5599,0 -1.00586,-0.15625 -1.33789,-0.46875 -0.32878,-0.31575 -0.49317,-0.7373 -0.49317,-1.26465 0,-0.61523 0.20508,-1.07909 0.61524,-1.3916 0.41341,-0.31249 1.02864,-0.46874 1.8457,-0.46875 l 1.25977,0 0,-0.0879 c -1e-5,-0.4134 -0.13673,-0.73242 -0.41016,-0.95703 -0.27019,-0.22786 -0.65104,-0.34179 -1.14258,-0.3418 -0.3125,1e-5 -0.61686,0.0374 -0.91308,0.11231 -0.29623,0.0749 -0.58106,0.18718 -0.8545,0.33691 l 0,-0.83007 c 0.32878,-0.12695 0.64779,-0.22135 0.95704,-0.28321 0.30924,-0.0651 0.61034,-0.0976 0.90332,-0.0976 0.79101,0 1.38183,0.20508 1.77246,0.61523 0.39062,0.41016 0.58593,1.03191 0.58593,1.86523"
style="font-size:10px"
id="path3120" />
<path
d="m 208.17943,458.21671 c -0.10092,-0.0586 -0.21159,-0.10091 -0.33203,-0.12696 -0.11719,-0.0293 -0.2474,-0.0439 -0.39063,-0.0439 -0.50781,0 -0.89844,0.16602 -1.17187,0.49804 -0.27019,0.32878 -0.40528,0.80242 -0.40528,1.4209 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33203 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0146 0.0749,0.007 0.15788,0.0179 0.24903,0.0342 l 0.005,0.92286"
style="font-size:10px"
id="path3122" />
<path
d="m 213.59447,459.88663 0,0.43945 -4.13086,0 c 0.0391,0.61849 0.22461,1.0905 0.55664,1.41602 0.33528,0.32226 0.80078,0.4834 1.39648,0.48339 0.34505,1e-5 0.67871,-0.0423 1.00098,-0.12695 0.32552,-0.0846 0.64778,-0.21159 0.9668,-0.38086 l 0,0.84961 c -0.32227,0.13672 -0.65268,0.24089 -0.99121,0.3125 -0.33855,0.0716 -0.68197,0.10742 -1.03028,0.10742 -0.8724,0 -1.56413,-0.2539 -2.07519,-0.76172 -0.50782,-0.50781 -0.76172,-1.19466 -0.76172,-2.06054 0,-0.89518 0.24088,-1.60482 0.72265,-2.12891 0.48503,-0.52734 1.1377,-0.79101 1.95801,-0.79101 0.73567,0 1.31673,0.23763 1.74317,0.71289 0.42968,0.47201 0.64452,1.11491 0.64453,1.92871 m -0.89844,-0.26367 c -0.007,-0.49154 -0.14486,-0.88379 -0.41504,-1.17676 -0.26693,-0.29297 -0.62175,-0.43945 -1.06445,-0.43946 -0.50131,1e-5 -0.90333,0.14161 -1.20606,0.42481 -0.29948,0.28321 -0.472,0.68197 -0.51758,1.19629 l 3.20313,-0.005"
style="font-size:10px"
id="path3124" />
<path
d="m 217.55443,460.09659 c -0.72592,0 -1.22885,0.083 -1.50879,0.24902 -0.27995,0.16602 -0.41992,0.44922 -0.41992,0.84961 0,0.31901 0.10416,0.57292 0.3125,0.76172 0.21158,0.18555 0.49804,0.27832 0.85937,0.27832 0.49805,0 0.89681,-0.17578 1.19629,-0.52734 0.30273,-0.35482 0.4541,-0.8252 0.4541,-1.41114 l 0,-0.20019 -0.89355,0 m 1.79199,-0.3711 0,3.12012 -0.89844,0 0,-0.83008 c -0.20508,0.33204 -0.46061,0.5778 -0.7666,0.73731 -0.30599,0.15625 -0.68034,0.23437 -1.12305,0.23437 -0.55989,0 -1.00586,-0.15625 -1.33789,-0.46875 -0.32877,-0.31575 -0.49316,-0.7373 -0.49316,-1.26465 0,-0.61523 0.20508,-1.07909 0.61523,-1.3916 0.41341,-0.31249 1.02865,-0.46874 1.84571,-0.46875 l 1.25976,0 0,-0.0879 c 0,-0.4134 -0.13672,-0.73242 -0.41015,-0.95703 -0.27019,-0.22786 -0.65105,-0.34179 -1.14258,-0.3418 -0.3125,1e-5 -0.61687,0.0374 -0.91309,0.11231 -0.29622,0.0749 -0.58105,0.18718 -0.85449,0.33691 l 0,-0.83007 c 0.32877,-0.12695 0.64779,-0.22135 0.95703,-0.28321 0.30924,-0.0651 0.61035,-0.0976 0.90332,-0.0976 0.79101,0 1.38183,0.20508 1.77246,0.61523 0.39062,0.41016 0.58594,1.03191 0.58594,1.86523"
style="font-size:10px"
id="path3126" />
<path
d="m 226.50462,458.00674 c -0.48177,1e-5 -0.86263,0.18881 -1.14257,0.56641 -0.27995,0.37435 -0.41993,0.88868 -0.41993,1.54297 0,0.6543 0.13835,1.17025 0.41504,1.54785 0.27995,0.37435 0.66243,0.56153 1.14746,0.56152 0.47852,1e-5 0.85775,-0.1888 1.1377,-0.5664 0.27994,-0.3776 0.41992,-0.89193 0.41992,-1.54297 0,-0.64778 -0.13998,-1.16048 -0.41992,-1.53809 -0.27995,-0.38085 -0.65918,-0.57128 -1.1377,-0.57129 m 0,-0.76171 c 0.78125,0 1.39486,0.25391 1.84082,0.76171 0.44596,0.50782 0.66894,1.21095 0.66895,2.10938 -1e-5,0.89518 -0.22299,1.59831 -0.66895,2.10937 -0.44596,0.50782 -1.05957,0.76172 -1.84082,0.76172 -0.7845,0 -1.39974,-0.2539 -1.8457,-0.76172 -0.44271,-0.51106 -0.66406,-1.21419 -0.66406,-2.10937 0,-0.89843 0.22135,-1.60156 0.66406,-2.10938 0.44596,-0.5078 1.0612,-0.76171 1.8457,-0.76171"
style="font-size:10px"
id="path3128" />
<path
d="m 233.66771,458.21671 c -0.10092,-0.0586 -0.21159,-0.10091 -0.33203,-0.12696 -0.11719,-0.0293 -0.2474,-0.0439 -0.39063,-0.0439 -0.50781,0 -0.89844,0.16602 -1.17187,0.49804 -0.27019,0.32878 -0.40528,0.80242 -0.40528,1.4209 l 0,2.88086 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33203 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0146 0.0749,0.007 0.15788,0.0179 0.24903,0.0342 l 0.005,0.92286"
style="font-size:10px"
id="path3130" />
<path
d="m 234.61986,457.37686 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3132" />
<path
d="m 240.99193,460.04776 c -1e-5,-0.65104 -0.1351,-1.15559 -0.40528,-1.51367 -0.26693,-0.35807 -0.6429,-0.53711 -1.12793,-0.53711 -0.48177,0 -0.85774,0.17904 -1.12792,0.53711 -0.26693,0.35808 -0.4004,0.86263 -0.4004,1.51367 0,0.64779 0.13347,1.15072 0.4004,1.50879 0.27018,0.35807 0.64615,0.53711 1.12792,0.53711 0.48503,0 0.861,-0.17904 1.12793,-0.53711 0.27018,-0.35807 0.40527,-0.861 0.40528,-1.50879 m 0.89844,2.11914 c -1e-5,0.93099 -0.20672,1.62272 -0.62012,2.0752 -0.41342,0.45572 -1.04655,0.68359 -1.89942,0.68359 -0.31575,0 -0.6136,-0.0244 -0.89355,-0.0732 -0.27995,-0.0456 -0.55176,-0.11719 -0.81543,-0.21485 l 0,-0.87402 c 0.26367,0.14323 0.52409,0.24902 0.78125,0.31738 0.25716,0.0684 0.5192,0.10254 0.78613,0.10254 0.58919,0 1.03027,-0.15462 1.32324,-0.46386 0.29297,-0.306 0.43945,-0.76986 0.43946,-1.39161 l 0,-0.44433 c -0.18555,0.32226 -0.42318,0.56315 -0.71289,0.72265 -0.28972,0.15951 -0.6364,0.23926 -1.04004,0.23926 -0.67058,0 -1.21094,-0.25553 -1.6211,-0.7666 -0.41015,-0.51107 -0.61523,-1.18815 -0.61523,-2.03125 0,-0.84635 0.20508,-1.52506 0.61523,-2.03613 0.41016,-0.51107 0.95052,-0.7666 1.6211,-0.7666 0.40364,0 0.75032,0.0797 1.04004,0.23925 0.28971,0.15951 0.52734,0.4004 0.71289,0.72266 l 0,-0.83008 0.89844,0 0,4.79004"
style="font-size:10px"
id="path3134" />
<path
d="m 243.74095,457.37686 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3136" />
<path
d="m 251.06029,459.54483 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51758 -0.10092,-0.90495 -0.30273,-1.16211 -0.20183,-0.25716 -0.50457,-0.38574 -0.90821,-0.38574 -0.48503,0 -0.86751,0.15462 -1.14746,0.46386 -0.27995,0.30925 -0.41992,0.7308 -0.41992,1.26465 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29296,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19531 1.42578,0.58593 0.32226,0.38738 0.48339,0.95867 0.4834,1.71387"
style="font-size:10px"
id="path3138" />
</g>
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text3017">
<path
d="m 367.17007,356.71783 -2.7832,-7.29003 1.03027,0 2.30958,6.13769 2.31445,-6.13769 1.02539,0 -2.77832,7.29003 -1.11817,0"
style="font-size:10px"
id="path3242" />
<path
d="m 371.87222,351.24908 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3244" />
<path
d="m 377.81461,352.08893 c -0.10092,-0.0586 -0.2116,-0.10091 -0.33204,-0.12695 -0.11719,-0.0293 -0.24739,-0.0439 -0.39062,-0.0439 -0.50782,0 -0.89844,0.16602 -1.17188,0.49805 -0.27018,0.32878 -0.40527,0.80241 -0.40527,1.4209 l 0,2.88085 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0146 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3246" />
<path
d="m 379.65543,349.69635 0,1.55273 1.85058,0 0,0.69825 -1.85058,0 0,2.96875 c -1e-5,0.44596 0.0602,0.73242 0.18066,0.85937 0.1237,0.12696 0.37272,0.19043 0.74707,0.19043 l 0.92285,0 0,0.75195 -0.92285,0 c -0.69336,0 -1.17188,-0.12858 -1.43555,-0.38574 -0.26367,-0.26041 -0.39551,-0.73242 -0.3955,-1.41601 l 0,-2.96875 -0.65918,0 0,-0.69825 0.65918,0 0,-1.55273 0.90332,0"
style="font-size:10px"
id="path3248" />
<path
d="m 382.59976,354.55963 0,-3.31055 0.89844,0 0,3.27637 c 0,0.51758 0.10091,0.90658 0.30273,1.16699 0.20182,0.25717 0.50456,0.38575 0.90821,0.38575 0.48502,0 0.86751,-0.15463 1.14746,-0.46387 0.2832,-0.30924 0.4248,-0.73079 0.4248,-1.26465 l 0,-3.10059 0.89844,0 0,5.46875 -0.89844,0 0,-0.83984 c -0.2181,0.33203 -0.47201,0.57943 -0.76172,0.74219 -0.28646,0.1595 -0.62012,0.23926 -1.00097,0.23926 -0.62826,0 -1.10515,-0.19532 -1.43067,-0.58594 -0.32552,-0.39063 -0.48828,-0.96191 -0.48828,-1.71387 m 2.26074,-3.44238 0,0"
style="font-size:10px"
id="path3250" />
<path
d="m 391.52554,353.96881 c -0.72591,0 -1.22884,0.083 -1.50879,0.24902 -0.27995,0.16602 -0.41992,0.44923 -0.41992,0.84961 0,0.31902 0.10417,0.57292 0.3125,0.76172 0.21159,0.18555 0.49805,0.27832 0.85938,0.27832 0.49804,0 0.8968,-0.17578 1.19629,-0.52734 0.30273,-0.35482 0.45409,-0.82519 0.4541,-1.41113 l 0,-0.2002 -0.89356,0 m 1.792,-0.37109 0,3.12011 -0.89844,0 0,-0.83007 c -0.20508,0.33203 -0.46062,0.5778 -0.7666,0.7373 -0.306,0.15625 -0.68035,0.23438 -1.12305,0.23438 -0.5599,0 -1.00586,-0.15625 -1.33789,-0.46875 -0.32878,-0.31576 -0.49317,-0.73731 -0.49317,-1.26465 0,-0.61523 0.20508,-1.0791 0.61524,-1.3916 0.41341,-0.3125 1.02864,-0.46875 1.8457,-0.46875 l 1.25977,0 0,-0.0879 c -1e-5,-0.41341 -0.13673,-0.73242 -0.41016,-0.95704 -0.27018,-0.22786 -0.65104,-0.34179 -1.14258,-0.34179 -0.3125,0 -0.61686,0.0374 -0.91308,0.1123 -0.29623,0.0749 -0.58106,0.18718 -0.85449,0.33692 l 0,-0.83008 c 0.32877,-0.12695 0.64778,-0.22135 0.95703,-0.28321 0.30924,-0.0651 0.61035,-0.0976 0.90332,-0.0976 0.79101,0 1.38183,0.20508 1.77246,0.61523 0.39062,0.41016 0.58593,1.03191 0.58594,1.86524"
style="font-size:10px"
id="path3252" />
<path
d="m 395.173,349.12018 0.89844,0 0,7.59765 -0.89844,0 0,-7.59765"
style="font-size:10px"
id="path3254" />
<path
d="m 404.61636,351.41022 0,0.84961 c -0.25391,-0.13021 -0.51758,-0.22786 -0.79101,-0.29297 -0.27344,-0.0651 -0.55665,-0.0976 -0.84961,-0.0977 -0.44597,1e-5 -0.78125,0.0684 -1.00586,0.20508 -0.22136,0.13672 -0.33203,0.3418 -0.33203,0.61523 0,0.20834 0.0797,0.37273 0.23926,0.49317 0.1595,0.11719 0.48014,0.22949 0.96191,0.33691 l 0.30762,0.0684 c 0.63801,0.13672 1.09049,0.33041 1.35742,0.58106 0.27018,0.24739 0.40527,0.59407 0.40527,1.04004 0,0.50781 -0.20183,0.90983 -0.60547,1.20605 -0.40039,0.29622 -0.95215,0.44434 -1.65527,0.44434 -0.29297,0 -0.59896,-0.0293 -0.91797,-0.0879 -0.31576,-0.0553 -0.64941,-0.13998 -1.00098,-0.25391 l 0,-0.92774 c 0.33204,0.17253 0.65918,0.30274 0.98145,0.39063 0.32226,0.0846 0.64127,0.12695 0.95703,0.12695 0.42318,0 0.7487,-0.0716 0.97656,-0.21484 0.22786,-0.14648 0.3418,-0.35156 0.3418,-0.61524 0,-0.24413 -0.083,-0.43131 -0.24902,-0.56152 -0.16277,-0.1302 -0.52247,-0.25553 -1.0791,-0.37598 l -0.3125,-0.0732 c -0.55665,-0.11718 -0.95866,-0.29622 -1.20606,-0.53711 -0.2474,-0.24413 -0.37109,-0.57779 -0.37109,-1.00097 0,-0.51432 0.18229,-0.91146 0.54687,-1.19141 0.36458,-0.27994 0.88216,-0.41992 1.55274,-0.41992 0.33202,0 0.64452,0.0244 0.9375,0.0732 0.29296,0.0488 0.56314,0.12208 0.81054,0.21973"
style="font-size:10px"
id="path3256" />
<path
d="m 410.28043,351.45905 0,0.83984 c -0.25391,-0.13997 -0.50945,-0.24414 -0.76661,-0.3125 -0.25391,-0.0716 -0.51107,-0.10742 -0.77148,-0.10742 -0.58268,0 -1.03516,0.18555 -1.35742,0.55664 -0.32227,0.36784 -0.4834,0.88542 -0.4834,1.55273 0,0.66732 0.16113,1.18653 0.4834,1.55762 0.32226,0.36784 0.77474,0.55176 1.35742,0.55176 0.26041,0 0.51757,-0.0342 0.77148,-0.10254 0.25716,-0.0716 0.5127,-0.17741 0.76661,-0.31738 l 0,0.83007 c -0.25066,0.11719 -0.51108,0.20508 -0.78125,0.26368 -0.26693,0.0586 -0.55177,0.0879 -0.8545,0.0879 -0.82357,0 -1.47786,-0.25879 -1.96289,-0.77637 -0.48502,-0.51758 -0.72754,-1.21582 -0.72754,-2.09473 0,-0.89192 0.24414,-1.59342 0.73243,-2.10449 0.49153,-0.51106 1.16373,-0.7666 2.0166,-0.7666 0.27669,0 0.54687,0.0293 0.81054,0.0879 0.26367,0.0553 0.51921,0.13998 0.76661,0.25391"
style="font-size:10px"
id="path3258" />
<path
d="m 415.02164,352.08893 c -0.10092,-0.0586 -0.2116,-0.10091 -0.33203,-0.12695 -0.1172,-0.0293 -0.2474,-0.0439 -0.39063,-0.0439 -0.50781,0 -0.89844,0.16602 -1.17187,0.49805 -0.27019,0.32878 -0.40528,0.80241 -0.40528,1.4209 l 0,2.88085 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0146 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3260" />
<path
d="m 420.43668,353.75885 0,0.43945 -4.13086,0 c 0.0391,0.61849 0.2246,1.0905 0.55664,1.41602 0.33528,0.32227 0.80078,0.4834 1.39648,0.4834 0.34505,0 0.67871,-0.0423 1.00098,-0.12696 0.32551,-0.0846 0.64778,-0.21158 0.9668,-0.38086 l 0,0.84961 c -0.32228,0.13672 -0.65268,0.24089 -0.99122,0.3125 -0.33854,0.0716 -0.68197,0.10743 -1.03027,0.10743 -0.8724,0 -1.56413,-0.25391 -2.07519,-0.76172 -0.50782,-0.50781 -0.76172,-1.19466 -0.76172,-2.06055 0,-0.89518 0.24088,-1.60481 0.72265,-2.12891 0.48503,-0.52733 1.1377,-0.79101 1.95801,-0.79101 0.73567,0 1.31673,0.23763 1.74316,0.71289 0.42969,0.47201 0.64453,1.11491 0.64454,1.92871 m -0.89844,-0.26367 c -0.007,-0.49153 -0.14486,-0.88379 -0.41504,-1.17676 -0.26693,-0.29296 -0.62175,-0.43945 -1.06445,-0.43945 -0.50131,0 -0.90333,0.1416 -1.20606,0.4248 -0.29948,0.28321 -0.47201,0.68197 -0.51758,1.19629 l 3.20313,-0.005"
style="font-size:10px"
id="path3262" />
<path
d="m 426.58902,353.75885 0,0.43945 -4.13086,0 c 0.0391,0.61849 0.22461,1.0905 0.55664,1.41602 0.33529,0.32227 0.80078,0.4834 1.39649,0.4834 0.34504,0 0.6787,-0.0423 1.00097,-0.12696 0.32552,-0.0846 0.64778,-0.21158 0.9668,-0.38086 l 0,0.84961 c -0.32227,0.13672 -0.65268,0.24089 -0.99121,0.3125 -0.33855,0.0716 -0.68197,0.10743 -1.03028,0.10743 -0.87239,0 -1.56412,-0.25391 -2.07519,-0.76172 -0.50781,-0.50781 -0.76172,-1.19466 -0.76172,-2.06055 0,-0.89518 0.24089,-1.60481 0.72266,-2.12891 0.48502,-0.52733 1.13769,-0.79101 1.958,-0.79101 0.73568,0 1.31673,0.23763 1.74317,0.71289 0.42968,0.47201 0.64452,1.11491 0.64453,1.92871 m -0.89844,-0.26367 c -0.007,-0.49153 -0.14486,-0.88379 -0.41504,-1.17676 -0.26693,-0.29296 -0.62175,-0.43945 -1.06445,-0.43945 -0.5013,0 -0.90332,0.1416 -1.20605,0.4248 -0.29949,0.28321 -0.47201,0.68197 -0.51758,1.19629 l 3.20312,-0.005"
style="font-size:10px"
id="path3264" />
<path
d="m 432.60953,353.41705 0,3.30078 -0.89844,0 0,-3.27148 c 0,-0.51757 -0.10092,-0.90494 -0.30273,-1.16211 -0.20183,-0.25716 -0.50457,-0.38574 -0.90821,-0.38574 -0.48503,0 -0.86751,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41992,0.73079 -0.41992,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75684,-0.7373 0.29296,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62825,0 1.10351,0.19532 1.42578,0.58594 0.32226,0.38737 0.48339,0.95866 0.4834,1.71386"
style="font-size:10px"
id="path3266" />
<path
d="m 439.71402,351.87897 c -0.48177,0 -0.86263,0.1888 -1.14258,0.5664 -0.27995,0.37436 -0.41992,0.88868 -0.41992,1.54297 0,0.6543 0.13834,1.17025 0.41504,1.54785 0.27994,0.37435 0.66243,0.56153 1.14746,0.56153 0.47851,0 0.85774,-0.1888 1.1377,-0.56641 0.27994,-0.3776 0.41991,-0.89192 0.41992,-1.54297 -10e-6,-0.64778 -0.13998,-1.16048 -0.41992,-1.53808 -0.27996,-0.38086 -0.65919,-0.57129 -1.1377,-0.57129 m 0,-0.76172 c 0.78125,0 1.39485,0.25391 1.84082,0.76172 0.44596,0.50781 0.66894,1.21094 0.66895,2.10937 -1e-5,0.89519 -0.22299,1.59831 -0.66895,2.10938 -0.44597,0.50781 -1.05957,0.76172 -1.84082,0.76172 -0.78451,0 -1.39974,-0.25391 -1.8457,-0.76172 -0.44271,-0.51107 -0.66407,-1.21419 -0.66407,-2.10938 0,-0.89843 0.22136,-1.60156 0.66407,-2.10937 0.44596,-0.50781 1.06119,-0.76172 1.8457,-0.76172"
style="font-size:10px"
id="path3268" />
<path
d="m 446.87711,352.08893 c -0.10092,-0.0586 -0.2116,-0.10091 -0.33204,-0.12695 -0.11719,-0.0293 -0.24739,-0.0439 -0.39062,-0.0439 -0.50782,0 -0.89844,0.16602 -1.17188,0.49805 -0.27018,0.32878 -0.40527,0.80241 -0.40527,1.4209 l 0,2.88085 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.1888,-0.33202 0.43457,-0.57779 0.73731,-0.7373 0.30273,-0.16276 0.67057,-0.24414 1.10351,-0.24414 0.0618,0 0.13021,0.005 0.20508,0.0146 0.0749,0.007 0.15787,0.0179 0.24902,0.0342 l 0.005,0.92285"
style="font-size:10px"
id="path3270" />
<path
d="m 447.82925,351.24908 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3272" />
<path
d="m 454.20132,353.91998 c 0,-0.65104 -0.13509,-1.15559 -0.40527,-1.51367 -0.26693,-0.35807 -0.64291,-0.5371 -1.12793,-0.53711 -0.48177,1e-5 -0.85775,0.17904 -1.12793,0.53711 -0.26693,0.35808 -0.40039,0.86263 -0.40039,1.51367 0,0.64779 0.13346,1.15072 0.40039,1.50879 0.27018,0.35808 0.64616,0.53711 1.12793,0.53711 0.48502,0 0.861,-0.17903 1.12793,-0.53711 0.27018,-0.35807 0.40527,-0.861 0.40527,-1.50879 m 0.89844,2.11914 c 0,0.93099 -0.20671,1.62272 -0.62012,2.0752 -0.41341,0.45573 -1.04655,0.68359 -1.89941,0.68359 -0.31576,0 -0.61361,-0.0244 -0.89355,-0.0732 -0.27995,-0.0456 -0.55176,-0.11719 -0.81543,-0.21484 l 0,-0.87403 c 0.26367,0.14323 0.52408,0.24903 0.78125,0.31739 0.25716,0.0684 0.5192,0.10253 0.78613,0.10254 0.58919,-10e-6 1.03027,-0.15463 1.32324,-0.46387 0.29297,-0.30599 0.43945,-0.76986 0.43945,-1.3916 l 0,-0.44434 c -0.18555,0.32227 -0.42318,0.56315 -0.71289,0.72266 -0.28971,0.1595 -0.63639,0.23925 -1.04004,0.23925 -0.67057,0 -1.21093,-0.25553 -1.62109,-0.7666 -0.41016,-0.51106 -0.61523,-1.18815 -0.61523,-2.03125 0,-0.84635 0.20507,-1.52506 0.61523,-2.03613 0.41016,-0.51106 0.95052,-0.7666 1.62109,-0.7666 0.40365,0 0.75033,0.0798 1.04004,0.23926 0.28971,0.15951 0.52734,0.40039 0.71289,0.72265 l 0,-0.83008 0.89844,0 0,4.79004"
style="font-size:10px"
id="path3274" />
<path
d="m 456.95035,351.24908 0.89844,0 0,5.46875 -0.89844,0 0,-5.46875 m 0,-2.1289 0.89844,0 0,1.13769 -0.89844,0 0,-1.13769"
style="font-size:10px"
id="path3276" />
<path
d="m 464.26968,353.41705 0,3.30078 -0.89843,0 0,-3.27148 c -10e-6,-0.51757 -0.10092,-0.90494 -0.30274,-1.16211 -0.20183,-0.25716 -0.50456,-0.38574 -0.9082,-0.38574 -0.48503,0 -0.86752,0.15463 -1.14746,0.46387 -0.27995,0.30924 -0.41993,0.73079 -0.41992,1.26464 l 0,3.09082 -0.90332,0 0,-5.46875 0.90332,0 0,0.84961 c 0.21484,-0.32877 0.46712,-0.57454 0.75683,-0.7373 0.29297,-0.16276 0.62988,-0.24414 1.01074,-0.24414 0.62826,0 1.10352,0.19532 1.42579,0.58594 0.32226,0.38737 0.48339,0.95866 0.48339,1.71386"
style="font-size:10px"
id="path3278" />
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
d="m 343.73692,26.224389 0.01,294.941191"
id="path3861"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc"
transform="translate(12.627039,339.86462)" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4307"
d="m 356.48533,366.00457 336.31202,-0.0196"
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend);stroke-miterlimit:4;stroke-dasharray:none" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4309"
d="m 159.89916,447.6257 -0.0625,145.00422"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend)"
d="m 160.03997,448.23877 184.95568,-0.0159"
id="path4493"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<g
style="font-size:12px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
id="text4495">
<path
d="m 228.57881,442.02737 0.49805,0 0.7666,3.08106 0.76416,-3.08106 0.5542,0 0.7666,3.08106 0.76416,-3.08106 0.50049,0 -0.91553,3.64502 -0.62012,0 -0.76904,-3.16406 -0.77637,3.16406 -0.62011,0 -0.91309,-3.64502"
style="font-size:5px"
id="path3141" />
<path
d="m 233.71797,442.93802 0.44922,0 0,2.73437 -0.44922,0 0,-2.73437 m 0,-1.06445 0.44922,0 0,0.56884 -0.44922,0 0,-0.56884"
style="font-size:5px"
id="path3143" />
<path
d="m 237.37764,444.022 0,1.65039 -0.44922,0 0,-1.63574 c 0,-0.25879 -0.0505,-0.45247 -0.15137,-0.58105 -0.10091,-0.12858 -0.25228,-0.19287 -0.4541,-0.19287 -0.24251,0 -0.43376,0.0773 -0.57373,0.23193 -0.13997,0.15462 -0.20996,0.3654 -0.20996,0.63232 l 0,1.54541 -0.45166,0 0,-2.73437 0.45166,0 0,0.4248 c 0.10742,-0.16438 0.23356,-0.28727 0.37842,-0.36865 0.14648,-0.0814 0.31494,-0.12207 0.50537,-0.12207 0.31413,0 0.55176,0.0977 0.71289,0.29297 0.16113,0.19369 0.2417,0.47933 0.2417,0.85693"
style="font-size:5px"
id="path3145" />
<path
d="m 240.07784,443.35306 0,-1.47949 0.44921,0 0,3.79882 -0.44921,0 0,-0.41015 c -0.0944,0.16276 -0.21404,0.28401 -0.35889,0.36377 -0.14323,0.0781 -0.31576,0.11718 -0.51758,0.11718 -0.3304,0 -0.59977,-0.13183 -0.80811,-0.3955 -0.2067,-0.26367 -0.31005,-0.61035 -0.31005,-1.04004 0,-0.42969 0.10335,-0.77637 0.31005,-1.04004 0.20834,-0.26367 0.47771,-0.39551 0.80811,-0.39551 0.20182,0 0.37435,0.0399 0.51758,0.11963 0.14485,0.0781 0.26448,0.19857 0.35889,0.36133 m -1.53077,0.95459 c 0,0.3304 0.0676,0.59 0.20264,0.77881 0.13672,0.18717 0.32389,0.28076 0.56152,0.28076 0.23763,0 0.42481,-0.0936 0.56153,-0.28076 0.13671,-0.18881 0.20507,-0.44841 0.20508,-0.77881 -1e-5,-0.3304 -0.0684,-0.58919 -0.20508,-0.77637 -0.13672,-0.1888 -0.3239,-0.2832 -0.56153,-0.2832 -0.23763,0 -0.4248,0.0944 -0.56152,0.2832 -0.13509,0.18718 -0.20264,0.44597 -0.20264,0.77637"
style="font-size:5px"
id="path3147" />
<path
d="m 242.51192,443.25296 c -0.24089,0 -0.43132,0.0944 -0.57129,0.2832 -0.13998,0.18718 -0.20996,0.44434 -0.20996,0.77149 0,0.32715 0.0692,0.58512 0.20752,0.77392 0.13997,0.18718 0.33121,0.28077 0.57373,0.28077 0.23925,0 0.42887,-0.0944 0.56884,-0.28321 0.13998,-0.1888 0.20996,-0.44596 0.20997,-0.77148 -1e-5,-0.32389 -0.07,-0.58024 -0.20997,-0.76905 -0.13997,-0.19042 -0.32959,-0.28564 -0.56884,-0.28564 m 0,-0.38086 c 0.39062,0 0.69742,0.12696 0.92041,0.38086 0.22298,0.25391 0.33447,0.60547 0.33447,1.05469 0,0.44759 -0.11149,0.79915 -0.33447,1.05469 -0.22299,0.2539 -0.52979,0.38085 -0.92041,0.38085 -0.39226,0 -0.69987,-0.12695 -0.92285,-0.38085 -0.22136,-0.25554 -0.33204,-0.6071 -0.33204,-1.05469 0,-0.44922 0.11068,-0.80078 0.33204,-1.05469 0.22298,-0.2539 0.53059,-0.38086 0.92285,-0.38086"
style="font-size:5px"
id="path3149" />
<path
d="m 244.24776,442.93802 0.44922,0 0.56152,2.13379 0.55908,-2.13379 0.52979,0 0.56152,2.13379 0.55908,-2.13379 0.44922,0 -0.71533,2.73437 -0.52979,0 -0.58838,-2.24121 -0.59082,2.24121 -0.52978,0 -0.71533,-2.73437"
style="font-size:5px"
id="path3151" />
<path
d="m 249.70674,442.02737 3.0835,0 0,0.41504 -1.29395,0 0,3.22998 -0.4956,0 0,-3.22998 -1.29395,0 0,-0.41504"
style="font-size:5px"
id="path3153" />
<path
d="m 253.09297,442.93802 0.44922,0 0,2.73437 -0.44922,0 0,-2.73437 m 0,-1.06445 0.44922,0 0,0.56884 -0.44922,0 0,-0.56884"
style="font-size:5px"
id="path3155" />
<path
d="m 254.92403,442.16165 0,0.77637 0.92529,0 0,0.34912 -0.92529,0 0,1.48437 c 0,0.22299 0.0301,0.36622 0.0903,0.42969 0.0618,0.0635 0.18636,0.0952 0.37353,0.0952 l 0.46143,0 0,0.37597 -0.46143,0 c -0.34668,0 -0.58593,-0.0643 -0.71777,-0.19287 -0.13184,-0.13021 -0.19775,-0.36621 -0.19775,-0.70801 l 0,-1.48437 -0.32959,0 0,-0.34912 0.32959,0 0,-0.77637 0.45166,0"
style="font-size:5px"
id="path3157" />
<path
d="m 256.44258,441.87357 0.44922,0 0,3.79882 -0.44922,0 0,-3.79882"
style="font-size:5px"
id="path3159" />
<path
d="m 260.16817,444.1929 0,0.21973 -2.06543,0 c 0.0195,0.30924 0.1123,0.54525 0.27832,0.70801 0.16764,0.16113 0.40039,0.2417 0.69824,0.2417 0.17252,0 0.33935,-0.0212 0.50049,-0.0635 0.16276,-0.0423 0.32389,-0.1058 0.4834,-0.19043 l 0,0.4248 c -0.16114,0.0684 -0.32634,0.12045 -0.49561,0.15625 -0.16927,0.0358 -0.34098,0.0537 -0.51514,0.0537 -0.43619,0 -0.78206,-0.12695 -1.03759,-0.38085 -0.25391,-0.25391 -0.38086,-0.59733 -0.38086,-1.03028 0,-0.44759 0.12044,-0.8024 0.36133,-1.06445 0.24251,-0.26367 0.56884,-0.39551 0.979,-0.39551 0.36784,0 0.65836,0.11882 0.87158,0.35645 0.21484,0.236 0.32226,0.55745 0.32227,0.96435 m -0.44922,-0.13183 c -0.003,-0.24577 -0.0724,-0.4419 -0.20752,-0.58838 -0.13347,-0.14649 -0.31088,-0.21973 -0.53223,-0.21973 -0.25065,0 -0.45166,0.0708 -0.60303,0.2124 -0.14974,0.14161 -0.236,0.34099 -0.25878,0.59815 l 1.60156,-0.002"
style="font-size:5px"
id="path3161" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 109 KiB

View File

@ -1,803 +0,0 @@
/*!
@page window Window guide
@tableofcontents
This guide introduces the window related functions of GLFW. There are also
guides for the other areas of GLFW.
- @ref intro
- @ref context
- @ref monitor
- @ref input
@section window_object Window objects
The @ref GLFWwindow object encapsulates both a window and a context. They are
created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or
@ref glfwTerminate, if any remain. As the window and context are inseparably
linked, the object pointer is used as both a context and window handle.
To see the event stream provided to the various window related callbacks, run
the `events` test program.
@subsection window_creation Window creation
A window and its OpenGL or OpenGL ES context are created with @ref
glfwCreateWindow, which returns a handle to the created window object. For
example, this creates a 640 by 480 windowed mode window:
@code
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
@endcode
If window creation fails, `NULL` will be returned, so it is necessary to check
the return value.
The window handle is passed to all window related functions and is provided to
along with all input events, so event handlers can tell which window received
the event.
@subsubsection window_full_screen Full screen windows
To create a full screen window, you need to specify which monitor the window
should use. In most cases, the user's primary monitor is a good choice.
For more information about retrieving monitors, see @ref monitor_monitors.
@code
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL);
@endcode
Full screen windows cover the entire display area of a monitor, have no border
or decorations.
Each field of the @ref GLFWvidmode structure corresponds to a function parameter
or window hint and combine to form the _desired video mode_ for that window.
The supported video mode most closely matching the desired video mode will be
set for the chosen monitor as long as the window has input focus. For more
information about retrieving video modes, see @ref monitor_modes.
Video mode field | Corresponds to
----------------------- | ------------------------
GLFWvidmode.width | `width` parameter
GLFWvidmode.height | `height` parameter
GLFWvidmode.redBits | `GLFW_RED_BITS` hint
GLFWvidmode.greenBits | `GLFW_GREEN_BITS` hint
GLFWvidmode.blueBits | `GLFW_BLUE_BITS` hint
GLFWvidmode.refreshRate | `GLFW_REFRESH_RATE` hint
Once you have a full screen window, you can change its resolution with @ref
glfwSetWindowSize. The new video mode will be selected and set the same way as
the video mode chosen by @ref glfwCreateWindow.
By default, the original video mode of the monitor will be restored and the
window iconified if it loses input focus, to allow the user to switch back to
the desktop. This behavior can be disabled with the `GLFW_AUTO_ICONIFY` window
hint, for example if you wish to simultaneously cover multiple windows with full
screen windows.
@subsubsection window_windowed_full_screen "Windowed full screen" windows
To create a so called _windowed full screen_ or _borderless full screen_ window,
i.e. a full screen window that doesn't change the video mode of the monitor, you
need to request the current video mode of the chosen monitor.
@code
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", monitor, NULL);
@endcode
GLFW will detect this and will not perform any mode setting for that window.
@subsection window_destruction Window destruction
When a window is no longer needed, destroy it with @ref glfwDestroyWindow.
@code
glfwDestroyWindow(window);
@endcode
Window destruction always succeeds. Before the actual destruction, all
callbacks are removed so no further events will be delivered for the window.
All windows remaining when @ref glfwTerminate is called are destroyed as well.
When a full screen window is destroyed, the original video mode of its monitor
is restored, but the gamma ramp is left untouched.
@subsection window_hints Window creation hints
There are a number of hints that can be set before the creation of a window and
context. Some affect the window itself, others affect the framebuffer or
context. These hints are set to their default values each time the library is
initialized with @ref glfwInit, can be set individually with @ref glfwWindowHint
and reset all at once to their defaults with @ref glfwDefaultWindowHints.
Note that hints need to be set _before_ the creation of the window and context
you wish to have the specified attributes.
@subsubsection window_hints_hard Hard and soft constraints
Some window hints are hard constraints. These must match the available
capabilities _exactly_ for window and context creation to succeed. Hints
that are not hard constraints are matched as closely as possible, but the
resulting window and context may differ from what these hints requested. To
find out the actual attributes of the created window and context, use the
@ref glfwGetWindowAttrib function.
The following hints are always hard constraints:
- `GLFW_STEREO`
- `GLFW_DOUBLEBUFFER`
- `GLFW_CLIENT_API`
The following additional hints are hard constraints when requesting an OpenGL
context, but are ignored when requesting an OpenGL ES context:
- `GLFW_OPENGL_FORWARD_COMPAT`
- `GLFW_OPENGL_PROFILE`
@subsubsection window_hints_wnd Window related hints
`GLFW_RESIZABLE` specifies whether the (windowed mode) window will be resizable
_by the user_. The window will still be resizable using the @ref
glfwSetWindowSize function. This hint is ignored for full screen windows.
`GLFW_VISIBLE` specifies whether the (windowed mode) window will be initially
visible. This hint is ignored for full screen windows.
`GLFW_DECORATED` specifies whether the (windowed mode) window will have window
decorations such as a border, a close widget, etc. This hint is ignored for
full screen windows. Note that even though a window may lack a close widget, it
is usually still possible for the user to generate close events.
`GLFW_FOCUSED` specifies whether the (windowed mode) window will be given input
focus when created. This hint is ignored for full screen and initially hidden
windows.
`GLFW_AUTO_ICONIFY` specifies whether the (full screen) window will
automatically iconify and restore the previous video mode on input focus loss.
This hint is ignored for windowed mode windows.
`GLFW_FLOATING` specifies whether the window will be floating above other
regular windows, also called topmost or always-on-top. This is intended
primarily for debugging purposes and cannot be used to implement proper full
screen windows. This hint is ignored for full screen windows.
@subsubsection window_hints_fb Framebuffer related hints
`GLFW_RED_BITS`, `GLFW_GREEN_BITS`, `GLFW_BLUE_BITS`, `GLFW_ALPHA_BITS`,
`GLFW_DEPTH_BITS` and `GLFW_STENCIL_BITS` specify the desired bit depths of the
various components of the default framebuffer. `GLFW_DONT_CARE` means the
application has no preference.
`GLFW_ACCUM_RED_BITS`, `GLFW_ACCUM_GREEN_BITS`, `GLFW_ACCUM_BLUE_BITS` and
`GLFW_ACCUM_ALPHA_BITS` specify the desired bit depths of the various components
of the accumulation buffer. `GLFW_DONT_CARE` means the application has no
preference.
@par
Accumulation buffers are a legacy OpenGL feature and should not be used in new
code.
`GLFW_AUX_BUFFERS` specifies the desired number of auxiliary buffers.
`GLFW_DONT_CARE` means the application has no preference.
@par
Auxiliary buffers are a legacy OpenGL feature and should not be used in new
code.
`GLFW_STEREO` specifies whether to use stereoscopic rendering. This is a hard
constraint.
`GLFW_SAMPLES` specifies the desired number of samples to use for multisampling.
Zero disables multisampling. `GLFW_DONT_CARE` means the application has no
preference.
`GLFW_SRGB_CAPABLE` specifies whether the framebuffer should be sRGB capable.
`GLFW_DOUBLEBUFFER` specifies whether the framebuffer should be double buffered.
You nearly always want to use double buffering. This is a hard constraint.
@subsubsection window_hints_mtr Monitor related hints
`GLFW_REFRESH_RATE` specifies the desired refresh rate for full screen windows.
If set to `GLFW_DONT_CARE`, the highest available refresh rate will be used.
This hint is ignored for windowed mode windows.
@subsubsection window_hints_ctx Context related hints
`GLFW_CLIENT_API` specifies which client API to create the context for.
Possible values are `GLFW_OPENGL_API` and `GLFW_OPENGL_ES_API`. This is a hard
constraint.
`GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` specify the client
API version that the created context must be compatible with. The exact
behavior of these hints depend on the requested client API.
@par
__OpenGL:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` are not hard
constraints, but creation will fail if the OpenGL version of the created context
is less than the one requested. It is therefore perfectly safe to use the
default of version 1.0 for legacy code and you may still get
backwards-compatible contexts of version 3.0 and above when available.
@par
While there is no way to ask the driver for a context of the highest supported
version, GLFW will attempt to provide this when you ask for a version 1.0
context, which is the default for these hints.
@par
__OpenGL ES:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` are not hard
constraints, but creation will fail if the OpenGL ES version of the created
context is less than the one requested. Additionally, OpenGL ES 1.x cannot be
returned if 2.0 or later was requested, and vice versa. This is because OpenGL
ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward
compatible with 1.x.
`GLFW_OPENGL_FORWARD_COMPAT` specifies whether the OpenGL context should be
forward-compatible, i.e. one where all functionality deprecated in the requested
version of OpenGL is removed. This may only be used if the requested OpenGL
version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
@par
Forward-compatibility is described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).
`GLFW_OPENGL_DEBUG_CONTEXT` specifies whether to create a debug OpenGL context,
which may have additional error and performance issue reporting functionality.
If OpenGL ES is requested, this hint is ignored.
`GLFW_OPENGL_PROFILE` specifies which OpenGL profile to create the context for.
Possible values are one of `GLFW_OPENGL_CORE_PROFILE` or
`GLFW_OPENGL_COMPAT_PROFILE`, or `GLFW_OPENGL_ANY_PROFILE` to not request
a specific profile. If requesting an OpenGL version below 3.2,
`GLFW_OPENGL_ANY_PROFILE` must be used. If another OpenGL ES is requested,
this hint is ignored.
@par
OpenGL profiles are described in detail in the
[OpenGL Reference Manual](https://www.opengl.org/registry/).
`GLFW_CONTEXT_ROBUSTNESS` specifies the robustness strategy to be used by the
context. This can be one of `GLFW_NO_RESET_NOTIFICATION` or
`GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request
a robustness strategy.
`GLFW_CONTEXT_RELEASE_BEHAVIOR` specifies the release behavior to be
used by the context. Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
the pipeline will be flushed whenever the context is released from being the
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
not be flushed on release.
@par
Context release behaviors are described in detail by the
[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
extension.
@subsubsection window_hints_values Supported and default values
Window hint | Default value | Supported values
------------------------------- | --------------------------- | ----------------
`GLFW_RESIZABLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_VISIBLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_DECORATED` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_FOCUSED` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_AUTO_ICONIFY` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_FLOATING` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE`
`GLFW_RED_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_GREEN_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_BLUE_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_ALPHA_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_DEPTH_BITS` | 24 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_STENCIL_BITS` | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_ACCUM_RED_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_ACCUM_GREEN_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_ACCUM_BLUE_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_ACCUM_ALPHA_BITS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_AUX_BUFFERS` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_SAMPLES` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_REFRESH_RATE` | `GLFW_DONT_CARE` | 0 to `INT_MAX` or `GLFW_DONT_CARE`
`GLFW_STEREO` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE`
`GLFW_SRGB_CAPABLE` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE`
`GLFW_DOUBLEBUFFER` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE`
`GLFW_CLIENT_API` | `GLFW_OPENGL_API` | `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`
`GLFW_CONTEXT_VERSION_MAJOR` | 1 | Any valid major version number of the chosen client API
`GLFW_CONTEXT_VERSION_MINOR` | 0 | Any valid minor version number of the chosen client API
`GLFW_CONTEXT_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
`GLFW_CONTEXT_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
`GLFW_OPENGL_FORWARD_COMPAT` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE`
`GLFW_OPENGL_DEBUG_CONTEXT` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE`
`GLFW_OPENGL_PROFILE` | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
@section window_events Window event processing
See @ref events.
@section window_properties Window properties and events
@subsection window_userptr User pointer
Each window has a user pointer that can be set with @ref
glfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer. This
can be used for any purpose you need and will not be modified by GLFW throughout
the life-time of the window.
The initial value of the pointer is `NULL`.
@subsection window_close Window closing and close flag
When the user attempts to close the window, for example by clicking the close
widget or using a key chord like Alt+F4, the _close flag_ of the window is set.
The window is however not actually destroyed and, unless you watch for this
state change, nothing further happens.
The current state of the close flag is returned by @ref glfwWindowShouldClose
and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common
pattern is to use the close flag as a main loop condition.
@code
while (!glfwWindowShouldClose(window))
{
render(window);
glfwSwapBuffers(window);
glfwPollEvents();
}
@endcode
If you wish to be notified when the user attempts to close a window, set a close
callback.
@code
glfwSetWindowCloseCallback(window, window_close_callback);
@endcode
The callback function is called directly _after_ the close flag has been set.
It can be used for example to filter close requests and clear the close flag
again unless certain conditions are met.
@code
void window_close_callback(GLFWwindow* window)
{
if (!time_to_close)
glfwSetWindowShouldClose(window, GL_FALSE);
}
@endcode
@subsection window_size Window size
The size of a window can be changed with @ref glfwSetWindowSize. For windowed
mode windows, this sets the size, in
[screen coordinates](@ref coordinate_systems) of the _client area_ or _content
area_ of the window. The window system may impose limits on window size.
@code
glfwSetWindowSize(window, 640, 480);
@endcode
For full screen windows, the specified size becomes the new resolution of the
window's *desired video mode*. The video mode most closely matching the new
desired video mode is set immediately. The window is resized to fit the
resolution of the set video mode.
If you wish to be notified when a window is resized, whether by the user or
the system, set a size callback.
@code
glfwSetWindowSizeCallback(window, window_size_callback);
@endcode
The callback function receives the new size, in screen coordinates, of the
client area of the window when it is resized.
@code
void window_size_callback(GLFWwindow* window, int width, int height)
{
}
@endcode
There is also @ref glfwGetWindowSize for directly retrieving the current size of
a window.
@code
int width, height;
glfwGetWindowSize(window, &width, &height);
@endcode
@note Do not pass the window size to `glViewport` or other pixel-based OpenGL
calls. The window size is in screen coordinates, not pixels. Use the
[framebuffer size](@ref window_fbsize), which is in pixels, for pixel-based
calls.
The above functions work with the size of the client area, but decorated windows
typically have title bars and window frames around this rectangle. You can
retrieve the extents of these with @ref glfwGetWindowFrameSize.
@code
int left, top, right, bottom;
glfwGetWindowFrameSize(window, &left, &top, &right, &bottom);
@endcode
The returned values are the distances, in screen coordinates, from the edges of
the client area to the corresponding edges of the full window. As they are
distances and not coordinates, they are always zero or positive.
@subsection window_fbsize Framebuffer size
While the size of a window is measured in screen coordinates, OpenGL works with
pixels. The size you pass into `glViewport`, for example, should be in pixels.
On some machines screen coordinates and pixels are the same, but on others they
will not be. There is a second set of functions to retrieve the size, in
pixels, of the framebuffer of a window.
If you wish to be notified when the framebuffer of a window is resized, whether
by the user or the system, set a size callback.
@code
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
@endcode
The callback function receives the new size of the framebuffer when it is
resized, which can for example be used to update the OpenGL viewport.
@code
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
@endcode
There is also @ref glfwGetFramebufferSize for directly retrieving the current
size of the framebuffer of a window.
@code
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
@endcode
The size of a framebuffer may change independently of the size of a window, for
example if the window is dragged between a regular monitor and a high-DPI one.
@subsection window_pos Window position
The position of a windowed-mode window can be changed with @ref
glfwSetWindowPos. This moves the window so that the upper-left corner of its
client area has the specified [screen coordinates](@ref coordinate_systems).
The window system may put limitations on window placement.
@code
glfwSetWindowPos(window, 100, 100);
@endcode
If you wish to be notified when a window is moved, whether by the user, system
or your own code, set a position callback.
@code
glfwSetWindowPosCallback(window, window_pos_callback);
@endcode
The callback function receives the new position of the upper-left corner of the
client area when the window is moved.
@code
void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
{
}
@endcode
There is also @ref glfwGetWindowPos for directly retrieving the current position
of the client area of the window.
@code
int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos);
@endcode
@subsection window_title Window title
All GLFW windows have a title, although undecorated or full screen windows may
not display it or only display it in a task bar or similar interface. You can
set a UTF-8 encoded window title with @ref glfwSetWindowTitle.
@code
glfwSetWindowTitle(window, "My Window");
@endcode
The specified string is copied before the function returns, so there is no need
to keep it around.
As long as your source file is encoded as UTF-8, you can use any Unicode
characters directly in the source.
@code
glfwSetWindowTitle(window, "ヒカルの碁");
@endcode
@subsection window_monitor Window monitor
Full screen windows are associated with a specific monitor. You can get the
handle for this monitor with @ref glfwGetWindowMonitor.
@code
GLFWmonitor* monitor = glfwGetWindowMonitor(window);
@endcode
This monitor handle is one of those returned by @ref glfwGetMonitors.
For windowed mode windows, this function returns `NULL`. This is the
recommended way to tell full screen windows from windowed mode windows.
@subsection window_iconify Window iconification
Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow.
@code
glfwIconifyWindow(window);
@endcode
When a full screen window is iconified, the original video mode of its monitor
is restored until the user or application restores the window.
Iconified windows can be restored with @ref glfwRestoreWindow.
@code
glfwRestoreWindow(window);
@endcode
When a full screen window is restored, the desired video mode is restored to its
monitor as well.
If you wish to be notified when a window is iconified or restored, whether by
the user, system or your own code, set a iconify callback.
@code
glfwSetWindowIconifyCallback(window, window_iconify_callback);
@endcode
The callback function receives changes in the iconification state of the window.
@code
void window_iconify_callback(GLFWwindow* window, int iconified)
{
if (iconified)
{
// The window was iconified
}
else
{
// The window was restored
}
}
@endcode
You can also get the current iconification state with @ref glfwGetWindowAttrib.
@code
int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
@endcode
@subsection window_hide Window visibility
Windowed mode windows can be hidden with @ref glfwHideWindow.
@code
glfwHideWindow(window);
@endcode
This makes the window completely invisible to the user, including removing it
from the task bar, dock or window list. Full screen windows cannot be hidden
and calling @ref glfwHideWindow on a full screen window does nothing.
Hidden windows can be shown with @ref glfwShowWindow.
@code
glfwShowWindow(window);
@endcode
Windowed mode windows can be created initially hidden with the `GLFW_VISIBLE`
[window hint](@ref window_hints_wnd). Windows created hidden are completely
invisible to the user until shown. This can be useful if you need to set up
your window further before showing it, for example moving it to a specific
location.
You can also get the current visibility state with @ref glfwGetWindowAttrib.
@code
int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);
@endcode
@subsection window_focus Window input focus
If you wish to be notified when a window gains or loses input focus, whether by
the user, system or your own code, set a focus callback.
@code
glfwSetWindowFocusCallback(window, window_focus_callback);
@endcode
The callback function receives changes in the input focus state of the window.
@code
void window_focus_callback(GLFWwindow* window, int focused)
{
if (focused)
{
// The window gained input focus
}
else
{
// The window lost input focus
}
}
@endcode
You can also get the current input focus state with @ref glfwGetWindowAttrib.
@code
int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);
@endcode
@subsection window_refresh Window damage and refresh
If you wish to be notified when the contents of a window is damaged and needs
to be refreshed, set a window refresh callback.
@code
glfwSetWindowRefreshCallback(m_handle, window_refresh_callback);
@endcode
The callback function is called when the contents of the window needs to be
refreshed.
@code
void window_refresh_callback(GLFWwindow* window)
{
draw_editor_ui(window);
glfwSwapBuffers(window);
}
@endcode
@note On compositing window systems such as Aero, Compiz or Aqua, where the
window contents are saved off-screen, this callback might only be called when
the window or framebuffer is resized.
@subsection window_attribs Window attributes
Windows have a number of attributes that can be returned using @ref
glfwGetWindowAttrib. Some reflect state that may change during the lifetime of
the window, while others reflect the corresponding hints and are fixed at the
time of creation. Some are related to the actual window and others to its
context.
@code
if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
{
// window has input focus
}
@endcode
@subsubsection window_attribs_wnd Window related attributes
`GLFW_FOCUSED` indicates whether the specified window has input focus. Initial
input focus is controlled by the [window hint](@ref window_hints_wnd) with the
same name.
`GLFW_ICONIFIED` indicates whether the specified window is iconified, whether by
the user or with @ref glfwIconifyWindow.
`GLFW_VISIBLE` indicates whether the specified window is visible. Window
visibility can be controlled with @ref glfwShowWindow and @ref glfwHideWindow
and initial visibility is controlled by the [window hint](@ref window_hints_wnd)
with the same name.
`GLFW_RESIZABLE` indicates whether the specified window is resizable _by the
user_. This is set on creation with the [window hint](@ref window_hints_wnd)
with the same name.
`GLFW_DECORATED` indicates whether the specified window has decorations such as
a border, a close widget, etc. This is set on creation with the
[window hint](@ref window_hints_wnd) with the same name.
`GLFW_FLOATING` indicates whether the specified window is floating, also called
topmost or always-on-top. This is controlled by the
[window hint](@ref window_hints_wnd) with the same name.
@subsubsection window_attribs_ctx Context related attributes
`GLFW_CLIENT_API` indicates the client API provided by the window's context;
either `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`.
`GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and
`GLFW_CONTEXT_REVISION` indicate the client API version of the window's context.
`GLFW_OPENGL_FORWARD_COMPAT` is `GL_TRUE` if the window's context is an OpenGL
forward-compatible one, or `GL_FALSE` otherwise.
`GLFW_OPENGL_DEBUG_CONTEXT` is `GL_TRUE` if the window's context is an OpenGL
debug context, or `GL_FALSE` otherwise.
`GLFW_OPENGL_PROFILE` indicates the OpenGL profile used by the context. This is
`GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` if the context uses
a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the OpenGL profile is unknown
or the context is an OpenGL ES context. Note that the returned profile may not
match the profile bits of the context flags, as GLFW will try other means of
detecting the profile when no bits are set.
`GLFW_CONTEXT_ROBUSTNESS` indicates the robustness strategy used by the context.
This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION` if the
window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
@section buffer_swap Buffer swapping
GLFW windows are by default double buffered. That means that you have two
rendering buffers; a front buffer and a back buffer. The front buffer is
the one being displayed and the back buffer the one you render to.
When the entire frame has been rendered, it is time to swap the back and the
front buffers in order to display what has been rendered and begin rendering
a new frame. This is done with @ref glfwSwapBuffers.
@code
glfwSwapBuffers(window);
@endcode
Sometimes it can be useful to select when the buffer swap will occur. With the
function @ref glfwSwapInterval it is possible to select the minimum number of
monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was
called before swapping the buffers:
@code
glfwSwapInterval(1);
@endcode
If the interval is zero, the swap will take place immediately when @ref
glfwSwapBuffers is called without waiting for a refresh. Otherwise at least
interval retraces will pass between each buffer swap. Using a swap interval of
zero can be useful for benchmarking purposes, when it is not desirable to
measure the time it takes to wait for the vertical retrace. However, a swap
interval of one lets you avoid tearing.
Note that this may not work on all machines, as some drivers have
user-controlled settings that override any swap interval the application
requests. It is also by default disabled on Windows Vista and later when using
DWM (Aero), as using it there sometimes leads to severe jitter. You can
forcibly enable it for machines using DWM using @ref compile_options_win32.
*/

View File

@ -1,80 +0,0 @@
link_libraries(glfw "${OPENGL_glu_LIBRARY}")
if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL)
link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}")
else()
link_libraries(${glfw_LIBRARIES})
endif()
include_directories("${GLFW_SOURCE_DIR}/include"
"${GLFW_SOURCE_DIR}/deps")
if ("${OPENGL_INCLUDE_DIR}")
include_directories("${OPENGL_INCLUDE_DIR}")
endif()
set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h"
"${GLFW_SOURCE_DIR}/deps/glad.c")
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
"${GLFW_SOURCE_DIR}/deps/getopt.c")
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
if (APPLE)
# Set fancy names for bundles
add_executable(Boing MACOSX_BUNDLE boing.c)
add_executable(Gears MACOSX_BUNDLE gears.c)
add_executable(Heightmap MACOSX_BUNDLE heightmap.c ${GLAD})
add_executable(Particles MACOSX_BUNDLE particles.c ${TINYCTHREAD})
add_executable(Simple MACOSX_BUNDLE simple.c)
add_executable(SplitView MACOSX_BUNDLE splitview.c)
add_executable(Wave MACOSX_BUNDLE wave.c)
set_target_properties(Boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Boing")
set_target_properties(Gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gears")
set_target_properties(Heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap")
set_target_properties(Particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles")
set_target_properties(Simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple")
set_target_properties(SplitView PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Split View")
set_target_properties(Wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
set_target_properties(Boing Gears Heightmap Particles Simple SplitView Wave PROPERTIES
FOLDER "GLFW3/Examples")
else()
# Set boring names for executables
add_executable(boing WIN32 boing.c)
add_executable(gears WIN32 gears.c)
add_executable(heightmap WIN32 heightmap.c ${GLAD})
add_executable(particles WIN32 particles.c ${TINYCTHREAD} ${GETOPT})
add_executable(simple WIN32 simple.c)
add_executable(splitview WIN32 splitview.c)
add_executable(wave WIN32 wave.c)
set_target_properties(boing gears heightmap particles simple splitview wave PROPERTIES
FOLDER "GLFW3/Examples")
endif()
if (APPLE)
target_link_libraries(Particles "${CMAKE_THREAD_LIBS_INIT}")
elseif (UNIX)
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}")
endif()
if (MSVC)
set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
if (APPLE)
set(BUNDLE_BINARIES Boing Gears Heightmap Particles Simple SplitView Wave)
set_target_properties(${BUNDLE_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
endif()

View File

@ -1,669 +0,0 @@
/*****************************************************************************
* Title: GLBoing
* Desc: Tribute to Amiga Boing.
* Author: Jim Brooks <gfx@jimbrooks.org>
* Original Amiga authors were R.J. Mical and Dale Luck.
* GLFW conversion by Marcus Geelnard
* Notes: - 360' = 2*PI [radian]
*
* - Distances between objects are created by doing a relative
* Z translations.
*
* - Although OpenGL enticingly supports alpha-blending,
* the shadow of the original Boing didn't affect the color
* of the grid.
*
* - [Marcus] Changed timing scheme from interval driven to frame-
* time based animation steps (which results in much smoother
* movement)
*
* History of Amiga Boing:
*
* Boing was demonstrated on the prototype Amiga (codenamed "Lorraine") in
* 1985. According to legend, it was written ad-hoc in one night by
* R. J. Mical and Dale Luck. Because the bouncing ball animation was so fast
* and smooth, attendees did not believe the Amiga prototype was really doing
* the rendering. Suspecting a trick, they began looking around the booth for
* a hidden computer or VCR.
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
/*****************************************************************************
* Various declarations and macros
*****************************************************************************/
/* Prototypes */
void init( void );
void display( void );
void reshape( GLFWwindow* window, int w, int h );
void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods );
void mouse_button_callback( GLFWwindow* window, int button, int action, int mods );
void cursor_position_callback( GLFWwindow* window, double x, double y );
void DrawBoingBall( void );
void BounceBall( double dt );
void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi );
void DrawGrid( void );
#define RADIUS 70.f
#define STEP_LONGITUDE 22.5f /* 22.5 makes 8 bands like original Boing */
#define STEP_LATITUDE 22.5f
#define DIST_BALL (RADIUS * 2.f + RADIUS * 0.1f)
#define VIEW_SCENE_DIST (DIST_BALL * 3.f + 200.f)/* distance from viewer to middle of boing area */
#define GRID_SIZE (RADIUS * 4.5f) /* length (width) of grid */
#define BOUNCE_HEIGHT (RADIUS * 2.1f)
#define BOUNCE_WIDTH (RADIUS * 2.1f)
#define SHADOW_OFFSET_X -20.f
#define SHADOW_OFFSET_Y 10.f
#define SHADOW_OFFSET_Z 0.f
#define WALL_L_OFFSET 0.f
#define WALL_R_OFFSET 5.f
/* Animation speed (50.0 mimics the original GLUT demo speed) */
#define ANIMATION_SPEED 50.f
/* Maximum allowed delta time per physics iteration */
#define MAX_DELTA_T 0.02f
/* Draw ball, or its shadow */
typedef enum { DRAW_BALL, DRAW_BALL_SHADOW } DRAW_BALL_ENUM;
/* Vertex type */
typedef struct {float x; float y; float z;} vertex_t;
/* Global vars */
int width, height;
GLfloat deg_rot_y = 0.f;
GLfloat deg_rot_y_inc = 2.f;
GLboolean override_pos = GL_FALSE;
GLfloat cursor_x = 0.f;
GLfloat cursor_y = 0.f;
GLfloat ball_x = -RADIUS;
GLfloat ball_y = -RADIUS;
GLfloat ball_x_inc = 1.f;
GLfloat ball_y_inc = 2.f;
DRAW_BALL_ENUM drawBallHow;
double t;
double t_old = 0.f;
double dt;
/* Random number generator */
#ifndef RAND_MAX
#define RAND_MAX 4095
#endif
/* PI */
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
/*****************************************************************************
* Truncate a degree.
*****************************************************************************/
GLfloat TruncateDeg( GLfloat deg )
{
if ( deg >= 360.f )
return (deg - 360.f);
else
return deg;
}
/*****************************************************************************
* Convert a degree (360-based) into a radian.
* 360' = 2 * PI
*****************************************************************************/
double deg2rad( double deg )
{
return deg / 360 * (2 * M_PI);
}
/*****************************************************************************
* 360' sin().
*****************************************************************************/
double sin_deg( double deg )
{
return sin( deg2rad( deg ) );
}
/*****************************************************************************
* 360' cos().
*****************************************************************************/
double cos_deg( double deg )
{
return cos( deg2rad( deg ) );
}
/*****************************************************************************
* Compute a cross product (for a normal vector).
*
* c = a x b
*****************************************************************************/
void CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n )
{
GLfloat u1, u2, u3;
GLfloat v1, v2, v3;
u1 = b.x - a.x;
u2 = b.y - a.y;
u3 = b.y - a.z;
v1 = c.x - a.x;
v2 = c.y - a.y;
v3 = c.z - a.z;
n->x = u2 * v3 - v2 * v3;
n->y = u3 * v1 - v3 * u1;
n->z = u1 * v2 - v1 * u2;
}
/*****************************************************************************
* Calculate the angle to be passed to gluPerspective() so that a scene
* is visible. This function originates from the OpenGL Red Book.
*
* Parms : size
* The size of the segment when the angle is intersected at "dist"
* (ie at the outermost edge of the angle of vision).
*
* dist
* Distance from viewpoint to scene.
*****************************************************************************/
GLfloat PerspectiveAngle( GLfloat size,
GLfloat dist )
{
GLfloat radTheta, degTheta;
radTheta = 2.f * (GLfloat) atan2( size / 2.f, dist );
degTheta = (180.f * radTheta) / (GLfloat) M_PI;
return degTheta;
}
#define BOING_DEBUG 0
/*****************************************************************************
* init()
*****************************************************************************/
void init( void )
{
/*
* Clear background.
*/
glClearColor( 0.55f, 0.55f, 0.55f, 0.f );
glShadeModel( GL_FLAT );
}
/*****************************************************************************
* display()
*****************************************************************************/
void display(void)
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
drawBallHow = DRAW_BALL_SHADOW;
DrawBoingBall();
DrawGrid();
drawBallHow = DRAW_BALL;
DrawBoingBall();
glPopMatrix();
glFlush();
}
/*****************************************************************************
* reshape()
*****************************************************************************/
void reshape( GLFWwindow* window, int w, int h )
{
glViewport( 0, 0, (GLsizei)w, (GLsizei)h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( PerspectiveAngle( RADIUS * 2, 200 ),
(GLfloat)w / (GLfloat)h,
1.0,
VIEW_SCENE_DIST );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt( 0.0, 0.0, VIEW_SCENE_DIST,/* eye */
0.0, 0.0, 0.0, /* center of vision */
0.0, -1.0, 0.0 ); /* up vector */
}
void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods )
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
static void set_ball_pos ( GLfloat x, GLfloat y )
{
ball_x = (width / 2) - x;
ball_y = y - (height / 2);
}
void mouse_button_callback( GLFWwindow* window, int button, int action, int mods )
{
if (button != GLFW_MOUSE_BUTTON_LEFT)
return;
if (action == GLFW_PRESS)
{
override_pos = GL_TRUE;
set_ball_pos(cursor_x, cursor_y);
}
else
{
override_pos = GL_FALSE;
}
}
void cursor_position_callback( GLFWwindow* window, double x, double y )
{
cursor_x = (float) x;
cursor_y = (float) y;
if ( override_pos )
set_ball_pos(cursor_x, cursor_y);
}
/*****************************************************************************
* Draw the Boing ball.
*
* The Boing ball is sphere in which each facet is a rectangle.
* Facet colors alternate between red and white.
* The ball is built by stacking latitudinal circles. Each circle is composed
* of a widely-separated set of points, so that each facet is noticably large.
*****************************************************************************/
void DrawBoingBall( void )
{
GLfloat lon_deg; /* degree of longitude */
double dt_total, dt2;
glPushMatrix();
glMatrixMode( GL_MODELVIEW );
/*
* Another relative Z translation to separate objects.
*/
glTranslatef( 0.0, 0.0, DIST_BALL );
/* Update ball position and rotation (iterate if necessary) */
dt_total = dt;
while( dt_total > 0.0 )
{
dt2 = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;
dt_total -= dt2;
BounceBall( dt2 );
deg_rot_y = TruncateDeg( deg_rot_y + deg_rot_y_inc*((float)dt2*ANIMATION_SPEED) );
}
/* Set ball position */
glTranslatef( ball_x, ball_y, 0.0 );
/*
* Offset the shadow.
*/
if ( drawBallHow == DRAW_BALL_SHADOW )
{
glTranslatef( SHADOW_OFFSET_X,
SHADOW_OFFSET_Y,
SHADOW_OFFSET_Z );
}
/*
* Tilt the ball.
*/
glRotatef( -20.0, 0.0, 0.0, 1.0 );
/*
* Continually rotate ball around Y axis.
*/
glRotatef( deg_rot_y, 0.0, 1.0, 0.0 );
/*
* Set OpenGL state for Boing ball.
*/
glCullFace( GL_FRONT );
glEnable( GL_CULL_FACE );
glEnable( GL_NORMALIZE );
/*
* Build a faceted latitude slice of the Boing ball,
* stepping same-sized vertical bands of the sphere.
*/
for ( lon_deg = 0;
lon_deg < 180;
lon_deg += STEP_LONGITUDE )
{
/*
* Draw a latitude circle at this longitude.
*/
DrawBoingBallBand( lon_deg,
lon_deg + STEP_LONGITUDE );
}
glPopMatrix();
return;
}
/*****************************************************************************
* Bounce the ball.
*****************************************************************************/
void BounceBall( double delta_t )
{
GLfloat sign;
GLfloat deg;
if ( override_pos )
return;
/* Bounce on walls */
if ( ball_x > (BOUNCE_WIDTH/2 + WALL_R_OFFSET ) )
{
ball_x_inc = -0.5f - 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX;
deg_rot_y_inc = -deg_rot_y_inc;
}
if ( ball_x < -(BOUNCE_HEIGHT/2 + WALL_L_OFFSET) )
{
ball_x_inc = 0.5f + 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX;
deg_rot_y_inc = -deg_rot_y_inc;
}
/* Bounce on floor / roof */
if ( ball_y > BOUNCE_HEIGHT/2 )
{
ball_y_inc = -0.75f - 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX;
}
if ( ball_y < -BOUNCE_HEIGHT/2*0.85 )
{
ball_y_inc = 0.75f + 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX;
}
/* Update ball position */
ball_x += ball_x_inc * ((float)delta_t*ANIMATION_SPEED);
ball_y += ball_y_inc * ((float)delta_t*ANIMATION_SPEED);
/*
* Simulate the effects of gravity on Y movement.
*/
if ( ball_y_inc < 0 ) sign = -1.0; else sign = 1.0;
deg = (ball_y + BOUNCE_HEIGHT/2) * 90 / BOUNCE_HEIGHT;
if ( deg > 80 ) deg = 80;
if ( deg < 10 ) deg = 10;
ball_y_inc = sign * 4.f * (float) sin_deg( deg );
}
/*****************************************************************************
* Draw a faceted latitude band of the Boing ball.
*
* Parms: long_lo, long_hi
* Low and high longitudes of slice, resp.
*****************************************************************************/
void DrawBoingBallBand( GLfloat long_lo,
GLfloat long_hi )
{
vertex_t vert_ne; /* "ne" means south-east, so on */
vertex_t vert_nw;
vertex_t vert_sw;
vertex_t vert_se;
vertex_t vert_norm;
GLfloat lat_deg;
static int colorToggle = 0;
/*
* Iterate thru the points of a latitude circle.
* A latitude circle is a 2D set of X,Z points.
*/
for ( lat_deg = 0;
lat_deg <= (360 - STEP_LATITUDE);
lat_deg += STEP_LATITUDE )
{
/*
* Color this polygon with red or white.
*/
if ( colorToggle )
glColor3f( 0.8f, 0.1f, 0.1f );
else
glColor3f( 0.95f, 0.95f, 0.95f );
#if 0
if ( lat_deg >= 180 )
if ( colorToggle )
glColor3f( 0.1f, 0.8f, 0.1f );
else
glColor3f( 0.5f, 0.5f, 0.95f );
#endif
colorToggle = ! colorToggle;
/*
* Change color if drawing shadow.
*/
if ( drawBallHow == DRAW_BALL_SHADOW )
glColor3f( 0.35f, 0.35f, 0.35f );
/*
* Assign each Y.
*/
vert_ne.y = vert_nw.y = (float) cos_deg(long_hi) * RADIUS;
vert_sw.y = vert_se.y = (float) cos_deg(long_lo) * RADIUS;
/*
* Assign each X,Z with sin,cos values scaled by latitude radius indexed by longitude.
* Eg, long=0 and long=180 are at the poles, so zero scale is sin(longitude),
* while long=90 (sin(90)=1) is at equator.
*/
vert_ne.x = (float) cos_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));
vert_se.x = (float) cos_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo ));
vert_nw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));
vert_sw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo ));
vert_ne.z = (float) sin_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));
vert_se.z = (float) sin_deg( lat_deg ) * (RADIUS * (float) sin_deg( long_lo ));
vert_nw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));
vert_sw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo ));
/*
* Draw the facet.
*/
glBegin( GL_POLYGON );
CrossProduct( vert_ne, vert_nw, vert_sw, &vert_norm );
glNormal3f( vert_norm.x, vert_norm.y, vert_norm.z );
glVertex3f( vert_ne.x, vert_ne.y, vert_ne.z );
glVertex3f( vert_nw.x, vert_nw.y, vert_nw.z );
glVertex3f( vert_sw.x, vert_sw.y, vert_sw.z );
glVertex3f( vert_se.x, vert_se.y, vert_se.z );
glEnd();
#if BOING_DEBUG
printf( "----------------------------------------------------------- \n" );
printf( "lat = %f long_lo = %f long_hi = %f \n", lat_deg, long_lo, long_hi );
printf( "vert_ne x = %.8f y = %.8f z = %.8f \n", vert_ne.x, vert_ne.y, vert_ne.z );
printf( "vert_nw x = %.8f y = %.8f z = %.8f \n", vert_nw.x, vert_nw.y, vert_nw.z );
printf( "vert_se x = %.8f y = %.8f z = %.8f \n", vert_se.x, vert_se.y, vert_se.z );
printf( "vert_sw x = %.8f y = %.8f z = %.8f \n", vert_sw.x, vert_sw.y, vert_sw.z );
#endif
}
/*
* Toggle color so that next band will opposite red/white colors than this one.
*/
colorToggle = ! colorToggle;
/*
* This circular band is done.
*/
return;
}
/*****************************************************************************
* Draw the purple grid of lines, behind the Boing ball.
* When the Workbench is dropped to the bottom, Boing shows 12 rows.
*****************************************************************************/
void DrawGrid( void )
{
int row, col;
const int rowTotal = 12; /* must be divisible by 2 */
const int colTotal = rowTotal; /* must be same as rowTotal */
const GLfloat widthLine = 2.0; /* should be divisible by 2 */
const GLfloat sizeCell = GRID_SIZE / rowTotal;
const GLfloat z_offset = -40.0;
GLfloat xl, xr;
GLfloat yt, yb;
glPushMatrix();
glDisable( GL_CULL_FACE );
/*
* Another relative Z translation to separate objects.
*/
glTranslatef( 0.0, 0.0, DIST_BALL );
/*
* Draw vertical lines (as skinny 3D rectangles).
*/
for ( col = 0; col <= colTotal; col++ )
{
/*
* Compute co-ords of line.
*/
xl = -GRID_SIZE / 2 + col * sizeCell;
xr = xl + widthLine;
yt = GRID_SIZE / 2;
yb = -GRID_SIZE / 2 - widthLine;
glBegin( GL_POLYGON );
glColor3f( 0.6f, 0.1f, 0.6f ); /* purple */
glVertex3f( xr, yt, z_offset ); /* NE */
glVertex3f( xl, yt, z_offset ); /* NW */
glVertex3f( xl, yb, z_offset ); /* SW */
glVertex3f( xr, yb, z_offset ); /* SE */
glEnd();
}
/*
* Draw horizontal lines (as skinny 3D rectangles).
*/
for ( row = 0; row <= rowTotal; row++ )
{
/*
* Compute co-ords of line.
*/
yt = GRID_SIZE / 2 - row * sizeCell;
yb = yt - widthLine;
xl = -GRID_SIZE / 2;
xr = GRID_SIZE / 2 + widthLine;
glBegin( GL_POLYGON );
glColor3f( 0.6f, 0.1f, 0.6f ); /* purple */
glVertex3f( xr, yt, z_offset ); /* NE */
glVertex3f( xl, yt, z_offset ); /* NW */
glVertex3f( xl, yb, z_offset ); /* SW */
glVertex3f( xr, yb, z_offset ); /* SE */
glEnd();
}
glPopMatrix();
return;
}
/*======================================================================*
* main()
*======================================================================*/
int main( void )
{
GLFWwindow* window;
/* Init GLFW */
if( !glfwInit() )
exit( EXIT_FAILURE );
glfwWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwCreateWindow( 400, 400, "Boing (classic Amiga demo)", NULL, NULL );
if (!window)
{
glfwTerminate();
exit( EXIT_FAILURE );
}
glfwSetFramebufferSizeCallback(window, reshape);
glfwSetKeyCallback(window, key_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval( 1 );
glfwGetFramebufferSize(window, &width, &height);
reshape(window, width, height);
glfwSetTime( 0.0 );
init();
/* Main loop */
for (;;)
{
/* Timing */
t = glfwGetTime();
dt = t - t_old;
t_old = t;
/* Draw one frame */
display();
/* Swap buffers */
glfwSwapBuffers(window);
glfwPollEvents();
/* Check if we are still running */
if (glfwWindowShouldClose(window))
break;
}
glfwTerminate();
exit( EXIT_SUCCESS );
}

View File

@ -1,372 +0,0 @@
/*
* 3-D gear wheels. This program is in the public domain.
*
* Command line options:
* -info print GL implementation information
* -exit automatically exit after 30 seconds
*
*
* Brian Paul
*
*
* Marcus Geelnard:
* - Conversion to GLFW
* - Time based rendering (frame rate independent)
* - Slightly modified camera that should work better for stereo viewing
*
*
* Camilla Berglund:
* - Removed FPS counter (this is not a benchmark)
* - Added a few comments
* - Enabled vsync
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GLFW/glfw3.h>
#ifndef M_PI
#define M_PI 3.141592654
#endif
/* If non-zero, the program exits after that many seconds
*/
static int autoexit = 0;
/**
Draw a gear wheel. You'll probably want to call this function when
building a display list since we do a lot of trig here.
Input: inner_radius - radius of hole at center
outer_radius - radius at center of teeth
width - width of gear teeth - number of teeth
tooth_depth - depth of tooth
**/
static void
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
GLint teeth, GLfloat tooth_depth)
{
GLint i;
GLfloat r0, r1, r2;
GLfloat angle, da;
GLfloat u, v, len;
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.f;
r2 = outer_radius + tooth_depth / 2.f;
da = 2.f * (float) M_PI / teeth / 4.f;
glShadeModel(GL_FLAT);
glNormal3f(0.f, 0.f, 1.f);
/* draw front face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);
if (i < teeth) {
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);
}
}
glEnd();
/* draw front sides of teeth */
glBegin(GL_QUADS);
da = 2.f * (float) M_PI / teeth / 4.f;
for (i = 0; i < teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);
glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f);
glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f);
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);
}
glEnd();
glNormal3f(0.0, 0.0, -1.0);
/* draw back face */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);
if (i < teeth) {
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);
}
}
glEnd();
/* draw back sides of teeth */
glBegin(GL_QUADS);
da = 2.f * (float) M_PI / teeth / 4.f;
for (i = 0; i < teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);
glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f);
glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f);
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);
}
glEnd();
/* draw outward faces of teeth */
glBegin(GL_QUAD_STRIP);
for (i = 0; i < teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);
glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);
u = r2 * (float) cos(angle + da) - r1 * (float) cos(angle);
v = r2 * (float) sin(angle + da) - r1 * (float) sin(angle);
len = (float) sqrt(u * u + v * v);
u /= len;
v /= len;
glNormal3f(v, -u, 0.0);
glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f);
glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f);
glNormal3f((float) cos(angle), (float) sin(angle), 0.f);
glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f);
glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f);
u = r1 * (float) cos(angle + 3 * da) - r2 * (float) cos(angle + 2 * da);
v = r1 * (float) sin(angle + 3 * da) - r2 * (float) sin(angle + 2 * da);
glNormal3f(v, -u, 0.f);
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);
glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);
glNormal3f((float) cos(angle), (float) sin(angle), 0.f);
}
glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), width * 0.5f);
glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), -width * 0.5f);
glEnd();
glShadeModel(GL_SMOOTH);
/* draw inside radius cylinder */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++) {
angle = i * 2.f * (float) M_PI / teeth;
glNormal3f(-(float) cos(angle), -(float) sin(angle), 0.f);
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);
glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);
}
glEnd();
}
static GLfloat view_rotx = 20.f, view_roty = 30.f, view_rotz = 0.f;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.f;
/* OpenGL draw function & timing */
static void draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(view_rotx, 1.0, 0.0, 0.0);
glRotatef(view_roty, 0.0, 1.0, 0.0);
glRotatef(view_rotz, 0.0, 0.0, 1.0);
glPushMatrix();
glTranslatef(-3.0, -2.0, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glCallList(gear1);
glPopMatrix();
glPushMatrix();
glTranslatef(3.1f, -2.f, 0.f);
glRotatef(-2.f * angle - 9.f, 0.f, 0.f, 1.f);
glCallList(gear2);
glPopMatrix();
glPushMatrix();
glTranslatef(-3.1f, 4.2f, 0.f);
glRotatef(-2.f * angle - 25.f, 0.f, 0.f, 1.f);
glCallList(gear3);
glPopMatrix();
glPopMatrix();
}
/* update animation parameters */
static void animate(void)
{
angle = 100.f * (float) glfwGetTime();
}
/* change view angle, exit upon ESC */
void key( GLFWwindow* window, int k, int s, int action, int mods )
{
if( action != GLFW_PRESS ) return;
switch (k) {
case GLFW_KEY_Z:
if( mods & GLFW_MOD_SHIFT )
view_rotz -= 5.0;
else
view_rotz += 5.0;
break;
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_UP:
view_rotx += 5.0;
break;
case GLFW_KEY_DOWN:
view_rotx -= 5.0;
break;
case GLFW_KEY_LEFT:
view_roty += 5.0;
break;
case GLFW_KEY_RIGHT:
view_roty -= 5.0;
break;
default:
return;
}
}
/* new window size */
void reshape( GLFWwindow* window, int width, int height )
{
GLfloat h = (GLfloat) height / (GLfloat) width;
GLfloat xmax, znear, zfar;
znear = 5.0f;
zfar = 30.0f;
xmax = znear * 0.5f;
glViewport( 0, 0, (GLint) width, (GLint) height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -xmax, xmax, -xmax*h, xmax*h, znear, zfar );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, -20.0 );
}
/* program & OpenGL initialization */
static void init(int argc, char *argv[])
{
static GLfloat pos[4] = {5.f, 5.f, 10.f, 0.f};
static GLfloat red[4] = {0.8f, 0.1f, 0.f, 1.f};
static GLfloat green[4] = {0.f, 0.8f, 0.2f, 1.f};
static GLfloat blue[4] = {0.2f, 0.2f, 1.f, 1.f};
GLint i;
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear(1.f, 4.f, 1.f, 20, 0.7f);
glEndList();
gear2 = glGenLists(1);
glNewList(gear2, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear(0.5f, 2.f, 2.f, 10, 0.7f);
glEndList();
gear3 = glGenLists(1);
glNewList(gear3, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear(1.3f, 2.f, 0.5f, 10, 0.7f);
glEndList();
glEnable(GL_NORMALIZE);
for ( i=1; i<argc; i++ ) {
if (strcmp(argv[i], "-info")==0) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
else if ( strcmp(argv[i], "-exit")==0) {
autoexit = 30;
printf("Auto Exit after %i seconds.\n", autoexit );
}
}
}
/* program entry */
int main(int argc, char *argv[])
{
GLFWwindow* window;
int width, height;
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
exit( EXIT_FAILURE );
}
glfwWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwCreateWindow( 300, 300, "Gears", NULL, NULL );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
glfwTerminate();
exit( EXIT_FAILURE );
}
// Set callback functions
glfwSetFramebufferSizeCallback(window, reshape);
glfwSetKeyCallback(window, key);
glfwMakeContextCurrent(window);
glfwSwapInterval( 1 );
glfwGetFramebufferSize(window, &width, &height);
reshape(window, width, height);
// Parse command-line options
init(argc, argv);
// Main loop
while( !glfwWindowShouldClose(window) )
{
// Draw gears
draw();
// Update animation
animate();
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
}
// Terminate GLFW
glfwTerminate();
// Exit program
exit( EXIT_SUCCESS );
}

View File

@ -1,509 +0,0 @@
//========================================================================
// Heightmap example program using OpenGL 3 core profile
// Copyright (c) 2010 Olivier Delannoy
//
// This software is provided 'as-is', without 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.
//
//========================================================================
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <stddef.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
/* Map height updates */
#define MAX_CIRCLE_SIZE (5.0f)
#define MAX_DISPLACEMENT (1.0f)
#define DISPLACEMENT_SIGN_LIMIT (0.3f)
#define MAX_ITER (200)
#define NUM_ITER_AT_A_TIME (1)
/* Map general information */
#define MAP_SIZE (10.0f)
#define MAP_NUM_VERTICES (80)
#define MAP_NUM_TOTAL_VERTICES (MAP_NUM_VERTICES*MAP_NUM_VERTICES)
#define MAP_NUM_LINES (3* (MAP_NUM_VERTICES - 1) * (MAP_NUM_VERTICES - 1) + \
2 * (MAP_NUM_VERTICES - 1))
/**********************************************************************
* Default shader programs
*********************************************************************/
static const char* vertex_shader_text =
"#version 150\n"
"uniform mat4 project;\n"
"uniform mat4 modelview;\n"
"in float x;\n"
"in float y;\n"
"in float z;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = project * modelview * vec4(x, y, z, 1.0);\n"
"}\n";
static const char* fragment_shader_text =
"#version 150\n"
"out vec4 color;\n"
"void main()\n"
"{\n"
" color = vec4(0.2, 1.0, 0.2, 1.0); \n"
"}\n";
/**********************************************************************
* Values for shader uniforms
*********************************************************************/
/* Frustum configuration */
static GLfloat view_angle = 45.0f;
static GLfloat aspect_ratio = 4.0f/3.0f;
static GLfloat z_near = 1.0f;
static GLfloat z_far = 100.f;
/* Projection matrix */
static GLfloat projection_matrix[16] = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/* Model view matrix */
static GLfloat modelview_matrix[16] = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/**********************************************************************
* Heightmap vertex and index data
*********************************************************************/
static GLfloat map_vertices[3][MAP_NUM_TOTAL_VERTICES];
static GLuint map_line_indices[2*MAP_NUM_LINES];
/* Store uniform location for the shaders
* Those values are setup as part of the process of creating
* the shader program. They should not be used before creating
* the program.
*/
static GLuint mesh;
static GLuint mesh_vbo[4];
/**********************************************************************
* OpenGL helper functions
*********************************************************************/
/* Creates a shader object of the specified type using the specified text
*/
static GLuint make_shader(GLenum type, const char* text)
{
GLuint shader;
GLint shader_ok;
GLsizei log_length;
char info_log[8192];
shader = glCreateShader(type);
if (shader != 0)
{
glShaderSource(shader, 1, (const GLchar**)&text, NULL);
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_ok);
if (shader_ok != GL_TRUE)
{
fprintf(stderr, "ERROR: Failed to compile %s shader\n", (type == GL_FRAGMENT_SHADER) ? "fragment" : "vertex" );
glGetShaderInfoLog(shader, 8192, &log_length,info_log);
fprintf(stderr, "ERROR: \n%s\n\n", info_log);
glDeleteShader(shader);
shader = 0;
}
}
return shader;
}
/* Creates a program object using the specified vertex and fragment text
*/
static GLuint make_shader_program(const char* vs_text, const char* fs_text)
{
GLuint program = 0u;
GLint program_ok;
GLuint vertex_shader = 0u;
GLuint fragment_shader = 0u;
GLsizei log_length;
char info_log[8192];
vertex_shader = make_shader(GL_VERTEX_SHADER, vs_text);
if (vertex_shader != 0u)
{
fragment_shader = make_shader(GL_FRAGMENT_SHADER, fs_text);
if (fragment_shader != 0u)
{
/* make the program that connect the two shader and link it */
program = glCreateProgram();
if (program != 0u)
{
/* attach both shader and link */
glAttachShader(program, vertex_shader);
glAttachShader(program, fragment_shader);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &program_ok);
if (program_ok != GL_TRUE)
{
fprintf(stderr, "ERROR, failed to link shader program\n");
glGetProgramInfoLog(program, 8192, &log_length, info_log);
fprintf(stderr, "ERROR: \n%s\n\n", info_log);
glDeleteProgram(program);
glDeleteShader(fragment_shader);
glDeleteShader(vertex_shader);
program = 0u;
}
}
}
else
{
fprintf(stderr, "ERROR: Unable to load fragment shader\n");
glDeleteShader(vertex_shader);
}
}
else
{
fprintf(stderr, "ERROR: Unable to load vertex shader\n");
}
return program;
}
/**********************************************************************
* Geometry creation functions
*********************************************************************/
/* Generate vertices and indices for the heightmap
*/
static void init_map(void)
{
int i;
int j;
int k;
GLfloat step = MAP_SIZE / (MAP_NUM_VERTICES - 1);
GLfloat x = 0.0f;
GLfloat z = 0.0f;
/* Create a flat grid */
k = 0;
for (i = 0 ; i < MAP_NUM_VERTICES ; ++i)
{
for (j = 0 ; j < MAP_NUM_VERTICES ; ++j)
{
map_vertices[0][k] = x;
map_vertices[1][k] = 0.0f;
map_vertices[2][k] = z;
z += step;
++k;
}
x += step;
z = 0.0f;
}
#if DEBUG_ENABLED
for (i = 0 ; i < MAP_NUM_TOTAL_VERTICES ; ++i)
{
printf ("Vertice %d (%f, %f, %f)\n",
i, map_vertices[0][i], map_vertices[1][i], map_vertices[2][i]);
}
#endif
/* create indices */
/* line fan based on i
* i+1
* | / i + n + 1
* | /
* |/
* i --- i + n
*/
/* close the top of the square */
k = 0;
for (i = 0 ; i < MAP_NUM_VERTICES -1 ; ++i)
{
map_line_indices[k++] = (i + 1) * MAP_NUM_VERTICES -1;
map_line_indices[k++] = (i + 2) * MAP_NUM_VERTICES -1;
}
/* close the right of the square */
for (i = 0 ; i < MAP_NUM_VERTICES -1 ; ++i)
{
map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i;
map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i + 1;
}
for (i = 0 ; i < (MAP_NUM_VERTICES - 1) ; ++i)
{
for (j = 0 ; j < (MAP_NUM_VERTICES - 1) ; ++j)
{
int ref = i * (MAP_NUM_VERTICES) + j;
map_line_indices[k++] = ref;
map_line_indices[k++] = ref + 1;
map_line_indices[k++] = ref;
map_line_indices[k++] = ref + MAP_NUM_VERTICES;
map_line_indices[k++] = ref;
map_line_indices[k++] = ref + MAP_NUM_VERTICES + 1;
}
}
#ifdef DEBUG_ENABLED
for (k = 0 ; k < 2 * MAP_NUM_LINES ; k += 2)
{
int beg, end;
beg = map_line_indices[k];
end = map_line_indices[k+1];
printf ("Line %d: %d -> %d (%f, %f, %f) -> (%f, %f, %f)\n",
k / 2, beg, end,
map_vertices[0][beg], map_vertices[1][beg], map_vertices[2][beg],
map_vertices[0][end], map_vertices[1][end], map_vertices[2][end]);
}
#endif
}
static void generate_heightmap__circle(float* center_x, float* center_y,
float* size, float* displacement)
{
float sign;
/* random value for element in between [0-1.0] */
*center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
*center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);
*size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX);
sign = (1.0f * rand()) / (1.0f * RAND_MAX);
sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;
*displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX);
}
/* Run the specified number of iterations of the generation process for the
* heightmap
*/
static void update_map(int num_iter)
{
assert(num_iter > 0);
while(num_iter)
{
/* center of the circle */
float center_x;
float center_z;
float circle_size;
float disp;
size_t ii;
generate_heightmap__circle(&center_x, &center_z, &circle_size, &disp);
disp = disp / 2.0f;
for (ii = 0u ; ii < MAP_NUM_TOTAL_VERTICES ; ++ii)
{
GLfloat dx = center_x - map_vertices[0][ii];
GLfloat dz = center_z - map_vertices[2][ii];
GLfloat pd = (2.0f * sqrtf((dx * dx) + (dz * dz))) / circle_size;
if (fabs(pd) <= 1.0f)
{
/* tx,tz is within the circle */
GLfloat new_height = disp + (float) (cos(pd*3.14f)*disp);
map_vertices[1][ii] += new_height;
}
}
--num_iter;
}
}
/**********************************************************************
* OpenGL helper functions
*********************************************************************/
/* Create VBO, IBO and VAO objects for the heightmap geometry and bind them to
* the specified program object
*/
static void make_mesh(GLuint program)
{
GLuint attrloc;
glGenVertexArrays(1, &mesh);
glGenBuffers(4, mesh_vbo);
glBindVertexArray(mesh);
/* Prepare the data for drawing through a buffer inidices */
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh_vbo[3]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint)* MAP_NUM_LINES * 2, map_line_indices, GL_STATIC_DRAW);
/* Prepare the attributes for rendering */
attrloc = glGetAttribLocation(program, "x");
glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[0][0], GL_STATIC_DRAW);
glEnableVertexAttribArray(attrloc);
glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);
attrloc = glGetAttribLocation(program, "z");
glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[2]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[2][0], GL_STATIC_DRAW);
glEnableVertexAttribArray(attrloc);
glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);
attrloc = glGetAttribLocation(program, "y");
glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0], GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(attrloc);
glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);
}
/* Update VBO vertices from source data
*/
static void update_mesh(void)
{
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0]);
}
/**********************************************************************
* GLFW callback functions
*********************************************************************/
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
switch(key)
{
case GLFW_KEY_ESCAPE:
/* Exit program on Escape */
glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
int main(int argc, char** argv)
{
GLFWwindow* window;
int iter;
double dt;
double last_update_time;
int frame;
float f;
GLint uloc_modelview;
GLint uloc_project;
GLuint shader_program;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
window = glfwCreateWindow(800, 600, "GLFW OpenGL3 Heightmap demo", NULL, NULL);
if (! window )
{
glfwTerminate();
exit(EXIT_FAILURE);
}
/* Register events callback */
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
/* Prepare opengl resources for rendering */
shader_program = make_shader_program(vertex_shader_text, fragment_shader_text);
if (shader_program == 0u)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glUseProgram(shader_program);
uloc_project = glGetUniformLocation(shader_program, "project");
uloc_modelview = glGetUniformLocation(shader_program, "modelview");
/* Compute the projection matrix */
f = 1.0f / tanf(view_angle / 2.0f);
projection_matrix[0] = f / aspect_ratio;
projection_matrix[5] = f;
projection_matrix[10] = (z_far + z_near)/ (z_near - z_far);
projection_matrix[11] = -1.0f;
projection_matrix[14] = 2.0f * (z_far * z_near) / (z_near - z_far);
glUniformMatrix4fv(uloc_project, 1, GL_FALSE, projection_matrix);
/* Set the camera position */
modelview_matrix[12] = -5.0f;
modelview_matrix[13] = -5.0f;
modelview_matrix[14] = -20.0f;
glUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix);
/* Create mesh data */
init_map();
make_mesh(shader_program);
/* Create vao + vbo to store the mesh */
/* Create the vbo to store all the information for the grid and the height */
/* setup the scene ready for rendering */
glViewport(0, 0, 800, 600);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
/* main loop */
frame = 0;
iter = 0;
last_update_time = glfwGetTime();
while (!glfwWindowShouldClose(window))
{
++frame;
/* render the next frame */
glClear(GL_COLOR_BUFFER_BIT);
glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0);
/* display and process events through callbacks */
glfwSwapBuffers(window);
glfwPollEvents();
/* Check the frame rate and update the heightmap if needed */
dt = glfwGetTime();
if ((dt - last_update_time) > 0.2)
{
/* generate the next iteration of the heightmap */
if (iter < MAX_ITER)
{
update_map(NUM_ITER_AT_A_TIME);
update_mesh();
iter += NUM_ITER_AT_A_TIME;
}
last_update_time = dt;
frame = 0;
}
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +0,0 @@
//========================================================================
// Simple GLFW example
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//! [code]
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
static void error_callback(int error, const char* description)
{
fputs(description, stderr);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
int main(void)
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
while (!glfwWindowShouldClose(window))
{
float ratio;
int width, height;
glfwGetFramebufferSize(window, &width, &height);
ratio = width / (float) height;
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f);
glBegin(GL_TRIANGLES);
glColor3f(1.f, 0.f, 0.f);
glVertex3f(-0.6f, -0.4f, 0.f);
glColor3f(0.f, 1.f, 0.f);
glVertex3f(0.6f, -0.4f, 0.f);
glColor3f(0.f, 0.f, 1.f);
glVertex3f(0.f, 0.6f, 0.f);
glEnd();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}
//! [code]

View File

@ -1,511 +0,0 @@
//========================================================================
// This is an example program for the GLFW library
//
// The program uses a "split window" view, rendering four views of the
// same scene in one window (e.g. uesful for 3D modelling software). This
// demo uses scissors to separete the four different rendering areas from
// each other.
//
// (If the code seems a little bit strange here and there, it may be
// because I am not a friend of orthogonal projections)
//========================================================================
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
//========================================================================
// Global variables
//========================================================================
// Mouse position
static double xpos = 0, ypos = 0;
// Window size
static int width, height;
// Active view: 0 = none, 1 = upper left, 2 = upper right, 3 = lower left,
// 4 = lower right
static int active_view = 0;
// Rotation around each axis
static int rot_x = 0, rot_y = 0, rot_z = 0;
// Do redraw?
static int do_redraw = 1;
//========================================================================
// Draw a solid torus (use a display list for the model)
//========================================================================
#define TORUS_MAJOR 1.5
#define TORUS_MINOR 0.5
#define TORUS_MAJOR_RES 32
#define TORUS_MINOR_RES 32
static void drawTorus(void)
{
static GLuint torus_list = 0;
int i, j, k;
double s, t, x, y, z, nx, ny, nz, scale, twopi;
if (!torus_list)
{
// Start recording displaylist
torus_list = glGenLists(1);
glNewList(torus_list, GL_COMPILE_AND_EXECUTE);
// Draw torus
twopi = 2.0 * M_PI;
for (i = 0; i < TORUS_MINOR_RES; i++)
{
glBegin(GL_QUAD_STRIP);
for (j = 0; j <= TORUS_MAJOR_RES; j++)
{
for (k = 1; k >= 0; k--)
{
s = (i + k) % TORUS_MINOR_RES + 0.5;
t = j % TORUS_MAJOR_RES;
// Calculate point on surface
x = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * cos(t * twopi / TORUS_MAJOR_RES);
y = TORUS_MINOR * sin(s * twopi / TORUS_MINOR_RES);
z = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * sin(t * twopi / TORUS_MAJOR_RES);
// Calculate surface normal
nx = x - TORUS_MAJOR * cos(t * twopi / TORUS_MAJOR_RES);
ny = y;
nz = z - TORUS_MAJOR * sin(t * twopi / TORUS_MAJOR_RES);
scale = 1.0 / sqrt(nx*nx + ny*ny + nz*nz);
nx *= scale;
ny *= scale;
nz *= scale;
glNormal3f((float) nx, (float) ny, (float) nz);
glVertex3f((float) x, (float) y, (float) z);
}
}
glEnd();
}
// Stop recording displaylist
glEndList();
}
else
{
// Playback displaylist
glCallList(torus_list);
}
}
//========================================================================
// Draw the scene (a rotating torus)
//========================================================================
static void drawScene(void)
{
const GLfloat model_diffuse[4] = {1.0f, 0.8f, 0.8f, 1.0f};
const GLfloat model_specular[4] = {0.6f, 0.6f, 0.6f, 1.0f};
const GLfloat model_shininess = 20.0f;
glPushMatrix();
// Rotate the object
glRotatef((GLfloat) rot_x * 0.5f, 1.0f, 0.0f, 0.0f);
glRotatef((GLfloat) rot_y * 0.5f, 0.0f, 1.0f, 0.0f);
glRotatef((GLfloat) rot_z * 0.5f, 0.0f, 0.0f, 1.0f);
// Set model color (used for orthogonal views, lighting disabled)
glColor4fv(model_diffuse);
// Set model material (used for perspective view, lighting enabled)
glMaterialfv(GL_FRONT, GL_DIFFUSE, model_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, model_specular);
glMaterialf(GL_FRONT, GL_SHININESS, model_shininess);
// Draw torus
drawTorus();
glPopMatrix();
}
//========================================================================
// Draw a 2D grid (used for orthogonal views)
//========================================================================
static void drawGrid(float scale, int steps)
{
int i;
float x, y;
glPushMatrix();
// Set background to some dark bluish grey
glClearColor(0.05f, 0.05f, 0.2f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Setup modelview matrix (flat XY view)
glLoadIdentity();
gluLookAt(0.0, 0.0, 1.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
// We don't want to update the Z-buffer
glDepthMask(GL_FALSE);
// Set grid color
glColor3f(0.0f, 0.5f, 0.5f);
glBegin(GL_LINES);
// Horizontal lines
x = scale * 0.5f * (float) (steps - 1);
y = -scale * 0.5f * (float) (steps - 1);
for (i = 0; i < steps; i++)
{
glVertex3f(-x, y, 0.0f);
glVertex3f(x, y, 0.0f);
y += scale;
}
// Vertical lines
x = -scale * 0.5f * (float) (steps - 1);
y = scale * 0.5f * (float) (steps - 1);
for (i = 0; i < steps; i++)
{
glVertex3f(x, -y, 0.0f);
glVertex3f(x, y, 0.0f);
x += scale;
}
glEnd();
// Enable Z-buffer writing again
glDepthMask(GL_TRUE);
glPopMatrix();
}
//========================================================================
// Draw all views
//========================================================================
static void drawAllViews(void)
{
const GLfloat light_position[4] = {0.0f, 8.0f, 8.0f, 1.0f};
const GLfloat light_diffuse[4] = {1.0f, 1.0f, 1.0f, 1.0f};
const GLfloat light_specular[4] = {1.0f, 1.0f, 1.0f, 1.0f};
const GLfloat light_ambient[4] = {0.2f, 0.2f, 0.3f, 1.0f};
double aspect;
// Calculate aspect of window
if (height > 0)
aspect = (double) width / (double) height;
else
aspect = 1.0;
// Clear screen
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Enable scissor test
glEnable(GL_SCISSOR_TEST);
// Enable depth test
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
// ** ORTHOGONAL VIEWS **
// For orthogonal views, use wireframe rendering
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Enable line anti-aliasing
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Setup orthogonal projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.0 * aspect, 3.0 * aspect, -3.0, 3.0, 1.0, 50.0);
// Upper left view (TOP VIEW)
glViewport(0, height / 2, width / 2, height / 2);
glScissor(0, height / 2, width / 2, height / 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 10.0f, 1e-3f, // Eye-position (above)
0.0f, 0.0f, 0.0f, // View-point
0.0f, 1.0f, 0.0f); // Up-vector
drawGrid(0.5, 12);
drawScene();
// Lower left view (FRONT VIEW)
glViewport(0, 0, width / 2, height / 2);
glScissor(0, 0, width / 2, height / 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0f, 0.0f, 10.0f, // Eye-position (in front of)
0.0f, 0.0f, 0.0f, // View-point
0.0f, 1.0f, 0.0f); // Up-vector
drawGrid(0.5, 12);
drawScene();
// Lower right view (SIDE VIEW)
glViewport(width / 2, 0, width / 2, height / 2);
glScissor(width / 2, 0, width / 2, height / 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(10.0f, 0.0f, 0.0f, // Eye-position (to the right)
0.0f, 0.0f, 0.0f, // View-point
0.0f, 1.0f, 0.0f); // Up-vector
drawGrid(0.5, 12);
drawScene();
// Disable line anti-aliasing
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
// ** PERSPECTIVE VIEW **
// For perspective view, use solid rendering
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// Enable face culling (faster rendering)
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
// Setup perspective projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(65.0f, aspect, 1.0f, 50.0f);
// Upper right view (PERSPECTIVE VIEW)
glViewport(width / 2, height / 2, width / 2, height / 2);
glScissor(width / 2, height / 2, width / 2, height / 2);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(3.0f, 1.5f, 3.0f, // Eye-position
0.0f, 0.0f, 0.0f, // View-point
0.0f, 1.0f, 0.0f); // Up-vector
// Configure and enable light source 1
glLightfv(GL_LIGHT1, GL_POSITION, light_position);
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
// Draw scene
drawScene();
// Disable lighting
glDisable(GL_LIGHTING);
// Disable face culling
glDisable(GL_CULL_FACE);
// Disable depth test
glDisable(GL_DEPTH_TEST);
// Disable scissor test
glDisable(GL_SCISSOR_TEST);
// Draw a border around the active view
if (active_view > 0 && active_view != 2)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f);
glColor3f(1.0f, 1.0f, 0.6f);
glBegin(GL_LINE_STRIP);
glVertex2i(0, 0);
glVertex2i(1, 0);
glVertex2i(1, 1);
glVertex2i(0, 1);
glVertex2i(0, 0);
glEnd();
}
}
//========================================================================
// Framebuffer size callback function
//========================================================================
static void framebufferSizeFun(GLFWwindow* window, int w, int h)
{
width = w;
height = h > 0 ? h : 1;
do_redraw = 1;
}
//========================================================================
// Window refresh callback function
//========================================================================
static void windowRefreshFun(GLFWwindow* window)
{
do_redraw = 1;
}
//========================================================================
// Mouse position callback function
//========================================================================
static void cursorPosFun(GLFWwindow* window, double x, double y)
{
// Depending on which view was selected, rotate around different axes
switch (active_view)
{
case 1:
rot_x += (int) (y - ypos);
rot_z += (int) (x - xpos);
do_redraw = 1;
break;
case 3:
rot_x += (int) (y - ypos);
rot_y += (int) (x - xpos);
do_redraw = 1;
break;
case 4:
rot_y += (int) (x - xpos);
rot_z += (int) (y - ypos);
do_redraw = 1;
break;
default:
// Do nothing for perspective view, or if no view is selected
break;
}
// Remember cursor position
xpos = x;
ypos = y;
}
//========================================================================
// Mouse button callback function
//========================================================================
static void mouseButtonFun(GLFWwindow* window, int button, int action, int mods)
{
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)
{
// Detect which of the four views was clicked
active_view = 1;
if (xpos >= width / 2)
active_view += 1;
if (ypos >= height / 2)
active_view += 2;
}
else if (button == GLFW_MOUSE_BUTTON_LEFT)
{
// Deselect any previously selected view
active_view = 0;
}
do_redraw = 1;
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
//========================================================================
// main
//========================================================================
int main(void)
{
GLFWwindow* window;
// Initialise GLFW
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
exit(EXIT_FAILURE);
}
// Open OpenGL window
window = glfwCreateWindow(500, 500, "Split view demo", NULL, NULL);
if (!window)
{
fprintf(stderr, "Failed to open GLFW window\n");
glfwTerminate();
exit(EXIT_FAILURE);
}
// Set callback functions
glfwSetFramebufferSizeCallback(window, framebufferSizeFun);
glfwSetWindowRefreshCallback(window, windowRefreshFun);
glfwSetCursorPosCallback(window, cursorPosFun);
glfwSetMouseButtonCallback(window, mouseButtonFun);
glfwSetKeyCallback(window, key_callback);
// Enable vsync
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwGetFramebufferSize(window, &width, &height);
framebufferSizeFun(window, width, height);
// Main loop
for (;;)
{
// Only redraw if we need to
if (do_redraw)
{
// Draw all views
drawAllViews();
// Swap buffers
glfwSwapBuffers(window);
do_redraw = 0;
}
// Wait for new events
glfwWaitEvents();
// Check if the window should be closed
if (glfwWindowShouldClose(window))
break;
}
// Close OpenGL window and terminate GLFW
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,452 +0,0 @@
/*****************************************************************************
* Wave Simulation in OpenGL
* (C) 2002 Jakob Thomsen
* http://home.in.tum.de/~thomsen
* Modified for GLFW by Sylvain Hellegouarch - sh@programmationworld.com
* Modified for variable frame rate by Marcus Geelnard
* 2003-Jan-31: Minor cleanups and speedups / MG
* 2010-10-24: Formatting and cleanup - Camilla Berglund
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
// Maximum delta T to allow for differential calculations
#define MAX_DELTA_T 0.01
// Animation speed (10.0 looks good)
#define ANIMATION_SPEED 10.0
GLfloat alpha = 210.f, beta = -70.f;
GLfloat zoom = 2.f;
double cursorX;
double cursorY;
struct Vertex
{
GLfloat x, y, z;
GLfloat r, g, b;
};
#define GRIDW 50
#define GRIDH 50
#define VERTEXNUM (GRIDW*GRIDH)
#define QUADW (GRIDW - 1)
#define QUADH (GRIDH - 1)
#define QUADNUM (QUADW*QUADH)
GLuint quad[4 * QUADNUM];
struct Vertex vertex[VERTEXNUM];
/* The grid will look like this:
*
* 3 4 5
* *---*---*
* | | |
* | 0 | 1 |
* | | |
* *---*---*
* 0 1 2
*/
//========================================================================
// Initialize grid geometry
//========================================================================
void init_vertices(void)
{
int x, y, p;
// Place the vertices in a grid
for (y = 0; y < GRIDH; y++)
{
for (x = 0; x < GRIDW; x++)
{
p = y * GRIDW + x;
vertex[p].x = (GLfloat) (x - GRIDW / 2) / (GLfloat) (GRIDW / 2);
vertex[p].y = (GLfloat) (y - GRIDH / 2) / (GLfloat) (GRIDH / 2);
vertex[p].z = 0;
if ((x % 4 < 2) ^ (y % 4 < 2))
vertex[p].r = 0.0;
else
vertex[p].r = 1.0;
vertex[p].g = (GLfloat) y / (GLfloat) GRIDH;
vertex[p].b = 1.f - ((GLfloat) x / (GLfloat) GRIDW + (GLfloat) y / (GLfloat) GRIDH) / 2.f;
}
}
for (y = 0; y < QUADH; y++)
{
for (x = 0; x < QUADW; x++)
{
p = 4 * (y * QUADW + x);
quad[p + 0] = y * GRIDW + x; // Some point
quad[p + 1] = y * GRIDW + x + 1; // Neighbor at the right side
quad[p + 2] = (y + 1) * GRIDW + x + 1; // Upper right neighbor
quad[p + 3] = (y + 1) * GRIDW + x; // Upper neighbor
}
}
}
double dt;
double p[GRIDW][GRIDH];
double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH];
double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH];
//========================================================================
// Initialize grid
//========================================================================
void init_grid(void)
{
int x, y;
double dx, dy, d;
for (y = 0; y < GRIDH; y++)
{
for (x = 0; x < GRIDW; x++)
{
dx = (double) (x - GRIDW / 2);
dy = (double) (y - GRIDH / 2);
d = sqrt(dx * dx + dy * dy);
if (d < 0.1 * (double) (GRIDW / 2))
{
d = d * 10.0;
p[x][y] = -cos(d * (M_PI / (double)(GRIDW * 4))) * 100.0;
}
else
p[x][y] = 0.0;
vx[x][y] = 0.0;
vy[x][y] = 0.0;
}
}
}
//========================================================================
// Draw scene
//========================================================================
void draw_scene(GLFWwindow* window)
{
// Clear the color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// We don't want to modify the projection matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Move back
glTranslatef(0.0, 0.0, -zoom);
// Rotate the view
glRotatef(beta, 1.0, 0.0, 0.0);
glRotatef(alpha, 0.0, 0.0, 1.0);
glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad);
glfwSwapBuffers(window);
}
//========================================================================
// Initialize Miscellaneous OpenGL state
//========================================================================
void init_opengl(void)
{
// Use Gouraud (smooth) shading
glShadeModel(GL_SMOOTH);
// Switch on the z-buffer
glEnable(GL_DEPTH_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), vertex);
glColorPointer(3, GL_FLOAT, sizeof(struct Vertex), &vertex[0].r); // Pointer to the first color
glPointSize(2.0);
// Background color is black
glClearColor(0, 0, 0, 0);
}
//========================================================================
// Modify the height of each vertex according to the pressure
//========================================================================
void adjust_grid(void)
{
int pos;
int x, y;
for (y = 0; y < GRIDH; y++)
{
for (x = 0; x < GRIDW; x++)
{
pos = y * GRIDW + x;
vertex[pos].z = (float) (p[x][y] * (1.0 / 50.0));
}
}
}
//========================================================================
// Calculate wave propagation
//========================================================================
void calc_grid(void)
{
int x, y, x2, y2;
double time_step = dt * ANIMATION_SPEED;
// Compute accelerations
for (x = 0; x < GRIDW; x++)
{
x2 = (x + 1) % GRIDW;
for(y = 0; y < GRIDH; y++)
ax[x][y] = p[x][y] - p[x2][y];
}
for (y = 0; y < GRIDH; y++)
{
y2 = (y + 1) % GRIDH;
for(x = 0; x < GRIDW; x++)
ay[x][y] = p[x][y] - p[x][y2];
}
// Compute speeds
for (x = 0; x < GRIDW; x++)
{
for (y = 0; y < GRIDH; y++)
{
vx[x][y] = vx[x][y] + ax[x][y] * time_step;
vy[x][y] = vy[x][y] + ay[x][y] * time_step;
}
}
// Compute pressure
for (x = 1; x < GRIDW; x++)
{
x2 = x - 1;
for (y = 1; y < GRIDH; y++)
{
y2 = y - 1;
p[x][y] = p[x][y] + (vx[x2][y] - vx[x][y] + vy[x][y2] - vy[x][y]) * time_step;
}
}
}
//========================================================================
// Print errors
//========================================================================
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
//========================================================================
// Handle key strokes
//========================================================================
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_SPACE:
init_grid();
break;
case GLFW_KEY_LEFT:
alpha += 5;
break;
case GLFW_KEY_RIGHT:
alpha -= 5;
break;
case GLFW_KEY_UP:
beta -= 5;
break;
case GLFW_KEY_DOWN:
beta += 5;
break;
case GLFW_KEY_PAGE_UP:
zoom -= 0.25f;
if (zoom < 0.f)
zoom = 0.f;
break;
case GLFW_KEY_PAGE_DOWN:
zoom += 0.25f;
break;
default:
break;
}
}
//========================================================================
// Callback function for mouse button events
//========================================================================
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
if (button != GLFW_MOUSE_BUTTON_LEFT)
return;
if (action == GLFW_PRESS)
{
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwGetCursorPos(window, &cursorX, &cursorY);
}
else
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
//========================================================================
// Callback function for cursor motion events
//========================================================================
void cursor_position_callback(GLFWwindow* window, double x, double y)
{
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
{
alpha += (GLfloat) (x - cursorX) / 10.f;
beta += (GLfloat) (y - cursorY) / 10.f;
cursorX = x;
cursorY = y;
}
}
//========================================================================
// Callback function for scroll events
//========================================================================
void scroll_callback(GLFWwindow* window, double x, double y)
{
zoom += (float) y / 4.f;
if (zoom < 0)
zoom = 0;
}
//========================================================================
// Callback function for framebuffer resize events
//========================================================================
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
float ratio = 1.f;
if (height > 0)
ratio = (float) width / (float) height;
// Setup viewport
glViewport(0, 0, width, height);
// Change to the projection matrix and set our viewing volume
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, ratio, 1.0, 1024.0);
}
//========================================================================
// main
//========================================================================
int main(int argc, char* argv[])
{
GLFWwindow* window;
double t, dt_total, t_old;
int width, height;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Wave Simulation", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetKeyCallback(window, key_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwSetScrollCallback(window, scroll_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwGetFramebufferSize(window, &width, &height);
framebuffer_size_callback(window, width, height);
// Initialize OpenGL
init_opengl();
// Initialize simulation
init_vertices();
init_grid();
adjust_grid();
// Initialize timer
t_old = glfwGetTime() - 0.01;
while (!glfwWindowShouldClose(window))
{
t = glfwGetTime();
dt_total = t - t_old;
t_old = t;
// Safety - iterate if dt_total is too large
while (dt_total > 0.f)
{
// Select iteration time step
dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;
dt_total -= dt;
// Calculate wave propagation
calc_grid();
}
// Compute height of each vertex
adjust_grid();
// Draw wave grid to OpenGL display
draw_scene(window);
glfwPollEvents();
}
exit(EXIT_SUCCESS);
}

View File

@ -1,81 +0,0 @@
link_libraries(glfw "${OPENGL_glu_LIBRARY}")
if (BUILD_SHARED_LIBS)
add_definitions(-DGLFW_DLL)
link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}")
else()
link_libraries(${glfw_LIBRARIES})
endif()
include_directories("${GLFW_SOURCE_DIR}/include"
"${GLFW_SOURCE_DIR}/deps")
if ("${OPENGL_INCLUDE_DIR}")
include_directories("${OPENGL_INCLUDE_DIR}")
endif()
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
"${GLFW_SOURCE_DIR}/deps/getopt.c")
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
"${GLFW_SOURCE_DIR}/deps/tinycthread.c")
add_executable(clipboard clipboard.c ${GETOPT})
add_executable(defaults defaults.c)
add_executable(events events.c ${GETOPT})
add_executable(fsaa fsaa.c ${GETOPT})
add_executable(gamma gamma.c ${GETOPT})
add_executable(glfwinfo glfwinfo.c ${GETOPT})
add_executable(iconify iconify.c ${GETOPT})
add_executable(joysticks joysticks.c)
add_executable(modes modes.c ${GETOPT})
add_executable(peter peter.c)
add_executable(reopen reopen.c)
add_executable(cursor cursor.c)
add_executable(cursoranim WIN32 MACOSX_BUNDLE cursoranim.c)
set_target_properties(cursoranim PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Cursor animation")
add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy")
add_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD})
set_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Empty Event")
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD})
set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads")
add_executable(title WIN32 MACOSX_BUNDLE title.c)
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}")
target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}" "${RT_LIBRARY}")
set(WINDOWS_BINARIES accuracy empty sharing tearing threads title windows cursoranim)
set(CONSOLE_BINARIES clipboard defaults events fsaa gamma glfwinfo
iconify joysticks modes peter reopen cursor)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
FOLDER "GLFW3/Tests")
if (MSVC)
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
if (APPLE)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
endif()

View File

@ -1,128 +0,0 @@
//========================================================================
// Mouse cursor accuracy test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test came about as the result of bug #1867804
//
// No sign of said bug has so far been detected
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
static double cursor_x = 0.0, cursor_y = 0.0;
static int window_width = 640, window_height = 480;
static int swap_interval = 1;
static void set_swap_interval(GLFWwindow* window, int interval)
{
char title[256];
swap_interval = interval;
glfwSwapInterval(swap_interval);
sprintf(title, "Cursor Inaccuracy Detector (interval %i)", swap_interval);
glfwSetWindowTitle(window, title);
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
window_width = width;
window_height = height;
glViewport(0, 0, window_width, window_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, window_width, 0.f, window_height, 0.f, 1.f);
}
static void cursor_position_callback(GLFWwindow* window, double x, double y)
{
cursor_x = x;
cursor_y = y;
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
set_swap_interval(window, 1 - swap_interval);
}
int main(void)
{
GLFWwindow* window;
int width, height;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(window_width, window_height, "", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
glfwGetFramebufferSize(window, &width, &height);
framebuffer_size_callback(window, width, height);
set_swap_interval(window, swap_interval);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2f(0.f, (GLfloat) (window_height - cursor_y));
glVertex2f((GLfloat) window_width, (GLfloat) (window_height - cursor_y));
glVertex2f((GLfloat) cursor_x, 0.f);
glVertex2f((GLfloat) cursor_x, (GLfloat) window_height);
glEnd();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,149 +0,0 @@
//========================================================================
// Clipboard test program
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This program is used to test the clipboard functionality.
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include "getopt.h"
static void usage(void)
{
printf("Usage: clipboard [-h]\n");
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_V:
if (mods == GLFW_MOD_CONTROL)
{
const char* string;
string = glfwGetClipboardString(window);
if (string)
printf("Clipboard contains \"%s\"\n", string);
else
printf("Clipboard does not contain a string\n");
}
break;
case GLFW_KEY_C:
if (mods == GLFW_MOD_CONTROL)
{
const char* string = "Hello GLFW World!";
glfwSetClipboardString(window, string);
printf("Setting clipboard to \"%s\"\n", string);
}
break;
}
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
int main(int argc, char** argv)
{
int ch;
GLFWwindow* window;
while ((ch = getopt(argc, argv, "h")) != -1)
{
switch (ch)
{
case 'h':
usage();
exit(EXIT_SUCCESS);
default:
usage();
exit(EXIT_FAILURE);
}
}
glfwSetErrorCallback(error_callback);
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
exit(EXIT_FAILURE);
}
window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL);
if (!window)
{
glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n");
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.5f, 0.5f, 0.5f, 0);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.8f, 0.2f, 0.4f);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,289 +0,0 @@
//========================================================================
// Cursor & input mode tests
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// System cursors and input modes tests.
//
//========================================================================
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
static int W = 640;
static int H = 480;
static int delay = 0;
static GLFWwindow* windows[2] = { NULL, NULL };
static GLFWwindow* activeWindow = NULL;
static GLFWcursor* cursor = NULL;
static struct
{
int key;
double time;
} commands[] = {
{GLFW_KEY_H, 0},
{GLFW_KEY_C, 0},
{GLFW_KEY_D, 0},
{GLFW_KEY_S, 0},
{GLFW_KEY_N, 0},
{GLFW_KEY_1, 0},
{GLFW_KEY_2, 0},
{GLFW_KEY_3, 0}
};
static int CommandCount = sizeof(commands) / sizeof(commands[0]);
static struct
{
int w, h;
} cursorSize[] = {
{ 24, 24 }, { 13, 37 }, { 5, 53 }, { 43, 64 }, { 300, 300 }
};
static int SizeCount = sizeof(cursorSize) / sizeof(cursorSize[0]);
static int currentSize = 0;
static void command_callback(int key)
{
switch (key)
{
case GLFW_KEY_H:
{
printf("H: show this help\n");
printf("C: call glfwCreateCursor()\n");
printf("D: call glfwDestroyCursor()\n");
printf("S: call glfwSetCursor()\n");
printf("N: call glfwSetCursor() with NULL\n");
printf("1: set GLFW_CURSOR_NORMAL\n");
printf("2: set GLFW_CURSOR_HIDDEN\n");
printf("3: set GLFW_CURSOR_DISABLED\n");
printf("T: enable 3s delay for all previous commands\n");
}
break;
case GLFW_KEY_C:
{
int x, y;
GLFWimage image;
unsigned char* pixels;
if (cursor)
break;
image.width = cursorSize[currentSize].w;
image.height = cursorSize[currentSize].h;
pixels = malloc(4 * image.width * image.height);
image.pixels = pixels;
for (y = 0; y < image.height; y++)
{
for (x = 0; x < image.width; x++)
{
*pixels++ = 0xff;
*pixels++ = 0;
*pixels++ = 255 * y / image.height;
*pixels++ = 255 * x / image.width;
}
}
cursor = glfwCreateCursor(&image, image.width / 2, image.height / 2);
currentSize = (currentSize + 1) % SizeCount;
free(image.pixels);
break;
}
case GLFW_KEY_D:
{
if (cursor != NULL)
{
glfwDestroyCursor(cursor);
cursor = NULL;
}
break;
}
case GLFW_KEY_S:
{
if (cursor != NULL)
glfwSetCursor(activeWindow, cursor);
else
printf("The cursor is not created\n");
break;
}
case GLFW_KEY_N:
glfwSetCursor(activeWindow, NULL);
break;
case GLFW_KEY_1:
glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
break;
case GLFW_KEY_2:
glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
break;
case GLFW_KEY_3:
glfwSetInputMode(activeWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
break;
}
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
W = width;
H = height;
glViewport(0, 0, W, H);
}
static void refresh_callback(GLFWwindow* window)
{
glfwMakeContextCurrent(window);
glClearColor(0.0f, window == activeWindow ? 0.8f : 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
case GLFW_KEY_T:
delay = !delay;
printf("Delay %s.\n", delay ? "enabled" : "disabled");
break;
default:
{
if (delay)
{
int i = 0;
while (i < CommandCount && commands[i].key != key)
i++;
if (i < CommandCount)
commands[i].time = glfwGetTime();
}
else
{
command_callback(key);
}
}
break;
}
}
static void focus_callback(GLFWwindow* window, int focused)
{
if (focused)
{
activeWindow = window;
refresh_callback(windows[0]);
refresh_callback(windows[1]);
}
}
int main(void)
{
int i;
GLboolean running = GL_TRUE;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
for (i = 0; i < 2; i++)
{
windows[i] = glfwCreateWindow(W, H, "Cursor testing", NULL, NULL);
if (!windows[i])
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetWindowPos(windows[i], 100 + (i & 1) * (W + 50), 100);
glfwSetWindowRefreshCallback(windows[i], refresh_callback);
glfwSetFramebufferSizeCallback(windows[i], framebuffer_size_callback);
glfwSetKeyCallback(windows[i], key_callback);
glfwSetWindowFocusCallback(windows[i], focus_callback);
glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(windows[i]);
}
activeWindow = windows[0];
key_callback(NULL, GLFW_KEY_H, 0, GLFW_PRESS, 0);
while (running)
{
if (delay)
{
int i;
double t = glfwGetTime();
for (i = 0; i < CommandCount; i++)
{
if (commands[i].time != 0 && t - commands[i].time >= 3.0)
{
command_callback(commands[i].key);
commands[i].time = 0;
}
}
}
running = !(glfwWindowShouldClose(windows[0]) || glfwWindowShouldClose(windows[1]));
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,135 +0,0 @@
//========================================================================
// Cursor animation
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// Cursor animation test.
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <math.h>
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#define SIZE 64 // cursor size (width & height)
#define N 60 // number of frames
unsigned char buffer[4 * SIZE * SIZE];
static float max(float a, float b) { return a > b ? a : b; }
static float min(float a, float b) { return a < b ? a : b; }
static float star(int x, int y, float t)
{
float c = SIZE / 2.0f;
float i = (0.25f * (float)sin(2.0f * 3.1415926f * t) + 0.75f);
float k = SIZE * 0.046875f * i;
float dist = (float)sqrt((x - c) * (x - c) + (y - c) * (y - c));
float salpha = 1.0f - dist / c;
float xalpha = (float)x == c ? c : k / (float)fabs(x - c);
float yalpha = (float)y == c ? c : k / (float)fabs(y - c);
return max(0.0f, min(1.0f, i * salpha * 0.2f + salpha * xalpha * yalpha));
}
static GLFWcursor* load_frame(float t)
{
int i = 0, x, y;
const GLFWimage image = { SIZE, SIZE, buffer };
for (y = 0; y < image.width; y++)
{
for (x = 0; x < image.height; x++)
{
buffer[i++] = 255;
buffer[i++] = 255;
buffer[i++] = 255;
buffer[i++] = (unsigned char)(255 * star(x, y, t));
}
}
return glfwCreateCursor(&image, image.width / 2, image.height / 2);
}
int main(void)
{
int i;
double t0, t1, frameTime = 0.0;
GLFWwindow* window;
GLFWcursor* frames[N];
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Cursor animation", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
for (i = 0; i < N; i++)
frames[i] = load_frame(i / (float)N);
i = 0;
t0 = glfwGetTime();
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSetCursor(window, frames[i]);
glfwSwapBuffers(window);
glfwPollEvents();
t1 = glfwGetTime();
frameTime += t1 - t0;
t0 = t1;
while (frameTime > 1.0 / (double)N)
{
i = (i + 1) % N;
frameTime -= 1.0 / (double)N;
}
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,131 +0,0 @@
//========================================================================
// Default window/context test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test creates a windowed mode window with all window hints set to
// default values and then reports the actual attributes of the created
// window and context
//
//========================================================================
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int attrib;
const char* ext;
const char* name;
} AttribGL;
typedef struct
{
int attrib;
const char* name;
} AttribGLFW;
static AttribGL gl_attribs[] =
{
{ GL_RED_BITS, NULL, "red bits" },
{ GL_GREEN_BITS, NULL, "green bits" },
{ GL_BLUE_BITS, NULL, "blue bits" },
{ GL_ALPHA_BITS, NULL, "alpha bits" },
{ GL_DEPTH_BITS, NULL, "depth bits" },
{ GL_STENCIL_BITS, NULL, "stencil bits" },
{ GL_STEREO, NULL, "stereo" },
{ GL_SAMPLES_ARB, "GL_ARB_multisample", "FSAA samples" },
{ 0, NULL, NULL }
};
static AttribGLFW glfw_attribs[] =
{
{ GLFW_CONTEXT_VERSION_MAJOR, "Context version major" },
{ GLFW_CONTEXT_VERSION_MINOR, "Context version minor" },
{ GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" },
{ GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" },
{ GLFW_OPENGL_PROFILE, "OpenGL profile" },
{ 0, NULL }
};
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
int main(void)
{
int i, width, height;
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(640, 480, "Defaults", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwGetFramebufferSize(window, &width, &height);
printf("framebuffer size: %ix%i\n", width, height);
for (i = 0; glfw_attribs[i].name; i++)
{
printf("%s: %i\n",
glfw_attribs[i].name,
glfwGetWindowAttrib(window, glfw_attribs[i].attrib));
}
for (i = 0; gl_attribs[i].name; i++)
{
GLint value = 0;
if (gl_attribs[i].ext)
{
if (!glfwExtensionSupported(gl_attribs[i].ext))
continue;
}
glGetIntegerv(gl_attribs[i].attrib, &value);
printf("%s: %i\n", gl_attribs[i].name, value);
}
glfwDestroyWindow(window);
window = NULL;
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,129 +0,0 @@
//========================================================================
// Empty event test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test is intended to verify that posting of empty events works
//
//========================================================================
#include "tinycthread.h"
#include <GLFW/glfw3.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
static volatile GLboolean running = GL_TRUE;
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static int thread_main(void* data)
{
struct timespec time;
while (running)
{
clock_gettime(CLOCK_REALTIME, &time);
time.tv_sec += 1;
thrd_sleep(&time, NULL);
glfwPostEmptyEvent();
}
return 0;
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
static float nrand(void)
{
return (float) rand() / (float) RAND_MAX;
}
int main(void)
{
int result;
thrd_t thread;
GLFWwindow* window;
srand((unsigned int) time(NULL));
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, key_callback);
if (thrd_create(&thread, thread_main, NULL) != thrd_success)
{
fprintf(stderr, "Failed to create secondary thread\n");
glfwTerminate();
exit(EXIT_FAILURE);
}
while (running)
{
int width, height;
float r = nrand(), g = nrand(), b = nrand();
float l = (float) sqrt(r * r + g * g + b * b);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glClearColor(r / l, g / l, b / l, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwWaitEvents();
if (glfwWindowShouldClose(window))
running = GL_FALSE;
}
glfwHideWindow(window);
thrd_join(thread, &result);
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,581 +0,0 @@
//========================================================================
// Event linter (event spewer)
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test hooks every available callback and outputs their arguments
//
// Log messages go to stdout, error messages to stderr
//
// Every event also gets a (sequential) number to aid discussion of logs
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <locale.h>
#include "getopt.h"
// Event index
static unsigned int counter = 0;
typedef struct
{
GLFWwindow* window;
int number;
int closeable;
} Slot;
static void usage(void)
{
printf("Usage: events [-f] [-h] [-n WINDOWS]\n");
printf("Options:\n");
printf(" -f use full screen\n");
printf(" -h show this help\n");
printf(" -n the number of windows to create\n");
}
static const char* get_key_name(int key)
{
switch (key)
{
// Printable keys
case GLFW_KEY_A: return "A";
case GLFW_KEY_B: return "B";
case GLFW_KEY_C: return "C";
case GLFW_KEY_D: return "D";
case GLFW_KEY_E: return "E";
case GLFW_KEY_F: return "F";
case GLFW_KEY_G: return "G";
case GLFW_KEY_H: return "H";
case GLFW_KEY_I: return "I";
case GLFW_KEY_J: return "J";
case GLFW_KEY_K: return "K";
case GLFW_KEY_L: return "L";
case GLFW_KEY_M: return "M";
case GLFW_KEY_N: return "N";
case GLFW_KEY_O: return "O";
case GLFW_KEY_P: return "P";
case GLFW_KEY_Q: return "Q";
case GLFW_KEY_R: return "R";
case GLFW_KEY_S: return "S";
case GLFW_KEY_T: return "T";
case GLFW_KEY_U: return "U";
case GLFW_KEY_V: return "V";
case GLFW_KEY_W: return "W";
case GLFW_KEY_X: return "X";
case GLFW_KEY_Y: return "Y";
case GLFW_KEY_Z: return "Z";
case GLFW_KEY_1: return "1";
case GLFW_KEY_2: return "2";
case GLFW_KEY_3: return "3";
case GLFW_KEY_4: return "4";
case GLFW_KEY_5: return "5";
case GLFW_KEY_6: return "6";
case GLFW_KEY_7: return "7";
case GLFW_KEY_8: return "8";
case GLFW_KEY_9: return "9";
case GLFW_KEY_0: return "0";
case GLFW_KEY_SPACE: return "SPACE";
case GLFW_KEY_MINUS: return "MINUS";
case GLFW_KEY_EQUAL: return "EQUAL";
case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET";
case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET";
case GLFW_KEY_BACKSLASH: return "BACKSLASH";
case GLFW_KEY_SEMICOLON: return "SEMICOLON";
case GLFW_KEY_APOSTROPHE: return "APOSTROPHE";
case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT";
case GLFW_KEY_COMMA: return "COMMA";
case GLFW_KEY_PERIOD: return "PERIOD";
case GLFW_KEY_SLASH: return "SLASH";
case GLFW_KEY_WORLD_1: return "WORLD 1";
case GLFW_KEY_WORLD_2: return "WORLD 2";
// Function keys
case GLFW_KEY_ESCAPE: return "ESCAPE";
case GLFW_KEY_F1: return "F1";
case GLFW_KEY_F2: return "F2";
case GLFW_KEY_F3: return "F3";
case GLFW_KEY_F4: return "F4";
case GLFW_KEY_F5: return "F5";
case GLFW_KEY_F6: return "F6";
case GLFW_KEY_F7: return "F7";
case GLFW_KEY_F8: return "F8";
case GLFW_KEY_F9: return "F9";
case GLFW_KEY_F10: return "F10";
case GLFW_KEY_F11: return "F11";
case GLFW_KEY_F12: return "F12";
case GLFW_KEY_F13: return "F13";
case GLFW_KEY_F14: return "F14";
case GLFW_KEY_F15: return "F15";
case GLFW_KEY_F16: return "F16";
case GLFW_KEY_F17: return "F17";
case GLFW_KEY_F18: return "F18";
case GLFW_KEY_F19: return "F19";
case GLFW_KEY_F20: return "F20";
case GLFW_KEY_F21: return "F21";
case GLFW_KEY_F22: return "F22";
case GLFW_KEY_F23: return "F23";
case GLFW_KEY_F24: return "F24";
case GLFW_KEY_F25: return "F25";
case GLFW_KEY_UP: return "UP";
case GLFW_KEY_DOWN: return "DOWN";
case GLFW_KEY_LEFT: return "LEFT";
case GLFW_KEY_RIGHT: return "RIGHT";
case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT";
case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT";
case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL";
case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL";
case GLFW_KEY_LEFT_ALT: return "LEFT ALT";
case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT";
case GLFW_KEY_TAB: return "TAB";
case GLFW_KEY_ENTER: return "ENTER";
case GLFW_KEY_BACKSPACE: return "BACKSPACE";
case GLFW_KEY_INSERT: return "INSERT";
case GLFW_KEY_DELETE: return "DELETE";
case GLFW_KEY_PAGE_UP: return "PAGE UP";
case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN";
case GLFW_KEY_HOME: return "HOME";
case GLFW_KEY_END: return "END";
case GLFW_KEY_KP_0: return "KEYPAD 0";
case GLFW_KEY_KP_1: return "KEYPAD 1";
case GLFW_KEY_KP_2: return "KEYPAD 2";
case GLFW_KEY_KP_3: return "KEYPAD 3";
case GLFW_KEY_KP_4: return "KEYPAD 4";
case GLFW_KEY_KP_5: return "KEYPAD 5";
case GLFW_KEY_KP_6: return "KEYPAD 6";
case GLFW_KEY_KP_7: return "KEYPAD 7";
case GLFW_KEY_KP_8: return "KEYPAD 8";
case GLFW_KEY_KP_9: return "KEYPAD 9";
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY";
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL";
case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER";
case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN";
case GLFW_KEY_NUM_LOCK: return "NUM LOCK";
case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK";
case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";
case GLFW_KEY_PAUSE: return "PAUSE";
case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
case GLFW_KEY_MENU: return "MENU";
default: return "UNKNOWN";
}
}
static const char* get_action_name(int action)
{
switch (action)
{
case GLFW_PRESS:
return "pressed";
case GLFW_RELEASE:
return "released";
case GLFW_REPEAT:
return "repeated";
}
return "caused unknown action";
}
static const char* get_button_name(int button)
{
switch (button)
{
case GLFW_MOUSE_BUTTON_LEFT:
return "left";
case GLFW_MOUSE_BUTTON_RIGHT:
return "right";
case GLFW_MOUSE_BUTTON_MIDDLE:
return "middle";
default:
{
static char name[16];
sprintf(name, "%i", button);
return name;
}
}
}
static const char* get_mods_name(int mods)
{
static char name[512];
if (mods == 0)
return " no mods";
name[0] = '\0';
if (mods & GLFW_MOD_SHIFT)
strcat(name, " shift");
if (mods & GLFW_MOD_CONTROL)
strcat(name, " control");
if (mods & GLFW_MOD_ALT)
strcat(name, " alt");
if (mods & GLFW_MOD_SUPER)
strcat(name, " super");
return name;
}
static const char* get_character_string(int codepoint)
{
// This assumes UTF-8, which is stupid
static char result[6 + 1];
int length = wctomb(result, codepoint);
if (length == -1)
length = 0;
result[length] = '\0';
return result;
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void window_pos_callback(GLFWwindow* window, int x, int y)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window position: %i %i\n",
counter++, slot->number, glfwGetTime(), x, y);
}
static void window_size_callback(GLFWwindow* window, int width, int height)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window size: %i %i\n",
counter++, slot->number, glfwGetTime(), width, height);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n",
counter++, slot->number, glfwGetTime(), width, height);
glViewport(0, 0, width, height);
}
static void window_close_callback(GLFWwindow* window)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window close\n",
counter++, slot->number, glfwGetTime());
glfwSetWindowShouldClose(window, slot->closeable);
}
static void window_refresh_callback(GLFWwindow* window)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window refresh\n",
counter++, slot->number, glfwGetTime());
glfwMakeContextCurrent(window);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
static void window_focus_callback(GLFWwindow* window, int focused)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window %s\n",
counter++, slot->number, glfwGetTime(),
focused ? "focused" : "defocused");
}
static void window_iconify_callback(GLFWwindow* window, int iconified)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Window was %s\n",
counter++, slot->number, glfwGetTime(),
iconified ? "iconified" : "restored");
}
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\n",
counter++, slot->number, glfwGetTime(), button,
get_button_name(button),
get_mods_name(mods),
get_action_name(action));
}
static void cursor_position_callback(GLFWwindow* window, double x, double y)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Cursor position: %f %f\n",
counter++, slot->number, glfwGetTime(), x, y);
}
static void cursor_enter_callback(GLFWwindow* window, int entered)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Cursor %s window\n",
counter++, slot->number, glfwGetTime(),
entered ? "entered" : "left");
}
static void scroll_callback(GLFWwindow* window, double x, double y)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Scroll: %0.3f %0.3f\n",
counter++, slot->number, glfwGetTime(), x, y);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
counter++, slot->number, glfwGetTime(), key, scancode,
get_key_name(key),
get_mods_name(mods),
get_action_name(action));
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_C:
{
slot->closeable = !slot->closeable;
printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled");
break;
}
}
}
static void char_callback(GLFWwindow* window, unsigned int codepoint)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
counter++, slot->number, glfwGetTime(), codepoint,
get_character_string(codepoint));
}
static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int mods)
{
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Character 0x%08x (%s) with modifiers (with%s) input\n",
counter++, slot->number, glfwGetTime(), codepoint,
get_character_string(codepoint),
get_mods_name(mods));
}
static void drop_callback(GLFWwindow* window, int count, const char** names)
{
int i;
Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: Drop input\n",
counter++, slot->number, glfwGetTime());
for (i = 0; i < count; i++)
printf(" %i: \"%s\"\n", i, names[i]);
}
static void monitor_callback(GLFWmonitor* monitor, int event)
{
if (event == GLFW_CONNECTED)
{
int x, y, widthMM, heightMM;
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwGetMonitorPos(monitor, &x, &y);
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n",
counter++,
glfwGetTime(),
glfwGetMonitorName(monitor),
mode->width, mode->height,
x, y,
widthMM, heightMM);
}
else
{
printf("%08x at %0.3f: Monitor %s was disconnected\n",
counter++,
glfwGetTime(),
glfwGetMonitorName(monitor));
}
}
int main(int argc, char** argv)
{
Slot* slots;
GLFWmonitor* monitor = NULL;
int ch, i, width, height, count = 1;
setlocale(LC_ALL, "");
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
printf("Library initialized\n");
glfwSetMonitorCallback(monitor_callback);
while ((ch = getopt(argc, argv, "hfn:")) != -1)
{
switch (ch)
{
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'f':
monitor = glfwGetPrimaryMonitor();
break;
case 'n':
count = (int) strtol(optarg, NULL, 10);
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
if (monitor)
{
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
width = mode->width;
height = mode->height;
}
else
{
width = 640;
height = 480;
}
if (!count)
{
fprintf(stderr, "Invalid user\n");
exit(EXIT_FAILURE);
}
slots = calloc(count, sizeof(Slot));
for (i = 0; i < count; i++)
{
char title[128];
slots[i].closeable = GL_TRUE;
slots[i].number = i + 1;
sprintf(title, "Event Linter (Window %i)", slots[i].number);
if (monitor)
{
printf("Creating full screen window %i (%ix%i on %s)\n",
slots[i].number,
width, height,
glfwGetMonitorName(monitor));
}
else
{
printf("Creating windowed mode window %i (%ix%i)\n",
slots[i].number,
width, height);
}
slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL);
if (!slots[i].window)
{
free(slots);
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetWindowUserPointer(slots[i].window, slots + i);
glfwSetWindowPosCallback(slots[i].window, window_pos_callback);
glfwSetWindowSizeCallback(slots[i].window, window_size_callback);
glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback);
glfwSetWindowCloseCallback(slots[i].window, window_close_callback);
glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback);
glfwSetWindowFocusCallback(slots[i].window, window_focus_callback);
glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback);
glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback);
glfwSetCursorPosCallback(slots[i].window, cursor_position_callback);
glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback);
glfwSetScrollCallback(slots[i].window, scroll_callback);
glfwSetKeyCallback(slots[i].window, key_callback);
glfwSetCharCallback(slots[i].window, char_callback);
glfwSetCharModsCallback(slots[i].window, char_mods_callback);
glfwSetDropCallback(slots[i].window, drop_callback);
glfwMakeContextCurrent(slots[i].window);
glfwSwapInterval(1);
}
printf("Main loop starting\n");
for (;;)
{
for (i = 0; i < count; i++)
{
if (glfwWindowShouldClose(slots[i].window))
break;
}
if (i < count)
break;
glfwWaitEvents();
// Workaround for an issue with msvcrt and mintty
fflush(stdout);
}
free(slots);
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,162 +0,0 @@
//========================================================================
// Full screen anti-aliasing test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test renders two high contrast, slowly rotating quads, one aliased
// and one (hopefully) anti-aliased, thus allowing for visual verification
// of whether FSAA is indeed enabled
//
//========================================================================
#define GLFW_INCLUDE_GLEXT
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include "getopt.h"
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_SPACE:
glfwSetTime(0.0);
break;
}
}
static void usage(void)
{
printf("Usage: fsaa [-h] [-s SAMPLES]\n");
}
int main(int argc, char** argv)
{
int ch, samples = 4;
GLFWwindow* window;
while ((ch = getopt(argc, argv, "hs:")) != -1)
{
switch (ch)
{
case 'h':
usage();
exit(EXIT_SUCCESS);
case 's':
samples = atoi(optarg);
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
if (samples)
printf("Requesting FSAA with %i samples\n", samples);
else
printf("Requesting that FSAA not be available\n");
glfwWindowHint(GLFW_SAMPLES, samples);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetKeyCallback(window, key_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
if (!glfwExtensionSupported("GL_ARB_multisample"))
{
printf("GL_ARB_multisample extension not supported\n");
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwShowWindow(window);
glGetIntegerv(GL_SAMPLES_ARB, &samples);
if (samples)
printf("Context reports FSAA is available with %i samples\n", samples);
else
printf("Context reports FSAA is unavailable\n");
glMatrixMode(GL_PROJECTION);
glOrtho(0.f, 1.f, 0.f, 0.5f, 0.f, 1.f);
glMatrixMode(GL_MODELVIEW);
while (!glfwWindowShouldClose(window))
{
GLfloat time = (GLfloat) glfwGetTime();
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.25f, 0.25f, 0.f);
glRotatef(time, 0.f, 0.f, 1.f);
glDisable(GL_MULTISAMPLE_ARB);
glRectf(-0.15f, -0.15f, 0.15f, 0.15f);
glLoadIdentity();
glTranslatef(0.75f, 0.25f, 0.f);
glRotatef(time, 0.f, 0.f, 1.f);
glEnable(GL_MULTISAMPLE_ARB);
glRectf(-0.15f, -0.15f, 0.15f, 0.15f);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,181 +0,0 @@
//========================================================================
// Gamma correction test program
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This program is used to test the gamma correction functionality for
// both full screen and windowed mode windows
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include "getopt.h"
#define STEP_SIZE 0.1f
static GLfloat gamma_value = 1.0f;
static void usage(void)
{
printf("Usage: gamma [-h] [-f]\n");
}
static void set_gamma(GLFWwindow* window, float value)
{
GLFWmonitor* monitor = glfwGetWindowMonitor(window);
if (!monitor)
monitor = glfwGetPrimaryMonitor();
gamma_value = value;
printf("Gamma: %f\n", gamma_value);
glfwSetGamma(monitor, gamma_value);
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_ESCAPE:
{
glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
case GLFW_KEY_KP_ADD:
case GLFW_KEY_Q:
{
set_gamma(window, gamma_value + STEP_SIZE);
break;
}
case GLFW_KEY_KP_SUBTRACT:
case GLFW_KEY_W:
{
if (gamma_value - STEP_SIZE > 0.f)
set_gamma(window, gamma_value - STEP_SIZE);
break;
}
}
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
int main(int argc, char** argv)
{
int width, height, ch;
GLFWmonitor* monitor = NULL;
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
while ((ch = getopt(argc, argv, "fh")) != -1)
{
switch (ch)
{
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'f':
monitor = glfwGetPrimaryMonitor();
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
if (monitor)
{
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
width = mode->width;
height = mode->height;
}
else
{
width = 200;
height = 200;
}
window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
set_gamma(window, 1.f);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.5f, 0.5f, 0.5f, 0);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.8f, 0.2f, 0.4f);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,429 +0,0 @@
//========================================================================
// Version information dumper
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test is a pale imitation of glxinfo(1), except not really
//
// It dumps GLFW and OpenGL version information
//
//========================================================================
#include <GLFW/glfw3.h>
#include <GL/glext.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "getopt.h"
#ifdef _MSC_VER
#define strcasecmp(x, y) _stricmp(x, y)
#endif
#define API_OPENGL "gl"
#define API_OPENGL_ES "es"
#define PROFILE_NAME_CORE "core"
#define PROFILE_NAME_COMPAT "compat"
#define STRATEGY_NAME_NONE "none"
#define STRATEGY_NAME_LOSE "lose"
#define BEHAVIOR_NAME_NONE "none"
#define BEHAVIOR_NAME_FLUSH "flush"
static void usage(void)
{
printf("Usage: glfwinfo [-h] [-a API] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-s STRATEGY] [-b BEHAVIOR]\n");
printf("Options:\n");
printf(" -a the client API to use (" API_OPENGL " or " API_OPENGL_ES ")\n");
printf(" -b the release behavior to use (" BEHAVIOR_NAME_NONE " or " BEHAVIOR_NAME_FLUSH ")\n");
printf(" -d request a debug context\n");
printf(" -f require a forward-compatible context\n");
printf(" -h show this help\n");
printf(" -l list all client API extensions after context creation\n");
printf(" -m the major number of the required client API version\n");
printf(" -n the minor number of the required client API version\n");
printf(" -p the OpenGL profile to use (" PROFILE_NAME_CORE " or " PROFILE_NAME_COMPAT ")\n");
printf(" -s the robustness strategy to use (" STRATEGY_NAME_NONE " or " STRATEGY_NAME_LOSE ")\n");
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static const char* get_client_api_name(int api)
{
if (api == GLFW_OPENGL_API)
return "OpenGL";
else if (api == GLFW_OPENGL_ES_API)
return "OpenGL ES";
return "Unknown API";
}
static const char* get_profile_name_gl(GLint mask)
{
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
return PROFILE_NAME_COMPAT;
if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
return PROFILE_NAME_CORE;
return "unknown";
}
static const char* get_profile_name_glfw(int profile)
{
if (profile == GLFW_OPENGL_COMPAT_PROFILE)
return PROFILE_NAME_COMPAT;
if (profile == GLFW_OPENGL_CORE_PROFILE)
return PROFILE_NAME_CORE;
return "unknown";
}
static const char* get_strategy_name_gl(GLint strategy)
{
if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
return STRATEGY_NAME_LOSE;
if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
return STRATEGY_NAME_NONE;
return "unknown";
}
static const char* get_strategy_name_glfw(int strategy)
{
if (strategy == GLFW_LOSE_CONTEXT_ON_RESET)
return STRATEGY_NAME_LOSE;
if (strategy == GLFW_NO_RESET_NOTIFICATION)
return STRATEGY_NAME_NONE;
return "unknown";
}
static void list_extensions(int api, int major, int minor)
{
int i;
GLint count;
const GLubyte* extensions;
printf("%s context supported extensions:\n", get_client_api_name(api));
if (api == GLFW_OPENGL_API && major > 2)
{
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
if (!glGetStringi)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (i = 0; i < count; i++)
puts((const char*) glGetStringi(GL_EXTENSIONS, i));
}
else
{
extensions = glGetString(GL_EXTENSIONS);
while (*extensions != '\0')
{
if (*extensions == ' ')
putchar('\n');
else
putchar(*extensions);
extensions++;
}
}
putchar('\n');
}
static GLboolean valid_version(void)
{
int major, minor, revision;
glfwGetVersion(&major, &minor, &revision);
printf("GLFW header version: %u.%u.%u\n",
GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION);
printf("GLFW library version: %u.%u.%u\n", major, minor, revision);
if (major != GLFW_VERSION_MAJOR)
{
printf("*** ERROR: GLFW major version mismatch! ***\n");
return GL_FALSE;
}
if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)
printf("*** WARNING: GLFW version mismatch! ***\n");
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
return GL_TRUE;
}
int main(int argc, char** argv)
{
int ch, api = 0, profile = 0, strategy = 0, behavior = 0, major = 1, minor = 0, revision;
GLboolean debug = GL_FALSE, forward = GL_FALSE, list = GL_FALSE;
GLint flags, mask;
GLFWwindow* window;
while ((ch = getopt(argc, argv, "a:b:dfhlm:n:p:s:")) != -1)
{
switch (ch)
{
case 'a':
if (strcasecmp(optarg, API_OPENGL) == 0)
api = GLFW_OPENGL_API;
else if (strcasecmp(optarg, API_OPENGL_ES) == 0)
api = GLFW_OPENGL_ES_API;
else
{
usage();
exit(EXIT_FAILURE);
}
break;
case 'b':
if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0)
behavior = GLFW_RELEASE_BEHAVIOR_NONE;
else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0)
behavior = GLFW_RELEASE_BEHAVIOR_FLUSH;
else
{
usage();
exit(EXIT_FAILURE);
}
break;
case 'd':
debug = GL_TRUE;
break;
case 'f':
forward = GL_TRUE;
break;
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'l':
list = GL_TRUE;
break;
case 'm':
major = atoi(optarg);
break;
case 'n':
minor = atoi(optarg);
break;
case 'p':
if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
profile = GLFW_OPENGL_CORE_PROFILE;
else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
profile = GLFW_OPENGL_COMPAT_PROFILE;
else
{
usage();
exit(EXIT_FAILURE);
}
break;
case 's':
if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
strategy = GLFW_NO_RESET_NOTIFICATION;
else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
strategy = GLFW_LOSE_CONTEXT_ON_RESET;
else
{
usage();
exit(EXIT_FAILURE);
}
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
// Initialize GLFW and create window
if (!valid_version())
exit(EXIT_FAILURE);
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
if (major != 1 || minor != 0)
{
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
}
if (api != 0)
glfwWindowHint(GLFW_CLIENT_API, api);
if (debug)
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
if (forward)
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
if (profile != 0)
glfwWindowHint(GLFW_OPENGL_PROFILE, profile);
if (strategy)
glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS, strategy);
if (behavior)
glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, behavior);
glfwWindowHint(GLFW_RED_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_GREEN_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_BLUE_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_ALPHA_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_DEPTH_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_ACCUM_RED_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_ACCUM_GREEN_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_ACCUM_BLUE_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_AUX_BUFFERS, GLFW_DONT_CARE);
glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE);
glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_DONT_CARE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
// Report client API version
api = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
printf("%s context version string: \"%s\"\n",
get_client_api_name(api),
glGetString(GL_VERSION));
printf("%s context version parsed by GLFW: %u.%u.%u\n",
get_client_api_name(api),
major, minor, revision);
// Report client API context properties
if (api == GLFW_OPENGL_API)
{
if (major >= 3)
{
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
printf("%s context flags (0x%08x):", get_client_api_name(api), flags);
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
printf(" forward-compatible");
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
printf(" debug");
if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)
printf(" robustness");
putchar('\n');
printf("%s context flags parsed by GLFW:", get_client_api_name(api));
if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT))
printf(" forward-compatible");
if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT))
printf(" debug");
if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS)
printf(" robustness");
putchar('\n');
}
if (major > 3 || (major == 3 && minor >= 2))
{
int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
printf("%s profile mask (0x%08x): %s\n",
get_client_api_name(api),
mask,
get_profile_name_gl(mask));
printf("%s profile mask parsed by GLFW: %s\n",
get_client_api_name(api),
get_profile_name_glfw(profile));
}
if (glfwExtensionSupported("GL_ARB_robustness"))
{
int robustness;
GLint strategy;
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);
printf("%s robustness strategy (0x%08x): %s\n",
get_client_api_name(api),
strategy,
get_strategy_name_gl(strategy));
robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS);
printf("%s robustness strategy parsed by GLFW: %s\n",
get_client_api_name(api),
get_strategy_name_glfw(robustness));
}
}
printf("%s context renderer string: \"%s\"\n",
get_client_api_name(api),
glGetString(GL_RENDERER));
printf("%s context vendor string: \"%s\"\n",
get_client_api_name(api),
glGetString(GL_VENDOR));
if (major > 1)
{
printf("%s context shading language version: \"%s\"\n",
get_client_api_name(api),
glGetString(GL_SHADING_LANGUAGE_VERSION));
}
// Report client API extensions
if (list)
list_extensions(api, major, minor);
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,254 +0,0 @@
//========================================================================
// Iconify/restore test program
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This program is used to test the iconify/restore functionality for
// both full screen and windowed mode windows
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include "getopt.h"
static void usage(void)
{
printf("Usage: iconify [-h] [-f [-a] [-n]]\n");
printf("Options:\n");
printf(" -a create windows for all monitors\n");
printf(" -f create full screen window(s)\n");
printf(" -h show this help\n");
printf(" -n no automatic iconification of full screen windows\n");
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
printf("%0.2f Key %s\n",
glfwGetTime(),
action == GLFW_PRESS ? "pressed" : "released");
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_SPACE:
glfwIconifyWindow(window);
break;
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
}
static void window_size_callback(GLFWwindow* window, int width, int height)
{
printf("%0.2f Window resized to %ix%i\n", glfwGetTime(), width, height);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
printf("%0.2f Framebuffer resized to %ix%i\n", glfwGetTime(), width, height);
glViewport(0, 0, width, height);
}
static void window_focus_callback(GLFWwindow* window, int focused)
{
printf("%0.2f Window %s\n",
glfwGetTime(),
focused ? "focused" : "defocused");
}
static void window_iconify_callback(GLFWwindow* window, int iconified)
{
printf("%0.2f Window %s\n",
glfwGetTime(),
iconified ? "iconified" : "restored");
}
static void window_refresh_callback(GLFWwindow* window)
{
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glfwMakeContextCurrent(window);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, width, height);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glScissor(0, 0, 640, 480);
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
static GLFWwindow* create_window(GLFWmonitor* monitor)
{
int width, height;
GLFWwindow* window;
if (monitor)
{
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
width = mode->width;
height = mode->height;
}
else
{
width = 640;
height = 480;
}
window = glfwCreateWindow(width, height, "Iconify", monitor, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
return window;
}
int main(int argc, char** argv)
{
int ch, i, window_count;
GLboolean auto_iconify = GL_TRUE, fullscreen = GL_FALSE, all_monitors = GL_FALSE;
GLFWwindow** windows;
while ((ch = getopt(argc, argv, "afhn")) != -1)
{
switch (ch)
{
case 'a':
all_monitors = GL_TRUE;
break;
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'f':
fullscreen = GL_TRUE;
break;
case 'n':
auto_iconify = GL_FALSE;
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_AUTO_ICONIFY, auto_iconify);
if (fullscreen && all_monitors)
{
int monitor_count;
GLFWmonitor** monitors = glfwGetMonitors(&monitor_count);
window_count = monitor_count;
windows = calloc(window_count, sizeof(GLFWwindow*));
for (i = 0; i < monitor_count; i++)
{
windows[i] = create_window(monitors[i]);
if (!windows[i])
break;
}
}
else
{
GLFWmonitor* monitor = NULL;
if (fullscreen)
monitor = glfwGetPrimaryMonitor();
window_count = 1;
windows = calloc(window_count, sizeof(GLFWwindow*));
windows[0] = create_window(monitor);
}
for (i = 0; i < window_count; i++)
{
glfwSetKeyCallback(windows[i], key_callback);
glfwSetFramebufferSizeCallback(windows[i], framebuffer_size_callback);
glfwSetWindowSizeCallback(windows[i], window_size_callback);
glfwSetWindowFocusCallback(windows[i], window_focus_callback);
glfwSetWindowIconifyCallback(windows[i], window_iconify_callback);
glfwSetWindowRefreshCallback(windows[i], window_refresh_callback);
window_refresh_callback(windows[i]);
printf("Window is %s and %s\n",
glfwGetWindowAttrib(windows[i], GLFW_ICONIFIED) ? "iconified" : "restored",
glfwGetWindowAttrib(windows[i], GLFW_FOCUSED) ? "focused" : "defocused");
}
for (;;)
{
glfwPollEvents();
for (i = 0; i < window_count; i++)
{
if (glfwWindowShouldClose(windows[i]))
break;
}
if (i < window_count)
break;
// Workaround for an issue with msvcrt and mintty
fflush(stdout);
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,234 +0,0 @@
//========================================================================
// Joystick input test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test displays the state of every button and axis of every connected
// joystick and/or gamepad
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef _MSC_VER
#define strdup(x) _strdup(x)
#endif
typedef struct Joystick
{
GLboolean present;
char* name;
float* axes;
unsigned char* buttons;
int axis_count;
int button_count;
} Joystick;
static Joystick joysticks[GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1 + 1];
static int joystick_count = 0;
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
static void draw_joystick(Joystick* j, int x, int y, int width, int height)
{
int i;
const int axis_height = 3 * height / 4;
const int button_height = height / 4;
if (j->axis_count)
{
const int axis_width = width / j->axis_count;
for (i = 0; i < j->axis_count; i++)
{
float value = j->axes[i] / 2.f + 0.5f;
glColor3f(0.3f, 0.3f, 0.3f);
glRecti(x + i * axis_width,
y,
x + (i + 1) * axis_width,
y + axis_height);
glColor3f(1.f, 1.f, 1.f);
glRecti(x + i * axis_width,
y + (int) (value * (axis_height - 5)),
x + (i + 1) * axis_width,
y + 5 + (int) (value * (axis_height - 5)));
}
}
if (j->button_count)
{
const int button_width = width / j->button_count;
for (i = 0; i < j->button_count; i++)
{
if (j->buttons[i])
glColor3f(1.f, 1.f, 1.f);
else
glColor3f(0.3f, 0.3f, 0.3f);
glRecti(x + i * button_width,
y + axis_height,
x + (i + 1) * button_width,
y + axis_height + button_height);
}
}
}
static void draw_joysticks(GLFWwindow* window)
{
int i, width, height;
glfwGetFramebufferSize(window, &width, &height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, width, height, 0.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
for (i = 0; i < sizeof(joysticks) / sizeof(Joystick); i++)
{
Joystick* j = joysticks + i;
if (j->present)
{
draw_joystick(j,
0, i * height / joystick_count,
width, height / joystick_count);
}
}
}
static void refresh_joysticks(void)
{
int i;
for (i = 0; i < sizeof(joysticks) / sizeof(Joystick); i++)
{
Joystick* j = joysticks + i;
if (glfwJoystickPresent(GLFW_JOYSTICK_1 + i))
{
const float* axes;
const unsigned char* buttons;
int axis_count, button_count;
free(j->name);
j->name = strdup(glfwGetJoystickName(GLFW_JOYSTICK_1 + i));
axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1 + i, &axis_count);
if (axis_count != j->axis_count)
{
j->axis_count = axis_count;
j->axes = realloc(j->axes, j->axis_count * sizeof(float));
}
memcpy(j->axes, axes, axis_count * sizeof(float));
buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1 + i, &button_count);
if (button_count != j->button_count)
{
j->button_count = button_count;
j->buttons = realloc(j->buttons, j->button_count);
}
memcpy(j->buttons, buttons, button_count * sizeof(unsigned char));
if (!j->present)
{
printf("Found joystick %i named \'%s\' with %i axes, %i buttons\n",
i + 1, j->name, j->axis_count, j->button_count);
joystick_count++;
}
j->present = GL_TRUE;
}
else
{
if (j->present)
{
printf("Lost joystick %i named \'%s\'\n", i + 1, j->name);
free(j->name);
free(j->axes);
free(j->buttons);
memset(j, 0, sizeof(Joystick));
joystick_count--;
}
}
}
}
int main(void)
{
GLFWwindow* window;
memset(joysticks, 0, sizeof(joysticks));
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "Joystick Test", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
refresh_joysticks();
draw_joysticks(window);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,240 +0,0 @@
//========================================================================
// Video mode test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test enumerates or verifies video modes
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "getopt.h"
enum Mode
{
LIST_MODE,
TEST_MODE
};
static void usage(void)
{
printf("Usage: modes [-t]\n");
printf(" modes -h\n");
}
static const char* format_mode(const GLFWvidmode* mode)
{
static char buffer[512];
sprintf(buffer,
"%i x %i x %i (%i %i %i) %i Hz",
mode->width, mode->height,
mode->redBits + mode->greenBits + mode->blueBits,
mode->redBits, mode->greenBits, mode->blueBits,
mode->refreshRate);
buffer[sizeof(buffer) - 1] = '\0';
return buffer;
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
printf("Framebuffer resized to %ix%i\n", width, height);
glViewport(0, 0, width, height);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE)
glfwSetWindowShouldClose(window, GL_TRUE);
}
static void list_modes(GLFWmonitor* monitor)
{
int count, x, y, widthMM, heightMM, dpi, i;
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
glfwGetMonitorPos(monitor, &x, &y);
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
printf("Name: %s (%s)\n",
glfwGetMonitorName(monitor),
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
printf("Current mode: %s\n", format_mode(mode));
printf("Virtual position: %i %i\n", x, y);
dpi = (int) ((float) mode->width * 25.4f / (float) widthMM);
printf("Physical size: %i x %i mm (%i dpi)\n", widthMM, heightMM, dpi);
printf("Modes:\n");
for (i = 0; i < count; i++)
{
printf("%3u: %s", (unsigned int) i, format_mode(modes + i));
if (memcmp(mode, modes + i, sizeof(GLFWvidmode)) == 0)
printf(" (current mode)");
putchar('\n');
}
}
static void test_modes(GLFWmonitor* monitor)
{
int i, count;
GLFWwindow* window;
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
for (i = 0; i < count; i++)
{
const GLFWvidmode* mode = modes + i;
GLFWvidmode current;
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
printf("Testing mode %u on monitor %s: %s\n",
(unsigned int) i,
glfwGetMonitorName(monitor),
format_mode(mode));
window = glfwCreateWindow(mode->width, mode->height,
"Video Mode Test",
glfwGetPrimaryMonitor(),
NULL);
if (!window)
{
printf("Failed to enter mode %u: %s\n",
(unsigned int) i,
format_mode(mode));
continue;
}
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetTime(0.0);
while (glfwGetTime() < 5.0)
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
if (glfwWindowShouldClose(window))
{
printf("User terminated program\n");
glfwTerminate();
exit(EXIT_SUCCESS);
}
}
glGetIntegerv(GL_RED_BITS, &current.redBits);
glGetIntegerv(GL_GREEN_BITS, &current.greenBits);
glGetIntegerv(GL_BLUE_BITS, &current.blueBits);
glfwGetWindowSize(window, &current.width, &current.height);
if (current.redBits != mode->redBits ||
current.greenBits != mode->greenBits ||
current.blueBits != mode->blueBits)
{
printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
current.redBits, current.greenBits, current.blueBits,
mode->redBits, mode->greenBits, mode->blueBits);
}
if (current.width != mode->width || current.height != mode->height)
{
printf("*** Size mismatch: %ix%i instead of %ix%i\n",
current.width, current.height,
mode->width, mode->height);
}
printf("Closing window\n");
glfwDestroyWindow(window);
window = NULL;
glfwPollEvents();
}
}
int main(int argc, char** argv)
{
int ch, i, count, mode = LIST_MODE;
GLFWmonitor** monitors;
while ((ch = getopt(argc, argv, "th")) != -1)
{
switch (ch)
{
case 'h':
usage();
exit(EXIT_SUCCESS);
case 't':
mode = TEST_MODE;
break;
default:
usage();
exit(EXIT_FAILURE);
}
}
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
monitors = glfwGetMonitors(&count);
for (i = 0; i < count; i++)
{
if (mode == LIST_MODE)
list_modes(monitors[i]);
else if (mode == TEST_MODE)
test_modes(monitors[i]);
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,151 +0,0 @@
//========================================================================
// Cursor mode test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test allows you to switch between the various cursor modes
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
static GLboolean reopen = GL_FALSE;
static double cursor_x;
static double cursor_y;
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void cursor_position_callback(GLFWwindow* window, double x, double y)
{
printf("%0.3f: Cursor position: %f %f (%f %f)\n",
glfwGetTime(),
x, y, x - cursor_x, y - cursor_y);
cursor_x = x;
cursor_y = y;
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_D:
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
printf("(( cursor is disabled ))\n");
break;
case GLFW_KEY_H:
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
printf("(( cursor is hidden ))\n");
break;
case GLFW_KEY_N:
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
printf("(( cursor is normal ))\n");
break;
case GLFW_KEY_R:
reopen = GL_TRUE;
break;
}
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
static GLFWwindow* open_window(void)
{
GLFWwindow* window = glfwCreateWindow(640, 480, "Peter Detector", NULL, NULL);
if (!window)
return NULL;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwGetCursorPos(window, &cursor_x, &cursor_y);
printf("Cursor position: %f %f\n", cursor_x, cursor_y);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwSetKeyCallback(window, key_callback);
return window;
}
int main(void)
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = open_window();
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glClearColor(0.f, 0.f, 0.f, 0.f);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwWaitEvents();
if (reopen)
{
glfwDestroyWindow(window);
window = open_window();
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
reopen = GL_FALSE;
}
// Workaround for an issue with msvcrt and mintty
fflush(stdout);
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,177 +0,0 @@
//========================================================================
// Window re-opener (open/close stress test)
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test came about as the result of bug #1262773
//
// It closes and re-opens the GLFW window every five seconds, alternating
// between windowed and full screen mode
//
// It also times and logs opening and closing actions and attempts to separate
// user initiated window closing from its own
//
//========================================================================
#include <GLFW/glfw3.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
static void window_close_callback(GLFWwindow* window)
{
printf("Close callback triggered\n");
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS)
return;
switch (key)
{
case GLFW_KEY_Q:
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
break;
}
}
static GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor)
{
double base;
GLFWwindow* window;
base = glfwGetTime();
window = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL);
if (!window)
return NULL;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetKeyCallback(window, key_callback);
if (monitor)
{
printf("Opening full screen window on monitor %s took %0.3f seconds\n",
glfwGetMonitorName(monitor),
glfwGetTime() - base);
}
else
{
printf("Opening regular window took %0.3f seconds\n",
glfwGetTime() - base);
}
return window;
}
static void close_window(GLFWwindow* window)
{
double base = glfwGetTime();
glfwDestroyWindow(window);
printf("Closing window took %0.3f seconds\n", glfwGetTime() - base);
}
int main(int argc, char** argv)
{
int count = 0;
GLFWwindow* window;
srand((unsigned int) time(NULL));
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
for (;;)
{
GLFWmonitor* monitor = NULL;
if (count % 2 == 0)
{
int monitorCount;
GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
monitor = monitors[rand() % monitorCount];
}
window = open_window(640, 480, monitor);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
glfwSetTime(0.0);
while (glfwGetTime() < 5.0)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f);
glRectf(-0.5f, -0.5f, 1.f, 1.f);
glPopMatrix();
glfwSwapBuffers(window);
glfwPollEvents();
if (glfwWindowShouldClose(window))
{
close_window(window);
printf("User closed window\n");
glfwTerminate();
exit(EXIT_SUCCESS);
}
}
printf("Closing window\n");
close_window(window);
count++;
}
glfwTerminate();
}

View File

@ -1,184 +0,0 @@
//========================================================================
// Context sharing test program
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This program is used to test sharing of objects between contexts
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 400
#define HEIGHT 400
#define OFFSET 50
static GLFWwindow* windows[2];
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
glfwSetWindowShouldClose(window, GL_TRUE);
}
static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY)
{
GLFWwindow* window;
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share);
if (!window)
return NULL;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowPos(window, posX, posY);
glfwShowWindow(window);
glfwSetKeyCallback(window, key_callback);
return window;
}
static GLuint create_texture(void)
{
int x, y;
char pixels[256 * 256];
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
for (y = 0; y < 256; y++)
{
for (x = 0; x < 256; x++)
pixels[y * 256 + x] = rand() % 256;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return texture;
}
static void draw_quad(GLuint texture)
{
int width, height;
glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin(GL_QUADS);
glTexCoord2f(0.f, 0.f);
glVertex2f(0.f, 0.f);
glTexCoord2f(1.f, 0.f);
glVertex2f(1.f, 0.f);
glTexCoord2f(1.f, 1.f);
glVertex2f(1.f, 1.f);
glTexCoord2f(0.f, 1.f);
glVertex2f(0.f, 1.f);
glEnd();
}
int main(int argc, char** argv)
{
int x, y, width;
GLuint texture;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
windows[0] = open_window("First", NULL, OFFSET, OFFSET);
if (!windows[0])
{
glfwTerminate();
exit(EXIT_FAILURE);
}
// This is the one and only time we create a texture
// It is created inside the first context, created above
// It will then be shared with the second context, created below
texture = create_texture();
glfwGetWindowPos(windows[0], &x, &y);
glfwGetWindowSize(windows[0], &width, NULL);
// Put the second window to the right of the first one
windows[1] = open_window("Second", windows[0], x + width + OFFSET, y);
if (!windows[1])
{
glfwTerminate();
exit(EXIT_FAILURE);
}
// Set drawing color for both contexts
glfwMakeContextCurrent(windows[0]);
glColor3f(0.6f, 0.f, 0.6f);
glfwMakeContextCurrent(windows[1]);
glColor3f(0.6f, 0.6f, 0.f);
glfwMakeContextCurrent(windows[0]);
while (!glfwWindowShouldClose(windows[0]) &&
!glfwWindowShouldClose(windows[1]))
{
glfwMakeContextCurrent(windows[0]);
draw_quad(texture);
glfwMakeContextCurrent(windows[1]);
draw_quad(texture);
glfwSwapBuffers(windows[0]);
glfwSwapBuffers(windows[1]);
glfwWaitEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,130 +0,0 @@
//========================================================================
// Vsync enabling test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test renders a high contrast, horizontally moving bar, allowing for
// visual verification of whether the set swap interval is indeed obeyed
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
static int swap_interval;
static double frame_rate;
static void update_window_title(GLFWwindow* window)
{
char title[256];
sprintf(title, "Tearing detector (interval %i, %0.1f Hz)",
swap_interval, frame_rate);
glfwSetWindowTitle(window, title);
}
static void set_swap_interval(GLFWwindow* window, int interval)
{
swap_interval = interval;
glfwSwapInterval(swap_interval);
update_window_title(window);
}
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
set_swap_interval(window, 1 - swap_interval);
}
int main(void)
{
float position;
unsigned long frame_count = 0;
double last_time, current_time;
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(640, 480, "", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
set_swap_interval(window, 0);
last_time = glfwGetTime();
frame_rate = 0.0;
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetKeyCallback(window, key_callback);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
position = cosf((float) glfwGetTime() * 4.f) * 0.75f;
glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f);
glfwSwapBuffers(window);
glfwPollEvents();
frame_count++;
current_time = glfwGetTime();
if (current_time - last_time > 1.0)
{
frame_rate = frame_count / (current_time - last_time);
frame_count = 0;
last_time = current_time;
update_window_title(window);
}
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,135 +0,0 @@
//========================================================================
// Multi-threading test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test is intended to verify whether the OpenGL context part of
// the GLFW API is able to be used from multiple threads
//
//========================================================================
#include "tinycthread.h"
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct
{
GLFWwindow* window;
const char* title;
float r, g, b;
thrd_t id;
} Thread;
static volatile GLboolean running = GL_TRUE;
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static int thread_main(void* data)
{
const Thread* thread = data;
glfwMakeContextCurrent(thread->window);
glfwSwapInterval(1);
while (running)
{
const float v = (float) fabs(sin(glfwGetTime() * 2.f));
glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(thread->window);
}
glfwMakeContextCurrent(NULL);
return 0;
}
int main(void)
{
int i, result;
Thread threads[] =
{
{ NULL, "Red", 1.f, 0.f, 0.f, 0 },
{ NULL, "Green", 0.f, 1.f, 0.f, 0 },
{ NULL, "Blue", 0.f, 0.f, 1.f, 0 }
};
const int count = sizeof(threads) / sizeof(Thread);
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
for (i = 0; i < count; i++)
{
threads[i].window = glfwCreateWindow(200, 200,
threads[i].title,
NULL, NULL);
if (!threads[i].window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);
glfwShowWindow(threads[i].window);
if (thrd_create(&threads[i].id, thread_main, threads + i) !=
thrd_success)
{
fprintf(stderr, "Failed to create secondary thread\n");
glfwTerminate();
exit(EXIT_FAILURE);
}
}
while (running)
{
glfwWaitEvents();
for (i = 0; i < count; i++)
{
if (glfwWindowShouldClose(threads[i].window))
running = GL_FALSE;
}
}
for (i = 0; i < count; i++)
glfwHideWindow(threads[i].window);
for (i = 0; i < count; i++)
thrd_join(threads[i].id, &result);
exit(EXIT_SUCCESS);
}

View File

@ -1,76 +0,0 @@
//========================================================================
// UTF-8 window title test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test sets a UTF-8 window title
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
int main(void)
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwWaitEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,117 +0,0 @@
//========================================================================
// Simple multi-window test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without 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.
//
//========================================================================
//
// This test creates four windows and clears each in a different color
//
//========================================================================
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
static const char* titles[4] =
{
"Foo",
"Bar",
"Baz",
"Quux"
};
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
{
int xpos, ypos;
glfwGetWindowPos(window, &xpos, &ypos);
glfwSetWindowPos(window, xpos, ypos);
}
}
int main(void)
{
int i;
GLboolean running = GL_TRUE;
GLFWwindow* windows[4];
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
for (i = 0; i < 4; i++)
{
int left, top, right, bottom;
windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);
if (!windows[i])
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetKeyCallback(windows[i], key_callback);
glfwMakeContextCurrent(windows[i]);
glClearColor((GLclampf) (i & 1),
(GLclampf) (i >> 1),
i ? 0.f : 1.f,
0.f);
glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);
glfwSetWindowPos(windows[i],
100 + (i & 1) * (200 + left + right),
100 + (i >> 1) * (200 + top + bottom));
}
for (i = 0; i < 4; i++)
glfwShowWindow(windows[i]);
while (running)
{
for (i = 0; i < 4; i++)
{
glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(windows[i]);
if (glfwWindowShouldClose(windows[i]))
running = GL_FALSE;
}
glfwPollEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -1,84 +0,0 @@
# Minimum cmake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Project configuration
PROJECT(OPENGLFRAMEWORK)
# Options
OPTION(USE_JPEG_TEXTURES "Select this if you want to use jpeg textures (libjpeg required)" OFF)
# Where to find the module to find special packages/libraries
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
# Find OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
IF(OPENGL_FOUND)
MESSAGE("OpenGL found")
ELSE()
MESSAGE("OpenGL not found")
ENDIF()
# Find the GLEW library
FIND_PACKAGE(GLEW REQUIRED)
IF(GLEW_FOUND)
MESSAGE("GLEW found")
ELSE()
MESSAGE("GLEW not found")
ENDIF()
# If the user wants to use JPEG textures
IF(USE_JPEG_TEXTURES)
# Find the LIBJPEG library
FIND_PACKAGE(JPEG REQUIRED)
IF(JPEG_FOUND)
MESSAGE("LIBJPEG found")
ELSE()
MESSAGE("LIBJPEG not found")
ENDIF()
ENDIF()
# Headers
INCLUDE_DIRECTORIES(src ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR})
# Source files
SET(OPENGL_FRAMEWORK_SOURCES
"src/maths/Color.h"
"src/maths/Matrix3.h"
"src/maths/Matrix4.h"
"src/maths/Vector2.h"
"src/maths/Vector3.h"
"src/maths/Vector4.h"
"src/Camera.cpp"
"src/Camera.h"
"src/definitions.h"
"src/FrameBufferObject.cpp"
"src/FrameBufferObject.h"
"src/Light.h"
"src/Light.cpp"
"src/Mesh.h"
"src/Mesh.cpp"
"src/MeshReaderWriter.h"
"src/MeshReaderWriter.cpp"
"src/Object3D.h"
"src/Object3D.cpp"
"src/openglframework.h"
"src/Shader.h"
"src/Shader.cpp"
"src/Texture2D.h"
"src/Texture2D.cpp"
"src/TextureReaderWriter.h"
"src/TextureReaderWriter.cpp"
"src/VertexBufferObject.h"
"src/VertexBufferObject.cpp"
)
IF(USE_JPEG_TEXTURES)
ADD_DEFINITIONS(-DUSE_JPEG_TEXTURE)
ENDIF()
# Create the library
ADD_LIBRARY (openglframework STATIC ${OPENGL_FRAMEWORK_SOURCES})
# Link with others libraries
TARGET_LINK_LIBRARIES(openglframework ${GLEW_LIBRARIES} ${OPENGL_LIBRARY})

View File

@ -1,32 +0,0 @@
# This module is used to try to find the Freeglut library and include files
IF(WIN32)
FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h)
FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut freeglut_static
PATHS ${OPENGL_LIBRARY_DIR})
ELSE(WIN32)
IF(APPLE)
# Do nothing, we do not want to use freeglut on Mac OS X
ELSE(APPLE)
FIND_PATH(FREEGLUT_INCLUDE_DIR GL/freeglut.h /usr/include/GL
/usr/openwin/share/include
/usr/openwin/include
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglut)
FIND_LIBRARY(FREEGLUT_LIBRARY NAMES glut freeglut freeglut_static PATHS /usr/openwin/lib)
FIND_LIBRARY(Xi_LIBRARY Xi /usr/openwin/lib)
FIND_LIBRARY(Xmu_LIBRARY Xmu /usr/openwin/lib)
ENDIF(APPLE)
ENDIF(WIN32)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREEGLUT REQUIRED_VARS FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR)
IF(FREEGLUT_FOUND)
SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY} ${Xi_LIBRARY} ${Xmu_LIBRARY})
SET(FREEGLUT_LIBRARY ${FREEGLUT_LIBRARIES})
ENDIF(FREEGLUT_FOUND)
MARK_AS_ADVANCED(FREEGLUT_INCLUDE_DIR FREEGLUT_LIBRARY Xi_LIBRARY Xmu_LIBRARY)

View File

@ -1,65 +0,0 @@
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_PATH
# GLEW_LIBRARY
#
IF (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
$ENV{PROGRAMFILES}/GLEW/include
${GLEW_ROOT_DIR}/include
DOC "The directory where GL/glew.h resides")
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
FIND_LIBRARY( GLEW_LIBRARY
NAMES glew64 glew64s
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEW library (64-bit)"
)
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
FIND_LIBRARY( GLEW_LIBRARY
NAMES glew GLEW glew32 glew32s
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEW library"
)
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
ELSE (WIN32)
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${GLEW_ROOT_DIR}/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES GLEW glew
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
${GLEW_ROOT_DIR}/lib
DOC "The GLEW library")
ENDIF (WIN32)
SET(GLEW_FOUND "NO")
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
SET(GLEW_FOUND "YES")
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH)

View File

@ -1,100 +0,0 @@
/********************************************************************************
* OpenGL-Framework *
* Copyright (c) 2013 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Light.h"
// Namespaces
using namespace openglframework;
// Constructor
Light::Light(GLuint id)
: mLightID(id), mDiffuseColor(Color::white()),
mSpecularColor(Color::white()), mIsActive(false) {
}
// Constructor
Light::Light(GLuint id, Color diffuseColor, Color specularColor)
: mLightID(id), mDiffuseColor(diffuseColor),
mSpecularColor(specularColor), mIsActive(false) {
}
// Destructor
Light::~Light() {
}
// Initialize the light
void Light::init() {
// Enable the light
enable();
// Set the diffuse and specular color
GLfloat diffuseColor[] = {mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a};
GLfloat specularColor[] = {mSpecularColor.r,mSpecularColor.g,mSpecularColor.b,mSpecularColor.a};
glLightfv(mLightID, GL_DIFFUSE, diffuseColor);
glLightfv(mLightID, GL_SPECULAR, specularColor);
}
// Create a shadow map associated with this light
bool Light::createShadowMap(uint width, uint height) {
// Destroy the current shadow map
destroyShadowMap();
// Create the Framebuffer object to render the shadow map
bool isFBOCreated = mFBOShadowMap.create(width, height, false);
if (!isFBOCreated) {
std::cerr << "Error : Cannot create the Shadow Map !" << std::endl;
destroyShadowMap();
return false;
}
// Bind the Framebuffer object
mFBOShadowMap.bind(GL_NONE);
// Create the shadow map depth texture
mShadowMap.create(width, height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE);
// Attache the shadow map texture to the Framebuffer object
mFBOShadowMap.attachTexture(GL_DEPTH_ATTACHMENT_EXT, mShadowMap.getID());
// Unbind the Framebuffer object
mFBOShadowMap.unbind();
// TODO : Change the path of the shader here so that it does not depend on the build folder
bool isShaderCreated = mDepthShader.create("../../opengl-framework/src/shaders/depth.vert",
"../../opengl-framework/src/shaders/depth.vert");
if (!isShaderCreated) {
std::cerr << "Error : Cannot create the Shadow Map !" << std::endl;
destroyShadowMap();
return false;
}
return true;
}

View File

@ -1,34 +0,0 @@
# Minimum cmake version required
cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(Cubes)
# Where to build the executables
SET(EXECUTABLE_OUTPUT_PATH "${OUR_EXECUTABLE_OUTPUT_PATH}/cubes")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
# Copy the shaders used for the demo into the build directory
FILE(COPY "${OPENGLFRAMEWORK_DIR}/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Headers
INCLUDE_DIRECTORIES("${OPENGLFRAMEWORK_DIR}/src/" "../common/glfw/include/" "../common/")
# Source files
SET(CUBES_SOURCES
Cubes.cpp
Scene.cpp
Scene.h
"../common/Box.cpp"
"../common/Box.h"
"../common/Viewer.cpp"
"../common/Viewer.h"
)
# Create the executable
ADD_EXECUTABLE(cubes ${CUBES_SOURCES})
# Link with libraries
TARGET_LINK_LIBRARIES(cubes reactphysics3d openglframework glfw ${GLFW_LIBRARIES})

View File

@ -1,148 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Scene.h"
#include "Viewer.h"
// Declarations
void simulate();
void render();
void update();
void mouseButton(GLFWwindow* window, int button, int action, int mods);
void mouseMotion(GLFWwindow* window, double x, double y);
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
void scroll(GLFWwindow* window, double xAxis, double yAxis);
void init();
// Namespaces
using namespace openglframework;
// Global variables
Viewer* viewer;
Scene* scene;
// Main function
int main(int argc, char** argv) {
// Create and initialize the Viewer
viewer = new Viewer();
Vector2 windowsSize = Vector2(800, 600);
Vector2 windowsPosition = Vector2(100, 100);
viewer->init(argc, argv, "ReactPhysics3D Examples - Cubes", windowsSize, windowsPosition, true);
// If the shaders folder is not specified as an argument
if (argc < 2) {
std::cerr << "Error : You need to specify the shaders folder as argument !" << std::endl;
return 1;
}
// Get the path of the shaders folder
std::string shaderFolderPath(argv[1]);
// Register callback methods
viewer->registerUpdateFunction(update);
viewer->registerKeyboardCallback(keyboard);
viewer->registerMouseButtonCallback(mouseButton);
viewer->registerMouseCursorCallback(mouseMotion);
viewer->registerScrollingCallback(scroll);
// Create the scene
scene = new Scene(viewer, shaderFolderPath);
init();
viewer->startMainLoop();
delete viewer;
delete scene;
return 0;
}
// Update function that is called each frame
void update() {
// Take a simulation step
simulate();
// Render
render();
}
// Simulate function
void simulate() {
// Physics simulation
scene->simulate();
// Compute the current framerate
viewer->computeFPS();
}
// Initialization
void init() {
// Define the background color (black)
glClearColor(0.0, 0.0, 0.0, 1.0);
}
// Callback method to receive keyboard events
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
else if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) {
scene->pauseContinueSimulation();
}
}
// Callback method to receive scrolling events
void scroll(GLFWwindow* window, double xAxis, double yAxis) {
viewer->scrollingEvent(static_cast<float>(yAxis));
}
// Called when a mouse button event occurs
void mouseButton(GLFWwindow* window, int button, int action, int mods) {
viewer->mouseButtonEvent(button, action);
}
// Called when a mouse motion event occurs
void mouseMotion(GLFWwindow* window, double x, double y) {
viewer->mouseMotionEvent(x, y);
}
// Display the scene
void render() {
// Render the scene
scene->render();
// Display the FPS
viewer->displayGUI();
// Check the OpenGL errors
Viewer::checkOpenGLErrors();
}

View File

@ -1,34 +0,0 @@
# Minimum cmake version required
cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(Joints)
# Where to build the executables
SET(EXECUTABLE_OUTPUT_PATH "${OUR_EXECUTABLE_OUTPUT_PATH}/joints")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
# Copy the shaders used for the demo into the build directory
FILE(COPY "${OPENGLFRAMEWORK_DIR}/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Headers
INCLUDE_DIRECTORIES("${OPENGLFRAMEWORK_DIR}/src/" "../common/glfw/include/" "../common/")
# Source files
SET(JOINTS_SOURCES
Joints.cpp
Scene.cpp
Scene.h
"../common/Box.cpp"
"../common/Box.h"
"../common/Viewer.cpp"
"../common/Viewer.h"
)
# Create the executable
ADD_EXECUTABLE(joints ${JOINTS_SOURCES})
# Link with libraries
TARGET_LINK_LIBRARIES(joints reactphysics3d openglframework glfw ${GLFW_LIBRARIES})

View File

@ -1,149 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Scene.h"
#include "../common/Viewer.h"
// Declarations
void simulate();
void update();
void render();
void mouseButton(GLFWwindow* window, int button, int action, int mods);
void mouseMotion(GLFWwindow* window, double x, double y);
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
void scroll(GLFWwindow* window, double xAxis, double yAxis);
void init();
// Namespaces
using namespace openglframework;
// Global variables
Viewer* viewer;
Scene* scene;
// Main function
int main(int argc, char** argv) {
// Create and initialize the Viewer
viewer = new Viewer();
Vector2 windowsSize = Vector2(800, 600);
Vector2 windowsPosition = Vector2(100, 100);
viewer->init(argc, argv, "ReactPhysics3D Examples - Joints", windowsSize, windowsPosition, true);
// If the shaders folder is not specified as an argument
if (argc < 2) {
std::cerr << "Error : You need to specify the shaders folder as argument !" << std::endl;
return 1;
}
// Get the path of the shaders folder
std::string shaderFolderPath(argv[1]);
// Register callback methods
viewer->registerUpdateFunction(update);
viewer->registerKeyboardCallback(keyboard);
viewer->registerMouseButtonCallback(mouseButton);
viewer->registerMouseCursorCallback(mouseMotion);
viewer->registerScrollingCallback(scroll);
// Create the scene
scene = new Scene(viewer, shaderFolderPath);
init();
viewer->startMainLoop();
delete viewer;
delete scene;
return 0;
}
// Update function that is called each frame
void update() {
// Take a simulation step
simulate();
// Render
render();
}
// Simulate function
void simulate() {
// Physics simulation
scene->simulate();
viewer->computeFPS();
}
// Initialization
void init() {
// Define the background color (black)
glClearColor(0.0, 0.0, 0.0, 1.0);
}
// Callback method to receive keyboard events
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
else if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) {
scene->pauseContinueSimulation();
}
}
// Callback method to receive scrolling events
void scroll(GLFWwindow* window, double xAxis, double yAxis) {
viewer->scrollingEvent(static_cast<float>(yAxis));
}
// Called when a mouse button event occurs
void mouseButton(GLFWwindow* window, int button, int action, int mods) {
viewer->mouseButtonEvent(button, action);
}
// Called when a mouse motion event occurs
void mouseMotion(GLFWwindow* window, double x, double y) {
viewer->mouseMotionEvent(x, y);
}
// Display the scene
void render() {
// Render the scene
scene->render();
// Display the FPS
viewer->displayGUI();
// Check the OpenGL errors
Viewer::checkOpenGLErrors();
}

View File

@ -1,43 +0,0 @@
# Minimum cmake version required
cmake_minimum_required(VERSION 2.6)
# Project configuration
PROJECT(Raycast)
# Where to build the executables
SET(EXECUTABLE_OUTPUT_PATH "${OUR_EXECUTABLE_OUTPUT_PATH}/raycast")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
# Copy the shaders used for the demo into the build directory
FILE(COPY "${OPENGLFRAMEWORK_DIR}/src/shaders/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/shaders/")
# Copy the meshes used for the demo into the build directory
FILE(COPY "../common/meshes/" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/meshes/")
# Headers
INCLUDE_DIRECTORIES("${OPENGLFRAMEWORK_DIR}/src/" "../common/glfw/include/" "../common/")
# Source files
SET(RAYCAST_SOURCES
Raycast.cpp
Scene.cpp
Scene.h
"../common/VisualContactPoint.cpp"
"../common/ConvexMesh.cpp"
"../common/Capsule.cpp"
"../common/Sphere.cpp"
"../common/Line.cpp"
"../common/Cylinder.cpp"
"../common/Cone.cpp"
"../common/Dumbbell.cpp"
"../common/Box.cpp"
"../common/Viewer.cpp"
)
# Create the executable
ADD_EXECUTABLE(raycast ${RAYCAST_SOURCES})
# Link with libraries
TARGET_LINK_LIBRARIES(raycast reactphysics3d openglframework glfw ${GLFW_LIBRARIES})

View File

@ -1,155 +0,0 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "Scene.h"
#include "../common/Viewer.h"
// Declarations
void simulate();
void render();
void update();
void mouseButton(GLFWwindow* window, int button, int action, int mods);
void mouseMotion(GLFWwindow* window, double x, double y);
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
void scroll(GLFWwindow* window, double xAxis, double yAxis);
void init();
// Namespaces
using namespace openglframework;
// Global variables
Viewer* viewer;
Scene* scene;
// Main function
int main(int argc, char** argv) {
// Create and initialize the Viewer
viewer = new Viewer();
Vector2 windowsSize = Vector2(800, 600);
Vector2 windowsPosition = Vector2(100, 100);
viewer->init(argc, argv, "ReactPhysics3D Examples - Raycast",
windowsSize, windowsPosition, true);
// If the shaders and meshes folders are not specified as an argument
if (argc < 3) {
std::cerr << "Error : You need to specify the shaders folder as the first argument"
<< " and the meshes folder as the second argument" << std::endl;
return 1;
}
// Get the path of the shaders folder
std::string shaderFolderPath(argv[1]);
std::string meshFolderPath(argv[2]);
// Register callback methods
viewer->registerUpdateFunction(update);
viewer->registerKeyboardCallback(keyboard);
viewer->registerMouseButtonCallback(mouseButton);
viewer->registerMouseCursorCallback(mouseMotion);
viewer->registerScrollingCallback(scroll);
// Create the scene
scene = new Scene(viewer, shaderFolderPath, meshFolderPath);
init();
viewer->startMainLoop();
delete viewer;
delete scene;
return 0;
}
// Update function that is called each frame
void update() {
// Take a simulation step
simulate();
// Render
render();
}
// Simulate function
void simulate() {
// Physics simulation
scene->simulate();
viewer->computeFPS();
}
// Initialization
void init() {
// Define the background color (black)
glClearColor(0.0, 0.0, 0.0, 1.0);
}
// Callback method to receive keyboard events
void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) {
scene->changeBody();
}
if (key == GLFW_KEY_N && action == GLFW_PRESS) {
scene->showHideNormals();
}
}
// Callback method to receive scrolling events
void scroll(GLFWwindow* window, double xAxis, double yAxis) {
viewer->scrollingEvent(static_cast<float>(yAxis));
}
// Called when a mouse button event occurs
void mouseButton(GLFWwindow* window, int button, int action, int mods) {
viewer->mouseButtonEvent(button, action);
}
// Called when a mouse motion event occurs
void mouseMotion(GLFWwindow* window, double x, double y) {
viewer->mouseMotionEvent(x, y);
}
// Display the scene
void render() {
// Render the scene
scene->render();
// Display the FPS
viewer->displayGUI();
// Check the OpenGL errors
Viewer::checkOpenGLErrors();
}

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -83,9 +83,6 @@ class Body {
/// Private assignment operator
Body& operator=(const Body& body);
/// Set the variable to know whether or not the body is sleeping
virtual void setIsSleeping(bool isSleeping);
public :
// -------------------- Methods -------------------- //
@ -105,6 +102,9 @@ class Body {
/// Set whether or not the body is allowed to go to sleep
void setIsAllowedToSleep(bool isAllowedToSleep);
/// Set the variable to know whether or not the body is sleeping
virtual void setIsSleeping(bool isSleeping);
/// Return whether or not the body is sleeping
bool isSleeping() const;

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -26,7 +26,7 @@
// Libraries
#include "CollisionBody.h"
#include "engine/CollisionWorld.h"
#include "engine/ContactManifold.h"
#include "collision/ContactManifold.h"
// We want to use the ReactPhysics3D namespace
using namespace reactphysics3d;
@ -41,10 +41,6 @@ CollisionBody::CollisionBody(const Transform& transform, CollisionWorld& world,
: Body(id), mType(DYNAMIC), mTransform(transform), mProxyCollisionShapes(NULL),
mNbCollisionShapes(0), mContactManifoldsList(NULL), mWorld(world) {
mInterpolationFactor = 0.0;
// Initialize the old transform
mOldTransform = transform;
}
// Destructor
@ -55,30 +51,27 @@ CollisionBody::~CollisionBody() {
removeAllCollisionShapes();
}
// Add a collision shape to the body.
/// When you add a collision shape to the body, an internal copy of this
/// collision shape will be created internally. Therefore, you can delete it
/// right after calling this method or use it later to add it to another body.
// Add a collision shape to the body. Note that you can share a collision
// shape between several bodies using the same collision shape instance to
// when you add the shape to the different bodies. Do not forget to delete
// the collision shape you have created at the end of your program.
/// This method will return a pointer to a new proxy shape. A proxy shape is
/// an object that links a collision shape and a given body. You can use the
/// returned proxy shape to get and set information about the corresponding
/// collision shape for that body.
/**
* @param collisionShape The collision shape you want to add to the body
* @param collisionShape A pointer to the collision shape you want to add to the body
* @param transform The transformation of the collision shape that transforms the
* local-space of the collision shape into the local-space of the body
* @return A pointer to the proxy shape that has been created to link the body to
* the new collision shape you have added.
*/
ProxyShape* CollisionBody::addCollisionShape(const CollisionShape& collisionShape,
ProxyShape* CollisionBody::addCollisionShape(CollisionShape* collisionShape,
const Transform& transform) {
// Create an internal copy of the collision shape into the world (if it does not exist yet)
CollisionShape* newCollisionShape = mWorld.createCollisionShape(collisionShape);
// Create a new proxy collision shape to attach the collision shape to the body
ProxyShape* proxyShape = new (mWorld.mMemoryAllocator.allocate(
sizeof(ProxyShape))) ProxyShape(this, newCollisionShape,
sizeof(ProxyShape))) ProxyShape(this, collisionShape,
transform, decimal(1));
// Add it to the list of proxy collision shapes of the body
@ -92,7 +85,7 @@ ProxyShape* CollisionBody::addCollisionShape(const CollisionShape& collisionShap
// Compute the world-space AABB of the new collision shape
AABB aabb;
newCollisionShape->computeAABB(aabb, mTransform * transform);
collisionShape->computeAABB(aabb, mTransform * transform);
// Notify the collision detection about this new collision shape
mWorld.mCollisionDetection.addProxyCollisionShape(proxyShape, aabb);
@ -122,11 +115,9 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
mWorld.mCollisionDetection.removeProxyCollisionShape(current);
}
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
current->~ProxyShape();
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
mNbCollisionShapes--;
assert(mNbCollisionShapes >= 0);
return;
}
@ -144,7 +135,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
mWorld.mCollisionDetection.removeProxyCollisionShape(elementToRemove);
}
mWorld.removeCollisionShape(proxyShape->mCollisionShape);
elementToRemove->~ProxyShape();
mWorld.mMemoryAllocator.release(elementToRemove, sizeof(ProxyShape));
mNbCollisionShapes--;
@ -154,8 +144,6 @@ void CollisionBody::removeCollisionShape(const ProxyShape* proxyShape) {
// Get the next element in the list
current = current->mNext;
}
assert(mNbCollisionShapes >= 0);
}
// Remove all the collision shapes
@ -173,7 +161,6 @@ void CollisionBody::removeAllCollisionShapes() {
mWorld.mCollisionDetection.removeProxyCollisionShape(current);
}
mWorld.removeCollisionShape(current->mCollisionShape);
current->~ProxyShape();
mWorld.mMemoryAllocator.release(current, sizeof(ProxyShape));
@ -207,15 +194,22 @@ void CollisionBody::updateBroadPhaseState() const {
// For all the proxy collision shapes of the body
for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) {
// Recompute the world-space AABB of the collision shape
AABB aabb;
shape->getCollisionShape()->computeAABB(aabb, mTransform *shape->getLocalToBodyTransform());
// Update the broad-phase state for the proxy collision shape
mWorld.mCollisionDetection.updateProxyCollisionShape(shape, aabb);
// Update the proxy
updateProxyShapeInBroadPhase(shape);
}
}
// Update the broad-phase state of a proxy collision shape of the body
void CollisionBody::updateProxyShapeInBroadPhase(ProxyShape* proxyShape, bool forceReinsert) const {
// Recompute the world-space AABB of the collision shape
AABB aabb;
proxyShape->getCollisionShape()->computeAABB(aabb, mTransform * proxyShape->getLocalToBodyTransform());
// Update the broad-phase state for the proxy collision shape
mWorld.mCollisionDetection.updateProxyCollisionShape(proxyShape, aabb, Vector3(0, 0, 0), forceReinsert);
}
// Set whether or not the body is active
/**
* @param isActive True if you want to activate the body

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -73,12 +73,6 @@ class CollisionBody : public Body {
/// Position and orientation of the body
Transform mTransform;
/// Last position and orientation of the body
Transform mOldTransform;
/// Interpolation factor used for the state interpolation
decimal mInterpolationFactor;
/// First element of the linked list of proxy collision shapes of this body
ProxyShape* mProxyCollisionShapes;
@ -105,12 +99,12 @@ class CollisionBody : public Body {
/// Remove all the collision shapes
void removeAllCollisionShapes();
/// Update the old transform with the current one.
void updateOldTransform();
/// Update the broad-phase state for this body (because it has moved for instance)
virtual void updateBroadPhaseState() const;
/// Update the broad-phase state of a proxy collision shape of the body
void updateProxyShapeInBroadPhase(ProxyShape* proxyShape, bool forceReinsert = false) const;
/// Ask the broad-phase to test again the collision shapes of the body for collision
/// (as if the body has moved).
void askForBroadPhaseCollisionCheck() const;
@ -118,9 +112,6 @@ class CollisionBody : public Body {
/// Reset the mIsAlreadyInIsland variable of the body and contact manifolds
int resetIsAlreadyInIslandAndCountManifolds();
/// Set the interpolation factor of the body
void setInterpolationFactor(decimal factor);
public :
// -------------------- Methods -------------------- //
@ -144,18 +135,15 @@ class CollisionBody : public Body {
const Transform& getTransform() const;
/// Set the current position and orientation
void setTransform(const Transform& transform);
virtual void setTransform(const Transform& transform);
/// Add a collision shape to the body.
virtual ProxyShape* addCollisionShape(const CollisionShape& collisionShape,
const Transform& transform);
virtual ProxyShape* addCollisionShape(CollisionShape* collisionShape,
const Transform& transform);
/// Remove a collision shape from the body
virtual void removeCollisionShape(const ProxyShape* proxyShape);
/// Return the interpolated transform for rendering
Transform getInterpolatedTransform() const;
/// Return the first element of the linked list of contact manifolds involving this body
const ContactManifoldListElement* getContactManifoldsList() const;
@ -227,20 +215,6 @@ inline void CollisionBody::setType(BodyType type) {
}
}
// Return the interpolated transform for rendering
/**
* @return The current interpolated transformation (between previous and current frame)
*/
inline Transform CollisionBody::getInterpolatedTransform() const {
return Transform::interpolateTransforms(mOldTransform, mTransform, mInterpolationFactor);
}
// Set the interpolation factor of the body
inline void CollisionBody::setInterpolationFactor(decimal factor) {
// Set the factor
mInterpolationFactor = factor;
}
// Return the current position and orientation
/**
* @return The current transformation of the body that transforms the local-space
@ -264,12 +238,6 @@ inline void CollisionBody::setTransform(const Transform& transform) {
updateBroadPhaseState();
}
// Update the old transform with the current one.
/// This is used to compute the interpolated position and orientation of the body
inline void CollisionBody::updateOldTransform() {
mOldTransform = mTransform;
}
// Return the first element of the linked list of contact manifolds involving this body
/**
* @return A pointer to the first element of the linked-list with the contact

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -209,18 +209,15 @@ void RigidBody::removeJointFromJointsList(MemoryAllocator& memoryAllocator, cons
* @return A pointer to the proxy shape that has been created to link the body to
* the new collision shape you have added.
*/
ProxyShape* RigidBody::addCollisionShape(const CollisionShape& collisionShape,
ProxyShape* RigidBody::addCollisionShape(CollisionShape* collisionShape,
const Transform& transform,
decimal mass) {
assert(mass > decimal(0.0));
// Create an internal copy of the collision shape into the world if it is not there yet
CollisionShape* newCollisionShape = mWorld.createCollisionShape(collisionShape);
// Create a new proxy collision shape to attach the collision shape to the body
ProxyShape* proxyShape = new (mWorld.mMemoryAllocator.allocate(
sizeof(ProxyShape))) ProxyShape(this, newCollisionShape,
sizeof(ProxyShape))) ProxyShape(this, collisionShape,
transform, mass);
// Add it to the list of proxy collision shapes of the body
@ -234,7 +231,7 @@ ProxyShape* RigidBody::addCollisionShape(const CollisionShape& collisionShape,
// Compute the world-space AABB of the new collision shape
AABB aabb;
newCollisionShape->computeAABB(aabb, mTransform * transform);
collisionShape->computeAABB(aabb, mTransform * transform);
// Notify the collision detection about this new collision shape
mWorld.mCollisionDetection.addProxyCollisionShape(proxyShape, aabb);
@ -265,6 +262,64 @@ void RigidBody::removeCollisionShape(const ProxyShape* proxyShape) {
recomputeMassInformation();
}
// Set the linear velocity of the rigid body.
/**
* @param linearVelocity Linear velocity vector of the body
*/
void RigidBody::setLinearVelocity(const Vector3& linearVelocity) {
// If it is a static body, we do nothing
if (mType == STATIC) return;
// Update the linear velocity of the current body state
mLinearVelocity = linearVelocity;
// If the linear velocity is not zero, awake the body
if (mLinearVelocity.lengthSquare() > decimal(0.0)) {
setIsSleeping(false);
}
}
// Set the angular velocity.
/**
* @param angularVelocity The angular velocity vector of the body
*/
void RigidBody::setAngularVelocity(const Vector3& angularVelocity) {
// If it is a static body, we do nothing
if (mType == STATIC) return;
// Set the angular velocity
mAngularVelocity = angularVelocity;
// If the velocity is not zero, awake the body
if (mAngularVelocity.lengthSquare() > decimal(0.0)) {
setIsSleeping(false);
}
}
// Set the current position and orientation
/**
* @param transform The transformation of the body that transforms the local-space
* of the body into world-space
*/
void RigidBody::setTransform(const Transform& transform) {
// Update the transform of the body
mTransform = transform;
const Vector3 oldCenterOfMass = mCenterOfMassWorld;
// Compute the new center of mass in world-space coordinates
mCenterOfMassWorld = mTransform * mCenterOfMassLocal;
// Update the linear velocity of the center of mass
mLinearVelocity += mAngularVelocity.cross(mCenterOfMassWorld - oldCenterOfMass);
// Update the broad-phase state of the body
updateBroadPhaseState();
}
// Recompute the center of mass, total mass and inertia tensor of the body using all
// the collision shapes attached to the body.
void RigidBody::recomputeMassInformation() {
@ -342,8 +397,8 @@ void RigidBody::updateBroadPhaseState() const {
PROFILE("RigidBody::updateBroadPhaseState()");
DynamicsWorld& world = dynamic_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimer.getTimeStep() * mLinearVelocity;
DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimeStep * mLinearVelocity;
// For all the proxy collision shapes of the body
for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) {

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -118,9 +118,6 @@ class RigidBody : public CollisionBody {
/// Update the broad-phase state for this body (because it has moved for instance)
virtual void updateBroadPhaseState() const;
/// Set the variable to know whether or not the body is sleeping
virtual void setIsSleeping(bool isSleeping);
public :
// -------------------- Methods -------------------- //
@ -134,6 +131,9 @@ class RigidBody : public CollisionBody {
/// Set the type of the body (static, kinematic or dynamic)
void setType(BodyType type);
/// Set the current position and orientation
virtual void setTransform(const Transform& transform);
/// Return the mass of the body
decimal getMass() const;
@ -149,6 +149,9 @@ class RigidBody : public CollisionBody {
/// Set the angular velocity.
void setAngularVelocity(const Vector3& angularVelocity);
/// Set the variable to know whether or not the body is sleeping
virtual void setIsSleeping(bool isSleeping);
/// Return the local inertia tensor of the body (in body coordinates)
const Matrix3x3& getInertiaTensorLocal() const;
@ -207,7 +210,7 @@ class RigidBody : public CollisionBody {
void applyTorque(const Vector3& torque);
/// Add a collision shape to the body.
virtual ProxyShape* addCollisionShape(const CollisionShape& collisionShape,
virtual ProxyShape* addCollisionShape(CollisionShape* collisionShape,
const Transform& transform,
decimal mass);
@ -252,20 +255,6 @@ inline Vector3 RigidBody::getAngularVelocity() const {
return mAngularVelocity;
}
// Set the angular velocity.
/// You should only call this method for a kinematic body. Otherwise, it
/// will do nothing.
/**
* @param angularVelocity The angular velocity vector of the body
*/
inline void RigidBody::setAngularVelocity(const Vector3& angularVelocity) {
// If it is a kinematic body
if (mType == KINEMATIC) {
mAngularVelocity = angularVelocity;
}
}
// Return the local inertia tensor of the body (in local-space coordinates)
/**
* @return The 3x3 inertia tensor matrix of the body (in local-space coordinates)
@ -310,22 +299,6 @@ inline Matrix3x3 RigidBody::getInertiaTensorInverseWorld() const {
mTransform.getOrientation().getMatrix().getTranspose();
}
// Set the linear velocity of the rigid body.
/// You should only call this method for a kinematic body. Otherwise, it
/// will do nothing.
/**
* @param linearVelocity Linear velocity vector of the body
*/
inline void RigidBody::setLinearVelocity(const Vector3& linearVelocity) {
// If it is a kinematic body
if (mType == KINEMATIC) {
// Update the linear velocity of the current body state
mLinearVelocity = linearVelocity;
}
}
// Return true if the gravity needs to be applied to this rigid body
/**
* @return True if the gravity is applied to the body
@ -366,7 +339,8 @@ inline decimal RigidBody::getLinearDamping() const {
return mLinearDamping;
}
// Set the linear damping factor
// Set the linear damping factor. This is the ratio of the linear velocity
// that the body will lose every at seconds of simulation.
/**
* @param linearDamping The linear damping factor of this body
*/
@ -383,7 +357,8 @@ inline decimal RigidBody::getAngularDamping() const {
return mAngularDamping;
}
// Set the angular damping factor
// Set the angular damping factor. This is the ratio of the angular velocity
// that the body will lose at every seconds of simulation.
/**
* @param angularDamping The angular damping factor of this body
*/

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -42,11 +42,15 @@ using namespace std;
// Constructor
CollisionDetection::CollisionDetection(CollisionWorld* world, MemoryAllocator& memoryAllocator)
: mWorld(world), mBroadPhaseAlgorithm(*this),
mNarrowPhaseGJKAlgorithm(memoryAllocator),
mNarrowPhaseSphereVsSphereAlgorithm(memoryAllocator),
: mMemoryAllocator(memoryAllocator),
mWorld(world), mBroadPhaseAlgorithm(*this),
mIsCollisionShapesAdded(false) {
// Set the default collision dispatch configuration
setCollisionDispatch(&mDefaultCollisionDispatch);
// Fill-in the collision detection matrix with algorithms
fillInCollisionMatrix();
}
// Destructor
@ -92,8 +96,8 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac
OverlappingPair* pair = it->second;
ProxyShape* shape1 = pair->getShape1();
ProxyShape* shape2 = pair->getShape2();
const ProxyShape* shape1 = pair->getShape1();
const ProxyShape* shape2 = pair->getShape2();
assert(shape1->mBroadPhaseID != shape2->mBroadPhaseID);
@ -115,26 +119,29 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac
continue;
}
// For each contact manifold of the overlapping pair
ContactManifold* manifold = pair->getContactManifold();
for (uint i=0; i<manifold->getNbContactPoints(); i++) {
// For each contact manifold set of the overlapping pair
const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
for (int j=0; j<manifoldSet.getNbContactManifolds(); j++) {
ContactPoint* contactPoint = manifold->getContactPoint(i);
const ContactManifold* manifold = manifoldSet.getContactManifold(j);
// Create the contact info object for the contact
ContactPointInfo* contactInfo = new (mWorld->mMemoryAllocator.allocate(sizeof(ContactPointInfo)))
ContactPointInfo(manifold->getShape1(), manifold->getShape2(),
contactPoint->getNormal(),
contactPoint->getPenetrationDepth(),
contactPoint->getLocalPointOnBody1(),
contactPoint->getLocalPointOnBody2());
// For each contact manifold of the manifold set
for (uint i=0; i<manifold->getNbContactPoints(); i++) {
// Notify the collision callback about this new contact
if (callback != NULL) callback->notifyContact(*contactInfo);
ContactPoint* contactPoint = manifold->getContactPoint(i);
// Delete and remove the contact info from the memory allocator
contactInfo->~ContactPointInfo();
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
// Create the contact info object for the contact
ContactPointInfo contactInfo(manifold->getShape1(), manifold->getShape2(),
manifold->getShape1()->getCollisionShape(),
manifold->getShape2()->getCollisionShape(),
contactPoint->getNormal(),
contactPoint->getPenetrationDepth(),
contactPoint->getLocalPointOnBody1(),
contactPoint->getLocalPointOnBody2());
// Notify the collision callback about this new contact
if (callback != NULL) callback->notifyContact(contactInfo);
}
}
}
}
@ -159,10 +166,12 @@ void CollisionDetection::computeNarrowPhase() {
PROFILE("CollisionDetection::computeNarrowPhase()");
// Clear the set of overlapping pairs in narrow-phase contact
mContactOverlappingPairs.clear();
// For each possible collision pair of bodies
map<overlappingpairid, OverlappingPair*>::iterator it;
for (it = mOverlappingPairs.begin(); it != mOverlappingPairs.end(); ) {
ContactPointInfo* contactInfo = NULL;
OverlappingPair* pair = it->second;
@ -209,36 +218,30 @@ void CollisionDetection::computeNarrowPhase() {
if (mNoCollisionPairs.count(bodiesIndex) > 0) continue;
// Select the narrow phase algorithm to use according to the two collision shapes
NarrowPhaseAlgorithm& narrowPhaseAlgorithm = selectNarrowPhaseAlgorithm(
shape1->getCollisionShape(),
shape2->getCollisionShape());
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Type][shape2Type];
// If there is no collision algorithm between those two kinds of shapes
if (narrowPhaseAlgorithm == NULL) continue;
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
narrowPhaseAlgorithm.setCurrentOverlappingPair(pair);
narrowPhaseAlgorithm->setCurrentOverlappingPair(pair);
// Create the CollisionShapeInfo objects
CollisionShapeInfo shape1Info(shape1, shape1->getCollisionShape(), shape1->getLocalToWorldTransform(),
pair, shape1->getCachedCollisionData());
CollisionShapeInfo shape2Info(shape2, shape2->getCollisionShape(), shape2->getLocalToWorldTransform(),
pair, shape2->getCachedCollisionData());
// Use the narrow-phase collision detection algorithm to check
// if there really is a collision
if (narrowPhaseAlgorithm.testCollision(shape1, shape2, contactInfo)) {
assert(contactInfo != NULL);
// If it is the first contact since the pair are overlapping
if (pair->getNbContactPoints() == 0) {
// Trigger a callback event
if (mWorld->mEventListener != NULL) mWorld->mEventListener->beginContact(*contactInfo);
}
// Create a new contact
createContact(pair, contactInfo);
// Trigger a callback event for the new contact
if (mWorld->mEventListener != NULL) mWorld->mEventListener->newContact(*contactInfo);
// Delete and remove the contact info from the memory allocator
contactInfo->~ContactPointInfo();
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
}
// if there really is a collision. If a collision occurs, the
// notifyContact() callback method will be called.
narrowPhaseAlgorithm->testCollision(shape1Info, shape2Info, this);
}
// Add all the contact manifolds (between colliding bodies) to the bodies
addAllContactManifoldsToBodies();
}
// Compute the narrow-phase collision detection
@ -246,10 +249,11 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
const std::set<uint>& shapes1,
const std::set<uint>& shapes2) {
mContactOverlappingPairs.clear();
// For each possible collision pair of bodies
map<overlappingpairid, OverlappingPair*>::iterator it;
for (it = mOverlappingPairs.begin(); it != mOverlappingPairs.end(); ) {
ContactPointInfo* contactInfo = NULL;
OverlappingPair* pair = it->second;
@ -316,29 +320,31 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
if (body1->isSleeping() && body2->isSleeping()) continue;
// Select the narrow phase algorithm to use according to the two collision shapes
NarrowPhaseAlgorithm& narrowPhaseAlgorithm = selectNarrowPhaseAlgorithm(
shape1->getCollisionShape(),
shape2->getCollisionShape());
const CollisionShapeType shape1Type = shape1->getCollisionShape()->getType();
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = mCollisionMatrix[shape1Type][shape2Type];
// If there is no collision algorithm between those two kinds of shapes
if (narrowPhaseAlgorithm == NULL) continue;
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
narrowPhaseAlgorithm.setCurrentOverlappingPair(pair);
narrowPhaseAlgorithm->setCurrentOverlappingPair(pair);
// Create the CollisionShapeInfo objects
CollisionShapeInfo shape1Info(shape1, shape1->getCollisionShape(), shape1->getLocalToWorldTransform(),
pair, shape1->getCachedCollisionData());
CollisionShapeInfo shape2Info(shape2, shape2->getCollisionShape(), shape2->getLocalToWorldTransform(),
pair, shape2->getCachedCollisionData());
TestCollisionBetweenShapesCallback narrowPhaseCallback(callback);
// Use the narrow-phase collision detection algorithm to check
// if there really is a collision
if (narrowPhaseAlgorithm.testCollision(shape1, shape2, contactInfo)) {
assert(contactInfo != NULL);
// Create a new contact
createContact(pair, contactInfo);
// Notify the collision callback about this new contact
if (callback != NULL) callback->notifyContact(*contactInfo);
// Delete and remove the contact info from the memory allocator
contactInfo->~ContactPointInfo();
mWorld->mMemoryAllocator.release(contactInfo, sizeof(ContactPointInfo));
}
narrowPhaseAlgorithm->testCollision(shape1Info, shape2Info, &narrowPhaseCallback);
}
// Add all the contact manifolds (between colliding bodies) to the bodies
addAllContactManifoldsToBodies();
}
// Allow the broadphase to notify the collision detection about an overlapping pair.
@ -360,12 +366,19 @@ void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, Pro
// Check if the overlapping pair already exists
if (mOverlappingPairs.find(pairID) != mOverlappingPairs.end()) return;
// Compute the maximum number of contact manifolds for this pair
int nbMaxManifolds = CollisionShape::computeNbMaxContactManifolds(shape1->getCollisionShape()->getType(),
shape2->getCollisionShape()->getType());
// Create the overlapping pair and add it into the set of overlapping pairs
OverlappingPair* newPair = new (mWorld->mMemoryAllocator.allocate(sizeof(OverlappingPair)))
OverlappingPair(shape1, shape2, mWorld->mMemoryAllocator);
OverlappingPair(shape1, shape2, nbMaxManifolds, mWorld->mMemoryAllocator);
assert(newPair != NULL);
#ifndef NDEBUG
std::pair<map<overlappingpairid, OverlappingPair*>::iterator, bool> check =
mOverlappingPairs.insert(make_pair(pairID, newPair));
#endif
mOverlappingPairs.insert(make_pair(pairID, newPair));
assert(check.second);
// Wake up the two bodies
@ -400,47 +413,85 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) {
mBroadPhaseAlgorithm.removeProxyCollisionShape(proxyShape);
}
// Called by a narrow-phase collision algorithm when a new contact has been found
void CollisionDetection::notifyContact(OverlappingPair* overlappingPair, const ContactPointInfo& contactInfo) {
// If it is the first contact since the pairs are overlapping
if (overlappingPair->getNbContactPoints() == 0) {
// Trigger a callback event
if (mWorld->mEventListener != NULL) mWorld->mEventListener->beginContact(contactInfo);
}
// Create a new contact
createContact(overlappingPair, contactInfo);
// Trigger a callback event for the new contact
if (mWorld->mEventListener != NULL) mWorld->mEventListener->newContact(contactInfo);
}
// Create a new contact
void CollisionDetection::createContact(OverlappingPair* overlappingPair,
const ContactPointInfo* contactInfo) {
const ContactPointInfo& contactInfo) {
// Create a new contact
ContactPoint* contact = new (mWorld->mMemoryAllocator.allocate(sizeof(ContactPoint)))
ContactPoint(*contactInfo);
assert(contact != NULL);
ContactPoint(contactInfo);
// Add the contact to the contact cache of the corresponding overlapping pair
// Add the contact to the contact manifold set of the corresponding overlapping pair
overlappingPair->addContact(contact);
// Add the contact manifold into the list of contact manifolds
// of the two bodies involved in the contact
addContactManifoldToBody(overlappingPair->getContactManifold(),
overlappingPair->getShape1()->getBody(),
overlappingPair->getShape2()->getBody());
// Add the overlapping pair into the set of pairs in contact during narrow-phase
overlappingpairid pairId = OverlappingPair::computeID(overlappingPair->getShape1(),
overlappingPair->getShape2());
mContactOverlappingPairs[pairId] = overlappingPair;
}
void CollisionDetection::addAllContactManifoldsToBodies() {
// For each overlapping pairs in contact during the narrow-phase
std::map<overlappingpairid, OverlappingPair*>::iterator it;
for (it = mContactOverlappingPairs.begin(); it != mContactOverlappingPairs.end(); ++it) {
// Add all the contact manifolds of the pair into the list of contact manifolds
// of the two bodies involved in the contact
addContactManifoldToBody(it->second);
}
}
// Add a contact manifold to the linked list of contact manifolds of the two bodies involved
// in the corresponding contact
void CollisionDetection::addContactManifoldToBody(ContactManifold* contactManifold,
CollisionBody* body1, CollisionBody* body2) {
void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
assert(contactManifold != NULL);
assert(pair != NULL);
// Add the contact manifold at the beginning of the linked
// list of contact manifolds of the first body
void* allocatedMemory1 = mWorld->mMemoryAllocator.allocate(sizeof(ContactManifoldListElement));
ContactManifoldListElement* listElement1 = new (allocatedMemory1)
ContactManifoldListElement(contactManifold,
body1->mContactManifoldsList);
body1->mContactManifoldsList = listElement1;
CollisionBody* body1 = pair->getShape1()->getBody();
CollisionBody* body2 = pair->getShape2()->getBody();
const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
// Add the contact manifold at the beginning of the linked
// list of the contact manifolds of the second body
void* allocatedMemory2 = mWorld->mMemoryAllocator.allocate(sizeof(ContactManifoldListElement));
ContactManifoldListElement* listElement2 = new (allocatedMemory2)
ContactManifoldListElement(contactManifold,
body2->mContactManifoldsList);
body2->mContactManifoldsList = listElement2;
// For each contact manifold in the set of manifolds in the pair
for (int i=0; i<manifoldSet.getNbContactManifolds(); i++) {
ContactManifold* contactManifold = manifoldSet.getContactManifold(i);
assert(contactManifold->getNbContactPoints() > 0);
// Add the contact manifold at the beginning of the linked
// list of contact manifolds of the first body
void* allocatedMemory1 = mWorld->mMemoryAllocator.allocate(sizeof(ContactManifoldListElement));
ContactManifoldListElement* listElement1 = new (allocatedMemory1)
ContactManifoldListElement(contactManifold,
body1->mContactManifoldsList);
body1->mContactManifoldsList = listElement1;
// Add the contact manifold at the beginning of the linked
// list of the contact manifolds of the second body
void* allocatedMemory2 = mWorld->mMemoryAllocator.allocate(sizeof(ContactManifoldListElement));
ContactManifoldListElement* listElement2 = new (allocatedMemory2)
ContactManifoldListElement(contactManifold,
body2->mContactManifoldsList);
body2->mContactManifoldsList = listElement2;
}
}
// Delete all the contact points in the currently overlapping pairs
@ -452,3 +503,30 @@ void CollisionDetection::clearContactPoints() {
it->second->clearContactPoints();
}
}
// Fill-in the collision detection matrix
void CollisionDetection::fillInCollisionMatrix() {
// For each possible type of collision shape
for (int i=0; i<NB_COLLISION_SHAPE_TYPES; i++) {
for (int j=0; j<NB_COLLISION_SHAPE_TYPES; j++) {
mCollisionMatrix[i][j] = mCollisionDispatch->selectAlgorithm(i, j);
}
}
}
// Return the world event listener
EventListener* CollisionDetection::getWorldEventListener() {
return mWorld->mEventListener;
}
/// Return a reference to the world memory allocator
MemoryAllocator& CollisionDetection::getWorldMemoryAllocator() {
return mWorld->mMemoryAllocator;
}
// Called by a narrow-phase collision algorithm when a new contact has been found
void TestCollisionBetweenShapesCallback::notifyContact(OverlappingPair* overlappingPair,
const ContactPointInfo& contactInfo) {
mCollisionCallback->notifyContact(contactInfo);
}

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -30,8 +30,8 @@
#include "body/CollisionBody.h"
#include "broadphase/BroadPhaseAlgorithm.h"
#include "engine/OverlappingPair.h"
#include "narrowphase/GJK/GJKAlgorithm.h"
#include "narrowphase/SphereVsSphereAlgorithm.h"
#include "engine/EventListener.h"
#include "narrowphase/DefaultCollisionDispatch.h"
#include "memory/MemoryAllocator.h"
#include "constraint/ContactPoint.h"
#include <vector>
@ -47,6 +47,26 @@ class BroadPhaseAlgorithm;
class CollisionWorld;
class CollisionCallback;
// Class TestCollisionBetweenShapesCallback
class TestCollisionBetweenShapesCallback : public NarrowPhaseCallback {
private:
CollisionCallback* mCollisionCallback;
public:
// Constructor
TestCollisionBetweenShapesCallback(CollisionCallback* callback)
: mCollisionCallback(callback) {
}
// Called by a narrow-phase collision algorithm when a new contact has been found
virtual void notifyContact(OverlappingPair* overlappingPair,
const ContactPointInfo& contactInfo);
};
// Class CollisionDetection
/**
* This class computes the collision detection algorithms. We first
@ -54,27 +74,40 @@ class CollisionCallback;
* collide and then we run a narrow-phase algorithm to compute the
* collision contacts between bodies.
*/
class CollisionDetection {
class CollisionDetection : public NarrowPhaseCallback {
private :
// -------------------- Attributes -------------------- //
/// Collision Detection Dispatch configuration
CollisionDispatch* mCollisionDispatch;
/// Default collision dispatch configuration
DefaultCollisionDispatch mDefaultCollisionDispatch;
/// Collision detection matrix (algorithms to use)
NarrowPhaseAlgorithm* mCollisionMatrix[NB_COLLISION_SHAPE_TYPES][NB_COLLISION_SHAPE_TYPES];
/// Reference to the memory allocator
MemoryAllocator& mMemoryAllocator;
/// Pointer to the physics world
CollisionWorld* mWorld;
/// Broad-phase overlapping pairs
std::map<overlappingpairid, OverlappingPair*> mOverlappingPairs;
/// Overlapping pairs in contact (during the current Narrow-phase collision detection)
std::map<overlappingpairid, OverlappingPair*> mContactOverlappingPairs;
/// Broad-phase algorithm
BroadPhaseAlgorithm mBroadPhaseAlgorithm;
/// Narrow-phase GJK algorithm
// TODO : Delete this
GJKAlgorithm mNarrowPhaseGJKAlgorithm;
/// Narrow-phase Sphere vs Sphere algorithm
SphereVsSphereAlgorithm mNarrowPhaseSphereVsSphereAlgorithm;
/// Set of pair of bodies that cannot collide between each other
std::set<bodyindexpair> mNoCollisionPairs;
@ -95,21 +128,19 @@ class CollisionDetection {
/// Compute the narrow-phase collision detection
void computeNarrowPhase();
/// Select the narrow phase algorithm to use given two collision shapes
NarrowPhaseAlgorithm& selectNarrowPhaseAlgorithm(const CollisionShape* collisionShape1,
const CollisionShape* collisionShape2);
/// Create a new contact
void createContact(OverlappingPair* overlappingPair, const ContactPointInfo* contactInfo);
/// Add a contact manifold to the linked list of contact manifolds of the two bodies
/// involed in the corresponding contact.
void addContactManifoldToBody(ContactManifold* contactManifold,
CollisionBody *body1, CollisionBody *body2);
void addContactManifoldToBody(OverlappingPair* pair);
/// Delete all the contact points in the currently overlapping pairs
void clearContactPoints();
/// Fill-in the collision detection matrix
void fillInCollisionMatrix();
/// Add all the contact manifold of colliding pairs to their bodies
void addAllContactManifoldsToBodies();
public :
// -------------------- Methods -------------------- //
@ -120,6 +151,13 @@ class CollisionDetection {
/// Destructor
~CollisionDetection();
/// Set the collision dispatch configuration
void setCollisionDispatch(CollisionDispatch* collisionDispatch);
/// Return the Narrow-phase collision detection algorithm to use between two types of shapes
NarrowPhaseAlgorithm* getCollisionAlgorithm(CollisionShapeType shape1Type,
CollisionShapeType shape2Type) const;
/// Add a proxy collision shape to the collision detection
void addProxyCollisionShape(ProxyShape* proxyShape, const AABB& aabb);
@ -128,7 +166,7 @@ class CollisionDetection {
/// Update a proxy collision shape (that has moved for instance)
void updateProxyCollisionShape(ProxyShape* shape, const AABB& aabb,
const Vector3& displacement = Vector3(0, 0, 0));
const Vector3& displacement = Vector3(0, 0, 0), bool forceReinsert = false);
/// Add a pair of bodies that cannot collide with each other
void addNoCollisionPair(CollisionBody* body1, CollisionBody* body2);
@ -167,29 +205,46 @@ class CollisionDetection {
/// Allow the broadphase to notify the collision detection about an overlapping pair.
void broadPhaseNotifyOverlappingPair(ProxyShape* shape1, ProxyShape* shape2);
// Compute the narrow-phase collision detection
/// Compute the narrow-phase collision detection
void computeNarrowPhaseBetweenShapes(CollisionCallback* callback,
const std::set<uint>& shapes1,
const std::set<uint>& shapes2);
/// Return a pointer to the world
CollisionWorld* getWorld();
/// Return the world event listener
EventListener* getWorldEventListener();
/// Return a reference to the world memory allocator
MemoryAllocator& getWorldMemoryAllocator();
/// Called by a narrow-phase collision algorithm when a new contact has been found
virtual void notifyContact(OverlappingPair* overlappingPair, const ContactPointInfo& contactInfo);
/// Create a new contact
void createContact(OverlappingPair* overlappingPair, const ContactPointInfo& contactInfo);
// -------------------- Friendship -------------------- //
friend class DynamicsWorld;
friend class ConvexMeshShape;
};
// Select the narrow-phase collision algorithm to use given two collision shapes
inline NarrowPhaseAlgorithm& CollisionDetection::selectNarrowPhaseAlgorithm(
const CollisionShape* collisionShape1,
const CollisionShape* collisionShape2) {
// Return the Narrow-phase collision detection algorithm to use between two types of shapes
inline NarrowPhaseAlgorithm* CollisionDetection::getCollisionAlgorithm(CollisionShapeType shape1Type,
CollisionShapeType shape2Type) const {
return mCollisionMatrix[shape1Type][shape2Type];
}
// Sphere vs Sphere algorithm
if (collisionShape1->getType() == SPHERE && collisionShape2->getType() == SPHERE) {
return mNarrowPhaseSphereVsSphereAlgorithm;
}
else { // GJK algorithm
return mNarrowPhaseGJKAlgorithm;
}
// Set the collision dispatch configuration
inline void CollisionDetection::setCollisionDispatch(CollisionDispatch* collisionDispatch) {
mCollisionDispatch = collisionDispatch;
mCollisionDispatch->init(this, &mMemoryAllocator);
// Fill-in the collision matrix with the new algorithms to use
fillInCollisionMatrix();
}
// Add a body to the collision detection
@ -223,7 +278,7 @@ inline void CollisionDetection::askForBroadPhaseCollisionCheck(ProxyShape* shape
// Update a proxy collision shape (that has moved for instance)
inline void CollisionDetection::updateProxyCollisionShape(ProxyShape* shape, const AABB& aabb,
const Vector3& displacement) {
const Vector3& displacement, bool forceReinsert) {
mBroadPhaseAlgorithm.updateProxyCollisionShape(shape, aabb, displacement);
}
@ -232,6 +287,8 @@ inline void CollisionDetection::raycast(RaycastCallback* raycastCallback,
const Ray& ray,
unsigned short raycastWithCategoryMaskBits) const {
PROFILE("CollisionDetection::raycast()");
RaycastTest rayCastTest(raycastCallback);
// Ask the broad-phase algorithm to call the testRaycastAgainstShape()
@ -251,6 +308,11 @@ inline bool CollisionDetection::testAABBOverlap(const ProxyShape* shape1,
return mBroadPhaseAlgorithm.testOverlappingShapes(shape1, shape2);
}
// Return a pointer to the world
inline CollisionWorld* CollisionDetection::getWorld() {
return mWorld;
}
}
#endif

View File

@ -0,0 +1,75 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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 REACTPHYSICS3D_COLLISION_SHAPE_INFO_H
#define REACTPHYSICS3D_COLLISION_SHAPE_INFO_H
// Libraries
#include "shapes/CollisionShape.h"
/// Namespace ReactPhysics3D
namespace reactphysics3d {
class OverlappingPair;
// Class CollisionShapeInfo
/**
* This structure regroups different things about a collision shape. This is
* used to pass information about a collision shape to a collision algorithm.
*/
struct CollisionShapeInfo {
public:
/// Broadphase overlapping pair
OverlappingPair* overlappingPair;
/// Proxy shape
ProxyShape* proxyShape;
/// Pointer to the collision shape
const CollisionShape* collisionShape;
/// Transform that maps from collision shape local-space to world-space
Transform shapeToWorldTransform;
/// Cached collision data of the proxy shape
void** cachedCollisionData;
/// Constructor
CollisionShapeInfo(ProxyShape* proxyCollisionShape, const CollisionShape* shape,
const Transform& shapeLocalToWorldTransform, OverlappingPair* pair,
void** cachedData)
: overlappingPair(pair), proxyShape(proxyCollisionShape), collisionShape(shape),
shapeToWorldTransform(shapeLocalToWorldTransform),
cachedCollisionData(cachedData) {
}
};
}
#endif

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -31,9 +31,10 @@ using namespace reactphysics3d;
// Constructor
ContactManifold::ContactManifold(ProxyShape* shape1, ProxyShape* shape2,
MemoryAllocator& memoryAllocator)
: mShape1(shape1), mShape2(shape2), mNbContactPoints(0), mFrictionImpulse1(0.0),
mFrictionImpulse2(0.0), mFrictionTwistImpulse(0.0), mIsAlreadyInIsland(false),
MemoryAllocator& memoryAllocator, short normalDirectionId)
: mShape1(shape1), mShape2(shape2), mNormalDirectionId(normalDirectionId),
mNbContactPoints(0), mFrictionImpulse1(0.0), mFrictionImpulse2(0.0),
mFrictionTwistImpulse(0.0), mIsAlreadyInIsland(false),
mMemoryAllocator(memoryAllocator) {
}
@ -58,10 +59,10 @@ void ContactManifold::addContactPoint(ContactPoint* contact) {
// Delete the new contact
contact->~ContactPoint();
mMemoryAllocator.release(contact, sizeof(ContactPoint));
//removeContact(i);
assert(mNbContactPoints > 0);
return;
//break;
}
}
@ -75,6 +76,8 @@ void ContactManifold::addContactPoint(ContactPoint* contact) {
// Add the new contact point in the manifold
mContactPoints[mNbContactPoints] = contact;
mNbContactPoints++;
assert(mNbContactPoints > 0);
}
// Remove a contact point from the manifold

View File

@ -1,6 +1,6 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2015 Daniel Chappuis *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
@ -98,6 +98,9 @@ class ContactManifold {
/// Contact points in the manifold
ContactPoint* mContactPoints[MAX_CONTACT_POINTS_IN_MANIFOLD];
/// Normal direction Id (Unique Id representing the normal direction)
short int mNormalDirectionId;
/// Number of contacts in the cache
uint mNbContactPoints;
@ -116,6 +119,9 @@ class ContactManifold {
/// Twist friction constraint accumulated impulse
decimal mFrictionTwistImpulse;
/// Accumulated rolling resistance impulse
Vector3 mRollingResistanceImpulse;
/// True if the contact manifold has already been added into an island
bool mIsAlreadyInIsland;
@ -151,7 +157,7 @@ class ContactManifold {
/// Constructor
ContactManifold(ProxyShape* shape1, ProxyShape* shape2,
MemoryAllocator& memoryAllocator);
MemoryAllocator& memoryAllocator, short int normalDirectionId);
/// Destructor
~ContactManifold();
@ -168,6 +174,9 @@ class ContactManifold {
/// Return a pointer to the second body of the contact manifold
CollisionBody* getBody2() const;
/// Return the normal direction Id
short int getNormalDirectionId() const;
/// Add a contact point to the manifold
void addContactPoint(ContactPoint* contact);
@ -210,9 +219,18 @@ class ContactManifold {
/// Set the friction twist accumulated impulse
void setFrictionTwistImpulse(decimal frictionTwistImpulse);
/// Set the accumulated rolling resistance impulse
void setRollingResistanceImpulse(const Vector3& rollingResistanceImpulse);
/// Return a contact point of the manifold
ContactPoint* getContactPoint(uint index) const;
/// Return the normalized averaged normal vector
Vector3 getAverageContactNormal() const;
/// Return the largest depth of all the contact points
decimal getLargestContactDepth() const;
// -------------------- Friendship -------------------- //
friend class DynamicsWorld;
@ -240,6 +258,11 @@ inline CollisionBody* ContactManifold::getBody2() const {
return mShape2->getBody();
}
// Return the normal direction Id
inline short int ContactManifold::getNormalDirectionId() const {
return mNormalDirectionId;
}
// Return the number of contact points in the manifold
inline uint ContactManifold::getNbContactPoints() const {
return mNbContactPoints;
@ -295,9 +318,14 @@ inline void ContactManifold::setFrictionTwistImpulse(decimal frictionTwistImpuls
mFrictionTwistImpulse = frictionTwistImpulse;
}
// Set the accumulated rolling resistance impulse
inline void ContactManifold::setRollingResistanceImpulse(const Vector3& rollingResistanceImpulse) {
mRollingResistanceImpulse = rollingResistanceImpulse;
}
// Return a contact point of the manifold
inline ContactPoint* ContactManifold::getContactPoint(uint index) const {
assert(index >= 0 && index < mNbContactPoints);
assert(index < mNbContactPoints);
return mContactPoints[index];
}
@ -306,6 +334,31 @@ inline bool ContactManifold::isAlreadyInIsland() const {
return mIsAlreadyInIsland;
}
// Return the normalized averaged normal vector
inline Vector3 ContactManifold::getAverageContactNormal() const {
Vector3 averageNormal;
for (uint i=0; i<mNbContactPoints; i++) {
averageNormal += mContactPoints[i]->getNormal();
}
return averageNormal.getUnit();
}
// Return the largest depth of all the contact points
inline decimal ContactManifold::getLargestContactDepth() const {
decimal largestDepth = 0.0f;
for (uint i=0; i<mNbContactPoints; i++) {
decimal depth = mContactPoints[i]->getPenetrationDepth();
if (depth > largestDepth) {
largestDepth = depth;
}
}
return largestDepth;
}
}
#endif

View File

@ -0,0 +1,236 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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. *
* *
********************************************************************************/
// Libraries
#include "ContactManifoldSet.h"
using namespace reactphysics3d;
// Constructor
ContactManifoldSet::ContactManifoldSet(ProxyShape* shape1, ProxyShape* shape2,
MemoryAllocator& memoryAllocator, int nbMaxManifolds)
: mNbMaxManifolds(nbMaxManifolds), mNbManifolds(0), mShape1(shape1),
mShape2(shape2), mMemoryAllocator(memoryAllocator) {
assert(nbMaxManifolds >= 1);
}
// Destructor
ContactManifoldSet::~ContactManifoldSet() {
// Clear all the contact manifolds
clear();
}
// Add a contact point to the manifold set
void ContactManifoldSet::addContactPoint(ContactPoint* contact) {
// Compute an Id corresponding to the normal direction (using a cubemap)
short int normalDirectionId = computeCubemapNormalId(contact->getNormal());
// If there is no contact manifold yet
if (mNbManifolds == 0) {
createManifold(normalDirectionId);
mManifolds[0]->addContactPoint(contact);
assert(mManifolds[mNbManifolds-1]->getNbContactPoints() > 0);
for (int i=0; i<mNbManifolds; i++) {
assert(mManifolds[i]->getNbContactPoints() > 0);
}
return;
}
// Select the manifold with the most similar normal (if exists)
int similarManifoldIndex = 0;
if (mNbMaxManifolds > 1) {
similarManifoldIndex = selectManifoldWithSimilarNormal(normalDirectionId);
}
// If a similar manifold has been found
if (similarManifoldIndex != -1) {
// Add the contact point to that similar manifold
mManifolds[similarManifoldIndex]->addContactPoint(contact);
assert(mManifolds[similarManifoldIndex]->getNbContactPoints() > 0);
return;
}
// If the maximum number of manifold has not been reached yet
if (mNbManifolds < mNbMaxManifolds) {
// Create a new manifold for the contact point
createManifold(normalDirectionId);
mManifolds[mNbManifolds-1]->addContactPoint(contact);
for (int i=0; i<mNbManifolds; i++) {
assert(mManifolds[i]->getNbContactPoints() > 0);
}
return;
}
// The contact point will be in a new contact manifold, we now have too much
// manifolds condidates. We need to remove one. We choose to keep the manifolds
// with the largest contact depth among their points
int smallestDepthIndex = -1;
decimal minDepth = contact->getPenetrationDepth();
assert(mNbManifolds == mNbMaxManifolds);
for (int i=0; i<mNbManifolds; i++) {
decimal depth = mManifolds[i]->getLargestContactDepth();
if (depth < minDepth) {
minDepth = depth;
smallestDepthIndex = i;
}
}
// If we do not want to keep to new manifold (not created yet) with the
// new contact point
if (smallestDepthIndex == -1) {
// Delete the new contact
contact->~ContactPoint();
mMemoryAllocator.release(contact, sizeof(ContactPoint));
return;
}
assert(smallestDepthIndex >= 0 && smallestDepthIndex < mNbManifolds);
// Here we need to replace an existing manifold with a new one (that contains
// the new contact point)
removeManifold(smallestDepthIndex);
createManifold(normalDirectionId);
mManifolds[mNbManifolds-1]->addContactPoint(contact);
assert(mManifolds[mNbManifolds-1]->getNbContactPoints() > 0);
for (int i=0; i<mNbManifolds; i++) {
assert(mManifolds[i]->getNbContactPoints() > 0);
}
return;
}
// Return the index of the contact manifold with a similar average normal.
// If no manifold has close enough average normal, it returns -1
int ContactManifoldSet::selectManifoldWithSimilarNormal(short int normalDirectionId) const {
// Return the Id of the manifold with the same normal direction id (if exists)
for (int i=0; i<mNbManifolds; i++) {
if (normalDirectionId == mManifolds[i]->getNormalDirectionId()) {
return i;
}
}
return -1;
}
// Map the normal vector into a cubemap face bucket (a face contains 4x4 buckets)
// Each face of the cube is divided into 4x4 buckets. This method maps the
// normal vector into of the of the bucket and returns a unique Id for the bucket
short int ContactManifoldSet::computeCubemapNormalId(const Vector3& normal) const {
assert(normal.lengthSquare() > MACHINE_EPSILON);
int faceNo;
decimal u, v;
decimal max = max3(fabs(normal.x), fabs(normal.y), fabs(normal.z));
Vector3 normalScaled = normal / max;
if (normalScaled.x >= normalScaled.y && normalScaled.x >= normalScaled.z) {
faceNo = normalScaled.x > 0 ? 0 : 1;
u = normalScaled.y;
v = normalScaled.z;
}
else if (normalScaled.y >= normalScaled.x && normalScaled.y >= normalScaled.z) {
faceNo = normalScaled.y > 0 ? 2 : 3;
u = normalScaled.x;
v = normalScaled.z;
}
else {
faceNo = normalScaled.z > 0 ? 4 : 5;
u = normalScaled.x;
v = normalScaled.y;
}
int indexU = floor(((u + 1)/2) * CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS);
int indexV = floor(((v + 1)/2) * CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS);
if (indexU == CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS) indexU--;
if (indexV == CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS) indexV--;
const int nbSubDivInFace = CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS * CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS;
return faceNo * 200 + indexU * nbSubDivInFace + indexV;
}
// Update the contact manifolds
void ContactManifoldSet::update() {
for (int i=mNbManifolds-1; i>=0; i--) {
// Update the contact manifold
mManifolds[i]->update(mShape1->getBody()->getTransform() * mShape1->getLocalToBodyTransform(),
mShape2->getBody()->getTransform() * mShape2->getLocalToBodyTransform());
// Remove the contact manifold if has no contact points anymore
if (mManifolds[i]->getNbContactPoints() == 0) {
removeManifold(i);
}
}
}
// Clear the contact manifold set
void ContactManifoldSet::clear() {
// Destroy all the contact manifolds
for (int i=mNbManifolds-1; i>=0; i--) {
removeManifold(i);
}
assert(mNbManifolds == 0);
}
// Create a new contact manifold and add it to the set
void ContactManifoldSet::createManifold(short int normalDirectionId) {
assert(mNbManifolds < mNbMaxManifolds);
mManifolds[mNbManifolds] = new (mMemoryAllocator.allocate(sizeof(ContactManifold)))
ContactManifold(mShape1, mShape2, mMemoryAllocator, normalDirectionId);
mNbManifolds++;
}
// Remove a contact manifold from the set
void ContactManifoldSet::removeManifold(int index) {
assert(mNbManifolds > 0);
assert(index >= 0 && index < mNbManifolds);
// Delete the new contact
mManifolds[index]->~ContactManifold();
mMemoryAllocator.release(mManifolds[index], sizeof(ContactManifold));
for (int i=index; (i+1) < mNbManifolds; i++) {
mManifolds[i] = mManifolds[i+1];
}
mNbManifolds--;
}

View File

@ -0,0 +1,154 @@
/********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2016 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without 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 REACTPHYSICS3D_CONTACT_MANIFOLD_SET_H
#define REACTPHYSICS3D_CONTACT_MANIFOLD_SET_H
// Libraries
#include "ContactManifold.h"
namespace reactphysics3d {
// Constants
const int MAX_MANIFOLDS_IN_CONTACT_MANIFOLD_SET = 3; // Maximum number of contact manifolds in the set
const int CONTACT_CUBEMAP_FACE_NB_SUBDIVISIONS = 3; // N Number for the N x N subdivisions of the cubemap
// Class ContactManifoldSet
/**
* This class represents a set of one or several contact manifolds. Typically a
* convex/convex collision will have a set with a single manifold and a convex-concave
* collision can have more than one manifolds. Note that a contact manifold can
* contains several contact points.
*/
class ContactManifoldSet {
private:
// -------------------- Attributes -------------------- //
/// Maximum number of contact manifolds in the set
int mNbMaxManifolds;
/// Current number of contact manifolds in the set
int mNbManifolds;
/// Pointer to the first proxy shape of the contact
ProxyShape* mShape1;
/// Pointer to the second proxy shape of the contact
ProxyShape* mShape2;
/// Reference to the memory allocator
MemoryAllocator& mMemoryAllocator;
/// Contact manifolds of the set
ContactManifold* mManifolds[MAX_MANIFOLDS_IN_CONTACT_MANIFOLD_SET];
// -------------------- Methods -------------------- //
/// Create a new contact manifold and add it to the set
void createManifold(short normalDirectionId);
/// Remove a contact manifold from the set
void removeManifold(int index);
// Return the index of the contact manifold with a similar average normal.
int selectManifoldWithSimilarNormal(short int normalDirectionId) const;
// Map the normal vector into a cubemap face bucket (a face contains 4x4 buckets)
// Each face of the cube is divided into 4x4 buckets. This method maps the
// normal vector into of the of the bucket and returns a unique Id for the bucket
short int computeCubemapNormalId(const Vector3& normal) const;
public:
// -------------------- Methods -------------------- //
/// Constructor
ContactManifoldSet(ProxyShape* shape1, ProxyShape* shape2,
MemoryAllocator& memoryAllocator, int nbMaxManifolds);
/// Destructor
~ContactManifoldSet();
/// Return the first proxy shape
ProxyShape* getShape1() const;
/// Return the second proxy shape
ProxyShape* getShape2() const;
/// Add a contact point to the manifold set
void addContactPoint(ContactPoint* contact);
/// Update the contact manifolds
void update();
/// Clear the contact manifold set
void clear();
/// Return the number of manifolds in the set
int getNbContactManifolds() const;
/// Return a given contact manifold
ContactManifold* getContactManifold(int index) const;
/// Return the total number of contact points in the set of manifolds
int getTotalNbContactPoints() const;
};
// Return the first proxy shape
inline ProxyShape* ContactManifoldSet::getShape1() const {
return mShape1;
}
// Return the second proxy shape
inline ProxyShape* ContactManifoldSet::getShape2() const {
return mShape2;
}
// Return the number of manifolds in the set
inline int ContactManifoldSet::getNbContactManifolds() const {
return mNbManifolds;
}
// Return a given contact manifold
inline ContactManifold* ContactManifoldSet::getContactManifold(int index) const {
assert(index >= 0 && index < mNbManifolds);
return mManifolds[index];
}
// Return the total number of contact points in the set of manifolds
inline int ContactManifoldSet::getTotalNbContactPoints() const {
int nbPoints = 0;
for (int i=0; i<mNbManifolds; i++) {
nbPoints += mManifolds[i]->getNbContactPoints();
}
return nbPoints;
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More