Merge pull request #1 from dcnieho/git_master

Update from original
This commit is contained in:
Jinrong Xie 2016-01-18 00:00:40 -08:00
commit 8702fc44ec
41 changed files with 2381 additions and 900 deletions

8
.gitattributes vendored
View File

@ -3,18 +3,12 @@ freeglut/freeglut/AUTHORS svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/CMakeLists.txt svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/COPYING svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/ChangeLog svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/FrequentlyAskedQuestions -text
freeglut/freeglut/LISEZMOI.cygwin_mingw svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/LISEZ_MOI svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/NEWS svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.android -text
freeglut/freeglut/README.cmake -text
freeglut/freeglut/README.cygwin_mingw svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.mac -text
freeglut/freeglut/README.mingw_cross svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.win32 svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/TODO svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/android/Android.mk -text
freeglut/freeglut/android/README -text
freeglut/freeglut/android_toolchain.cmake -text
@ -44,6 +38,7 @@ freeglut/freeglut/progs/demos/One/objects.ico -text
freeglut/freeglut/progs/demos/One/one.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/progs/demos/One/one.rc -text
freeglut/freeglut/progs/demos/Resizer/Resizer.cpp -text
freeglut/freeglut/progs/demos/init_error_func/init_error_func.c -text
freeglut/freeglut/progs/demos/multi-touch/multi-touch.c -text
freeglut/freeglut/progs/demos/shapes/glmatrix.c -text
freeglut/freeglut/progs/demos/shapes/glmatrix.h -text
@ -178,3 +173,4 @@ freeglut/web-src/news.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/progress.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/template.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/uinfo.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/upload -text

View File

@ -27,11 +27,14 @@ James 'J.C.' Jones
designing the new website
John Tsiombikas <nuclear@member.fsf.org>
Linux spaceball support, XR&R gamemode, misc linux fixes and breakages
Linux spaceball support, XR&R gamemode, misc linux fixes and breakages
Sylvain Beucler
support for Android, X11/EGL, OpenGL(ES) 2.x, misc fixes
Manuel Bachmann
support for Wayland
Diederick C. Niehorster
Chris Marshall
Clive McCarthy

View File

@ -1,6 +1,9 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR)
PROJECT(freeglut)
# for multiarch LIBDIR support (requires cmake>=2.8.8)
INCLUDE(GNUInstallDirs)
# NOTE: On Windows and Cygwin, the dll's are placed in the
# CMAKE_RUNTIME_OUTPUT_DIRECTORY, while their corresponding import
# libraries end up in CMAKE_ARCHIVE_OUTPUT_DIRECTORY. On other
@ -17,6 +20,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Update fg_version.h to match the versions number here in cmake
CONFIGURE_FILE(src/fg_version.h.in src/fg_version.h)
@ -49,6 +53,13 @@ ENDIF()
# OpenGL ES support
OPTION(FREEGLUT_GLES "Use OpenGL ES (requires EGL)" OFF)
IF(NOT WIN32)
# Wayland support
OPTION(FREEGLUT_WAYLAND "Use Wayland (no X11)" OFF)
# option to build either as "glut" (ON) or "freeglut" (OFF)
OPTION(FREEGLUT_REPLACE_GLUT "Be a replacement for GLUT" ON)
ENDIF()
SET(FREEGLUT_HEADERS
include/GL/freeglut.h
@ -159,36 +170,60 @@ ELSEIF(ANDROID OR BLACKBERRY)
src/blackberry/fg_window_blackberry.c
)
ENDIF()
ELSE()
LIST(APPEND FREEGLUT_SRCS
src/x11/fg_cursor_x11.c
src/x11/fg_ext_x11.c
src/x11/fg_gamemode_x11.c
src/x11/fg_glutfont_definitions_x11.c
src/x11/fg_init_x11.c
src/x11/fg_internal_x11.h
src/x11/fg_input_devices_x11.c
src/x11/fg_joystick_x11.c
src/x11/fg_main_x11.c
src/x11/fg_menu_x11.c
src/x11/fg_spaceball_x11.c
src/x11/fg_state_x11.c
src/x11/fg_structure_x11.c
src/x11/fg_window_x11.c
src/x11/fg_xinput_x11.c
)
IF(NOT(FREEGLUT_GLES))
# UNIX (Wayland)
IF(FREEGLUT_WAYLAND)
LIST(APPEND FREEGLUT_SRCS
src/x11/fg_internal_x11_glx.h
src/x11/fg_display_x11_glx.c
src/x11/fg_state_x11_glx.c
src/x11/fg_state_x11_glx.h
src/x11/fg_window_x11_glx.c
src/x11/fg_window_x11_glx.h
src/wayland/fg_cursor_wl.c
src/wayland/fg_ext_wl.c
src/wayland/fg_gamemode_wl.c
src/wayland/fg_init_wl.c
src/wayland/fg_internal_wl.h
src/wayland/fg_input_devices_wl.c
src/wayland/fg_main_wl.c
src/wayland/fg_state_wl.c
src/wayland/fg_structure_wl.c
src/wayland/fg_window_wl.c
# font, serial port & joystick code are agnostic
src/x11/fg_glutfont_definitions_x11.c
src/x11/fg_input_devices_x11.c
src/x11/fg_joystick_x11.c
)
# UNIX (X11)
ELSE()
LIST(APPEND FREEGLUT_SRCS
src/x11/fg_cursor_x11.c
src/x11/fg_ext_x11.c
src/x11/fg_gamemode_x11.c
src/x11/fg_glutfont_definitions_x11.c
src/x11/fg_init_x11.c
src/x11/fg_internal_x11.h
src/x11/fg_input_devices_x11.c
src/x11/fg_joystick_x11.c
src/x11/fg_main_x11.c
src/x11/fg_menu_x11.c
src/x11/fg_spaceball_x11.c
src/x11/fg_state_x11.c
src/x11/fg_structure_x11.c
src/x11/fg_window_x11.c
src/x11/fg_xinput_x11.c
)
IF(NOT(FREEGLUT_GLES))
LIST(APPEND FREEGLUT_SRCS
src/x11/fg_internal_x11_glx.h
src/x11/fg_display_x11_glx.c
src/x11/fg_state_x11_glx.c
src/x11/fg_state_x11_glx.h
src/x11/fg_window_x11_glx.c
src/x11/fg_window_x11_glx.h
)
ENDIF()
ENDIF()
ENDIF()
IF(FREEGLUT_GLES)
# OpenGL ES requires EGL, and so does Wayland
IF(FREEGLUT_GLES OR FREEGLUT_WAYLAND)
LIST(APPEND FREEGLUT_SRCS
src/egl/fg_internal_egl.h
src/egl/fg_display_egl.c
@ -210,14 +245,20 @@ ENDIF()
# but do use GLES constants directly for all other needs
# GLES1 and GLES2 libraries are compatible and can be co-linked.
IF(FREEGLUT_GLES)
ADD_DEFINITIONS(-DFREEGLUT_GLES)
LIST(APPEND LIBS GLESv2 GLESv1_CM EGL)
LIST(APPEND PUBLIC_DEFINITIONS -DFREEGLUT_GLES)
LIST(APPEND LIBS GLESv2 GLESv1_CM EGL)
ELSE()
FIND_PACKAGE(OpenGL REQUIRED)
LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
ENDIF()
# For Wayland: compile with -DFREEGLUT_WAYLAND and pull EGL
IF(FREEGLUT_WAYLAND)
ADD_DEFINITIONS(-DFREEGLUT_WAYLAND)
LIST(APPEND LIBS wayland-client wayland-cursor wayland-egl EGL xkbcommon)
ENDIF()
# lib m for math, not needed on windows
IF (NOT WIN32)
# For compilation:
@ -251,15 +292,16 @@ ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
IF(NOT(ANDROID OR BLACKBERRY))
IF(NOT(ANDROID OR BLACKBERRY OR FREEGLUT_WAYLAND))
# not setting -ansi as EGL/KHR headers doesn't support it
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
ENDIF()
ENDIF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE(CheckIncludeFiles)
IF(UNIX AND NOT(ANDROID OR BLACKBERRY))
IF(UNIX AND NOT(ANDROID OR BLACKBERRY OR FREEGLUT_WAYLAND))
FIND_PACKAGE(X11 REQUIRED)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
LIST(APPEND LIBS ${X11_LIBRARIES})
IF(X11_Xrandr_FOUND)
SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE)
@ -267,10 +309,6 @@ IF(UNIX AND NOT(ANDROID OR BLACKBERRY))
ENDIF()
IF(X11_xf86vmode_FOUND)
SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE)
# Work-around http://www.cmake.org/Bug/bug_view_page.php?bug_id=6976
IF(NOT "${X11_Xxf86vm_LIB}")
SET(X11_Xxf86vm_LIB "Xxf86vm")
ENDIF()
LIST(APPEND LIBS ${X11_Xxf86vm_LIB})
ENDIF()
IF(X11_Xinput_FOUND)
@ -331,7 +369,7 @@ ENDIF()
# ensure that all CMake-generated files are kept away from the main source tree.
# As a result, the build directory must to be added to the include path list.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
IF(WIN32)
# we also have to generate freeglut.rc, which contains the version
@ -351,13 +389,14 @@ IF(FREEGLUT_BUILD_STATIC_LIBS)
ENDIF()
SET(LIBNAME freeglut)
IF(WIN32)
LIST(APPEND LIBS winmm)
IF(FREEGLUT_BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(freeglut PROPERTIES COMPILE_FLAGS -DFREEGLUT_EXPORTS)
TARGET_COMPILE_DEFINITIONS(freeglut PRIVATE FREEGLUT_EXPORTS)
ENDIF()
IF(FREEGLUT_BUILD_STATIC_LIBS)
SET_TARGET_PROPERTIES(freeglut_static PROPERTIES COMPILE_FLAGS -DFREEGLUT_STATIC)
TARGET_COMPILE_DEFINITIONS(freeglut_static PUBLIC FREEGLUT_STATIC)
# need to set machine:x64 for linker, at least for VC10, and
# doesn't hurt for older compilers:
# http://public.kitware.com/Bug/view.php?id=11240#c22768
@ -376,15 +415,18 @@ ELSE()
# or special-cased FreeGLUT long ago (e.g. .so.4 on OpenBSD), so
# the lack of support for current:revision:age in CMake should
# not be a problem.
# - the output library should be named glut so it'll be linkable with -lglut
# - the output library should be named glut so it'll be linkable with -lglut
# (unless FREEGLUT_REPLACE_GLUT is false).
# - the shared library should link to the dependency libraries so that the user
# won't have to link them explicitly (they shouldn't have to know that we depend
# on Xrandr or Xxf86vm)
IF(FREEGLUT_GLES)
SET(LIBNAME freeglut-gles)
SET(LIBNAME freeglut-gles)
ELSE()
SET(LIBNAME glut)
ENDIF()
IF(FREEGLUT_REPLACE_GLUT)
SET(LIBNAME glut)
ENDIF()
ENDIF()
IF(FREEGLUT_BUILD_SHARED_LIBS)
SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION ${SO_MAJOR}.${SO_MINOR}.${SO_REV} SOVERSION ${SO_MAJOR} OUTPUT_NAME ${LIBNAME})
@ -406,36 +448,36 @@ ELSE()
ENDIF()
IF(FREEGLUT_BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(freeglut ${LIBS})
TARGET_COMPILE_DEFINITIONS(freeglut PUBLIC ${PUBLIC_DEFINITIONS})
ENDIF()
IF(FREEGLUT_BUILD_STATIC_LIBS)
TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
TARGET_COMPILE_DEFINITIONS(freeglut_static PUBLIC ${PUBLIC_DEFINITIONS})
ENDIF()
IF(FREEGLUT_BUILD_SHARED_LIBS)
INSTALL(TARGETS freeglut
INSTALL(TARGETS freeglut EXPORT FreeGLUTTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
)
IF(INSTALL_PDB)
INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/freeglut${CMAKE_DEBUG_POSTFIX}.pdb
DESTINATION bin
CONFIGURATIONS Debug)
CONFIGURATIONS Debug
COMPONENT Devel)
ENDIF()
ENDIF()
IF(FREEGLUT_BUILD_STATIC_LIBS)
INSTALL(TARGETS freeglut_static
INSTALL(TARGETS freeglut_static EXPORT FreeGLUTTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
)
IF(INSTALL_PDB)
INSTALL(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Debug/freeglut_static${CMAKE_DEBUG_POSTFIX}.pdb
DESTINATION lib
CONFIGURATIONS Debug)
ENDIF()
ENDIF()
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL COMPONENT Devel)
@ -460,7 +502,6 @@ MACRO(ADD_DEMO name)
IF(FREEGLUT_BUILD_STATIC_LIBS)
ADD_EXECUTABLE(${name}_static ${ARGN})
TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static)
SET_TARGET_PROPERTIES(${name}_static PROPERTIES COMPILE_FLAGS -DFREEGLUT_STATIC)
IF(WIN32 AND MSVC)
SET_TARGET_PROPERTIES(${name}_static PROPERTIES DEBUG_POSTFIX d)
ENDIF()
@ -507,15 +548,21 @@ ELSEIF(FREEGLUT_GLES)
ELSE()
SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lscreen -lGLESv2 -lGLESv1_CM -lEGL -lm")
ENDIF()
ELSEIF(FREEGLUT_WAYLAND)
SET(PC_LIBS_PRIVATE "-lwayland-client -lwayland-cursor -lwayland-egl -lGLESv2 -lGLESv1_CM -lEGL -lxkbcommon -lm")
ELSE()
SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lGLESv1_CM -lEGL -lm")
ENDIF()
ELSE()
SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL -lm")
IF(FREEGLUT_WAYLAND)
SET(PC_LIBS_PRIVATE "-lwayland-client -lwayland-cursor -lwayland-egl -lGL -lxkbcommon -lm")
ELSE()
SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL -lm")
ENDIF()
ENDIF()
# Client applications need to define FreeGLUT GLES version to
# bootstrap headers inclusion in freeglut_std.h:
SET(PC_LIBNAME "glut")
SET(PC_LIBNAME ${LIBNAME})
SET(PC_FILENAME "freeglut.pc")
IF(FREEGLUT_GLES)
SET(PC_CFLAGS "-DFREEGLUT_GLES")
@ -523,6 +570,36 @@ IF(FREEGLUT_GLES)
SET(PC_FILENAME "freeglut-gles.pc")
ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig/ RENAME ${PC_FILENAME})
INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ RENAME ${PC_FILENAME} COMPONENT Devel)
# TODO: change the library and .pc name when building for GLES,
# e.g. -lglut-GLES
INCLUDE(CMakePackageConfigHelpers)
WRITE_BASIC_PACKAGE_VERSION_FILE(
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfigVersion.cmake"
VERSION ${VERSION}
COMPATIBILITY AnyNewerVersion
)
# needs cmake 3.0 (as does the "INCLUDES DIRECTORY" argument to install(TARGETS)):
EXPORT(EXPORT FreeGLUTTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTTargets.cmake"
NAMESPACE FreeGLUT::
)
CONFIGURE_FILE(FreeGLUTConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfig.cmake"
@ONLY
)
SET(ConfigPackageLocation lib/cmake/FreeGLUT)
INSTALL(EXPORT FreeGLUTTargets
FILE FreeGLUTTargets.cmake
NAMESPACE FreeGLUT::
DESTINATION ${ConfigPackageLocation}
)
INSTALL(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
COMPONENT Devel
)

View File

@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/FreeGLUTTargets.cmake")

View File

@ -1,70 +0,0 @@
========== ===== ========= ===== ========
FREQUENTLY ASKED QUESTIONS ABOUT freeglut
========== ===== ========= ===== ========
Last updated on November 28, 2006
General Questions
======= =========
(1) Will "freeglut" ever support (fill in the blank)?
If the GLUT library supports the feature, "freeglut" should support it. If "freeglut" does not support it and there is a call for it, then we are certainly open to adding it.
If the GLUT library does not support the feature, "freeglut" is probably not going to. The "freeglut" library was designed to be a drop-in replacement for GLUT, a lightweight and simple windowing system for the OpenGL Red Book demonstration programs and no more. If you want a more functional windowing system we suggest that you look elsewhere.
(#) I have a question that is not answered here. What do I do to get an answer?
Check the "README" files that came with the distribution. If the question is not addressed there, please post it on the "freeglut-developer" mailing list on the Source Forge web site.
*nix Questions
==== =========
(1) How I can build "freeglut" with debugging symbols and traces?
CFLAGS="-g $CFLAGS" LDFLAGS="-g $LDFLAGS" ./configure \
--enable-debug
(2) How can I have both a normal, and a debug-enabled version of "freeglut"?
cd ..
mkdir freeglut-normal
cd freeglut-normal
../freeglut-2.x/configure
make
cd ..
mkdir freeglut-debug
CFLAGS="-g $CFLAGS" LDFLAGS="-g $LDFLAGS" \
../freeglut-2.x/ configure --enable-debug [*]
make
[*] optionally use --program-suffix=dbg to have them coexist when installing
(3) My linking fails due to undefined symbols. What libraries do I need to link?
Look at the generated libfreeglut.la or use libtool --link (see the libtool manual).
Windows Questions
======= =========
(1) My linking fails due to undefined symbols. What libraries do I need to link?
All the required libraries (and a couple of unnecessary ones) should be automatically included thanks to the "#pragma comment (lib" statements in "freeglut_std.h". If your linking fails due to undefined symbols, there is an excellent chance that "freeglut" is not the culprit.
Other Operating System Questions
===== ========= ====== =========

View File

@ -1,218 +0,0 @@
Glut alors!
Par Jean-Seb le vendredi 10 juillet 2009, 00:18
Freeglut est une évolution open-source de Glut.
Sous Windows, on peut l'utiliser avec Cygwin.
Facile ? Oui, si on accepte de distribuer "cygwin1.dll"
Aidons Freeglut à conquérir son indépendance !
m.à.j 10/7/2009 : génération d'une librairie pour linker depuis la dll.
Récupération des sources
* Reprenez les sources de la version 2.6.0 qui intègre les changements
récents.
* Pour l'instant, il s'agit d'une RC (Release Candidate), mais la version
finale ne saurait tarder.
* L'utilisation de la 2.6 est préférable à la branche 2.4-stable, de
nombreux bugs étant corrigés.
* Vous trouverez les sources sur le site de Freeglut:
o http://freeglut.sourceforge.net/
Principe
Objectif
* Nous allons créer une dll liée à Cygwin, et une bibliothèque statique
indépendante
* Nous créerons également une librairie dynamique, permettant de linker avec
la dll.
Liste des fichiers générés
* freeglut.dll : une dll classique pour le linkage dynamique.
* libfreeglut.a : la bibliothèque statique. Le programme final est autonome
(du moins pour OpenGL).
* libfreeglutdll.a : la bibliothèque dynamique. Le programme final a besoin
de freeglut.dll.
Préparation
* Dépliez l'archive freeglut.
* Allez dans le répertoire src (situé à la racine du répertoire Freeglut),
et créez un sous-répertoire "Gl"
o Dans ce sous-répertoire, copiez les fichiers du répertoire
"include/Gl"
* Pourquoi faut-il créer un répertoire "Gl" pour la compilation ?
o C'était juste pour simplifier les choses lors de mes essais.
o Sinon vous pouvez créer directement les répertoires, et copier les
fichiers comme indiqué au point installation (lire plus loin).
* Faites un peu de ménage dans /lib :
o Effacez toutes les références à la glut, pour ne pas avoir de
conflit au linkage.
o Cette étape est facultative, vous pouvez également choisir de ne
faire le ménage qu' après une compilation réussie de Freeglut.
o Attention à ne pas effacer, dans un enthousiasme rédempteur, la
bibliothèque glu32.lib (à ne pas confondre avec glut32.lib).
Compilation
* Oubliez le triptyque ./configure , make , make install.
o Ca ne marche pas du tout avec Cygwin.
* Voici un Makefile qui fera l'affaire:
#Makefile pour Freeglut 2.6.0-rc et Cygwin
#A placer dans le répertoire "src/Common"
sources=$(wildcard *.c)
objs=$(sources:.c=.o)
libname=freeglut
CFLAGS=-O2 -DTARGET_HOST_MS_WINDOWS -DX_DISPLAY_MISSING -DFREEGLUT_STATIC -I./
LDFLAGS=-lopengl32 -lgdi32 -lwinmm
nocyg=-mno-cygwin -mwindows
all: $(objs)
#construction dll liée à cygwin1.dll
gcc $(nocyg) $(objs) -shared $(LDFLAGS) -o $(libname).dll
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
#construction bibliothèque statique indépendante de cygwin
ar cr lib$(libname).a $(objs)
#pas forcément obligatoire (création d'un index pour accélérer les accès)
ranlib lib$(libname).a
%.o: %.c
gcc $(nocyg) -c $(CFLAGS) $<
clean:
rm -f *.o $(libname).dll $(libname).def lib$(libname)dll.a lib$(libname).a
Quelques remarques sur le Makefile
* Ce makefile crée une dll, une bibliothèque statique (une archive, en
d'autres termes) et la bibliothèque dynamique qui permettra l'utilisation
de la dll.
* Ne cherchez pas à stripper la bibliothèque statique! Vous ne pourriez plus
compiler en statique.
o Par contre, vous pouvez stripper l'exécutable final obtenu lors de
la compilation de votre application.
* J'ai choisi d'appeller la dll et les bibliothèques par leurs "vrais noms":
freeglut.dll libfreeglutdll.a et libfreeglut.a.
o Le script configure recréait (pour des raisons de compatibilité avec
l'ancienne bibliothèque Glut) glut.dll et libglut.a.
o Lors des mes essais, j'ai eu des conflits avec une authentique
"glut" qui trainait dans mon "/lib". J'ai décidé d'appeller les
choses par leur nom, afin d'éviter les confusions.
o Rien ne vous empêche de renommer la dll, si vous avez besoin
d'utiliser des programmes Glut que vous ne pouvez pas recompiler.
* La bibliothèque dynamique est générée à partir de la dll.
o Par souci de concision, j'ai utilisé awk. Il génère le fichier
d'exports utilisé par dlltool.
o La seule chose notable est la sélection des fonctions dont le nom
commence par _glut, afin d'éviter d'inclure dans la librairie
dynamique des fonctions sans rapport avec freeglut.
o ensuite, on utilise dlltool de façon très classique.
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
Installation
* Copiez libfreeglut.a, libfreeglutdll.a dans le répertoire /lib de Cygwin.
* Copiez freglut.dll dans le system32 de Windows (ce qui est pratique, mais
pas propre!).
* Copiez les fichiers headers de Freeglut (/include/gl) dans /usr/include/Gl
de Cygwin.
* Copiez les fichiers headers (toujours /include/gl) dans
/usr/include/mingw/Gl : ceci sert aux compilations avec le flag
-mno-cygwin, qui utilise alors les includes de mingw.
o Vous aurez éventuellement besoin d'écraser d'anciens fichiers
include, correspondants à Glut, si vous l'avez installé avec Cygwin.
Utilisation de la bibliothèque
* Nous allons tester avec le programme shapes, présent dans
progs/demos/shapes
o -mno-cygwin sert à forcer l'utilisation de Mingw sans la grosse
dépendance cygwin1.dll.
o -mwindows sert uniquement à enlever l'horrible fenêtre shell (très
utile pour la mise au point, par contre).
o -L. (notez le point après le "L") : j'ai laissé libfreeglut.a,
libfreeglutdll.a et freeglut.dll dans le répertoire de test, le
temps des tests justement.
Compilation en librairie statique freeglut, sans cygwin
* Toute l'astuce réside dans le define : -DFREEGLUT_STATIC
o Il sert à obtenir la bonne décoration des noms de fonctions dans les
imports de la lib Freeglut.
o Vous pouvez essayer sans et prendre un éditeur hexa pour voir les
différences dans l'objet.
* attention à l'ordre des bibliothèques : -lfreeglut (statique) doit se
trouver avant la déclaration des bibliothèques dynamiques.
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin
-mwindows -DFREEGLUT_STATIC
Compilation avec dll freeglut, sans cygwin
* Pour le define, même remarque que ci-dessus
* L'ordre des bibliothèques n'a plus d'importance.
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin
-DFREEGLUT_STATIC
Compilation avec dll freeglut, avec Cygwin
* Cet exemple est donné uniquement pour référence, le thème de ce billet étant de se débarrasser de Cygwin.
o Disons que ça peut servir pendant la mise au point (et encore).
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
Où sont les dooooocs ?
* Freeglut est livré avec sa documentation, plus très à jour.
o Il semble qu'il y ait un problème avec la doc Glut originale. Non
seulement elle ne correspond pas forcément au fonctionnement de
Freeglut, mais de plus, son auteur (Mark Kilgard) l'a copyrighté. Sa
distribution est donc difficile.
* Jocelyn Fréchot a entrepris une mise à niveau des docs pour la version
2.6.0. On peut les trouver sur son site pour l'instant:
o http://jocelyn.frechot.free.fr/freeglut/
Quelque chose a survécu ...
* J'ai également testé la recompilation des démos de la lib Glut originelle
(paix à ses cendres).
o Rien de particulier à signaler.
* Merci à tous les mainteneurs courageux de Freeglut, qu'on croyait morts,
mais qui bougent encore.

View File

@ -1,86 +0,0 @@
Brève Vue d'ensemble
====================
C'est le paquet de freeglut.
Freeglut, le toolkit de service d'openGL ("OpenGL Utility Toolkit") libre, est censé pour être
un libre changent l'indigène à la bibliothèque de GLUT de Mark Kilgard. Il est distribué sous
un permis de modèle de X-Consortium (voyez COPIER pour des détails), de vous offrir une chance
d'employer et/ou modifier la source.
Il se sert de bibliothèques OpenGL, GLU, GLib, et pthreads-win32. La bibliothèque ne se sert
d'aucun code de SURABONDANCE et n'est pas 100% compatible. La recompilation de code et/ou les
légères modifications pourraient être exigées pour vos applications pour fonctionner avec le
freeglut.
PORTS
=====
X11 et les ports Win32 sont à une étape avançée d'alpha, qui signifie qu'elles fournissent la fonctionnalité limitée de la SURABONDANCE api 3. Il y a un cours d'en de recherche pour vérifier si le port de BeOS pourrait être facilement fait en utilisant la structure courante de freeglut.
INSTALLATION
============
Voyez le dossier d'INSTALLATION. Pour le Windows:
1)Téléchargez Freeglut.tar.gz
2)Renommez en Freeglut.tar
3)Décompressez avec WINZIP
4)Dans MSVC,vous obtenez un répertoire FREEGLUT\DEBUG ou se trouve FREEGLUT.DLL
5)Si vous n'avez pas FEEGLUT.LIB,il faut la construire:
Ouvrez FREEGLUT.DSW(C'est un workspace)
ouvrez le projet et cliquez sur "BUILD" puis "SET ACTIVE CONFIGURATION"
ajoutez "FREEGLUT-DEBUG".
6)Pour votre propre projet,apres la compilation,appuyer sur ALT-F7.Cliquez sur LINK,puis sur
CATEGORIES et selectionnez "INPUT".Plus bas dans la fenetre,il y a un champ appelé
"ADDITIONNAL LIBRARY PATH",ajoutez:C:\MSVC\FREEGLUT\DEBUG pour que le programme trouve la
FREEGLUT.LIB.
7)Copiez(NE PAS DEPLACER) la FREEGLUT.DLL de DEBUG vers le répertoire qui contient votre fichier
EXE.
8)Pour une installation globale copier FREEGLUT.DLL dans C:\WINNT\SYSTEM32.
CONTRIBUTION
============
Le bogue et les pièces rapportées absentes de dispositifs sont certainement bienvenus. Juste
comme des commentaires et des propositions de FREEGLUT api 1 soyez. Veuillez juste pour rendre
le regard de difficultés visuellement juste comme le reste du code (les étiquettes ont converti
les 4 espaces blancs). Les commentaires sont vraiment bienvenus, comme je crois qu'il ferait
beau pour des personnes nouveaux que frais à OpenGL voient comment les choses sont faites...
EMPLACEMENT DE WEB ET ENTRER EN CONTACT AVEC LE D'AUTEUR
========================================================
Le projet de Freeglut s'est déplacé au SourceForge :
http://freeglut.sourceforge.net
LE D'ESPOIR
===========
Espoir vous trouvez mon travail de façon ou d'autre utile.
Pawel W. Olszta, <olszta@sourceforge.net>
DÉPASSEMENT DU BATON====================
En décembre 2000, Pawel a décidé qu'il n'a plus souhaité maintenir le freeglut parce qu'il s'est
déplacé hors du champ de graphiques. J'ai offert pour succéder de lui et avoir couru le projet
depuis 2001 le 13 janv.. I'm également l'auteur et le défenseur de la suite de bibliothèque de
PLIB et du 'freeglut' ; vraiment ajustements dedans bien avec ce travail. J'espère juste que je
peux vivre jusqu'aux niveaux élevés de Pawel's. Pawel reste sur la liste active de réalisateurs.
Steve Baker <sjbaker1@airmail.net>
http://plib.sourceforge.net

View File

@ -1,70 +0,0 @@
Jan 16th 2000:
First really functional release of freeglut.
Jan 13th 2001:
Steve Baker takes over as maintainer of freeglut.
Jun ??th 2003:
freeglut 1.4 released.
September 29, 2003:
freeglut 2.0.0 released.
...
Mar ??, 2009:
freeglut 2.6.0 released. Changes compared to 2.4.0:
* Tons of bug fixes
* Added deprecated, but working Joystick API.
* Added new constant GLUT_INIT_STATE for glutGet() to check if freeglut is
already initialized.
* Added new API entry for full-screen mode
void glutFullScreenToggle( void );
with a related new constant GLUT_FULL_SCREEN for glutGet().
* Added new API entry to de-initialize freeglut:
void glutExit( void );
* Added more special keys: GLUT_KEY_NUM_LOCK, GLUT_KEY_BEGIN GLUT_KEY_DELETE
* Added support for windows without captions and/or borders via two new
constants GLUT_CAPTIONLESS and GLUT_BORDERLESS for glutInitDisplayMode
(currently works for Windows only).
* Added support for multisampling: The number of samples per pixel to use
when GLUT_MULTISAMPLE is specified in glutInitDisplayMode() can be set via
glutSetOption() with parameter GLUT_MULTISAMPLE now. glutGet() with the
same token retrieves that value. The possible number of samples per pixels
can be queried via the new API entry
int *glutGetModeValues( GLenum mode, int *size );
with mode GLUT_MULTISAMPLE. (glutGetModeValues() currently only works for
X11)
* Added new constant GLUT_AUX for glutSetOption() to set the number of
auxiliary buffers. The possible number of auxiliary buffers can be
queried via glutGetModeValues with mode GLUT_AUX.
* Added support for versioned (i.e. 3.0) OpenGL contexts: New API entries
void glutInitContextVersion( int majorVersion, int minorVersion );
void glutInitContextFlags( int flags );
with related new constants GLUT_DEBUG and GLUT_FORWARD_COMPATIBLE for
the latter API entry. Added new constants GLUT_INIT_MAJOR_VERSION,
GLUT_INIT_MINOR_VERSION and GLUT_INIT_FLAGS for glutGet().

View File

@ -1,77 +1,61 @@
BRIEF OVERVIEW
==============
BRIEF OVERVIEW
==============
This is the freeglut package.
This is the freeglut package.
Freeglut, the Free OpenGL Utility Toolkit, is meant to be a free alternative to
Mark Kilgard's GLUT library. Freeglut is free software, distributed under an
MIT/X11 style license. You are free to use, modify, and redistribute FreeGLUT
with or without modifications (see COPYING for details).
Freeglut, the Free openGL Utility Toolkit, is meant to be a free alter-
native to Mark Kilgard's GLUT library. It is distributed under an X-Consor-
tium style license (see COPYING for details), to offer you a chance to use
and/or modify the source.
PORTS
=====
It makes use of OpenGL, GLU, and pthreads-win32 libraries. The library does
not make use of any GLUT code and is not 100% compatible. Code recompilation
and/or slight modifications might be required for your applications to work
with freeglut.
Currently supported platforms:
- UNIX systems with X11 and Wayland (such as GNU/Linux, FreeBSD, etc)
- MS Windows
- MacOS X with XQuartz (no native Cocoa support yet)
- Android (NDK)
- Blackberry
Consult the platform-specific readme files for details on the level of support
and build instructions.
PORTS
=====
INSTALLATION
============
Both X11 and Win32 ports are in an advanced alpha stage, which means that
they provide limited functionality of GLUT API 3. A somewhat more
limited port (mostly due to limits of the OS) to Andriod is now also
available.
See README.cmake as a starting point, as well as the other README
files for further info.
INSTALLATION
============
CONTRIBUTING
============
See README.cmake as a starting point, as well as the other README
files for further info.
Patches for bugfixes and new features are certainly welcome. Please send patches
to the freeglut-developer mailing list (see CONTACT below).
Feel free to report any bugs you encounter, using our bug tracking system:
https://sourceforge.net/p/freeglut/bugs/
Feature requests are also welcome at:
https://sourceforge.net/p/freeglut/feature-requests/
If your bug report needs urgent attention, please also post a message to the
aforementioned freeglut-developer mailing list, to make sure we'll see it ASAP.
CONTRIBUTING
============
CONTACT
=======
Bug and missing features patches are certainly welcome. Just as comments
and FREEGLUT API propositions are.
Just please to make the fixes look visually just as the rest of the code
does (tabs converted 4 white spaces). Comments are really welcome, as I
believe it would be nice for people fresh new to OpenGL see how the things
are done...
WEB SITE AND CONTACTING THE AUTHOR
==================================
Freeglut project has moved to the SourceForge:
http://freeglut.sourceforge.net
THE HOPE
========
Hope you find my work somehow useful.
Pawel W. Olszta, <olszta@sourceforge.net>
PASSING THE BATON
=================
In late December 2000, Pawel decided that he no longer
wished to maintain freeglut because he has moved out of
the graphics field. I volunteered to take over from him
and have been running the project since Jan 13th 2001.
I'm also the author and maintainer of the PLIB library suite
and 'freeglut' really fits in well with that work.
I just hope I can live up to Pawel's high standards. Pawel
remains on the active developers list.
Steve Baker <sjbaker1@airmail.net>
http://plib.sourceforge.net
FreeGLUT website: http://freeglut.sourceforge.net
FreeGLUT mailing lists:
- developer: https://lists.sourceforge.net/lists/listinfo/freeglut-developer
- bugs: https://lists.sourceforge.net/lists/listinfo/freeglut-bugs
- announce: https://lists.sourceforge.net/lists/listinfo/freeglut-announce
You need to subscribe before posting to any of our mailing lists. Make sure
to avoid selecting "daily digest mode" if you intend to post, so that you can
reply properly to specific messages. Also, please do not top-post, and try to
send properly formated emails (text, hard-wrapped at 72 columns, no binary or
large attachements).

View File

@ -40,21 +40,41 @@ How to build freeglut on UNIX
- Make sure you have the basics for compiling code, such as C compiler
(e.g., GCC) and the make package.
- Also make sure you have packages installed that provide the relevant
header files for x11 (including xrandr) and opengl (e.g.,
libgl1-mesa-dev, libx11-dev and libxrandr-dev on Debian/Ubuntu).
- Install XInput: libxi-dev / libXi-devel
- Run 'cmake .' in the freeglut directory to generate the makefile.
header files for opengl (e.g., libgl1-mesa-dev on Debian/Ubuntu) and
the chosen backend :
- X11: x11 (e.g., libx11-dev, libxrandr-devel on Debian/Ubuntu) and
XInput (libxi-dev / libXi-devel)
- Wayland: wayland (e.g., libwayland-dev and libegl1-mesa-dev on
Debian/Ubuntu) and xkbcommon (libxkbcommon-dev /libxkbcommon-devel)
- Run 'cmake .' (or 'cmake . -DFREEGLUT_WAYLAND=ON' for Wayland) in the
freeglut directory to generate the makefile.
- Run 'make' to build, and 'make install' to install freeglut.
- If you wish to change any build options run 'ccmake .'
Breakdown of CMake configuration options
----------------------------------------
BUILD_SHARED_LIBS [ON, OFF] Build freeglut as a shared library
BUILD_STATIC_LIBS [ON, OFF] Build freeglut as a static library
CMAKE_BUILD_TYPE [Empty, Debug, Release] Can be overriden by passing it
as a make variable during build.
CMAKE_INSTALL_PREFIX Installation prefix (e.g. /usr/local on UNIX)
FREEGLUT_BUILD_DEMOS [ON, OFF] Controls whether the demos are built or not.
FREEGLUT_GLES1 [ON, OFF] TODO
FREEGLUT_GLES2 [ON, OFF] TODO
CMAKE_BUILD_TYPE [Empty, Debug, Release] Can be overriden by
passing it as a make variable during build.
CMAKE_INSTALL_PREFIX Installation prefix (e.g. /usr/local on UNIX)
FREEGLUT_BUILD_DEMOS [ON, OFF] Controls whether the demos are
built or not.
FREEGLUT_BUILD_SHARED_LIBS [ON, OFF] Build freeglut as a shared library
FREEGLUT_BUILD_STATIC_LIBS [ON, OFF] Build freeglut as a static library
FREEGLUT_GLES [ON, OFF] Link with GLEs libraries instead
of OpenGL
FREEGLUT_WAYLAND [ON, OFF] Link with Wayland libraries instead
of X11
FREEGLUT_PRINT_ERRORS [ON, OFF] Controls whether errors are
default handled or not when user does not
provide an error callback
FREEGLUT_PRINT_WARNINGS [ON, OFF] Controls whether warnings are
default handled or not when user does not
provide an warning callback
FREEGLUT_REPLACE_GLUT [ON, OFF] For non-Windows platforms,
freeglut is by default built as -lglut. if
off, built as -lfreeglut. On Windows,
libraries are always built as freeglut.
INSTALL_PDB [ON, OFF] MSVC only: controls whether debug
information files are included with the
install or not

View File

@ -1,33 +0,0 @@
January 2011
To the gentle Mac user,
I realize that this is hardly a full explanation of how to build on a Mac,
but it will need to suffice for now.
There was an e-mail on the "freeglut" developers mailing list titled
"Compiling Static freeglut on mac" with a datestamp of 10/12/2010 at
11:20 AM (possibly corrected for Central time, USA). Another e-mail
on the same mailing list from the same person, in reply to his original
missive, is dated 11/9/2010 at 10:03 PM. This file is an attempt to
capture the knowledge in those two e-mails.
The author of the e-mails was trying to compile a static "freeglut"
library on Mac OSX version 10.5.8. He tried building both freeglut
versions 2.4.0 and 2.6.0 with a command ...
./configure --disabled-shared --enable-static
make
... and got a "non_lazy_ptr" error in both cases. He was able to fix
the problem by using the following "configure" command instead:
./configure --disable-warnings --disable-shared --enable-static CPPFLAGS=-I/usr/X11/include -L/usr/X11/lib LDFLAGS=-I/usr/X11/include -L/usr/X11/lib -framework GLUT
Any further information on building "freeglut" on a Mac would be deeply
appreciated. I believe that much of the information on building it on
*nix systems also applies to the Mac.
John F. Fay
1/22/11

View File

@ -1,107 +0,0 @@
The not-so-up-to-date TODO list can be found under following URL:
http://freeglut.sourceforge.net/progress.html
Issues in Freeglut (so we don't forget):
*fixed*(D) I'd like to change the names of the Windows target directories from names like "Debug__Win32_freeglut_static" (or something like that) to names like "DebugStatic".
Issues that can Wait until 2.2.0:
(1) In the Atlantis demo, under windows and with the task bar to the left of the screen, the GLUT window comes up in a position relative to the corner of the screen while the "freeglut" window comes up down and to the right of where it was the last time it was opened.
(2) In the Atlantis demo, if you stop the animation and move the mouse around with a menu open, the whales jiggle but don't circulate. My guess is that you need a way to redisplay the menu without forcing a redisplay from the application.
(3) In the Atlantis demo, if you bring up the menu in GLUT the animation stops; in freeglut the fish and whales wiggle without advancing. This may be another manifestation of (2).
(4) In the Atlantis demo modified to draw a solid torus instead of a mother whale, the torus is not shaded according to the lighting. This is true with both GLUT and freeglut. With freeglut, when you bring up a menu the shading used to turn on but doesn't any longer; with GLUT it never did and still does not. Interestingly, if you change to a teapot it is shaded, but other geometric shapes are not shaded.
*fixed*(5) The "freeglut" wire cone does not look like the GLUT wire cone. There are several differences, one of which is that the "freeglut" cone draws the base.
*fixed*(6) With the "bluepony" demo under Windows, if you reshape the window using the mouse, the scene does not redraw until you move it with a keypress (arrow key or space bar to start the animation). Check out the "CS_VREDRAW or CS_HREDRAW" sections in MSVC help for a pointer about this.
(7) If you compare the "bounce" demo with freeglut and GLUT, you see that the "freeglut" lights are larger and dimmer (and don't shine on the walls) than the GLUT lights.
*fixed*(8) Large submenus in "freeglut" tend to cover their parent menus, making it difficult to get past them. This is visible in the "geoface" demo. In GLUT the menus can extend outside the window; "freeglut" should do the same thing.
(9) In the "gliq" demo, the cones forming the ends of the arrows in the "select board" are lighted differently in "freeglut" than they are in GLUT.
*fixed*(10) The "skyfly" demo resized my video and set it to 256 colors but didn't set it back when it was done. This is a problem with "skyfly" and not freeglut. <This seems to have fixed itself.>
*fixed*(11) We seem to have troubles with programs that use display lists. Check out the "walker" demo and load a new curve set. If you have the debugger going while it is loading, you get the new curves; otherwise you don't. This has to do with the debugger hiding the freeglut window while the display list is being changed. <This seems to have fixed itself.>
*fixed*(12) The "fgCleanUpGlutsMess" function seems to duplicate the "fgDestroyStructure" or "fgDeinitialize" function and should probably be removed.
*fixed*(13) The "G_LOG_DOMAIN" defined constants are never used. Should we start using them in warning and error messages or should we delete them?
*fixed*(14) The "freeglut_internal.h" file on lines 45ff defines or undefines "G_DISABLE_ASSERT" and "G_DISABLE_CHECKS" but these are never used. Shall we start using them or should we delete them?
*fixed*(15) P-GUIDE apparently calls the get and set window size functions repeatedly. Each time it does, the window shrinks by 2 pixels in each direction.
(16) (for Don Heyse) We need to implement the "glutLayerGet ( GLUT_NORMAL_DAMAGED )" call.
(17) Also from Aleksandar Donev: can some add support for building a debugging version of freeglut to the makefiles? I have no clue how to use automake...
(18) There is a big guess about the mouse buttons count under X11 (always 3) -- I must remember to correct the menu activation code if this shows to be invalid.
(19) None of the bizarre input devices found in GLUT API is supported (and probably won't).
(20) The joystick code should work fine but I haven't tested it out yet. It might not compile under FreeBSD, as I had to convert it from C++ to C and had no possibility to compile it under FreeBSD.
(21) The menu is displayed using OpenGL, so it requires the window's contents to be refreshed at an interactive rate, which sometimes does not happen. That's why I'll consider adding optional window-system menu navigation later. For now -- extensive testing is what I believe should be done with the menu system. (Several of the GLUT demos use the menu system. John Fay has checked it out pretty well.)
(22) Need to have own cursor shapes, so that freeglut can pass them to the windowing system, draw them using glBitmap() and/or texture mapping. The cursor shapes are very probable to be found in XFree86 sources.
(23) Indexed color mode might work, however I have not tested it yet. glutGetColor/glutSetColor is not implemented. Again, looks like a single Xlib call, but there might be some problems with the colormap access. Need to switch into indexed color mode some day and check it out (does Mesa 3.1 work with indexed color mode?)
(24) Overlays are not supported, but one of the GLUT conformance tests fails due to glutLayerGet( GLUT_NORMAL_DAMAGED ) returning FALSE when the window has actually been damaged.
(25) Layers would be good for drawing the menus and mouse cursor, as they wouldn't force the application redraw to update their state.
(26) Does the init display string work?
(27) Is the game mode string parsed correctly?
(28) Does the geometry need normal vectors?
(29) The visibility/window status function is a conceptual mess. I had to peer into the GLUT source code to see what actually happens inside. It helped me a bit, but still one of the visibility tests fails. This is probably the reason for which a window covered by enlightenment status bar is marked as hidden and does not get redrawn.
(30) GLX 1.3 spec states that glXChooseVisual() et consortes are deprecated. Should move to glXFBConfig.
(31) Need to investigate what happens when initial window position is set to (-1,-1). GLUT specification says, that the window positioning should be left to the window system. And I do not know how to force it do so...
(32) I was told it is wrong to have the redisplay forced in the main loop. Is that right?
(33) Some of the tests freeze because they do not generate the glutPostRedisplay() call every frame. Again, this is somehow handled by GLUT, but I can't see how. And why. Looks like I've fixed it (or rather hacked it?) by forcing a redisplay every frame, but this is no good and kills interactiveness of my console :D
(34) We should really implement overlays, if only for the sake of completeness.
(35) Menus do not display in single-buffered windows, although they are active and the user can pick from them if he knows how to move the mouse exactly right.
(36) In the "boundary.c" demo in the "advanced" directory, if the outline rendering is turned on the menu background turns black.
(37) In the "comp.c" demo in the "advanced" directory, we find that we need a window to be defined before "glutGet ( GLUT_DISPLAY_MODE_POSSIBLE )" can be called. GLUT does not have this restriction. In "freeglut" there is a check at the beginning of the "fgSetupPixelFormat" call and a few references to "window->" later in the function.
(38) When you get around the requirement for an existing window in "comp.c", you find that "freeglut" renders the window differently from GLUT. For starters, "freeglut" looks like it is double-buffering while GLUT looks like it is single-buffering. In 'freeglut" the background is all black while in GLUT it starts black and turns white before your eyes.
(39) Running the "convolve" GLUT demo in the "advanced" directory (after fixing it so it doesn't terminate on error), I find that the "freeglut" version runs much more slowly than the GLUT version. I think this has to do with forcing redraws when the menu comes up.
(40) The "genmipmap" demo runs much more slowly in "freeglut" than in GLUT (try moving a window!) and flashes the texture over the whole window instead of just the part of the window where it finally settles down.
(41) We need to keep the "freeglut" structure current (including the GLUT action on window closure) after the last window closes. (Aleksandar Donev e-mail, 7/4/03, 5:00 PM).
*fixed*(42) Menus need to display in their own subwindow with a special menu OpenGL rendering context. This will fix a wide range of menu-related bugs.
*fixed*(43) We need to keep the "freeglut" structure current (including the GLUT action on window closure) after the last window closes.
*fixed*(44) The "freeglut" wire cone differs from the GLUT wire cone. As a minimum, it draws the base where GLUT does not. I would check the solid cone as well.
(45) The different mouse pointers (crosshair, double pointer, etc.) do not get shown.
(46) The visibility callback is not invoked when minimizing a window. It should be.
(47) We should add a "glutExit" call to the interface. Also a "glutGet" to tell whether it has been initialized properly. And have "freeglut" call "glutExit" before it calls "exit ()".

View File

@ -1,5 +1,5 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=${prefix}/include
Name: glut

View File

@ -90,6 +90,8 @@
#define GLUT_STROKE_FONT_DRAW_JOIN_DOTS 0x0206 /* Draw dots between line segments of stroke fonts? */
#define GLUT_ALLOW_NEGATIVE_WINDOW_POSITION 0x0207 /* GLUT doesn't allow negative window positions by default */
/*
* New tokens for glutInitDisplayMode.
* Only one GLUT_AUXn bit may be used at a time.

View File

@ -0,0 +1,58 @@
/*
* ------------------------------------------
* user_error_handler.c
*
* This is a sample program showing a basic
* user defined error handlers with FreeGLUT
* ------------------------------------------
*/
#include <GL/freeglut.h>
/*
* ------------------------------------------
* Declare our own Error handler for FreeGLUT
* ------------------------------------------
*/
/* This declares the vprintf() routine */
#include <stdio.h>
/* This declares the va_list type */
#include <stdarg.h>
/* The new handler looks like a vprintf prototype */
void myError (const char *fmt, va_list ap)
{
fprintf(stderr, "myError: Entering user defined error handler\n");
/* print warning message */
fprintf(stderr, "myError:");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
/* deInitialize the freeglut state */
fprintf(stderr, "myError: Calling glutExit()\n");
glutExit();
/* terminate error handler appropriately */
fprintf(stderr, "myError: Exit-ing handler routine\n");
exit(1);
}
/*
* ------------------------------------------
* Just enough code to create the error to
* demonstrate the user defined handler
* ------------------------------------------
*/
int main(int argc, char** argv)
{
glutInitErrorFunc(&myError);
glutCreateWindow ("error test"); /* This is an error! */
glutInit(&argc, argv); /* Should be called
after glutInit() */
glutMainLoop();
return 0;
}

View File

@ -34,8 +34,13 @@ void fghPlatformInitializeEGL()
{
/* CreateDisplay */
/* Using EGL_DEFAULT_DISPLAY, or a specific native display */
#ifdef FREEGLUT_WAYLAND
fgDisplay.pDisplay.egl.Display = eglGetDisplay(
(EGLNativeDisplayType)fgDisplay.pDisplay.display);
#else
EGLNativeDisplayType nativeDisplay = EGL_DEFAULT_DISPLAY;
fgDisplay.pDisplay.egl.Display = eglGetDisplay(nativeDisplay);
#endif
FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY,
"No display available", "fgPlatformInitialize");

View File

@ -27,6 +27,7 @@
#include "fg_internal.h"
int fghChooseConfig(EGLConfig* config) {
EGLint num_config;
EGLint attributes[32];
int where = 0;
ATTRIB_VAL(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
@ -68,7 +69,6 @@ int fghChooseConfig(EGLConfig* config) {
ATTRIB_VAL(EGL_SAMPLES, (fgState.DisplayMode & GLUT_MULTISAMPLE) ? fgState.SampleNumber : 0);
ATTRIB(EGL_NONE);
EGLint num_config;
if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display,
attributes, config, 1, &num_config)) {
fgWarning("eglChooseConfig: error %x\n", eglGetError());
@ -94,7 +94,7 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
ATTRIB_VAL(EGL_CONTEXT_CLIENT_VERSION, fgState.MajorVersion);
#ifdef EGL_CONTEXT_MINOR_VERSION
if (fgDisplay.pDisplay.egl.MinorVersion >= 5) {
// EGL_CONTEXT_CLIENT_VERSION == EGL_CONTEXT_MAJOR_VERSION
/* EGL_CONTEXT_CLIENT_VERSION == EGL_CONTEXT_MAJOR_VERSION */
ATTRIB_VAL(EGL_CONTEXT_MINOR_VERSION, fgState.MinorVersion);
}
#endif

View File

@ -88,6 +88,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
4, /* SampleNumber */
GL_FALSE, /* SkipStaleMotion */
GL_FALSE, /* StrokeFontDrawJoinDots */
GL_FALSE, /* AllowNegativeWindowPosition */
1, /* OpenGL context MajorVersion */
0, /* OpenGL context MinorVersion */
0, /* OpenGL ContextFlags */
@ -357,7 +358,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* size.
*/
if (geometry )
if ( geometry )
{
unsigned int parsedWidth, parsedHeight;
int mask = XParseGeometry( geometry,
@ -370,10 +371,10 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
if( (mask & (WidthValue|HeightValue)) == (WidthValue|HeightValue) )
fgState.Size.Use = GL_TRUE;
if( mask & XNegative )
if( ( mask & XNegative ) && !fgState.AllowNegativeWindowPosition )
fgState.Position.X += fgDisplay.ScreenWidth - fgState.Size.X;
if( mask & YNegative )
if( ( mask & YNegative ) && !fgState.AllowNegativeWindowPosition )
fgState.Position.Y += fgDisplay.ScreenHeight - fgState.Size.Y;
if( (mask & (XValue|YValue)) == (XValue|YValue) )
@ -397,7 +398,7 @@ void FGAPIENTRY glutInitWindowPosition( int x, int y )
fgState.Position.X = x;
fgState.Position.Y = y;
if( ( x >= 0 ) && ( y >= 0 ) )
if( ( ( x >= 0 ) && ( y >= 0 ) ) || fgState.AllowNegativeWindowPosition )
fgState.Position.Use = GL_TRUE;
else
fgState.Position.Use = GL_FALSE;

View File

@ -51,7 +51,11 @@
# define TARGET_HOST_BLACKBERRY 1
#elif defined(__posix__) || defined(__unix__) || defined(__linux__) || defined(__sun)
# define TARGET_HOST_POSIX_X11 1
# if defined(FREEGLUT_WAYLAND)
# define TARGET_HOST_POSIX_WAYLAND 1
# else
# define TARGET_HOST_POSIX_X11 1
# endif
#elif defined(__APPLE__)
/* This is a placeholder until we get native OSX support ironed out -- JFF 11/18/09 */
@ -70,32 +74,36 @@
#endif
#ifndef TARGET_HOST_MS_WINDOWS
# define TARGET_HOST_MS_WINDOWS 0
# define TARGET_HOST_MS_WINDOWS 0
#endif
#ifndef TARGET_HOST_ANDROID
# define TARGET_HOST_ANDROID 0
# define TARGET_HOST_ANDROID 0
#endif
#ifndef TARGET_HOST_BLACKBERRY
# define TARGET_HOST_BLACKBERRY 0
# define TARGET_HOST_BLACKBERRY 0
#endif
#ifndef TARGET_HOST_POSIX_WAYLAND
# define TARGET_HOST_POSIX_WAYLAND 0
#endif
#ifndef TARGET_HOST_POSIX_X11
# define TARGET_HOST_POSIX_X11 0
# define TARGET_HOST_POSIX_X11 0
#endif
#ifndef TARGET_HOST_MAC_OSX
# define TARGET_HOST_MAC_OSX 0
# define TARGET_HOST_MAC_OSX 0
#endif
#ifndef TARGET_HOST_SOLARIS
# define TARGET_HOST_SOLARIS 0
# define TARGET_HOST_SOLARIS 0
#endif
/* -- FIXED CONFIGURATION LIMITS ------------------------------------------- */
#define FREEGLUT_MAX_MENUS 3
#define FREEGLUT_MAX_MENUS 3
/* These files should be available on every platform. */
#include <stdio.h>
@ -188,6 +196,9 @@
#endif
/* Platform-specific includes */
#if TARGET_HOST_POSIX_WAYLAND
#include "wayland/fg_internal_wl.h"
#endif
#if TARGET_HOST_POSIX_X11
#include "x11/fg_internal_x11.h"
#endif
@ -343,6 +354,7 @@ struct tagSFG_State
GLboolean SkipStaleMotion; /* skip stale motion events */
GLboolean StrokeFontDrawJoinDots;/* Draw dots between line segments of stroke fonts? */
GLboolean AllowNegativeWindowPosition; /* GLUT, by default, doesn't allow negative window positions. Enable it? */
int MajorVersion; /* Major OpenGL context version */
int MinorVersion; /* Minor OpenGL context version */
@ -413,8 +425,7 @@ struct tagSFG_Context
#define GLUT_DISPLAY_WORK (1<<6)
/*
* An enumeration containing the state of the GLUT execution:
* initializing, running, or stopping
* An enumeration containing the desired mapping state of a window
*/
typedef enum
{

View File

@ -11,7 +11,7 @@
#include <GL/freeglut.h>
#include "fg_internal.h"
#if(_WIN32_WINNT >= 0x0501)
#if( !_WIN32 || _WIN32_WINNT >= 0x0501)
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */

View File

@ -122,6 +122,10 @@ void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
fgState.StrokeFontDrawJoinDots = !!value;
break;
case GLUT_ALLOW_NEGATIVE_WINDOW_POSITION:
fgState.AllowNegativeWindowPosition = !!value;
break;
default:
fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
break;
@ -225,6 +229,9 @@ int FGAPIENTRY glutGet( GLenum eWhat )
case GLUT_STROKE_FONT_DRAW_JOIN_DOTS:
return fgState.StrokeFontDrawJoinDots;
case GLUT_ALLOW_NEGATIVE_WINDOW_POSITION:
return fgState.AllowNegativeWindowPosition;
default:
return fgPlatformGlutGet ( eWhat );
break;

View File

@ -75,6 +75,11 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
/* Have the window object created */
SFG_Window *window = (SFG_Window *)calloc( 1, sizeof(SFG_Window) );
if( !window )
{
fgError( "Out of memory. Could not create window." );
}
fgPlatformCreateWindow ( window );
fghClearCallBacks( window );

View File

@ -177,12 +177,12 @@ int FGAPIENTRY glutCreateWindow( const char* title )
* XXX application has not already done so. The "freeglut" community
* XXX decided not to go this route (freeglut-developer e-mail from
* XXX Steve Baker, 12/16/04, 4:22 PM CST, "Re: [Freeglut-developer]
* XXX Desired 'freeglut' behaviour when there is no current window"
* XXX Desired 'freeglut' behaviour when there is no current window")
*/
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
return fgCreateWindow( NULL, title, fgState.Position.Use,
fgState.Position.X, fgState.Position.Y,
return fgCreateWindow( NULL, title,
fgState.Position.Use, fgState.Position.X, fgState.Position.Y,
fgState.Size.Use, fgState.Size.X, fgState.Size.Y,
GL_FALSE, GL_FALSE )->ID;
}
@ -199,33 +199,51 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateSubWindow" );
parent = fgWindowByID( parentID );
freeglut_return_val_if_fail( parent != NULL, 0 );
if ( x < 0 )
if ( fgState.AllowNegativeWindowPosition )
{
x = parent->State.Width + x ;
if ( w >= 0 ) x -= w ;
/* XXX This results in different widths/heights than if AllowNegativeWindowPosition
* XXX was false. The "freeglut" community defined this logic.
* XXX (freeglut-developer e-mail from Diederick C. Niehorster, 11/15/2015, 4:06 PM EST.
* XXX "Re: [Freeglut-developer] glutInitWindowPosition with negative coordinate(s)")
*/
if ( w < 0 ) w = parent->State.Width + w ;
if ( h < 0 ) h = parent->State.Height + h ;
}
else
{
if ( ( x < 0 ) )
{
x = parent->State.Width + x ;
if ( w > 0 ) x -= w ;
}
if ( w < 0 ) w = parent->State.Width - x + w ;
if ( w < 0 )
{
x += w ;
w = -w ;
}
if ( ( y < 0 ) )
{
y = parent->State.Height + y ;
if ( h > 0 ) y -= h ;
}
if ( h < 0 ) h = parent->State.Height - y + h ;
if ( h < 0 )
{
y += h ;
h = -h ;
}
}
if ( w < 0 ) w = parent->State.Width - x + w ;
if ( w < 0 )
{
x += w ;
w = -w ;
}
if ( y < 0 )
{
y = parent->State.Height + y ;
if ( h >= 0 ) y -= h ;
}
if ( h < 0 ) h = parent->State.Height - y + h ;
if ( h < 0 )
{
y += h ;
h = -h ;
}
window = fgCreateWindow( parent, "", GL_TRUE, x, y, GL_TRUE, w, h, GL_FALSE, GL_FALSE );
window = fgCreateWindow( parent, "",
GL_TRUE, x, y,
GL_TRUE, w, h,
GL_FALSE, GL_FALSE );
ret = window->ID;
return ret;

View File

@ -64,14 +64,16 @@ void fgPlatformInitializeSpaceball(void)
}
hwnd = fgStructure.CurrentWindow->Window.Handle;
BOOL ok;
UINT cbSize = sizeof(__fgSpaceball);
__fgSpaceball.hwndTarget = hwnd;
ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
{
BOOL ok;
UINT cbSize = sizeof(__fgSpaceball);
__fgSpaceball.hwndTarget = hwnd;
ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
if (!ok){
__fgSpaceball.hwndTarget = NULL;
sball_initialized = 0;
if (!ok){
__fgSpaceball.hwndTarget = NULL;
sball_initialized = 0;
}
}
}
@ -138,57 +140,58 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size);
if (res == -1)
return;
SFG_Window* window = fgWindowByHandle(hwnd);
if ((window == NULL))
return;
if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
{
// Motion data comes in two parts: motion type and
// displacement/rotation along three axis.
// Orientation is a right handed coordinate system with
// X goes right, Y goes up and Z goes towards viewer, e.g.
// the one used in OpenGL
if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_TRANSLATION)
{ // Translation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short X = pnData[0];
short Y = -pnData[2];
short Z = pnData[1];
INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_ROTATION)
{ // Axis aligned rotation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short rX = pnData[0];
short rY = -pnData[2];
short rZ = pnData[1];
INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_BUTTON)
{ // State of the keys
unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
unsigned int state = GLUT_UP;
if (FETCH_WCB(*window, SpaceButton))
{
int i;
for (i = 0; i < 32; i++)
{
unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
unsigned long stateNow = dwKeystate&(1 << i);
SFG_Window* window = fgWindowByHandle(hwnd);
if ((window == NULL))
return;
if (stateBefore && !stateNow)
INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_DOWN));
if (!stateBefore && stateNow)
INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_UP));
}
if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
{
// Motion data comes in two parts: motion type and
// displacement/rotation along three axis.
// Orientation is a right handed coordinate system with
// X goes right, Y goes up and Z goes towards viewer, e.g.
// the one used in OpenGL
if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_TRANSLATION)
{ // Translation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short X = pnData[0];
short Y = -pnData[2];
short Z = pnData[1];
INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_ROTATION)
{ // Axis aligned rotation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short rX = pnData[0];
short rY = -pnData[2];
short rZ = pnData[1];
INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_BUTTON)
{ // State of the keys
unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
unsigned int state = GLUT_UP;
if (FETCH_WCB(*window, SpaceButton))
{
int i;
for (i = 0; i < 32; i++)
{
unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
unsigned long stateNow = dwKeystate&(1 << i);
if (stateBefore && !stateNow)
INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_DOWN));
if (!stateBefore && stateNow)
INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_UP));
}
}
__fgSpaceKeystate = dwKeystate;
}
__fgSpaceKeystate = dwKeystate;
}
}
}

View File

@ -0,0 +1,137 @@
/*
* fg_cursor_wl.c
*
* The Wayland-specific mouse cursor related stuff.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Thur Mar 19, 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <GL/freeglut.h>
#include "../fg_internal.h"
/*
* Note: The arrangement of the table below depends on the fact that
* the "normal" GLUT_CURSOR_* values start a 0 and are consecutive.
*/
static char* cursorList[] = {
"UNSUPPORTED", /* GLUT_CURSOR_RIGHT_ARROW */
"left_ptr", /* GLUT_CURSOR_LEFT_ARROW */
"hand1", /* GLUT_CURSOR_INFO */
"UNSUPPORTED", /* GLUT_CURSOR_DESTROY */
"UNSUPPORTED", /* GLUT_CURSOR_HELP */
"UNSUPPORTED", /* GLUT_CURSOR_CYCLE */
"UNSUPPORTED", /* GLUT_CURSOR_SPRAY */
"watch", /* GLUT_CURSOR_WAIT */
"xterm", /* GLUT_CURSOR_TEXT */
"grabbing", /* GLUT_CURSOR_CROSSHAIR */
"UNSUPPORTED", /* GLUT_CURSOR_UP_DOWN */
"UNSUPPORTED", /* GLUT_CURSOR_LEFT_RIGHT */
"top_side", /* GLUT_CURSOR_TOP_SIDE */
"bottom_side", /* GLUT_CURSOR_BOTTOM_SIDE */
"left_side", /* GLUT_CURSOR_LEFT_SIDE */
"right_side", /* GLUT_CURSOR_RIGHT_SIDE */
"top_left_corner", /* GLUT_CURSOR_TOP_LEFT_CORNER */
"top_right_corner", /* GLUT_CURSOR_TOP_RIGHT_CORNER */
"bottom_right_corner", /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
"bottom_left_corner" /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
};
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
{
/*
* XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows
* for this, but if there is a system that easily supports a full-
* window (or full-screen) crosshair, we might consider it.
*/
int cursorIDToUse =
( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID;
char* cursor;
if( ( cursorIDToUse >= 0 ) &&
( cursorIDToUse < sizeof( cursorList ) / sizeof( cursorList[0] ) ) ) {
cursor = cursorList[cursorIDToUse];
/* if the type is UNSUPPORTED, fall back to GLUT_CURSOR_LEFT_ARROW */
if ( ! strcmp( cursor, "UNSUPPORTED" ) )
{
fgWarning( "glutSetCursor(): cursor type unsupported under Wayland : %d",
cursorIDToUse );
cursor = "left_ptr";
}
} else {
switch( cursorIDToUse )
{
case GLUT_CURSOR_NONE:
case GLUT_CURSOR_INHERIT:
cursor = NULL;
break;
default:
fgError( "Unknown cursor type: %d", cursorIDToUse );
return;
}
}
if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) {
if( window->Parent )
window->Window.pContext.cursor =
window->Parent->Window.pContext.cursor;
} else {
window->Window.pContext.cursor = wl_cursor_theme_get_cursor(
fgDisplay.pDisplay.cursor_theme,
cursor );
if ( ! window->Window.pContext.cursor )
fgError( "Failed to create cursor" );
}
}
void fgPlatformWarpPointer ( int x, int y )
{
/* unsupported under Wayland */
fgWarning( "glutWarpPointer(): function unsupported under Wayland" );
}
void fghPlatformGetCursorPos(const SFG_Window *window, GLboolean client, SFG_XYUse *mouse_pos)
{
/* Get current pointer location relative to top-left of client area of window (if client is true and window is not NULL)
* We cannot get current pointer location in screen coordinates under Wayland, so inform the user and return -1 is this case
*/
if (client && window)
{
mouse_pos->X = window->State.MouseX;
mouse_pos->Y = window->State.MouseY;
}
else
{
fgWarning( "glutGetCursorPos(): cannot get screen position under Wayland" );
mouse_pos->X = -1;
mouse_pos->Y = -1;
}
mouse_pos->Use = GL_TRUE;
}

View File

@ -0,0 +1,49 @@
/*
* fg_ext_wl.c
*
* Wayland-specific functions related to OpenGL extensions.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Wed Mar 25 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <GL/freeglut.h>
#include "../fg_internal.h"
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
{
/* optimization: quick initial check */
if( strncmp( procName, "glut", 4 ) != 0 )
return NULL;
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
CHECK_NAME(glutJoystickFunc);
CHECK_NAME(glutForceJoystickFunc);
CHECK_NAME(glutGameModeString);
CHECK_NAME(glutEnterGameMode);
CHECK_NAME(glutLeaveGameMode);
CHECK_NAME(glutGameModeGet);
#undef CHECK_NAME
return NULL;
}

View File

@ -0,0 +1,161 @@
/*
* fg_gamemode_wl.c
*
* The game mode handling code.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Sun Mar 23 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/freeglut.h>
#include "../fg_internal.h"
/* Pointer locking is a Weston-specific WIP protocol (for now)
*
* #include "pointer-lock-client-protocol.h"
* #include "relative-pointer-client-protocol.h"
*
* static struct _wl_relative_pointer_manager* relative_pointer_manager;
* static struct _wl_pointer_lock* pointer_lock;
*
* static struct _wl_relative_pointer* relative_pointer;
* static struct _wl_locked_pointer* locked_pointer;
*
*
* static void fghRelativeMotion( void* data, struct _wl_relative_pointer
* pointer, uint32_t time,
* wl_fixed_t x_w, wl_fixed_t y_w,
* wl_fixed_t x_noacc, wl_fixed_t y_noacc )
* {
* SFG_Window* win = fgStructure.CurrentWindow;
* win->State.MouseX = wl_fixed_to_int( x_w );
* win->State.MouseY = wl_fixed_to_int( y_w );
* INVOKE_WCB( *win, Passive, ( win->State.MouseX,
* win->State.MouseY ) );
* }
* static const struct _wl_relative_pointer_listener
* fghRelativeListener =
* {
* fghRelativeMotion
* };
*
* static void fghLockedLocked( void* data, struct _wl_locked_pointer
* pointer, uint32_t serial )
* {
* fgPlatformRememberState();
* fgPlatformSetCursor( win, GLUT_CURSOR_NONE ):
* }
* static void fghLockedUnlocked( void* data, struct _wl_locked_pointer
* pointer )
* {
* fgPlatformRestoreState();
* }
* static const struct _wl_locked_pointer_listener
* fghLockedListener =
* {
* fghLockedLocked,
* fghLockedUnlocked
* };
*/
static struct wl_cursor* saved_cursor;
/*
* Remembers the current visual settings, so that
* we can change them and restore later...
*/
void fgPlatformRememberState( void )
{
SFG_Window* win = fgStructure.CurrentWindow;
saved_cursor = win->Window.pContext.cursor;
}
/*
* Restores the previously remembered visual settings
*/
void fgPlatformRestoreState( void )
{
SFG_Window* win = fgStructure.CurrentWindow;
win->Window.pContext.cursor = saved_cursor;
}
/*
* * Private function to get the virtual maximum screen extent
* */
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
{
/*
* under Wayland, just return the size of the window,
* at least until we start messing with the outputs...
*/
*x = window->State.Width;
*y = window->State.Height;
}
/*
* Changes the current display mode to match user's settings
*/
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
{
/* Such a protocol is being studied in Wayland */
return GL_FALSE;
}
void fgPlatformEnterGameMode( void )
{
SFG_Window* win = fgStructure.CurrentWindow;
struct wl_region* region;
region = wl_compositor_create_region (
fgDisplay.pDisplay.compositor );
wl_region_add( region, 0, 0,
win->State.Width,
win->State.Height );
/*
* relative_pointer =
* _wl_relative_pointer_manager_get_relative_pointer (
* relative_pointer_manager,
* fgDisplay.pDisplay.seat );
* _wl_relative_pointer_add_listener( relative_pointer,
* &fghRelativeListener,
* NULL );
* locked_pointer = _wl_pointer_lock_lock_pointer (
* pointer_lock,
* win->Window.pContext.surface,
* fgDisplay.pDisplay.seat,
* NULL);
* _wl_locked_pointer_add_listener( locked_pointer,
* &fghLockedListener,
* NULL );
*/
wl_region_destroy( region );
}
void fgPlatformLeaveGameMode( void )
{
/*
* _wl_locked_pointer_destroy( locked_pointer );
* _wl_relative_pointer_release( relative_pointer );
*/
}

View File

@ -0,0 +1,134 @@
/*
* fg_init_wl.c
*
* Various freeglut Wayland initialization functions.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Tue Mar 17, 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define FREEGLUT_BUILDING_LIB
#include <string.h>
#include <GL/freeglut.h>
#include "fg_internal.h"
#include "egl/fg_init_egl.h"
void fgPlatformInitialiseInputDevices( void );
void fgPlatformCloseInputDevices( void );
static void fghRegistryGlobal( void* data,
struct wl_registry* registry,
uint32_t id,
const char* interface,
uint32_t version )
{
SFG_PlatformDisplay* pDisplay = data;
if ( ! strcmp( interface, "wl_compositor" ) )
pDisplay->compositor = wl_registry_bind ( registry, id,
&wl_compositor_interface, 1 );
else if ( ! strcmp( interface, "wl_shell" ) )
pDisplay->shell = wl_registry_bind ( registry, id,
&wl_shell_interface, 1 );
else if ( ! strcmp( interface, "wl_seat" ) )
pDisplay->seat = wl_registry_bind ( registry, id,
&wl_seat_interface, 1 );
else if ( ! strcmp( interface, "wl_shm" ) )
pDisplay->shm = wl_registry_bind ( registry, id,
&wl_shm_interface, 1 );
}
static void fghRegistryGlobalRemove( void* data,
struct wl_registry* registry,
uint32_t id )
{
}
static const struct wl_registry_listener fghRegistryListener =
{
fghRegistryGlobal,
fghRegistryGlobalRemove
};
static void fghInitialiseCursorTheme(void)
{
fgDisplay.pDisplay.cursor_theme = wl_cursor_theme_load (
"default", 32,
fgDisplay.pDisplay.shm );
};
void fgPlatformInitialize( const char* displayName )
{
fgDisplay.pDisplay.display = wl_display_connect( NULL );
if( fgDisplay.pDisplay.display == NULL )
fgError( "failed to connect to a Wayland compositor" );
fgDisplay.pDisplay.registry = wl_display_get_registry(
fgDisplay.pDisplay.display );
wl_registry_add_listener( fgDisplay.pDisplay.registry,
&fghRegistryListener,
&fgDisplay.pDisplay );
wl_display_roundtrip( fgDisplay.pDisplay.display );
if( fgDisplay.pDisplay.compositor == NULL ||
fgDisplay.pDisplay.shell == NULL ||
fgDisplay.pDisplay.seat == NULL ||
fgDisplay.pDisplay.shm == NULL )
fgError( "failed to discover all needed compositor interfaces" );
fghInitialiseCursorTheme();
fghPlatformInitializeEGL();
/* Get start time */
fgState.Time = fgSystemTime();
fgState.Initialised = GL_TRUE;
atexit(fgDeinitialize);
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
fgPlatformInitialiseInputDevices();
}
void fgPlatformDeinitialiseInputDevices ( void )
{
fgPlatformCloseInputDevices();
fgState.InputDevsInitialised = GL_FALSE;
}
void fgPlatformCloseDisplay ( void )
{
wl_cursor_theme_destroy( fgDisplay.pDisplay.cursor_theme );
wl_shm_destroy( fgDisplay.pDisplay.shm );
wl_seat_destroy( fgDisplay.pDisplay.seat );
wl_shell_destroy( fgDisplay.pDisplay.shell );
wl_compositor_destroy( fgDisplay.pDisplay.compositor );
wl_registry_destroy( fgDisplay.pDisplay.registry );
wl_display_disconnect( fgDisplay.pDisplay.display );
}

View File

@ -0,0 +1,433 @@
/*
* fg_input_devices_wl.c
*
* Handles Wayland input devices : keyboard, pointer, touchscreen.
*
* Written by Manuel Bachmann <tarnyko@tarnyko.net> 2015
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Creation date: Thur Mar 19 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef __linux__
#include <linux/input.h>
#else
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
#define BTN_MIDDLE 0x112
#endif
#include <sys/mman.h>
#include <GL/freeglut.h>
#include "../fg_internal.h"
/*
* This function will effectively set the pointer (mouse) cursor
* depending on the GLUT_CURSOR_* choice.
*/
void fghPointerSetCursor( SFG_Window* window,
struct wl_pointer* pointer,
uint32_t serial )
{
struct wl_cursor_image* image;
struct wl_buffer* buffer;
image = window->Window.pContext.cursor->images[0];
buffer = wl_cursor_image_get_buffer( image );
wl_surface_attach( window->Window.pContext.cursor_surface, buffer,
0, 0 );
wl_surface_damage( window->Window.pContext.cursor_surface, 0, 0,
image->width, image->height );
wl_surface_commit( window->Window.pContext.cursor_surface );
wl_pointer_set_cursor( pointer, serial,
window->Window.pContext.cursor_surface,
image->hotspot_x, image->hotspot_y );
}
/*
* This function will interpret a keyboard keysym, and call the
* possible callbacks accordingly.
*/
void fghKeyboardInterpretKeysym( SFG_Window* window,
uint32_t key,
xkb_keysym_t sym,
uint32_t state )
{
FGCBKeyboard keyboard_cb;
FGCBSpecial special_cb;
char string[16];
int special = -1;
/* GLUT API tells us to have two separate callbacks, one for
* the ASCII translateable keypresses, and one for all the
* others, which need to be translated to GLUT_KEY_Xs... */
if( state )
{
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special ));
}
else
{
keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp ));
special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp ));
}
switch( sym )
{
case XKB_KEY_F1: special = GLUT_KEY_F1; break;
case XKB_KEY_F2: special = GLUT_KEY_F2; break;
case XKB_KEY_F3: special = GLUT_KEY_F3; break;
case XKB_KEY_F4: special = GLUT_KEY_F4; break;
case XKB_KEY_F5: special = GLUT_KEY_F5; break;
case XKB_KEY_F6: special = GLUT_KEY_F6; break;
case XKB_KEY_F7: special = GLUT_KEY_F7; break;
case XKB_KEY_F8: special = GLUT_KEY_F8; break;
case XKB_KEY_F9: special = GLUT_KEY_F9; break;
case XKB_KEY_F10: special = GLUT_KEY_F10; break;
case XKB_KEY_F11: special = GLUT_KEY_F11; break;
case XKB_KEY_F12: special = GLUT_KEY_F12; break;
case XKB_KEY_Left: special = GLUT_KEY_LEFT; break;
case XKB_KEY_Right: special = GLUT_KEY_RIGHT; break;
case XKB_KEY_Up: special = GLUT_KEY_UP; break;
case XKB_KEY_Down: special = GLUT_KEY_DOWN; break;
case XKB_KEY_Page_Up: special = GLUT_KEY_PAGE_UP; break;
case XKB_KEY_Page_Down: special = GLUT_KEY_PAGE_DOWN; break;
case XKB_KEY_Home: special = GLUT_KEY_HOME; break;
case XKB_KEY_End: special = GLUT_KEY_END; break;
case XKB_KEY_Insert: special = GLUT_KEY_INSERT; break;
case XKB_KEY_Num_Lock: special = GLUT_KEY_NUM_LOCK; break;
case XKB_KEY_Begin: special = GLUT_KEY_BEGIN; break;
case XKB_KEY_Delete: special = GLUT_KEY_DELETE; break;
case XKB_KEY_Shift_L: special = GLUT_KEY_SHIFT_L; break;
case XKB_KEY_Shift_R: special = GLUT_KEY_SHIFT_R; break;
case XKB_KEY_Control_L: special = GLUT_KEY_CTRL_L; break;
case XKB_KEY_Control_R: special = GLUT_KEY_CTRL_R; break;
case XKB_KEY_Alt_L: special = GLUT_KEY_ALT_L; break;
case XKB_KEY_Alt_R: special = GLUT_KEY_ALT_R; break;
}
if( special_cb && (special != -1) )
{
fgSetWindow( window );
special_cb( special, window->State.MouseX, window->State.MouseY );
}
else if( keyboard_cb && (special == -1) )
{
fgSetWindow( window );
xkb_keysym_to_utf8( sym, string, sizeof( string ) );
keyboard_cb( string[0], window->State.MouseX, window->State.MouseY );
}
}
/*
* Touchscreen section
* For now, let us pretend it is a mouse with only one button
*/
static void fghTouchDown( void* data, struct wl_touch* touch,
uint32_t serial, uint32_t time,
struct wl_surface* surface,
int32_t id,
wl_fixed_t x_w, wl_fixed_t y_w )
{
SFG_Window* win = fgStructure.CurrentWindow;
win->State.MouseX = wl_fixed_to_int( x_w );
win->State.MouseY = wl_fixed_to_int( y_w );
INVOKE_WCB( *win, Mouse, ( GLUT_LEFT_BUTTON,
GLUT_DOWN,
win->State.MouseX,
win->State.MouseY ) );
}
static void fghTouchUp( void* data, struct wl_touch* touch,
uint32_t serial, uint32_t time,
int32_t id )
{
SFG_Window* win = fgStructure.CurrentWindow;
INVOKE_WCB( *win, Mouse, ( GLUT_LEFT_BUTTON,
GLUT_UP,
win->State.MouseX,
win->State.MouseY ) );
}
static void fghTouchMotion( void* data, struct wl_touch* touch,
uint32_t time, int32_t id,
wl_fixed_t x_w, wl_fixed_t y_w )
{
SFG_Window* win = fgStructure.CurrentWindow;
win->State.MouseX = wl_fixed_to_int( x_w );
win->State.MouseY = wl_fixed_to_int( y_w );
INVOKE_WCB( *win, Motion, ( win->State.MouseX,
win->State.MouseY ) );
}
static void fghTouchFrame( void* data, struct wl_touch* touch )
{
}
static void fghTouchCancel( void* data, struct wl_touch* touch )
{
}
static const struct wl_touch_listener fghTouchListener =
{
fghTouchDown,
fghTouchUp,
fghTouchMotion,
fghTouchFrame,
fghTouchCancel
};
/*
* Pointer (mouse) section
*/
static void fghPointerEnter( void* data, struct wl_pointer* pointer,
uint32_t serial,
struct wl_surface* surface,
wl_fixed_t x_w, wl_fixed_t y_w )
{
SFG_Window* win = fgStructure.CurrentWindow;
fghPointerSetCursor( win, pointer, serial );
win->State.MouseX = wl_fixed_to_int( x_w );
win->State.MouseY = wl_fixed_to_int( y_w );
INVOKE_WCB( *win, Entry, ( GLUT_ENTERED ) );
}
static void fghPointerLeave( void* data, struct wl_pointer* pointer,
uint32_t serial,
struct wl_surface* surface )
{
SFG_Window* win = fgStructure.CurrentWindow;
INVOKE_WCB( *win, Entry, ( GLUT_LEFT ) );
}
static void fghPointerMotion( void* data, struct wl_pointer* pointer,
uint32_t time,
wl_fixed_t x_w, wl_fixed_t y_w )
{
SFG_Window* win = fgStructure.CurrentWindow;
win->State.MouseX = wl_fixed_to_int( x_w );
win->State.MouseY = wl_fixed_to_int( y_w );
if ( win->Window.pContext.pointer_button_pressed )
INVOKE_WCB( *win, Motion, ( win->State.MouseX,
win->State.MouseY ) );
else
INVOKE_WCB( *win, Passive, ( win->State.MouseX,
win->State.MouseY ) );
}
static void fghPointerButton( void* data, struct wl_pointer* pointer,
uint32_t serial, uint32_t time,
uint32_t button, uint32_t state )
{
SFG_Window* win = fgStructure.CurrentWindow;
int button_f;
switch( button )
{
case BTN_LEFT:
button_f = GLUT_LEFT_BUTTON;
break;
case BTN_RIGHT:
button_f = GLUT_RIGHT_BUTTON;
break;
case BTN_MIDDLE:
button_f = GLUT_MIDDLE_BUTTON;
break;
}
win->Window.pContext.pointer_button_pressed =
state ? GL_TRUE : GL_FALSE;
INVOKE_WCB( *win, Mouse, ( button_f,
state ? GLUT_DOWN : GLUT_UP ,
win->State.MouseX,
win->State.MouseY ) );
}
static void fghPointerAxis( void* data, struct wl_pointer* pointer,
uint32_t time, uint32_t axis,
wl_fixed_t value )
{
SFG_Window* win = fgStructure.CurrentWindow;
int direction = wl_fixed_to_int( value );
INVOKE_WCB( *win, MouseWheel, ( 0,
direction ,
win->State.MouseX,
win->State.MouseY ) );
}
static const struct wl_pointer_listener fghPointerListener =
{
fghPointerEnter,
fghPointerLeave,
fghPointerMotion,
fghPointerButton,
fghPointerAxis
};
/*
* Keyboard section
*/
static void fghKeyboardKeymap( void* data, struct wl_keyboard* keyboard,
uint32_t format, int fd, uint32_t size )
{
SFG_PlatformDisplay* pDisplay = data;
char* keymap_str;
struct xkb_keymap* keymap;
keymap_str = mmap( NULL, size, PROT_READ, MAP_SHARED, fd, 0 );
keymap = xkb_keymap_new_from_string( pDisplay->xkb_context,
keymap_str,
XKB_KEYMAP_FORMAT_TEXT_V1,
0 );
munmap( keymap_str, size );
if( pDisplay->xkb_state )
xkb_state_unref( pDisplay->xkb_state );
pDisplay->xkb_state = xkb_state_new( keymap );
}
static void fghKeyboardEnter( void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface,
struct wl_array* keys )
{
SFG_Window* win = fgStructure.CurrentWindow;
INVOKE_WCB( *win, Entry, ( GLUT_ENTERED ) );
}
static void fghKeyboardLeave( void* data, struct wl_keyboard* keyboard,
uint32_t serial, struct wl_surface* surface )
{
SFG_Window* win = fgStructure.CurrentWindow;
INVOKE_WCB( *win, Entry, ( GLUT_LEFT ) );
}
static void fghKeyboardKey( void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t time,
uint32_t key, uint32_t state )
{
SFG_PlatformDisplay* pDisplay = data;
SFG_Window* win = fgStructure.CurrentWindow;
const xkb_keysym_t* syms;
xkb_state_key_get_syms( pDisplay->xkb_state,
key + 8, &syms );
fghKeyboardInterpretKeysym( win, key, syms[0], state );
}
static void fghKeyboardModifiers( void* data, struct wl_keyboard* keyboard,
uint32_t serial, uint32_t mods_depr,
uint32_t mods_latch, uint32_t mods_lock,
uint32_t group )
{
}
static const struct wl_keyboard_listener fghKeyboardListener =
{
fghKeyboardKeymap,
fghKeyboardEnter,
fghKeyboardLeave,
fghKeyboardKey,
fghKeyboardModifiers
};
/*
* Discover potential input device(s) (keyboard, pointer, touch)
*/
static void fghSeatCapabilities( void* data,
struct wl_seat* seat,
enum wl_seat_capability capabilities )
{
SFG_PlatformDisplay* pDisplay = data;
if( capabilities & WL_SEAT_CAPABILITY_KEYBOARD )
{
pDisplay->xkb_context = xkb_context_new ( 0 );
pDisplay->keyboard = wl_seat_get_keyboard( seat );
wl_keyboard_add_listener( pDisplay->keyboard,
&fghKeyboardListener,
pDisplay );
}
if( capabilities & WL_SEAT_CAPABILITY_POINTER )
{
pDisplay->pointer = wl_seat_get_pointer( seat );
wl_pointer_add_listener( pDisplay->pointer,
&fghPointerListener,
pDisplay );
}
if( capabilities & WL_SEAT_CAPABILITY_TOUCH )
{
pDisplay->touch = wl_seat_get_touch( seat );
wl_touch_add_listener( pDisplay->touch,
&fghTouchListener,
pDisplay );
}
}
static const struct wl_seat_listener fghSeatListener =
{
fghSeatCapabilities
};
/*
* Try initializing the input device(s)
*/
void fgPlatformInitialiseInputDevices( void )
{
wl_seat_add_listener( fgDisplay.pDisplay.seat,
&fghSeatListener,
&fgDisplay.pDisplay );
wl_display_roundtrip( fgDisplay.pDisplay.display );
}
/*
* Try closing the input device(s)
*/
void fgPlatformCloseInputDevices( void )
{
if( fgDisplay.pDisplay.touch )
wl_touch_destroy( fgDisplay.pDisplay.touch );
if( fgDisplay.pDisplay.pointer )
wl_pointer_destroy( fgDisplay.pDisplay.pointer );
if( fgDisplay.pDisplay.keyboard )
wl_keyboard_destroy( fgDisplay.pDisplay.keyboard );
if( fgDisplay.pDisplay.xkb_state )
xkb_state_unref( fgDisplay.pDisplay.xkb_state );
if( fgDisplay.pDisplay.xkb_context )
xkb_context_unref( fgDisplay.pDisplay.xkb_context );
}
/*
* Wayland backend will not be implementing spaceball at all
*/
void fgPlatformInitializeSpaceball( void )
{
}
void fgPlatformSpaceballClose( void )
{
}
void fgPlatformSpaceballSetWindow( SFG_Window *window )
{
}
int fgPlatformHasSpaceball( void )
{
return 0;
}
int fgPlatformSpaceballNumButtons( void )
{
return 0;
}

View File

@ -0,0 +1,186 @@
/*
* fg_internal_wl.h
*
* The freeglut library private include file.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Tue Mar 17, 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef FREEGLUT_INTERNAL_WL_H
#define FREEGLUT_INTERNAL_WL_H
/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
#include "egl/fg_internal_egl.h"
#include <wayland-egl.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <xkbcommon/xkbcommon.h>
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
/* The structure used by display initialization in fg_init.c */
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
struct tagSFG_PlatformDisplay
{
struct tagSFG_PlatformDisplayEGL egl;
struct wl_display* display; /* The display we are being run in */
struct wl_registry* registry; /* The global interface registry */
struct wl_compositor* compositor; /* The compositor */
struct wl_shell* shell; /* The shell, AKA window manager */
struct wl_seat* seat; /* The seat, references input devices */
struct xkb_context* xkb_context; /* The global XKB keyboard context */
struct xkb_state* xkb_state; /* The current XKB keyboard state */
struct wl_keyboard* keyboard; /* The keyboard input device */
struct wl_pointer* pointer; /* The pointer input device (mouse) */
struct wl_touch* touch; /* The touchscreen input device */
struct wl_shm* shm; /* The software rendering engine */
struct wl_cursor_theme* cursor_theme; /* The pointer cursor theme */
};
/* The structure used by window creation in fg_window.c */
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
struct tagSFG_PlatformContext
{
struct tagSFG_PlatformContextEGL egl;
GLboolean pointer_button_pressed;
struct wl_surface* surface; /* The drawing surface */
struct wl_shell_surface* shsurface; /* The shell surface, has states */
struct wl_egl_window* egl_window; /* Binding between WL/EGL surfaces */
struct wl_cursor* cursor; /* The active cursor */
struct wl_surface* cursor_surface; /* The active cursor surface */
};
/* The window state description. This structure should be kept portable. */
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState
{
int OldWidth; /* Window width from before a resize */
int OldHeight; /* " height " " " " */
};
/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
/*
* Initial defines from "js.h" starting around line 33 with the existing "fg_joystick.c"
* interspersed
*/
# ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
# endif
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# endif
#include <errno.h>
#include <string.h>
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
/* XXX The below hack is done until freeglut's autoconf is updated. */
# define HAVE_USB_JS 1
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/joystick.h>
# else
/*
* XXX NetBSD/amd64 systems may find that they have to steal the
* XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
* XXX I cannot comment whether that works for the interface, but
* XXX it lets you compile...(^& I do not think that we can do away
* XXX with this header.
*/
# include <machine/joystick.h> /* For analog joysticks */
# endif
# define JS_DATA_TYPE joystick
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
# endif
# if defined(__linux__)
# include <linux/joystick.h>
/* check the joystick driver version */
# if defined(JS_VERSION) && JS_VERSION >= 0x010000
# define JS_NEW
# endif
# else /* Not BSD or Linux */
# ifndef JS_RETURN
/*
* We'll put these values in and that should
* allow the code to at least compile when there is
* no support. The JS open routine should error out
* and shut off all the code downstream anyway and if
* the application doesn't use a joystick we'll be fine.
*/
struct JS_DATA_TYPE
{
int buttons;
int x;
int y;
};
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
# endif
# endif
/* XXX It might be better to poll the operating system for the numbers of buttons and
* XXX axes and then dynamically allocate the arrays.
*/
# define _JS_MAX_AXES 16
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
struct tagSFG_PlatformJoystick
{
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
struct os_specific_s *os;
# endif
# ifdef JS_NEW
struct js_event js;
int tmp_buttons;
float tmp_axes [ _JS_MAX_AXES ];
# else
struct JS_DATA_TYPE js;
# endif
char fname [ 128 ];
int fd;
};
/* Menu font and color definitions */
#define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18
#define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
#define FREEGLUT_MENU_PEN_BACK_COLORS {0.70f, 0.70f, 0.70f, 1.0f}
#define FREEGLUT_MENU_PEN_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
#define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
#endif /* FREEGLUT_INTERNAL_WL_H */

View File

@ -0,0 +1,134 @@
/*
* fg_main_wl.c
*
* The Wayland-specific windows message processing methods.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Sun Mar 22 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/freeglut.h>
#include "../fg_internal.h"
#include <errno.h>
#include <poll.h>
void fgPlatformFullScreenToggle( SFG_Window *win );
void fgPlatformPositionWindow( SFG_Window *window, int x, int y );
void fgPlatformReshapeWindow( SFG_Window *window, int width, int height );
void fgPlatformPushWindow( SFG_Window *window );
void fgPlatformPopWindow( SFG_Window *window );
void fgPlatformHideWindow( SFG_Window *window );
void fgPlatformIconifyWindow( SFG_Window *window );
void fgPlatformShowWindow( SFG_Window *window );
fg_time_t fgPlatformSystemTime( void )
{
#ifdef CLOCK_MONOTONIC
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_nsec/1000000 + now.tv_sec*1000;
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval now;
gettimeofday( &now, NULL );
return now.tv_usec/1000 + now.tv_sec*1000;
#endif
}
void fgPlatformSleepForEvents( fg_time_t msec )
{
struct pollfd pfd;
int err;
pfd.fd = wl_display_get_fd( fgDisplay.pDisplay.display );
pfd.events = POLLIN | POLLERR | POLLHUP;
wl_display_dispatch_pending( fgDisplay.pDisplay.display );
if ( ! wl_display_flush( fgDisplay.pDisplay.display ) )
{
err = poll( &pfd, 1, msec );
if( ( -1 == err ) && ( errno != EINTR ) )
fgWarning ( "freeglut poll() error: %d", errno );
}
}
void fgPlatformProcessSingleEvent( void )
{
SFG_Window *win = fgStructure.CurrentWindow;
wl_display_dispatch_pending( fgDisplay.pDisplay.display );
INVOKE_WCB( *win, Display, ( ) );
}
void fgPlatformMainLoopPreliminaryWork( void )
{
/* Under Wayland, this is a no-op */
}
void fgPlatformInitWork( SFG_Window* window )
{
/* Under Wayland, all events happen relative to input handlers
* -> this is a no-op
*/
return;
}
void fgPlatformPosResZordWork( SFG_Window* window, unsigned int workMask )
{
if( workMask & GLUT_FULL_SCREEN_WORK )
fgPlatformFullScreenToggle( window );
if( workMask & GLUT_POSITION_WORK )
fgPlatformPositionWindow( window, window->State.DesiredXpos, window->State.DesiredYpos );
if( workMask & GLUT_SIZE_WORK )
fgPlatformReshapeWindow ( window, window->State.DesiredWidth, window->State.DesiredHeight );
if( workMask & GLUT_ZORDER_WORK )
{
if( window->State.DesiredZOrder < 0 )
fgPlatformPushWindow( window );
else
fgPlatformPopWindow( window );
}
}
void fgPlatformVisibilityWork( SFG_Window* window )
{
/* Visibility status of window gets updated in the window message handlers above
*/
SFG_Window *win = window;
switch (window->State.DesiredVisibility)
{
case DesireHiddenState:
fgPlatformHideWindow( window );
break;
case DesireIconicState:
/* Call on top-level window */
while (win->Parent)
win = win->Parent;
fgPlatformIconifyWindow( win );
break;
case DesireNormalState:
fgPlatformShowWindow( window );
break;
}
}

View File

@ -0,0 +1,150 @@
/*
* fg_state_wl.c
*
* Wayland-specific freeglut state query methods.
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Sun Mar 23 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/freeglut.h>
#include "fg_internal.h"
#include "egl/fg_state_egl.h"
int fgPlatformGlutDeviceGet ( GLenum eWhat )
{
switch( eWhat )
{
case GLUT_HAS_KEYBOARD:
if( fgDisplay.pDisplay.keyboard )
return 1;
else
return 0;
case GLUT_HAS_MOUSE:
/* we want the touchscreen to behave like a mouse,
* so let us pretend it is one.
*/
if( fgDisplay.pDisplay.pointer ||
fgDisplay.pDisplay.touch )
return 1;
else
return 0;
case GLUT_NUM_MOUSE_BUTTONS:
/* Wayland has no way of telling us how much buttons
* a mouse has, unless the actual event gets sent to
* the client. As we are only handling 3 buttons
* currently, return this fixed number for now.
*/
if( fgDisplay.pDisplay.pointer )
return 3;
/* touchscreen is considered as having one button */
else if( fgDisplay.pDisplay.touch )
return 1;
else
return 0;
default:
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
return -1;
}
}
int fgPlatformGlutGet ( GLenum eWhat )
{
switch( eWhat )
{
/*
* Those calls are pointless under Wayland, so inform the user
*/
case GLUT_WINDOW_X:
case GLUT_WINDOW_Y:
{
if( fgStructure.CurrentWindow == NULL )
{
return 0;
}
else
{
fgWarning( "glutGet(): GLUT_WINDOW_X/Y properties "
"unsupported under Wayland" );
return -1;
}
}
/*
* TODO : support this correctly once we will start drawing
* client-side decorations
*/
case GLUT_WINDOW_BORDER_WIDTH:
case GLUT_WINDOW_HEADER_HEIGHT:
{
if( fgStructure.CurrentWindow == NULL ||
fgStructure.CurrentWindow->Parent )
/* can't get widths/heights if no current window
* and child windows don't have borders */
return 0;
return 0;
}
case GLUT_WINDOW_WIDTH:
case GLUT_WINDOW_HEIGHT:
{
if( fgStructure.CurrentWindow == NULL )
return 0;
switch ( eWhat )
{
case GLUT_WINDOW_WIDTH:
return fgStructure.CurrentWindow->State.Width;
case GLUT_WINDOW_HEIGHT:
return fgStructure.CurrentWindow->State.Height;
}
}
/* Colormap size is handled in a bit different way than all the rest */
case GLUT_WINDOW_COLORMAP_SIZE:
{
if( fgStructure.CurrentWindow == NULL )
{
return 0;
}
else
{
int result = 0;
if ( ! eglGetConfigAttrib( fgDisplay.pDisplay.egl.Display,
fgStructure.CurrentWindow->Window.pContext.egl.Config,
EGL_BUFFER_SIZE, &result ) )
fgError( "eglGetConfigAttrib(EGL_BUFFER_SIZE) failed" );
return result;
}
}
default:
return fghPlatformGlutGetEGL( eWhat );
}
}

View File

@ -0,0 +1,40 @@
/*
* fg_structure_wl.c
*
* Windows and menus need tree structure for Wayland
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Tue Mar 17, 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <GL/freeglut.h>
#include "fg_internal.h"
#include "egl/fg_structure_egl.h"
extern SFG_Structure fgStructure;
void fgPlatformCreateWindow( SFG_Window *window )
{
fghPlatformCreateWindowEGL( window );
window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;
}

View File

@ -0,0 +1,310 @@
/*
* fg_window_wl.c
*
* Window management methods for Wayland
*
* Copyright (c) 2015 Manuel Bachmann. All Rights Reserved.
* Written by Manuel Bachmann, <tarnyko@tarnyko.net>
* Creation date: Tue Mar 17, 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* MANUEL BACHMANN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define FREEGLUT_BUILDING_LIB
#include <GL/freeglut.h>
#include "../fg_internal.h"
#include "egl/fg_window_egl.h"
#define fghCreateNewContext fghCreateNewContextEGL
extern void fghOnReshapeNotify( SFG_Window *window, int width, int height, GLboolean forceNotify );
void fgPlatformReshapeWindow( SFG_Window *window, int width, int height );
void fgPlatformIconifyWindow( SFG_Window *window );
static void fghShSurfacePing( void* data,
struct wl_shell_surface* shsurface,
uint32_t serial )
{
wl_shell_surface_pong( shsurface, serial );
}
static void fghShSurfaceConfigure( void* data,
struct wl_shell_surface* shsurface,
uint32_t edges,
int32_t width, int32_t height )
{
SFG_Window* window = data;
fgPlatformReshapeWindow( window, width, height );
}
static const struct wl_shell_surface_listener fghShSurfaceListener =
{
fghShSurfacePing,
fghShSurfaceConfigure,
NULL
};
static int fghToggleFullscreen(void)
{
SFG_Window* win = fgStructure.CurrentWindow;
if ( ! win->State.IsFullscreen )
{
win->State.pWState.OldWidth = win->State.Width;
win->State.pWState.OldHeight = win->State.Height;
wl_shell_surface_set_fullscreen( win->Window.pContext.shsurface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0, NULL );
}
else
{
fgPlatformReshapeWindow( win, win->State.pWState.OldWidth,
win->State.pWState.OldHeight );
wl_shell_surface_set_toplevel( win->Window.pContext.shsurface );
}
return 0;
}
void fgPlatformOpenWindow( SFG_Window* window, const char* title,
GLboolean positionUse, int x, int y,
GLboolean sizeUse, int w, int h,
GLboolean gameMode, GLboolean isSubWindow )
{
/* Save the display mode if we are creating a menu window */
if( window->IsMenu && ( ! fgStructure.MenuContext ) )
fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ;
fghChooseConfig( &window->Window.pContext.egl.Config );
if( ! window->Window.pContext.egl.Config )
{
/*
* The "fghChooseConfig" returned a null meaning that the visual
* context is not available.
* Try a couple of variations to see if they will work.
*/
if( fgState.DisplayMode & GLUT_MULTISAMPLE )
{
fgState.DisplayMode &= ~GLUT_MULTISAMPLE ;
fghChooseConfig( &window->Window.pContext.egl.Config );
fgState.DisplayMode |= GLUT_MULTISAMPLE;
}
}
FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.pContext.egl.Config != NULL,
"EGL configuration with necessary capabilities "
"not found", "fgOpenWindow" );
if( ! positionUse )
x = y = -1; /* default window position */
if( ! sizeUse )
w = h = 300; /* default window size */
/* Create the cursor */
window->Window.pContext.cursor = wl_cursor_theme_get_cursor(
fgDisplay.pDisplay.cursor_theme,
"left_ptr" );
window->Window.pContext.cursor_surface = wl_compositor_create_surface(
fgDisplay.pDisplay.compositor );
/* Create the main surface */
window->Window.pContext.surface = wl_compositor_create_surface(
fgDisplay.pDisplay.compositor );
/* Create the shell surface with respects to the parent/child tree */
window->Window.pContext.shsurface = wl_shell_get_shell_surface(
fgDisplay.pDisplay.shell,
window->Window.pContext.surface );
wl_shell_surface_add_listener( window->Window.pContext.shsurface,
&fghShSurfaceListener, window );
if( title)
wl_shell_surface_set_title( window->Window.pContext.shsurface, title );
if( gameMode )
{
window->State.IsFullscreen = GL_TRUE;
wl_shell_surface_set_fullscreen( window->Window.pContext.shsurface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
0, NULL );
}
else if( !isSubWindow && !window->IsMenu )
{
wl_shell_surface_set_toplevel( window->Window.pContext.shsurface );
}
else
{
wl_shell_surface_set_transient( window->Window.pContext.shsurface,
window->Parent->Window.pContext.surface,
x, y, 0 );
}
/* Create the Wl_EGL_Window */
window->Window.Context = fghCreateNewContext( window );
window->Window.pContext.egl_window = wl_egl_window_create(
window->Window.pContext.surface,
w, h);
window->Window.pContext.egl.Surface = eglCreateWindowSurface(
fgDisplay.pDisplay.egl.Display,
window->Window.pContext.egl.Config,
(EGLNativeWindowType)window->Window.pContext.egl_window,
NULL );
eglMakeCurrent( fgDisplay.pDisplay.egl.Display, window->Window.pContext.egl.Surface,
window->Window.pContext.egl.Surface, window->Window.Context );
window->Window.pContext.pointer_button_pressed = GL_FALSE;
}
/*
* Request a window resize
*/
void fgPlatformReshapeWindow( SFG_Window *window, int width, int height )
{
fghOnReshapeNotify(window, width, height, GL_FALSE);
if( window->Window.pContext.egl_window )
wl_egl_window_resize( window->Window.pContext.egl_window,
width, height, 0, 0 );
}
/*
* Closes a window, destroying the frame and OpenGL context
*/
void fgPlatformCloseWindow( SFG_Window* window )
{
fghPlatformCloseWindowEGL(window);
if ( window->Window.pContext.egl_window )
wl_egl_window_destroy( window->Window.pContext.egl_window );
if ( window->Window.pContext.shsurface )
wl_shell_surface_destroy( window->Window.pContext.shsurface );
if ( window->Window.pContext.surface )
wl_surface_destroy( window->Window.pContext.surface );
if ( window->Window.pContext.cursor_surface )
wl_surface_destroy( window->Window.pContext.cursor_surface );
}
/*
* This function re-creates the window assets if they
* have been destroyed
*/
void fgPlatformShowWindow( SFG_Window *window )
{
if ( ! window->Window.pContext.egl_window ||
! window->Window.pContext.shsurface ||
! window->Window.pContext.surface)
{
fgPlatformCloseWindow( window );
fgPlatformOpenWindow( window, "", /* TODO : save the title for further use */
GL_TRUE, window->State.Xpos, window->State.Ypos,
GL_TRUE, window->State.Width, window->State.Height,
(GLboolean)(window->State.IsFullscreen ? GL_TRUE : GL_FALSE),
(GLboolean)(window->Parent ? GL_TRUE : GL_FALSE) );
}
else
{
/* TODO : support this once we start using xdg-shell
*
* xdg_surface_present( window->Window.pContext.shsurface, 0 );
* INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
* window->State.Visible = GL_TRUE;
*/
fgWarning( "glutShownWindow(): function unsupported for an already existing"
" window under Wayland" );
}
}
/*
* This function hides the specified window
*/
void fgPlatformHideWindow( SFG_Window *window )
{
fgPlatformIconifyWindow( window );
}
/*
* Iconify the specified window (top-level windows only)
*/
void fgPlatformIconifyWindow( SFG_Window *window )
{
/* TODO : support this once we start using xdg-shell
*
* xdg_surface_set_minimized( window->Window.pContext.shsurface );
* INVOKE_WCB( *window, WindowStatus, ( GLUT_HIDDEN ) );
* window->State.Visible = GL_FALSE;
*/
fgWarning( "glutIconifyWindow(): function unsupported under Wayland" );
}
/*
* Set the current window's title
*/
void fgPlatformGlutSetWindowTitle( const char* title )
{
SFG_Window* win = fgStructure.CurrentWindow;
wl_shell_surface_set_title( win->Window.pContext.shsurface, title );
}
/*
* Set the current window's iconified title
*/
void fgPlatformGlutSetIconTitle( const char* title )
{
fgPlatformGlutSetWindowTitle( title );
}
/*
* Change the specified window's position
*/
void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
{
/* pointless under Wayland */
fgWarning( "glutPositionWindow(): function unsupported under Wayland" );
}
/*
* Lowers the specified window (by Z order change)
*/
void fgPlatformPushWindow( SFG_Window *window )
{
/* pointless under Wayland */
fgWarning( "glutPushWindow(): function unsupported under Wayland" );
}
/*
* Raises the specified window (by Z order change)
*/
void fgPlatformPopWindow( SFG_Window *window )
{
/* pointless under Wayland */
fgWarning( "glutPopWindow(): function unsupported under Wayland" );
}
/*
* Toggle the window's full screen state.
*/
void fgPlatformFullScreenToggle( SFG_Window *win )
{
if(fghToggleFullscreen() != -1) {
win->State.IsFullscreen = !win->State.IsFullscreen;
}
}

View File

@ -61,6 +61,7 @@ struct tag_cursorCacheEntry {
unsigned int cursorShape; /* an XC_foo value */
Cursor cachedCursor; /* None if the corresponding cursor has
not been created yet */
Display *dpy; /* display used to allocate this cursor */
};
/*
@ -68,26 +69,26 @@ struct tag_cursorCacheEntry {
* the "normal" GLUT_CURSOR_* values start a 0 and are consecutive.
*/
static cursorCacheEntry cursorCache[] = {
{ XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */
{ XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */
{ XC_hand1, None }, /* GLUT_CURSOR_INFO */
{ XC_pirate, None }, /* GLUT_CURSOR_DESTROY */
{ XC_question_arrow, None }, /* GLUT_CURSOR_HELP */
{ XC_exchange, None }, /* GLUT_CURSOR_CYCLE */
{ XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */
{ XC_watch, None }, /* GLUT_CURSOR_WAIT */
{ XC_xterm, None }, /* GLUT_CURSOR_TEXT */
{ XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */
{ XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */
{ XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */
{ XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */
{ XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */
{ XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */
{ XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */
{ XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */
{ XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
{ XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
{ XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
{ XC_arrow, None, 0 }, /* GLUT_CURSOR_RIGHT_ARROW */
{ XC_top_left_arrow, None, 0 }, /* GLUT_CURSOR_LEFT_ARROW */
{ XC_hand1, None, 0 }, /* GLUT_CURSOR_INFO */
{ XC_pirate, None, 0 }, /* GLUT_CURSOR_DESTROY */
{ XC_question_arrow, None, 0 }, /* GLUT_CURSOR_HELP */
{ XC_exchange, None, 0 }, /* GLUT_CURSOR_CYCLE */
{ XC_spraycan, None, 0 }, /* GLUT_CURSOR_SPRAY */
{ XC_watch, None, 0 }, /* GLUT_CURSOR_WAIT */
{ XC_xterm, None, 0 }, /* GLUT_CURSOR_TEXT */
{ XC_crosshair, None, 0 }, /* GLUT_CURSOR_CROSSHAIR */
{ XC_sb_v_double_arrow, None, 0 }, /* GLUT_CURSOR_UP_DOWN */
{ XC_sb_h_double_arrow, None, 0 }, /* GLUT_CURSOR_LEFT_RIGHT */
{ XC_top_side, None, 0 }, /* GLUT_CURSOR_TOP_SIDE */
{ XC_bottom_side, None, 0 }, /* GLUT_CURSOR_BOTTOM_SIDE */
{ XC_left_side, None, 0 }, /* GLUT_CURSOR_LEFT_SIDE */
{ XC_right_side, None, 0 }, /* GLUT_CURSOR_RIGHT_SIDE */
{ XC_top_left_corner, None, 0 }, /* GLUT_CURSOR_TOP_LEFT_CORNER */
{ XC_top_right_corner, None, 0 }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
{ XC_bottom_right_corner, None, 0 }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
{ XC_bottom_left_corner, None, 0 } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
};
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
@ -104,10 +105,18 @@ void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
if( ( cursorIDToUse >= 0 ) &&
( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) {
cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ];
if( entry->cachedCursor == None ) {
/* the second clause forces an invalidation of the cached cursor, if it was
* created through a different display connection.
* This can only happen, in the extremely rare case where the user program calls the
* freeglut extension glutLeaveMainLoop, and then re-initializes freeglut and
* starts over.
*/
if( entry->cachedCursor == None || entry->dpy != fgDisplay.pDisplay.Display ) {
entry->cachedCursor =
XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape );
}
entry->dpy = fgDisplay.pDisplay.Display;
}
cursor = entry->cachedCursor;
} else {
switch( cursorIDToUse )

View File

@ -40,6 +40,10 @@
#include "x11/fg_window_x11_glx.h"
#endif
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
/* Motif window hints, only define needed ones */
typedef struct
{

View File

@ -313,10 +313,14 @@ upper left hand corner of the outside of the window (the non-client
area) is at (x,y) and the size of the drawable (client) area is (w,h).
The coordinates taken by <tt>glutInitPosition</tt> and
<tt>glutPositionWindow</tt>, as well as the coordinates provided by
<i>FreeGLUT</i> when it calls the <tt>glutPositionFunc</tt> callback,
specify the top-left of the non-client area of the window.</li>
<i>freeglut</i> when it calls the <tt>glutPositionFunc</tt> callback,
specify the top-left of the non-client area of the window. By default
only positive-signed coordinates are supported. If GLUT_ALLOW_NEGATIVE_WINDOW_POSITION
is enabled, then negative coordinates are supported. An exception
for <tt>glutPositionWindow</tt> exists as it's always supported negative
window coordinates.</li>
<li>When you query the size and position of the window using
<tt>glutGet</tt>, <i>FreeGLUT</i> will return the size of the drawable
<tt>glutGet</tt>, <i>freeglut</i> will return the size of the drawable
area--the (w,h) that you specified when you created the window--and the
coordinates of the upper left hand corner of the drawable (client)
area--which is <u>NOT</u> the (x,y) position of the window you specified
@ -440,7 +444,7 @@ functions specify a desired position and size for windows that
<i>freeglut</i> will create in the future.
The position is measured in pixels from the upper left hand corner of the
screen, with "x" increasing to the right and "y" increasing towards the bottom
of the screen. The size is measured in pixels. <i>Freeglut</i>
of the screen. The size is measured in pixels. <i>Freeglut</i>
does not promise to follow these specifications in creating its windows,
but it certainly makes an attempt to.
</p>
@ -457,7 +461,14 @@ With <tt>glutGet</tt> information can be acquired about the current
window's size, position and decorations. Note however that according to
<a href="#Conventions">FreeGLUT's conventions</a>, the information
returned about the window coordinates does not correspond to the
coordinates used when setting window position.
coordinates used when setting window position. In addition, GLUT only
accepts positive window coordinates, and ignores all negative window
coordinates. But if GLUT_ALLOW_NEGATIVE_WINDOW_POSITION is enabled,
then negative window coordinates can be used. This is useful for
multi-montitor setups where the second monitor may be in the negative
desktop space of the primary monitor, as now the window can be placed
on the additional monitors. Furthermore, this flag also determines how
negative coordinates and sizes are interpreted for subwindows.
</p>
<p>
@ -479,6 +490,11 @@ the window will immediately snap out to this width, but the application can
call <tt>glutReshapeWindow</tt> and make a window narrower again.
</p>
<p>
If GLUT_ALLOW_NEGATIVE_WINDOW_POSITION is enabled, <tt>glutInitWindowPosition</tt>
will accept negative window coordinates.
</p>
<h2>4.3 glutInitDisplayMode</h2>
<h2>4.4 glutInitDisplayString</h2>
@ -634,9 +650,9 @@ will exit.
<p>
If the application has two nested calls to <tt>glutMainLoop</tt> and calls
<tt>glutLeaveMainLoop</tt>, the behaviour
of <i>freeglut</i> is undefined. It may leave only the inner nested
of <i>FreeGLUT</i> is undefined. It may leave only the inner nested
loop or it may leave both loops. If the reader has a strong preference
for one behaviour over the other he should contact the <i>freeglut</i> Programming
for one behaviour over the other he should contact the <i>FreeGLUT</i> Programming
Consortium and ask for the code to be fixed.
</p>
@ -650,6 +666,44 @@ Consortium and ask for the code to be fixed.
<h2>6.2 glutCreateSubwindow</h2>
<p>
The <tt>glutCreateSubwindow</tt> function creates a subwindow of an existing window.
</p>
<p><b>Usage</b></p>
<p>
<tt>int glutCreateSubwindow(int window, int x, int y, int width, int height);</tt>
</p>
<p><b>Description</b></p>
<p>
Creates a subwindow of <i>window</i> that is at location <i>x</i> and <i>y</i>
relative to the window's upper-left corner, and is of the specified <i>width</i> and <i>height</i>. The newly created
window ID is returned by <tt>glutCreateSubwindow</tt>. By default, the position coordinates will only allow windows within the bounds of the parent.
Negative coordinates be treated as coordinates from the opposite edge for a given axis. In addition, the width of the window will be taken into account.
For example, if the parent window is 100 pixels wide, and the <i>x</i> is 10, and <i>width</i> is 20, the subwindow will be located at <tt>x = 10</tt>.
If <i>x</i> is -10, then the subwindow will be located at 70 <tt>(parent - abs(pos) - dim)</tt>. If the <i>width</i> or <i>height</i> are negative, then the dimension is taken as a
subtraction of the parent dimension. For example, if the parent window is 100 pixels wide, and the <i>x</i> is 10, and <i>width</i> is 20, the
subwindow will have a size of 20. If <i>width</i> is -20, then the subwindow will have a width of 70 <tt>(parent - pos - abs(dim))</tt>.
</p>
<p>
If GLUT_ALLOW_NEGATIVE_WINDOW_POSITION is enabled, the window behavior differs. Negative window coordinates are now accepted and may result in windows outside
of the viewing area, depending on the platform of operation. Negative <i>width</i> and <i>height</i> are still used as a subtraction of the parent window dimension,
but they do not take <i>x</i> or <i>y</i> into account. For example, if the parent window is 100 pixels wide, and the <i>x</i> is 10, and <i>width</i> is 20, the
subwindow will be located at <tt>x = 10</tt>. If <i>x</i> is -10, then the subwindow will be located at <tt>x = -10</tt>. If the parent window is 100 pixels wide,
and the <i>x</i> is 10, and <i>width</i> is 20, the subwindow will have a size of 20. If <i>width</i> is -20, then the subwindow will have a width of 80 <tt>(parent - abs(dim))</tt>.
</p>
<p><b>Changes From GLUT</b></p>
<p>
GLUT does not support negative <i>x</i> or <i>y</i>. Nor does it have GLUT_ALLOW_NEGATIVE_WINDOW_POSITION
which changes the the functionality of <tt>glutCreateSubwindow</tt>.
</p>
<h2>6.3 glutDestroyWindow</h2>
<h2>6.4 glutSetWindow, glutGetWindow</h2>
@ -1528,6 +1582,8 @@ href="#GeometricObject"><i>FreeGLUT</i>'s geometric object rendering
functions</a> also visualize the object's normals or not.</li>
<li>GLUT_STROKE_FONT_DRAW_JOIN_DOTS - Set whether join dots are drawn
between line segments when drawing letters of stroke fonts or not.</li>
<li>GLUT_ALLOW_NEGATIVE_WINDOW_POSITION - Set if negative positions can be
used for window coordinates.</li>
</ul>
</p>
@ -1606,6 +1662,7 @@ glutInitDisplayMode or glutSetOption(GLUT_INIT_DISPLAY_MODE, value)</li>
<li>GLUT_VERSION - Return value will be X*10000+Y*100+Z where X is the
major version, Y is the minor version and Z is the patch level.
This query is only supported in <i>freeglut</i> (version 2.0.0 or later).</li>
<li>GLUT_ALLOW_NEGATIVE_WINDOW_POSITION - 1 if negative window positions are enabled, 0 otherwise</li>
</ul>
<h2>13.3 glutDeviceGet</h2>

View File

@ -16,27 +16,56 @@ generateHeader($_SERVER['PHP_SELF']);
<p></p>
<div class="textheader">What?</div>
<p>FreeGLUT is a completely OpenSourced alternative to the OpenGL Utility Toolkit (GLUT) library. GLUT was originally written by Mark Kilgard to support the sample programs in the second edition OpenGL 'RedBook'. Since then, GLUT has been used in a wide variety of practical applications because it is simple, widely available and highly portable.</p>
<p>GLUT (and hence FreeGLUT) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions.</p>
<p>FreeGLUT is a free-software/open-source alternative to the OpenGL Utility
Toolkit (GLUT) library. GLUT was originally written by Mark Kilgard to support
the sample programs in the second edition OpenGL 'RedBook'. Since then, GLUT has
been used in a wide variety of practical applications because it is simple,
widely available and highly portable.</p>
<p>GLUT (and hence FreeGLUT) takes care of all the system-specific chores
required for creating windows, initializing OpenGL contexts, and handling input
events, to allow for trully portable OpenGL programs.</p>
<p>FreeGLUT is released under the X-Consortium license.</p>
<div class="textheader">Why?</div>
<p>The original GLUT library seems to have been abandoned with the most recent version (3.7) dating back to August 1998. Its license does not allow anyone to distribute modified library code. This would be OK, if not for the fact that GLUT is getting old and really needs improvement. Also, GLUT's license is incompatible with some software distributions (e.g., XFree86).</p>
<p>The original GLUT library seems to have been abandoned with the most recent
version (3.7) dating back to August 1998. Its license does not allow anyone to
distribute modified library code. This is really unfortunate, since GLUT is
getting old and really needs improvement. Also, GLUT's license is incompatible
with some software distributions (e.g., XFree86).</p>
<div class="textheader">Who?</div>
<p>FreeGLUT was originally written by Pawel W. Olszta with contributions from Andreas Umbach and Steve Baker. Steve is now the official owner/maintainer of FreeGLUT.</p>
<p>FreeGLUT was originally written by Pawel W. Olszta with contributions from
Andreas Umbach and Steve Baker.</p>
<p>John F. Fay, John Tsiombikas, and Diederick C. Niehorster are the current
maintainers of the FreeGLUT project.</p>
<div class="textheader">When?</div>
<p>Pawel started FreeGLUT development on December 1st, 1999. The project is now virtually a 100% replacement for the original GLUT with only a few departures (such as the abandonment of SGI-specific features such as the Dials&amp;Buttons box and Dynamic Video Resolution) and a shrinking set of bugs.</p>
<p>There are some additional features such as a larger set of predefined shapes for use in applications.</p>
<p>Pawel started FreeGLUT development on December 1st, 1999. The project is now
virtually a 100% replacement for the original GLUT with only a few departures
(such as the abandonment of SGI-specific features such as the Dials&amp;Buttons
box and Dynamic Video Resolution) and a shrinking set of bugs.</p>
<p>FreeGLUT adds some additional features over the basic GLUT functionality,
such as a larger set of predefined objects to use, the ability to run single
iterations of the event loop, or exit from it gracefully, mousewheel input
callbacks, optional OpenGL core/compatibility profile context creation,
multitouch/multi-pointer input, and support for a larger and growing set of
platforms, being just some of them.</p>
<div class="textheader"><a name="download"></a>Help out!</div>
<p>FreeGLUT 3.0 is in active development, and will feature ports to
Android and BlackBerry 10 as well as a host of other enhancements. We are looking
for developers to help out with further work on the Android and BlackBerry 10
ports. Furthermore, ports to Cocoa/Carbon on OSX, and maybe even Wayland
are planned, along with some enhancements to the API and implementation.
See <a href="progress.php">here</a> for an overview of the major points
<p>We are looking for developers to help out with further work on the Android
and BlackBerry 10 ports. Furthermore, ports to Cocoa on OSX, and maybe even
Wayland are planned, along with some enhancements to the API and implementation.</p>
<p>See <a href="progress.php">here</a> for an overview of the major points
on our todo list. You can easily help out by forking the unofficial clone
of our <a
href="https://sourceforge.net/p/freeglut/code/HEAD/tree/">sourceforge.net
@ -54,34 +83,21 @@ mailing list.</p>
<div class="indent">
<div class="textheader">Testing Releases</div>
<p>Version 3.0.0, Release Candidate 1 was released on Wednesday,
October 29, 2014.</p>
<p>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-3.0.0-rc1.tar.gz?download">Freeglut 3.0.0 Release Candidate 1</a> [<i>Released: 29 Oct 2014</i>]<br/>
</p>
<p>Amongst many smaller enhancements and bugfixes, this RC includes
experimental ports to Android and BlackBerry 10 as well as other API
and implementation enhancements (e.g., move to CMake build system,
VBO and shader support for geometry). Also moved to CMake as build
system. Please try it out and give us feedback on how it worked for
you.
<!--
Feel free to test by downloading a <a
<p>Feel free to test by downloading a <a
href="https://sourceforge.net/p/freeglut/code/HEAD/tarball?path=/trunk/freeglut/freeglut">tarball
of current trunk</a>, or <a href="help.php#svn">grabbing a copy from
svn</a>, and give us feedback on how it worked for you. All this
will eventually become a FreeGLUT 3.0 release.</p>
<p>There are no presently active testing releases.
</p>
-->
will eventually become a FreeGLUT 3.1 release.</p>
<p>There are no presently active testing releases.</p>
</div>
<div class="indent">
<div class="textheader">Stable Releases</div>
<p>
<div class="textheader">Stable Releases</div>
<p>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-3.0.0.tar.gz?download">Freeglut 3.0.0</a> [<i>Released: 7 March 2015</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.8.1.tar.gz?download">Freeglut 2.8.1</a> [<i>Released: 5 April 2013</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.8.0.tar.gz?download">Freeglut 2.8.0</a> [<i>Released: 2 January 2012</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.8.0.tar.gz?download">Freeglut 2.8.0</a> [<i>Released: 2 January 2012</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.6.0.tar.gz?download">Freeglut 2.6.0</a> [<i>Released: 27 November 2009</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.4.0.tar.gz?download">Freeglut 2.4.0</a> [<i>Released: 9 June 2005</i>]<br/>
<a href="http://prdownloads.sourceforge.net/freeglut/freeglut-2.2.0.tar.gz?download">Freeglut 2.2.0</a> [<i>Released: 12 December 2003</i>]<br/>
@ -89,7 +105,13 @@ mailing list.</p>
</p>
<div class="textheader">Prepackaged Releases</div>
<p>The FreeGLUT project does not support packaged versions of FreeGLUT excepting, of course, the tarballs distributed here. However, various members of the community have put time and effort into providing source or binary rollups, and we thank them for their efforts. Here's a list which is likely incomplete:</p>
<p>The FreeGLUT project does not support packaged versions of FreeGLUT
excepting, of course, the tarballs distributed here. However, various members of
the community have put time and effort into providing source or binary rollups,
and we thank them for their efforts. Here's a list which is likely
incomplete:</p>
<!--
<p>
Andy Piper's <a href="http://jumpgate.homelinux.net/random/freeglut-fedora/">RedHat Fedora RPMs</a><br/>
@ -121,7 +143,10 @@ mailing list.</p>
<li><a href="mailto:freeglut-bugs@lists.sourceforge.net">freeglut-bugs</a> [<a href="http://lists.sourceforge.net/lists/listinfo/freeglut-bugs">Subscribe</a>]</li>
</ul>
<p>Please note that <a href="http://sourceforge.net/p/freeglut/mailman/?source=navbar">you must subscribe before you can post</a> to our mailing lists. Sorry for the inconvenience.</p>
<p>Please note that <a
href="http://sourceforge.net/p/freeglut/mailman/?source=navbar">you must
subscribe before you can post</a> to our mailing lists. Sorry for the
inconvenience.</p>
<?php generateFooter(); ?>

View File

@ -8,7 +8,7 @@ setPageTitle("A Look At Progress");
generateHeader($_SERVER['PHP_SELF']);
?>
<div class="textheader">FreeGLUT 3.0</div>
<div class="textheader">FreeGLUT 3.0 an onwards</div>
<p>
Major work, its status and planned milestone. <a
href="help.php">Help</a> on any of these plans is very welcome! Fork the
@ -26,9 +26,17 @@ points</a></td><td>Basic functionality as is now done: 3.0. Future
enhancements: 3.0 or later.</td></tr>
<tr><td>BlackBerry 10 port</td><td>Basic but complete functionality
by <a href="https://github.com/rcmaniac25">Vinnie Simonetti</a>.</td><td>Basic functionality as is now done: 3.0. Future
by <a href="https://github.com/rcmaniac25">Vinnie
Simonetti</a>.</td><td>Basic functionality as is now done: 3.0. Future
enhancements: 3.0 or later.</td></tr>
<tr><td>callbacks with closures</td><td>Have versions of each callback
that take an additional void* that is passed back to the user upon
invocation.</td><td>3.2</td></tr>
<tr><td>Windows 8 touch support</td><td>Windows 8 replaced how touch
input works, so we need to implement support for that.</td><td>3.2</td></tr>
<tr><td>10bit display formats</td><td>GLUT supports that but FreeGLUT
currently does not. Unfinished effort to implement <a
href="https://github.com/dcnieho/FreeGLUT/tree/feature_30bit_framebuffer">here</a>.</td><td>3.0
@ -38,6 +46,29 @@ or later.</td></tr>
cube, cone, etc, as well as the teapot and other parts of the
teaset)</td><td>3.0</td></tr>
<tr><td>handling non-western script input to windows</td><td>For
Windows, see associated <a
href="https://github.com/dcnieho/FreeGLUT/tree/feature_IMECHAR_callback">github
branch</a>. What can be done on the Linux side?</td><td>Figure this out
for 3.2</td></tr>
<tr><td>option to not deinitialize when mainloop terminates</td><td>As
is often requested, in some usage cases, it would be advantageous if
FreeGLUT did not automatically deinitialize when its last window is
closed. This has been implemented, but is awaiting testing on platforms
other than windows. Discussed <a
href="http://sourceforge.net/p/freeglut/mailman/message/32926301/">here</a>.</td><td>As
it has potential complications on mobile platforms, it was decided to
leave this feature until after 3.0.</td></tr>
<tr><td>High-DPI awareness.</td><td>As discussed <a
href="http://sourceforge.net/p/freeglut/mailman/message/30859054/">here</a>,
it is unclear what should be done. See also associated <a
href="https://github.com/dcnieho/FreeGLUT/tree/feature_DPI_awareness">github
branch</a>, though in the end maybe no code has to be added to FreeGLUT
for this at all, its the host program's responsibility to decide on DPI
awareness for his work.</td><td>Figure this out for 3.2</td></tr>
<tr><td>GL2+ and GLES 1/2 clean API for fonts and menus</td><td>For
stroke fonts, we can use a similar approach as for the shapes, should
thus be straightforward. For the bitmap fonts, this is more complex.
@ -47,17 +78,14 @@ href="http://nuclear.mutantstargoat.com/sw/libdrawtext/">libdrawtext
library</a></td><td>The sooner the better, but will have to wait for
asap after 3.0.</td></tr>
<tr><td>At runtime loading of OpenGL, OpenGL ES1 or OpenGL ES2 libraries,
<tr><td>At runtime loading of OpenGL or OpenGL ES libraries,
like SDL.</td><td>Currently CMake variables define at compile time which
of these three the library will be compiled against. No work has been
done on moving this to an at-runtime API.</td><td>Having this in 3.0
would be nice, but not essential.</td></tr>
of the two the library will be compiled against. No work has been
done to move this to an at-runtime API.</td><td>After 3.0</td></tr>
<tr><td>Code reorganized such that platform-specific and display
server-specific code are decoupled</td><td>Done, thanks John Fay! This
already led to a port to Android and support for GLES 1/2 on X11
(thanks Sylvain for both!), and paves the way for implementing native
OSX and Wayland support</td><td>3.0</td></tr>
server-specific code are decoupled</td><td>Done, thanks John
Fay!</td><td>3.0</td></tr>
<tr><td>Position callback</td><td>Done: we now have a position callback
to notify the client when the position of the window

View File

@ -92,10 +92,6 @@ function generateSideBar($current_page)
<a href="http://sourceforge.net/">
<img src="http://sourceforge.net/sflogo.php?group_id=1032" width="88" height="31" alt="SourceForge" style="border: 0;" /></a>
</span>
<span class="navbar-header">
<a href="http://freshmeat.net/">
<img src="/images/freshmeat.png" width="88" height="31" alt="SourceForge" style="border: 0;" /></a>
</span>
<span class="navbar-header">
<a href="http://validator.w3.org/check/referer">
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" style="border: 0;"/></a>

21
freeglut/web-src/upload Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
if [ -n "$1" ]; then
user=$1
else
# read the username out of .sfuser
if [ -f .sfuser ]; then
user=$(cat .sfuser)
else
user=$USER
fi
if [ -z "$user" ]; then
echo "please pass your sourceforge username as argument, or create a .sfuser file" >&2
exit 1
fi
fi
echo "connecting as user: $user ..."
rsync -vr --exclude='.sfuser' --exclude '*.swp' \
--rsh="ssh -l $user" * $user,freeglut@web.sourceforge.net:htdocs/