Setting the line endings and keywords on a bunch of new text files

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1076 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2012-02-08 02:39:29 +00:00
parent b40d212cfb
commit 3eca89fc14
63 changed files with 28898 additions and 28897 deletions

125
.gitattributes vendored
View File

@ -1,18 +1,18 @@
* text=auto !eol * text=auto !eol
freeglut/freeglut/AUTHORS svn_keywords=Author+Date+Id+Revision freeglut/freeglut/AUTHORS svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/CMakeLists.txt -text freeglut/freeglut/CMakeLists.txt svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/COPYING 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/ChangeLog svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/FrequentlyAskedQuestions -text freeglut/freeglut/FrequentlyAskedQuestions -text
freeglut/freeglut/LISEZMOI.cygwin_mingw -text freeglut/freeglut/LISEZMOI.cygwin_mingw svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/LISEZ_MOI svn_keywords=Author+Date+Id+Revision freeglut/freeglut/LISEZ_MOI svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/Makefile.am svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/Makefile.wat -text freeglut/freeglut/Makefile.wat svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/NEWS 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 svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.cygwin_mingw -text freeglut/freeglut/README.cygwin_mingw svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.mac -text freeglut/freeglut/README.mac -text
freeglut/freeglut/README.mingw_cross -text freeglut/freeglut/README.mingw_cross svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/README.win32 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/TODO svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/VisualStudio/2008/CallbackMaker/CallbackMaker.vcproj -text freeglut/freeglut/VisualStudio/2008/CallbackMaker/CallbackMaker.vcproj -text
@ -48,7 +48,7 @@ freeglut/freeglut/VisualStudio/2010/smooth_opengl3/smooth_opengl3.vcxproj.filter
freeglut/freeglut/VisualStudio/2010/subwin/subwin.vcxproj -text freeglut/freeglut/VisualStudio/2010/subwin/subwin.vcxproj -text
freeglut/freeglut/VisualStudio/2010/subwin/subwin.vcxproj.filters -text freeglut/freeglut/VisualStudio/2010/subwin/subwin.vcxproj.filters -text
freeglut/freeglut/autogen.sh svn_keywords=Author+Date+Id+Revision freeglut/freeglut/autogen.sh svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/config.h.in -text freeglut/freeglut/config.h.in svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/configure.ac svn_keywords=Author+Date+Id+Revision freeglut/freeglut/configure.ac svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/doc/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/doc/Makefile.am svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/doc/download.html svn_keywords=Author+Date+Id+Revision freeglut/freeglut/doc/download.html svn_keywords=Author+Date+Id+Revision
@ -125,65 +125,66 @@ freeglut/freeglut/progs/demos/subwin/Makefile.am -text
freeglut/freeglut/progs/demos/subwin/subwin.c -text freeglut/freeglut/progs/demos/subwin/subwin.c -text
freeglut/freeglut/progs/demos/subwin/subwin.dsp -text freeglut/freeglut/progs/demos/subwin/subwin.dsp -text
freeglut/freeglut/progs/demos/subwin/subwinStatic.dsp -text freeglut/freeglut/progs/demos/subwin/subwinStatic.dsp -text
freeglut/freeglut/src/Common/freeglut_callbacks.c -text freeglut/freeglut/src/Common/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_cursor.c -text freeglut/freeglut/src/Common/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_display.c -text freeglut/freeglut/src/Common/freeglut_display.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_ext.c -text freeglut/freeglut/src/Common/freeglut_ext.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_font.c -text freeglut/freeglut/src/Common/freeglut_font.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_font_data.c -text freeglut/freeglut/src/Common/freeglut_font_data.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_gamemode.c -text freeglut/freeglut/src/Common/freeglut_gamemode.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_geometry.c -text freeglut/freeglut/src/Common/freeglut_geometry.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_init.c -text freeglut/freeglut/src/Common/freeglut_init.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_input_devices.c -text freeglut/freeglut/src/Common/freeglut_input_devices.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_internal.h -text freeglut/freeglut/src/Common/freeglut_internal.h svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_joystick.c -text freeglut/freeglut/src/Common/freeglut_joystick.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_main.c -text freeglut/freeglut/src/Common/freeglut_main.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_menu.c -text freeglut/freeglut/src/Common/freeglut_menu.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_misc.c -text freeglut/freeglut/src/Common/freeglut_misc.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_overlay.c -text freeglut/freeglut/src/Common/freeglut_overlay.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_spaceball.c -text freeglut/freeglut/src/Common/freeglut_spaceball.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_state.c -text freeglut/freeglut/src/Common/freeglut_state.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_stroke_mono_roman.c -text freeglut/freeglut/src/Common/freeglut_stroke_mono_roman.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_stroke_roman.c -text freeglut/freeglut/src/Common/freeglut_stroke_roman.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_structure.c -text freeglut/freeglut/src/Common/freeglut_structure.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_teapot.c -text freeglut/freeglut/src/Common/freeglut_teapot.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_teapot_data.h -text freeglut/freeglut/src/Common/freeglut_teapot_data.h svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_videoresize.c -text freeglut/freeglut/src/Common/freeglut_videoresize.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglut_window.c -text freeglut/freeglut/src/Common/freeglut_window.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Common/freeglutdll.def -text freeglut/freeglut/src/Common/freeglutdll.def svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/Makefile.am svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_cursor_mswin.c -text freeglut/freeglut/src/mswin/freeglut_cursor_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_display_mswin.c -text freeglut/freeglut/src/mswin/freeglut_display_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_ext_mswin.c -text freeglut/freeglut/src/mswin/freeglut_ext_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_gamemode_mswin.c -text freeglut/freeglut/src/mswin/freeglut_gamemode_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_init_mswin.c -text freeglut/freeglut/src/mswin/freeglut_init_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_input_devices_mswin.c -text freeglut/freeglut/src/mswin/freeglut_input_devices_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_internal_mswin.h -text freeglut/freeglut/src/mswin/freeglut_internal_mswin.h svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c -text freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_main_mswin.c -text freeglut/freeglut/src/mswin/freeglut_main_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_menu_mswin.c -text freeglut/freeglut/src/mswin/freeglut_menu_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_spaceball_mswin.c -text freeglut/freeglut/src/mswin/freeglut_spaceball_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_state_mswin.c -text freeglut/freeglut/src/mswin/freeglut_state_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_structure_mswin.c -text freeglut/freeglut/src/mswin/freeglut_structure_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/mswin/freeglut_window_mswin.c -text freeglut/freeglut/src/mswin/freeglut_window_mswin.c svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/templates/cpp_template svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/templates/cpp_template svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/templates/header_template svn_keywords=Author+Date+Id+Revision freeglut/freeglut/src/templates/header_template svn_keywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_cursor_x11.c -text freeglut/freeglut/src/x11 svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_display_x11.c -text freeglut/freeglut/src/x11/freeglut_cursor_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_ext_x11.c -text freeglut/freeglut/src/x11/freeglut_display_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_gamemode_x11.c -text freeglut/freeglut/src/x11/freeglut_ext_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_glutfont_definitions_x11.c -text freeglut/freeglut/src/x11/freeglut_gamemode_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_init_x11.c -text freeglut/freeglut/src/x11/freeglut_glutfont_definitions_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_input_devices_x11.c -text freeglut/freeglut/src/x11/freeglut_init_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_internal_x11.h -text freeglut/freeglut/src/x11/freeglut_input_devices_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_joystick_x11.c -text freeglut/freeglut/src/x11/freeglut_internal_x11.h svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_main_x11.c -text freeglut/freeglut/src/x11/freeglut_joystick_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_menu_x11.c -text freeglut/freeglut/src/x11/freeglut_main_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_spaceball_x11.c -text freeglut/freeglut/src/x11/freeglut_menu_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_state_x11.c -text freeglut/freeglut/src/x11/freeglut_spaceball_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_structure_x11.c -text freeglut/freeglut/src/x11/freeglut_state_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_window_x11.c -text freeglut/freeglut/src/x11/freeglut_structure_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_xinput_x11.c -text freeglut/freeglut/src/x11/freeglut_window_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/freeglut/src/x11/freeglut_xinput_x11.c -text svnc_svn_005fkeywords=Author+Date+Id+Revision
freeglut/web-src/basic_page.php svn_keywords=Author+Date+Id+Revision freeglut/web-src/basic_page.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/docs/api.php svn_keywords=Author+Date+Id+Revision freeglut/web-src/docs/api.php svn_keywords=Author+Date+Id+Revision
freeglut/web-src/docs/install.php svn_keywords=Author+Date+Id+Revision freeglut/web-src/docs/install.php svn_keywords=Author+Date+Id+Revision

View File

@ -1,194 +1,194 @@
PROJECT(freeglut) PROJECT(freeglut)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(FREEGLUT_HEADERS SET(FREEGLUT_HEADERS
include/GL/freeglut.h include/GL/freeglut.h
include/GL/freeglut_ext.h include/GL/freeglut_ext.h
include/GL/freeglut_std.h include/GL/freeglut_std.h
include/GL/glut.h include/GL/glut.h
) )
SET(FREEGLUT_SRCS SET(FREEGLUT_SRCS
${FREEGLUT_HEADERS} ${FREEGLUT_HEADERS}
src/Common/freeglut_callbacks.c src/Common/freeglut_callbacks.c
src/Common/freeglut_cursor.c src/Common/freeglut_cursor.c
src/Common/freeglut_display.c src/Common/freeglut_display.c
src/Common/freeglut_ext.c src/Common/freeglut_ext.c
src/Common/freeglut_font.c src/Common/freeglut_font.c
src/Common/freeglut_font_data.c src/Common/freeglut_font_data.c
src/Common/freeglut_gamemode.c src/Common/freeglut_gamemode.c
src/Common/freeglut_geometry.c src/Common/freeglut_geometry.c
src/Common/freeglut_init.c src/Common/freeglut_init.c
src/Common/freeglut_internal.h src/Common/freeglut_internal.h
src/Common/freeglut_input_devices.c src/Common/freeglut_input_devices.c
src/Common/freeglut_joystick.c src/Common/freeglut_joystick.c
src/Common/freeglut_main.c src/Common/freeglut_main.c
src/Common/freeglut_menu.c src/Common/freeglut_menu.c
src/Common/freeglut_misc.c src/Common/freeglut_misc.c
src/Common/freeglut_overlay.c src/Common/freeglut_overlay.c
src/Common/freeglut_spaceball.c src/Common/freeglut_spaceball.c
src/Common/freeglut_state.c src/Common/freeglut_state.c
src/Common/freeglut_stroke_mono_roman.c src/Common/freeglut_stroke_mono_roman.c
src/Common/freeglut_stroke_roman.c src/Common/freeglut_stroke_roman.c
src/Common/freeglut_structure.c src/Common/freeglut_structure.c
src/Common/freeglut_teapot.c src/Common/freeglut_teapot.c
src/Common/freeglut_videoresize.c src/Common/freeglut_videoresize.c
src/Common/freeglut_window.c src/Common/freeglut_window.c
) )
IF(WIN32) IF(WIN32)
LIST(APPEND FREEGLUT_SRCS LIST(APPEND FREEGLUT_SRCS
src/mswin/freeglut_cursor_mswin.c src/mswin/freeglut_cursor_mswin.c
src/mswin/freeglut_display_mswin.c src/mswin/freeglut_display_mswin.c
src/mswin/freeglut_ext_mswin.c src/mswin/freeglut_ext_mswin.c
src/mswin/freeglut_gamemode_mswin.c src/mswin/freeglut_gamemode_mswin.c
src/mswin/freeglut_init_mswin.c src/mswin/freeglut_init_mswin.c
src/mswin/freeglut_internal_mswin.h src/mswin/freeglut_internal_mswin.h
src/mswin/freeglut_input_devices_mswin.c src/mswin/freeglut_input_devices_mswin.c
src/mswin/freeglut_joystick_mswin.c src/mswin/freeglut_joystick_mswin.c
src/mswin/freeglut_main_mswin.c src/mswin/freeglut_main_mswin.c
src/mswin/freeglut_menu_mswin.c src/mswin/freeglut_menu_mswin.c
src/mswin/freeglut_spaceball_mswin.c src/mswin/freeglut_spaceball_mswin.c
src/mswin/freeglut_state_mswin.c src/mswin/freeglut_state_mswin.c
src/mswin/freeglut_structure_mswin.c src/mswin/freeglut_structure_mswin.c
src/mswin/freeglut_window_mswin.c src/mswin/freeglut_window_mswin.c
) )
ELSE() ELSE()
LIST(APPEND FREEGLUT_SRCS LIST(APPEND FREEGLUT_SRCS
src/x11/freeglut_cursor_x11.c src/x11/freeglut_cursor_x11.c
src/x11/freeglut_display_x11.c src/x11/freeglut_display_x11.c
src/x11/freeglut_ext_x11.c src/x11/freeglut_ext_x11.c
src/x11/freeglut_gamemode_x11.c src/x11/freeglut_gamemode_x11.c
src/x11/freeglut_glutfont_definitions_x11.c src/x11/freeglut_glutfont_definitions_x11.c
src/x11/freeglut_init_x11.c src/x11/freeglut_init_x11.c
src/x11/freeglut_internal_x11.h src/x11/freeglut_internal_x11.h
src/x11/freeglut_input_devices_x11.c src/x11/freeglut_input_devices_x11.c
src/x11/freeglut_joystick_x11.c src/x11/freeglut_joystick_x11.c
src/x11/freeglut_main_x11.c src/x11/freeglut_main_x11.c
src/x11/freeglut_menu_x11.c src/x11/freeglut_menu_x11.c
src/x11/freeglut_spaceball_x11.c src/x11/freeglut_spaceball_x11.c
src/x11/freeglut_state_x11.c src/x11/freeglut_state_x11.c
src/x11/freeglut_structure_x11.c src/x11/freeglut_structure_x11.c
src/x11/freeglut_window_x11.c src/x11/freeglut_window_x11.c
src/x11/freeglut_xinput_x11.c src/x11/freeglut_xinput_x11.c
) )
ENDIF() ENDIF()
# Neatly organize all of the output files in the build directory # Neatly organize all of the output files in the build directory
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
# BUILD_SHARED_LIBS is already a standard CMake variable, but we need to # BUILD_SHARED_LIBS is already a standard CMake variable, but we need to
# re-declare it here so it will show up in the GUI. # re-declare it here so it will show up in the GUI.
OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON) OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON) OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
FIND_PACKAGE(OpenGL REQUIRED) FIND_PACKAGE(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${OPENGL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${OPENGL_INCLUDE_DIR})
IF(WIN32) IF(WIN32)
MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)") MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF() ENDIF()
if(UNIX) if(UNIX)
FIND_PACKAGE(X11 REQUIRED) FIND_PACKAGE(X11 REQUIRED)
LIST(APPEND LIBS ${X11_LIBRARIES}) LIST(APPEND LIBS ${X11_LIBRARIES})
IF(X11_Xrandr_FOUND) IF(X11_Xrandr_FOUND)
SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE) SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE)
LIST(APPEND LIBS ${X11_Xrandr_LIB}) LIST(APPEND LIBS ${X11_Xrandr_LIB})
ENDIF() ENDIF()
IF(X11_xf86vmode_FOUND) IF(X11_xf86vmode_FOUND)
SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE) SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE)
LIST(APPEND LIBS ${X11_xf86vmode_LIB}) LIST(APPEND LIBS ${X11_xf86vmode_LIB})
ENDIF() ENDIF()
ENDIF() ENDIF()
INCLUDE(CheckIncludeFiles) INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H) CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H) CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H) CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H) CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H) CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H) CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H)
CHECK_INCLUDE_FILES(usbhid.h HAVE_USBHID_H) CHECK_INCLUDE_FILES(usbhid.h HAVE_USBHID_H)
# The generated config.h is placed in the project's build directory, just to # The generated config.h is placed in the project's build directory, just to
# ensure that all CMake-generated files are kept away from the main source tree. # 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. # As a result, the build directory must to be added to the include path list.
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_CONFIG_H) ADD_DEFINITIONS(-DHAVE_CONFIG_H)
# by default, at least on UNIX, we want to build both # by default, at least on UNIX, we want to build both
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
ADD_LIBRARY(freeglut SHARED ${FREEGLUT_SRCS}) ADD_LIBRARY(freeglut SHARED ${FREEGLUT_SRCS})
ENDIF() ENDIF()
IF(BUILD_STATIC_LIBS) IF(BUILD_STATIC_LIBS)
ADD_LIBRARY(freeglut_static STATIC ${FREEGLUT_SRCS}) ADD_LIBRARY(freeglut_static STATIC ${FREEGLUT_SRCS})
ENDIF() ENDIF()
IF(WIN32) IF(WIN32)
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
LIST(APPEND FREEGLUT_SRCS src/Common/freeglutdll.def freeglut.rc) LIST(APPEND FREEGLUT_SRCS src/Common/freeglutdll.def freeglut.rc)
# XXX I assume that if we want both shared and static this one is appropriate # XXX I assume that if we want both shared and static this one is appropriate
ADD_DEFINITIONS(-DFREEGLUT_EXPORTS) ADD_DEFINITIONS(-DFREEGLUT_EXPORTS)
ELSE() ELSE()
ADD_DEFINITIONS(-DFREEGLUT_STATIC) ADD_DEFINITIONS(-DFREEGLUT_STATIC)
ENDIF() ENDIF()
ELSE() ELSE()
# on UNIX we need to make sure: # on UNIX we need to make sure:
# - all shared libraries must have a soname/version # - all shared libraries must have a soname/version
# - 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
# - the shared library should link to the dependency libraries so that the user # - 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 # won't have to link them explicitly (they shouldn't have to know that we depend
# on Xrandr or Xxf86vm) # on Xrandr or Xxf86vm)
SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut) SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut) SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
TARGET_LINK_LIBRARIES(freeglut ${LIBS}) TARGET_LINK_LIBRARIES(freeglut ${LIBS})
ENDIF() ENDIF()
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
INSTALL(TARGETS freeglut DESTINATION lib) INSTALL(TARGETS freeglut DESTINATION lib)
ENDIF() ENDIF()
IF(BUILD_STATIC_LIBS) IF(BUILD_STATIC_LIBS)
INSTALL(TARGETS freeglut_static DESTINATION lib) INSTALL(TARGETS freeglut_static DESTINATION lib)
ENDIF() ENDIF()
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL) INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
# Optionally build demos, on by default. # Optionally build demos, on by default.
option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON ) option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
SET(DEMO_LIBS ${OPENGL_LIBRARY} ${LIBS}) SET(DEMO_LIBS ${OPENGL_LIBRARY} ${LIBS})
MACRO(ADD_DEMO name) MACRO(ADD_DEMO name)
if( FREEGLUT_BUILD_DEMOS ) if( FREEGLUT_BUILD_DEMOS )
ADD_EXECUTABLE(${name} ${ARGN}) ADD_EXECUTABLE(${name} ${ARGN})
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut) TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
ELSE() ELSE()
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static) TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static)
ENDIF() ENDIF()
endif() endif()
ENDMACRO() ENDMACRO()
ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c) ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c)
ADD_DEMO(Fractals progs/demos/Fractals/fractals.c) ADD_DEMO(Fractals progs/demos/Fractals/fractals.c)
ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c) ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c)
ADD_DEMO(Lorenz progs/demos/Lorenz/lorenz.c) ADD_DEMO(Lorenz progs/demos/Lorenz/lorenz.c)
ADD_DEMO(One progs/demos/One/one.c) ADD_DEMO(One progs/demos/One/one.c)
ADD_DEMO(Resizer progs/demos/Resizer/Resizer.cpp) ADD_DEMO(Resizer progs/demos/Resizer/Resizer.cpp)
ADD_DEMO(shapes progs/demos/shapes/shapes.c) ADD_DEMO(shapes progs/demos/shapes/shapes.c)
ADD_DEMO(smooth_opengl3 progs/demos/smooth_opengl3/smooth_opengl3.c) ADD_DEMO(smooth_opengl3 progs/demos/smooth_opengl3/smooth_opengl3.c)
ADD_DEMO(spaceball progs/demos/spaceball/spaceball.c ADD_DEMO(spaceball progs/demos/spaceball/spaceball.c
progs/demos/spaceball/vmath.c progs/demos/spaceball/vmath.c
progs/demos/spaceball/vmath.h) progs/demos/spaceball/vmath.h)
ADD_DEMO(subwin progs/demos/subwin/subwin.c) ADD_DEMO(subwin progs/demos/subwin/subwin.c)

View File

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

0
freeglut/freeglut/LISEZ_MOI Executable file → Normal file
View File

View File

@ -1,210 +1,210 @@
# #
# Makefile.wat # Makefile.wat
# Open Watcom makefile for Freeglut # Open Watcom makefile for Freeglut
# Usage: # Usage:
# wmake -f Makefile.wat {target} # wmake -f Makefile.wat {target}
# Where target is one of: # Where target is one of:
# debug-static # debug-static
# debug-dynamic # debug-dynamic
# release-static # release-static
# release-dynamic # release-dynamic
# debug # debug
# release # release
# all # all
# clean # clean
# Assumes: # Assumes:
# WATCOM enviroment variable points to your Watcom installation directory # WATCOM enviroment variable points to your Watcom installation directory
# %WATCOM%\BINNT and %WATCOM%\BINW are in your path # %WATCOM%\BINNT and %WATCOM%\BINW are in your path
# #
RELEASE_STATIC_DIR = release-static RELEASE_STATIC_DIR = release-static
RELEASE_DYNAMIC_DIR = release-dynamic RELEASE_DYNAMIC_DIR = release-dynamic
DEBUG_STATIC_DIR = debug-static DEBUG_STATIC_DIR = debug-static
DEBUG_DYNAMIC_DIR = debug-dynamic DEBUG_DYNAMIC_DIR = debug-dynamic
INCLUDE_DIR = ..\include INCLUDE_DIR = ..\include
SRC_DIR = ..\src\Common SRC_DIR = ..\src\Common
COMPILER = wcc386 COMPILER = wcc386
COMPILE_COMMON_OPTIONS = -i$(INCLUDE_DIR);$(%WATCOM)\h;$(%WATCOM)\h\nt -fp6 -w4 -e25 -wcd202 -bt=nt -mf -zq COMPILE_COMMON_OPTIONS = -i$(INCLUDE_DIR);$(%WATCOM)\h;$(%WATCOM)\h\nt -fp6 -w4 -e25 -wcd202 -bt=nt -mf -zq
COMPILE_DEBUG_OPTIONS = -d3 -od -DDEBUG -D_DEBUG COMPILE_DEBUG_OPTIONS = -d3 -od -DDEBUG -D_DEBUG
COMPILE_RELEASE_OPTIONS = -d0 -otexanh COMPILE_RELEASE_OPTIONS = -d0 -otexanh
COMPILE_STATIC_OPTIONS = -DFREEGLUT_STATIC -6r COMPILE_STATIC_OPTIONS = -DFREEGLUT_STATIC -6r
COMPILE_DYNAMIC_OPTIONS = -DFREEGLUT_EXPORTS -6s -bd -bm COMPILE_DYNAMIC_OPTIONS = -DFREEGLUT_EXPORTS -6s -bd -bm
COMPILE_OPTIONS = $(COMPILE_COMMON_OPTIONS) $(COMPILE_$(MODE)_OPTIONS) $(COMPILE_$(TYPE)_OPTIONS) COMPILE_OPTIONS = $(COMPILE_COMMON_OPTIONS) $(COMPILE_$(MODE)_OPTIONS) $(COMPILE_$(TYPE)_OPTIONS)
LINKER = wlink LINKER = wlink
LINK_OPTIONS = SYS nt_dll op m op maxe=25 op q op symf FIL LINK_OPTIONS = SYS nt_dll op m op maxe=25 op q op symf FIL
LIB_TOOL = wlib LIB_TOOL = wlib
LIB_COMMON_OPTIONS = -q -n -b LIB_COMMON_OPTIONS = -q -n -b
LIB_DYNAMIC_OPTIONS = LIB_DYNAMIC_OPTIONS =
LIB_STATIC_OPTIONS = -c -p=512 LIB_STATIC_OPTIONS = -c -p=512
LIB_OPTIONS = $(LIB_COMMON_OPTIONS) $(LIB_$(TYPE)_OPTIONS) LIB_OPTIONS = $(LIB_COMMON_OPTIONS) $(LIB_$(TYPE)_OPTIONS)
MAKE = wmake -h -f ..\Makefile.wat MAKE = wmake -h -f ..\Makefile.wat
OBJ_FILES = & OBJ_FILES = &
freeglut_callbacks.obj & freeglut_callbacks.obj &
freeglut_cursor.obj & freeglut_cursor.obj &
freeglut_display.obj & freeglut_display.obj &
freeglut_ext.obj & freeglut_ext.obj &
freeglut_font.obj & freeglut_font.obj &
freeglut_font_data.obj & freeglut_font_data.obj &
freeglut_gamemode.obj & freeglut_gamemode.obj &
freeglut_geometry.obj & freeglut_geometry.obj &
freeglut_glutfont_definitions.obj & freeglut_glutfont_definitions.obj &
freeglut_init.obj & freeglut_init.obj &
freeglut_input_devices.obj & freeglut_input_devices.obj &
freeglut_joystick.obj & freeglut_joystick.obj &
freeglut_main.obj & freeglut_main.obj &
freeglut_menu.obj & freeglut_menu.obj &
freeglut_misc.obj & freeglut_misc.obj &
freeglut_overlay.obj & freeglut_overlay.obj &
freeglut_spaceball.obj & freeglut_spaceball.obj &
freeglut_state.obj & freeglut_state.obj &
freeglut_stroke_mono_roman.obj & freeglut_stroke_mono_roman.obj &
freeglut_stroke_roman.obj & freeglut_stroke_roman.obj &
freeglut_structure.obj & freeglut_structure.obj &
freeglut_teapot.obj & freeglut_teapot.obj &
freeglut_videoresize.obj & freeglut_videoresize.obj &
freeglut_window.obj freeglut_window.obj
default : .SYMBOLIC default : .SYMBOLIC
@echo Usage: @echo Usage:
@echo wmake -f Makefile.wat {target} @echo wmake -f Makefile.wat {target}
@echo Where target is one of: @echo Where target is one of:
@echo debug-static @echo debug-static
@echo debug-dynamic @echo debug-dynamic
@echo release-static @echo release-static
@echo release-dynamic @echo release-dynamic
@echo debug @echo debug
@echo release @echo release
@echo all @echo all
@echo clean @echo clean
# static library # static library
freeglut_static.lib : $(OBJ_FILES) freeglut_static.lib : $(OBJ_FILES)
$(LIB_TOOL) $(LIB_OPTIONS) $^* $(OBJ_FILES) $(LIB_TOOL) $(LIB_OPTIONS) $^* $(OBJ_FILES)
# dynamic link library # dynamic link library
freeglut.dll : $(OBJ_FILES) freeglut.dll : $(OBJ_FILES)
$(LINKER) name $^* $(LINK_OPTIONS) $(OBJ_FILES: =,) $(LINKER) name $^* $(LINK_OPTIONS) $(OBJ_FILES: =,)
freeglut.lib : freeglut.dll freeglut.lib : freeglut.dll
$(LIB_TOOL) $(LIB_OPTIONS) $^. +$[. $(LIB_TOOL) $(LIB_OPTIONS) $^. +$[.
freeglut_callbacks.obj : $(SRC_DIR)\freeglut_callbacks.c freeglut_callbacks.obj : $(SRC_DIR)\freeglut_callbacks.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_cursor.obj : $(SRC_DIR)\freeglut_cursor.c freeglut_cursor.obj : $(SRC_DIR)\freeglut_cursor.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_display.obj : $(SRC_DIR)\freeglut_display.c freeglut_display.obj : $(SRC_DIR)\freeglut_display.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_ext.obj : $(SRC_DIR)\freeglut_ext.c freeglut_ext.obj : $(SRC_DIR)\freeglut_ext.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_font.obj : $(SRC_DIR)\freeglut_font.c freeglut_font.obj : $(SRC_DIR)\freeglut_font.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_font_data.obj : $(SRC_DIR)\freeglut_font_data.c freeglut_font_data.obj : $(SRC_DIR)\freeglut_font_data.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_gamemode.obj : $(SRC_DIR)\freeglut_gamemode.c freeglut_gamemode.obj : $(SRC_DIR)\freeglut_gamemode.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_geometry.obj : $(SRC_DIR)\freeglut_geometry.c freeglut_geometry.obj : $(SRC_DIR)\freeglut_geometry.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_glutfont_definitions.obj : $(SRC_DIR)\freeglut_glutfont_definitions.c freeglut_glutfont_definitions.obj : $(SRC_DIR)\freeglut_glutfont_definitions.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_init.obj : $(SRC_DIR)\freeglut_init.c freeglut_init.obj : $(SRC_DIR)\freeglut_init.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_input_devices.obj : $(SRC_DIR)\freeglut_input_devices.c freeglut_input_devices.obj : $(SRC_DIR)\freeglut_input_devices.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_joystick.obj : $(SRC_DIR)\freeglut_joystick.c freeglut_joystick.obj : $(SRC_DIR)\freeglut_joystick.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_main.obj : $(SRC_DIR)\freeglut_main.c freeglut_main.obj : $(SRC_DIR)\freeglut_main.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_menu.obj : $(SRC_DIR)\freeglut_menu.c freeglut_menu.obj : $(SRC_DIR)\freeglut_menu.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_misc.obj : $(SRC_DIR)\freeglut_misc.c freeglut_misc.obj : $(SRC_DIR)\freeglut_misc.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_overlay.obj : $(SRC_DIR)\freeglut_overlay.c freeglut_overlay.obj : $(SRC_DIR)\freeglut_overlay.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_spaceball.obj : $(SRC_DIR)\freeglut_spaceball.c freeglut_spaceball.obj : $(SRC_DIR)\freeglut_spaceball.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_state.obj : $(SRC_DIR)\freeglut_state.c freeglut_state.obj : $(SRC_DIR)\freeglut_state.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_stroke_mono_roman.obj : $(SRC_DIR)\freeglut_stroke_mono_roman.c freeglut_stroke_mono_roman.obj : $(SRC_DIR)\freeglut_stroke_mono_roman.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_stroke_roman.obj : $(SRC_DIR)\freeglut_stroke_roman.c freeglut_stroke_roman.obj : $(SRC_DIR)\freeglut_stroke_roman.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_structure.obj : $(SRC_DIR)\freeglut_structure.c freeglut_structure.obj : $(SRC_DIR)\freeglut_structure.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_teapot.obj : $(SRC_DIR)\freeglut_teapot.c freeglut_teapot.obj : $(SRC_DIR)\freeglut_teapot.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_videoresize.obj : $(SRC_DIR)\freeglut_videoresize.c freeglut_videoresize.obj : $(SRC_DIR)\freeglut_videoresize.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
freeglut_window.obj : $(SRC_DIR)\freeglut_window.c freeglut_window.obj : $(SRC_DIR)\freeglut_window.c
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS) $(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
clean : .SYMBOLIC clean : .SYMBOLIC
@-del $(DEBUG_STATIC_DIR)\*.obj @-del $(DEBUG_STATIC_DIR)\*.obj
@-del $(DEBUG_DYNAMIC_DIR)\*.obj @-del $(DEBUG_DYNAMIC_DIR)\*.obj
@-del $(RELEASE_STATIC_DIR)\*.obj @-del $(RELEASE_STATIC_DIR)\*.obj
@-del $(RELEASE_DYNAMIC_DIR)\*.obj @-del $(RELEASE_DYNAMIC_DIR)\*.obj
@echo All object files removed @echo All object files removed
debug-static : .SYMBOLIC debug-static : .SYMBOLIC
@-if not exist $(DEBUG_STATIC_DIR)\. mkdir $(DEBUG_STATIC_DIR) @-if not exist $(DEBUG_STATIC_DIR)\. mkdir $(DEBUG_STATIC_DIR)
@-cd $(DEBUG_STATIC_DIR) @-cd $(DEBUG_STATIC_DIR)
@$(MAKE) MODE=DEBUG TYPE=STATIC freeglut_static.lib @$(MAKE) MODE=DEBUG TYPE=STATIC freeglut_static.lib
@-cd .. @-cd ..
@echo Debug static library up to date @echo Debug static library up to date
debug-dynamic : .SYMBOLIC debug-dynamic : .SYMBOLIC
@-if not exist $(DEBUG_DYNAMIC_DIR)\. mkdir $(DEBUG_DYNAMIC_DIR) @-if not exist $(DEBUG_DYNAMIC_DIR)\. mkdir $(DEBUG_DYNAMIC_DIR)
@-cd $(DEBUG_DYNAMIC_DIR) @-cd $(DEBUG_DYNAMIC_DIR)
@$(MAKE) MODE=DEBUG TYPE=DYNAMIC freeglut.lib @$(MAKE) MODE=DEBUG TYPE=DYNAMIC freeglut.lib
@-cd .. @-cd ..
@echo Debug dynamic link library up to date @echo Debug dynamic link library up to date
release-static : .SYMBOLIC release-static : .SYMBOLIC
@-if not exist $(RELEASE_STATIC_DIR)\. mkdir $(RELEASE_STATIC_DIR) @-if not exist $(RELEASE_STATIC_DIR)\. mkdir $(RELEASE_STATIC_DIR)
@-cd $(RELEASE_STATIC_DIR) @-cd $(RELEASE_STATIC_DIR)
@$(MAKE) MODE=RELEASE TYPE=STATIC freeglut_static.lib @$(MAKE) MODE=RELEASE TYPE=STATIC freeglut_static.lib
@-cd .. @-cd ..
@echo Release static library up to date @echo Release static library up to date
release-dynamic : .SYMBOLIC release-dynamic : .SYMBOLIC
@-if not exist $(RELEASE_DYNAMIC_DIR)\. mkdir $(RELEASE_DYNAMIC_DIR) @-if not exist $(RELEASE_DYNAMIC_DIR)\. mkdir $(RELEASE_DYNAMIC_DIR)
@-cd $(RELEASE_DYNAMIC_DIR) @-cd $(RELEASE_DYNAMIC_DIR)
@$(MAKE) MODE=RELEASE TYPE=DYNAMIC freeglut.lib @$(MAKE) MODE=RELEASE TYPE=DYNAMIC freeglut.lib
@-cd .. @-cd ..
@echo Release dynamic link library up to date @echo Release dynamic link library up to date
debug : debug-static debug-dynamic .SYMBOLIC debug : debug-static debug-dynamic .SYMBOLIC
@echo Debug targets up to date @echo Debug targets up to date
release : release-static release-dynamic .SYMBOLIC release : release-static release-dynamic .SYMBOLIC
@echo Release targets up to date @echo Release targets up to date
all : debug release .SYMBOLIC all : debug release .SYMBOLIC
@echo All targets up to date @echo All targets up to date

View File

@ -1,212 +1,212 @@
Glut then! Glut then!
By Jean-Seb on Friday July 10, 2009, 00:18 By Jean-Seb on Friday July 10, 2009, 00:18
Translated by Babelfish with a scrub from John F. Fay. For points of confusion Translated by Babelfish with a scrub from John F. Fay. For points of confusion
please refer to the original French version. please refer to the original French version.
Freeglut is an open-source evolution of GLUT. Freeglut is an open-source evolution of GLUT.
Under Windows, one can use it with Cygwin. Under Windows, one can use it with Cygwin.
Easy? Yes, if one agrees to distribute "cygwin1.dll". Easy? Yes, if one agrees to distribute "cygwin1.dll".
Let us help freeglut gain its independence ! Let us help freeglut gain its independence !
m.à.j 10/7/2009: generation of a library for linking without the DLL. m.à.j 10/7/2009: generation of a library for linking without the DLL.
Recovery of the sources Recovery of the sources
* Download the sources of version 2.6.0 which integrates recent changes. * Download the sources of version 2.6.0 which integrates recent changes.
* For the moment, it is a RC (Release Candidate), but the final version * For the moment, it is a RC (Release Candidate), but the final version
should not delay. should not delay.
* The use of the 2.6 is preferable with the 2.4-stable branch because many * The use of the 2.6 is preferable with the 2.4-stable branch because many
bugs have been corrected. bugs have been corrected.
* You will find the sources on the site of Freeglut: * You will find the sources on the site of Freeglut:
o http://freeglut.sourceforge.net/ o http://freeglut.sourceforge.net/
Objectives and preparation Objectives and preparation
Objectives Objectives
* We will create a DLL related to Cygwin, and an independent static library * We will create a DLL related to Cygwin, and an independent static library
* We will also create a dynamic library, allowing linking with the DLL. * We will also create a dynamic library, allowing linking with the DLL.
List of generated files List of generated files
* freeglut.dll: a traditional DLL for the dynamic linkage. * freeglut.dll: a traditional DLL for the dynamic linkage.
* libfreeglut.a: the static library. The final program is autonomous (at * libfreeglut.a: the static library. The final program is autonomous (at
least for OpenGL). least for OpenGL).
* libfreeglutdll.a: the dynamic library. The final program needs * libfreeglutdll.a: the dynamic library. The final program needs
freeglut.dll. freeglut.dll.
Preparation Preparation
* Extract the files from the freeglut archive. * Extract the files from the freeglut archive.
* Go in the directory src (located at the root of the Freeglut directory), * Go in the directory src (located at the root of the Freeglut directory),
and create a "Gl" sub-directory and create a "Gl" sub-directory
o In this sub-directory, copy the files of the directory "include/Gl" o In this sub-directory, copy the files of the directory "include/Gl"
* Why is it necessary to create a "Gl" directory for compilation? * Why is it necessary to create a "Gl" directory for compilation?
o I needed it to simplify things during my tests. o I needed it to simplify things during my tests.
o If not you can create the repertories directly, and copy the files o If not you can create the repertories directly, and copy the files
as indicated in the point installation (see below). as indicated in the point installation (see below).
* Do a little housekeeping in /lib: * Do a little housekeeping in /lib:
o Erase all the references to the glut, so as not to conflict with the o Erase all the references to the glut, so as not to conflict with the
linking. linking.
o This stage is optional, you can also choose to do the housekeeping o This stage is optional, you can also choose to do the housekeeping
only after a successful compilation of Freeglut. only after a successful compilation of Freeglut.
o In your enthusiasm to clean things up, be careful not to erase the o In your enthusiasm to clean things up, be careful not to erase the
library glu32.lib (not to be confused with glut32.lib). library glu32.lib (not to be confused with glut32.lib).
Compilation Compilation
* Forget the "./configure, make, make install" triptych. * Forget the "./configure, make, make install" triptych.
o It does not go at all with Cygwin. o It does not go at all with Cygwin.
* Here Makefile which will make the deal: * Here Makefile which will make the deal:
#Makefile for Freeglut 2.6.0-rc and Cygwin #Makefile for Freeglut 2.6.0-rc and Cygwin
#To place in the directory “src/Common” #To place in the directory “src/Common”
sources=$ (wildcard *.c) sources=$ (wildcard *.c)
objs=$ (sources: .c=.o) objs=$ (sources: .c=.o)
libname=freeglut libname=freeglut
CFLAGS=-O2 - DTARGET_HOST_MS_WINDOWS - DX_DISPLAY_MISSING - DFREEGLUT_STATIC - I./ CFLAGS=-O2 - DTARGET_HOST_MS_WINDOWS - DX_DISPLAY_MISSING - DFREEGLUT_STATIC - I./
LDFLAGS=-lopengl32 - lgdi32 - lwinmm LDFLAGS=-lopengl32 - lgdi32 - lwinmm
nocyg=-mno-cygwin - mwindows nocyg=-mno-cygwin - mwindows
all: $ (objs) all: $ (objs)
#construction DLL related to cygwin1.dll #construction DLL related to cygwin1.dll
GCC $ (nocyg) $ (objs) - shared $ (LDFLAGS) - O $ (libname) .dll GCC $ (nocyg) $ (objs) - shared $ (LDFLAGS) - O $ (libname) .dll
Nm $ (libname) .dll | awk “BEGIN {print “EXPORTS”} /T _glut/{sub (/^.*T _/,” \ T "); print}” > $ (libname) .def 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 dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
#construction static library independent of cygwin #construction static library independent of cygwin
rear Cr lib$ (libname) .a $ (objs) rear Cr lib$ (libname) .a $ (objs)
#pas inevitably obligatory (creation of an index to accelerate the accesses) #pas inevitably obligatory (creation of an index to accelerate the accesses)
ranlib lib$ (libname) .a ranlib lib$ (libname) .a
%.o: %.c %.o: %.c
GCC $ (nocyg) - C $ (CFLAGS) $< GCC $ (nocyg) - C $ (CFLAGS) $<
clean: clean:
rm - F *.o $ (libname) .dll $ (libname) .def lib$ (libname) dll.a lib$ (libname) .a rm - F *.o $ (libname) .dll $ (libname) .def lib$ (libname) dll.a lib$ (libname) .a
Some remarks on the makefile Some remarks on the makefile
* This makefile creates a DLL, a static library (a file, in other words) and * This makefile creates a DLL, a static library (a file, in other words) and
the dynamic library which will allow the use of the DLL. the dynamic library which will allow the use of the DLL.
* Do not try to strip the static library! You may not be able to compile * Do not try to strip the static library! You may not be able to compile
applications with static library any more. applications with static library any more.
o On the other hand, you can strip the final executable obtained after o On the other hand, you can strip the final executable obtained after
compiling your application. compiling your application.
* I chose to call the DLL and the libraries by their "true names": * I chose to call the DLL and the libraries by their "true names":
freeglut.dll libfreeglutdll.a and libfreeglut.a. freeglut.dll libfreeglutdll.a and libfreeglut.a.
o Script configures recreated (for reasons of compatibility with the o Script configures recreated (for reasons of compatibility with the
old GLUT library) glut.dll and libglut.a. old GLUT library) glut.dll and libglut.a.
o During the my tests, I had conflicts with an authentic "glut" which o During the my tests, I had conflicts with an authentic "glut" which
trailed in my "/lib". I decided to call the things by their name, in trailed in my "/lib". I decided to call the things by their name, in
order to avoid confusions. order to avoid confusions.
o Nothing prevents you from renaming the DLL, if you need to use GLUT o Nothing prevents you from renaming the DLL, if you need to use GLUT
programs which you cannot recompile. programs which you cannot recompile.
* The dynamic library is generated starting from the DLL. * The dynamic library is generated starting from the DLL.
o For reasons of brevity, I used awk. It generates the export file o For reasons of brevity, I used awk. It generates the export file
used by dlltool. used by dlltool.
o The only notable thing is the selection of the functions whose name o The only notable thing is the selection of the functions whose name
starts with _glut, in order to avoid including in the dynamic starts with _glut, in order to avoid including in the dynamic
library the functions that are not related to freeglut. library the functions that are not related to freeglut.
o then, one uses dlltool in a very traditional way. o then, one uses dlltool in a very traditional way.
Nm $ (libname) .dll | awk “BEGIN {print “EXPORTS”} /T _glut/{sub (/^.*T _/,” \ T "); print}” > $ (libname) .def 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 dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
Installation Installation
* Copy libfreeglut.a, libfreeglutdll.a into the Cygwin directory /lib. * Copy libfreeglut.a, libfreeglutdll.a into the Cygwin directory /lib.
* Copy freglut.dll in the system32 of Windows (this is practical, but not * Copy freglut.dll in the system32 of Windows (this is practical, but not
clean!). clean!).
* Copy the files headers of Freeglut (/include/gl) into the Cygwin directory * Copy the files headers of Freeglut (/include/gl) into the Cygwin directory
/usr/include/Gl. /usr/include/Gl.
* Copy the files headers (always /include/gl) into /usr/include/mingw/Gl: * Copy the files headers (always /include/gl) into /usr/include/mingw/Gl:
this is used for compilations with the flag - mno-cygwin, which uses the this is used for compilations with the flag - mno-cygwin, which uses the
includes in mingw. includes in mingw.
o You may need to erase the old GLUT include files if you installed it o You may need to erase the old GLUT include files if you installed it
with Cygwin. with Cygwin.
Use of the library Use of the library
* We will test with the program shapes, found in progs/demonstrations/shapes * We will test with the program shapes, found in progs/demonstrations/shapes
o -mno-cygwin is used to force the use of Mingw without the large o -mno-cygwin is used to force the use of Mingw without the large
dependence cygwin1.dll. dependence cygwin1.dll.
o -mwindows is only used to remove the horrible Shell window (very o -mwindows is only used to remove the horrible Shell window (very
useful for the settling, on the other hand). useful for the settling, on the other hand).
o -L. (note the period after the "L"): I left libfreeglut.a, o -L. (note the period after the "L"): I left libfreeglut.a,
libfreeglutdll.a and freeglut.dll in the test directory, at the time libfreeglutdll.a and freeglut.dll in the test directory, at the time
of the tests. of the tests.
Compilation of the static freeglut library, without cygwin Compilation of the static freeglut library, without cygwin
* All the simplicity lies in the define: -DFREEGLUT_STATIC * All the simplicity lies in the define: -DFREEGLUT_STATIC
o It serves to obtain good decoration of the function names in the o It serves to obtain good decoration of the function names in the
imports of the lib Freeglut. imports of the lib Freeglut.
o You can test without and use a hex editor to see the differences o You can test without and use a hex editor to see the differences
in the objects. in the objects.
* attention with the order of the libraries: -lfreeglut (static) must be * attention with the order of the libraries: -lfreeglut (static) must be
before the declaration of the dynamic libraries. before the declaration of the dynamic libraries.
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin -mwindows -DFREEGLUT_STATIC * gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin -mwindows -DFREEGLUT_STATIC
Compilation with DLL freeglut, without cygwin Compilation with DLL freeglut, without cygwin
* For the define, see the notices above * For the define, see the notices above
* The order of the libraries is no longer important. * The order of the libraries is no longer important.
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin -DFREEGLUT_STATIC * gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin -DFREEGLUT_STATIC
Compilation with DLL freeglut, Cygwin Compilation with DLL freeglut, Cygwin
* This example is given only for reference, the topic of this ticket being * This example is given only for reference, the topic of this ticket being
to get rid of Cygwin. to get rid of Cygwin.
o Let us say that can be used to make the point (and later). o Let us say that can be used to make the point (and later).
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut * gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
Where are the dooooocs? Where are the dooooocs?
* Freeglut is delivered with its documentation, more very up to date. * Freeglut is delivered with its documentation, more very up to date.
o It seems that there is a problem with the original GLUT o It seems that there is a problem with the original GLUT
documentation. Not only it does not correspond completely to the documentation. Not only it does not correspond completely to the
operation of Freeglut, but moreover, its author (Mark Kilgard) operation of Freeglut, but moreover, its author (Mark Kilgard)
copyrighted it. Its distribution is thus difficult. copyrighted it. Its distribution is thus difficult.
* Jocelyn Fréchot undertook a levelling of the docs for version 2.6.0. One can find them on his site for the moment: * Jocelyn Fréchot undertook a levelling of the docs for version 2.6.0. One can find them on his site for the moment:
o http://jocelyn.frechot.free.fr/freeglut/ o http://jocelyn.frechot.free.fr/freeglut/
Something survived… Something survived…
* I also tested the recompiling of the demonstrations of the original lib * I also tested the recompiling of the demonstrations of the original lib
GLUT (peace with its ashes). GLUT (peace with its ashes).
o Nothing in particular to be announced. o Nothing in particular to be announced.
* Thank you with all the courageous maintainers for Freeglut, that one * Thank you with all the courageous maintainers for Freeglut, that one
believed dead, but which still move. believed dead, but which still move.

View File

@ -1,24 +1,24 @@
Cross-compilation from GNU/Linux (static and shared DLL) Cross-compilation from GNU/Linux (static and shared DLL)
======================================================== ========================================================
Install MinGW32 and prepare FreeGLUT on Debian/Ubuntu: Install MinGW32 and prepare FreeGLUT on Debian/Ubuntu:
apt-get install mingw32 apt-get install mingw32
./configure --host=i586-mingw32msvc --prefix=/freeglut ./configure --host=i586-mingw32msvc --prefix=/freeglut
Install MinGW32 and prepare FreeGLUT on Fedora: Install MinGW32 and prepare FreeGLUT on Fedora:
yum install mingw32-gcc yum install mingw32-gcc
./configure --host=i686-pc-mingw32 --prefix=/freeglut ./configure --host=i686-pc-mingw32 --prefix=/freeglut
Cross-compile! Cross-compile!
make make
make install DESTDIR=$(pwd) make install DESTDIR=$(pwd)
Everything is in the new freeglut/ directory. Everything is in the new freeglut/ directory.
The .dll is in the freeglut/bin/. The .dll is in the freeglut/bin/.
Compilation of your own programs is done as usual. Compilation of your own programs is done as usual.
See README.cygwin_mingw for details. See README.cygwin_mingw for details.

0
freeglut/freeglut/README.win32 Executable file → Normal file
View File

View File

@ -1,412 +1,412 @@
/* /*
* freeglut_callbacks.c * freeglut_callbacks.c
* *
* The callbacks setting methods. * The callbacks setting methods.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Fri Dec 3 1999 * Creation date: Fri Dec 3 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* All of the callbacks setting methods can be generalized to this: * All of the callbacks setting methods can be generalized to this:
*/ */
#define SET_CALLBACK(a) \ #define SET_CALLBACK(a) \
do \ do \
{ \ { \
if( fgStructure.CurrentWindow == NULL ) \ if( fgStructure.CurrentWindow == NULL ) \
return; \ return; \
SET_WCB( ( *( fgStructure.CurrentWindow ) ), a, callback ); \ SET_WCB( ( *( fgStructure.CurrentWindow ) ), a, callback ); \
} while( 0 ) } while( 0 )
/* /*
* Sets the Display callback for the current window * Sets the Display callback for the current window
*/ */
void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) ) void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
if( !callback ) if( !callback )
fgError( "Fatal error in program. NULL display callback not " fgError( "Fatal error in program. NULL display callback not "
"permitted in GLUT 3.0+ or freeglut 2.0.1+" ); "permitted in GLUT 3.0+ or freeglut 2.0.1+" );
SET_CALLBACK( Display ); SET_CALLBACK( Display );
} }
/* /*
* Sets the Reshape callback for the current window * Sets the Reshape callback for the current window
*/ */
void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
SET_CALLBACK( Reshape ); SET_CALLBACK( Reshape );
} }
/* /*
* Sets the Keyboard callback for the current window * Sets the Keyboard callback for the current window
*/ */
void FGAPIENTRY glutKeyboardFunc( void (* callback) void FGAPIENTRY glutKeyboardFunc( void (* callback)
( unsigned char, int, int ) ) ( unsigned char, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
SET_CALLBACK( Keyboard ); SET_CALLBACK( Keyboard );
} }
/* /*
* Sets the Special callback for the current window * Sets the Special callback for the current window
*/ */
void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) ) void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
SET_CALLBACK( Special ); SET_CALLBACK( Special );
} }
/* /*
* Sets the global idle callback * Sets the global idle callback
*/ */
void FGAPIENTRY glutIdleFunc( void (* callback)( void ) ) void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
fgState.IdleCallback = callback; fgState.IdleCallback = callback;
} }
/* /*
* Sets the Timer callback for the current window * Sets the Timer callback for the current window
*/ */
void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
int timerID ) int timerID )
{ {
SFG_Timer *timer, *node; SFG_Timer *timer, *node;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
if( (timer = fgState.FreeTimers.Last) ) if( (timer = fgState.FreeTimers.Last) )
{ {
fgListRemove( &fgState.FreeTimers, &timer->Node ); fgListRemove( &fgState.FreeTimers, &timer->Node );
} }
else else
{ {
if( ! (timer = malloc(sizeof(SFG_Timer))) ) if( ! (timer = malloc(sizeof(SFG_Timer))) )
fgError( "Fatal error: " fgError( "Fatal error: "
"Memory allocation failure in glutTimerFunc()" ); "Memory allocation failure in glutTimerFunc()" );
} }
timer->Callback = callback; timer->Callback = callback;
timer->ID = timerID; timer->ID = timerID;
timer->TriggerTime = fgElapsedTime() + timeOut; timer->TriggerTime = fgElapsedTime() + timeOut;
for( node = fgState.Timers.First; node; node = node->Node.Next ) for( node = fgState.Timers.First; node; node = node->Node.Next )
{ {
if( node->TriggerTime > timer->TriggerTime ) if( node->TriggerTime > timer->TriggerTime )
break; break;
} }
fgListInsert( &fgState.Timers, &node->Node, &timer->Node ); fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
} }
/* /*
* Sets the Visibility callback for the current window. * Sets the Visibility callback for the current window.
*/ */
static void fghVisibility( int status ) static void fghVisibility( int status )
{ {
int glut_status = GLUT_VISIBLE; int glut_status = GLUT_VISIBLE;
FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" ); FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" );
freeglut_return_if_fail( fgStructure.CurrentWindow ); freeglut_return_if_fail( fgStructure.CurrentWindow );
if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) ) if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) )
glut_status = GLUT_NOT_VISIBLE; glut_status = GLUT_NOT_VISIBLE;
INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) ); INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) );
} }
void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) ) void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
SET_CALLBACK( Visibility ); SET_CALLBACK( Visibility );
if( callback ) if( callback )
glutWindowStatusFunc( fghVisibility ); glutWindowStatusFunc( fghVisibility );
else else
glutWindowStatusFunc( NULL ); glutWindowStatusFunc( NULL );
} }
/* /*
* Sets the keyboard key release callback for the current window * Sets the keyboard key release callback for the current window
*/ */
void FGAPIENTRY glutKeyboardUpFunc( void (* callback) void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
( unsigned char, int, int ) ) ( unsigned char, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
SET_CALLBACK( KeyboardUp ); SET_CALLBACK( KeyboardUp );
} }
/* /*
* Sets the special key release callback for the current window * Sets the special key release callback for the current window
*/ */
void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) ) void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
SET_CALLBACK( SpecialUp ); SET_CALLBACK( SpecialUp );
} }
/* /*
* Sets the joystick callback and polling rate for the current window * Sets the joystick callback and polling rate for the current window
*/ */
void FGAPIENTRY glutJoystickFunc( void (* callback) void FGAPIENTRY glutJoystickFunc( void (* callback)
( unsigned int, int, int, int ), ( unsigned int, int, int, int ),
int pollInterval ) int pollInterval )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
fgInitialiseJoysticks (); fgInitialiseJoysticks ();
if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) || if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
!FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was disabled */ !FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was disabled */
( callback && ( pollInterval >= 0 ) ) ) /* but is now enabled */ ( callback && ( pollInterval >= 0 ) ) ) /* but is now enabled */
++fgState.NumActiveJoysticks; ++fgState.NumActiveJoysticks;
else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) && else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was enabled */ FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was enabled */
( !callback || ( pollInterval < 0 ) ) ) /* but is now disabled */ ( !callback || ( pollInterval < 0 ) ) ) /* but is now disabled */
--fgState.NumActiveJoysticks; --fgState.NumActiveJoysticks;
SET_CALLBACK( Joystick ); SET_CALLBACK( Joystick );
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval; fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
fgStructure.CurrentWindow->State.JoystickLastPoll = fgStructure.CurrentWindow->State.JoystickLastPoll =
fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate; fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 ) if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
fgStructure.CurrentWindow->State.JoystickLastPoll = 0; fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
} }
/* /*
* Sets the mouse callback for the current window * Sets the mouse callback for the current window
*/ */
void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) ) void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
SET_CALLBACK( Mouse ); SET_CALLBACK( Mouse );
} }
/* /*
* Sets the mouse wheel callback for the current window * Sets the mouse wheel callback for the current window
*/ */
void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) ) void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
SET_CALLBACK( MouseWheel ); SET_CALLBACK( MouseWheel );
} }
/* /*
* Sets the mouse motion callback for the current window (one or more buttons * Sets the mouse motion callback for the current window (one or more buttons
* are pressed) * are pressed)
*/ */
void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
SET_CALLBACK( Motion ); SET_CALLBACK( Motion );
} }
/* /*
* Sets the passive mouse motion callback for the current window (no mouse * Sets the passive mouse motion callback for the current window (no mouse
* buttons are pressed) * buttons are pressed)
*/ */
void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
SET_CALLBACK( Passive ); SET_CALLBACK( Passive );
} }
/* /*
* Window mouse entry/leave callback * Window mouse entry/leave callback
*/ */
void FGAPIENTRY glutEntryFunc( void (* callback)( int ) ) void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
SET_CALLBACK( Entry ); SET_CALLBACK( Entry );
} }
/* /*
* Window destruction callbacks * Window destruction callbacks
*/ */
void FGAPIENTRY glutCloseFunc( void (* callback)( void ) ) void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
SET_CALLBACK( Destroy ); SET_CALLBACK( Destroy );
} }
void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) ) void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
glutCloseFunc( callback ); glutCloseFunc( callback );
} }
/* A. Donev: Destruction callback for menus */ /* A. Donev: Destruction callback for menus */
void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) ) void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
if( fgStructure.CurrentMenu ) if( fgStructure.CurrentMenu )
fgStructure.CurrentMenu->Destroy = callback; fgStructure.CurrentMenu->Destroy = callback;
} }
/* /*
* Deprecated version of glutMenuStatusFunc callback setting method * Deprecated version of glutMenuStatusFunc callback setting method
*/ */
void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) ) void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
fgState.MenuStateCallback = callback; fgState.MenuStateCallback = callback;
} }
/* /*
* Sets the global menu status callback for the current window * Sets the global menu status callback for the current window
*/ */
void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) ) void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
fgState.MenuStatusCallback = callback; fgState.MenuStatusCallback = callback;
} }
/* /*
* Sets the overlay display callback for the current window * Sets the overlay display callback for the current window
*/ */
void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) ) void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
SET_CALLBACK( OverlayDisplay ); SET_CALLBACK( OverlayDisplay );
} }
/* /*
* Sets the window status callback for the current window * Sets the window status callback for the current window
*/ */
void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) ) void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
SET_CALLBACK( WindowStatus ); SET_CALLBACK( WindowStatus );
} }
/* /*
* Sets the spaceball motion callback for the current window * Sets the spaceball motion callback for the current window
*/ */
void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) ) void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
fgInitialiseSpaceball(); fgInitialiseSpaceball();
SET_CALLBACK( SpaceMotion ); SET_CALLBACK( SpaceMotion );
} }
/* /*
* Sets the spaceball rotate callback for the current window * Sets the spaceball rotate callback for the current window
*/ */
void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) ) void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
fgInitialiseSpaceball(); fgInitialiseSpaceball();
SET_CALLBACK( SpaceRotation ); SET_CALLBACK( SpaceRotation );
} }
/* /*
* Sets the spaceball button callback for the current window * Sets the spaceball button callback for the current window
*/ */
void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
fgInitialiseSpaceball(); fgInitialiseSpaceball();
SET_CALLBACK( SpaceButton ); SET_CALLBACK( SpaceButton );
} }
/* /*
* Sets the button box callback for the current window * Sets the button box callback for the current window
*/ */
void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
SET_CALLBACK( ButtonBox ); SET_CALLBACK( ButtonBox );
} }
/* /*
* Sets the dials box callback for the current window * Sets the dials box callback for the current window
*/ */
void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
SET_CALLBACK( Dials ); SET_CALLBACK( Dials );
} }
/* /*
* Sets the tablet motion callback for the current window * Sets the tablet motion callback for the current window
*/ */
void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) ) void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
SET_CALLBACK( TabletMotion ); SET_CALLBACK( TabletMotion );
} }
/* /*
* Sets the tablet buttons callback for the current window * Sets the tablet buttons callback for the current window
*/ */
void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) ) void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
SET_CALLBACK( TabletButton ); SET_CALLBACK( TabletButton );
} }
/* /*
* Sets the multi-pointer entry callback for the current window * Sets the multi-pointer entry callback for the current window
*/ */
void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) ) void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" );
SET_CALLBACK( MultiEntry ); SET_CALLBACK( MultiEntry );
} }
/* /*
* Sets the multi-pointer button callback for the current window * Sets the multi-pointer button callback for the current window
*/ */
void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) ) void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" );
SET_CALLBACK( MultiButton ); SET_CALLBACK( MultiButton );
} }
/* /*
* Sets the multi-pointer motion callback for the current window * Sets the multi-pointer motion callback for the current window
*/ */
void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) ) void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" );
SET_CALLBACK( MultiMotion ); SET_CALLBACK( MultiMotion );
} }
/* /*
* Sets the multi-pointer passive motion callback for the current window * Sets the multi-pointer passive motion callback for the current window
*/ */
void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) ) void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
SET_CALLBACK( MultiPassive ); SET_CALLBACK( MultiPassive );
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -1,79 +1,79 @@
/* /*
* freeglut_cursor.c * freeglut_cursor.c
* *
* The mouse cursor related stuff. * The mouse cursor related stuff.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* glutSetCursor() -- Win32 mappings are incomplete. * glutSetCursor() -- Win32 mappings are incomplete.
* *
* It would be good to use custom mouse cursor shapes, and introduce * It would be good to use custom mouse cursor shapes, and introduce
* an option to display them using glBitmap() and/or texture mapping, * an option to display them using glBitmap() and/or texture mapping,
* apart from the windowing system version. * apart from the windowing system version.
*/ */
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */ /* -- PRIVATE FUNCTIONS --------------------------------------------------- */
extern void fgPlatformSetCursor ( SFG_Window *window, int cursorID ); extern void fgPlatformSetCursor ( SFG_Window *window, int cursorID );
extern void fgPlatformWarpPointer ( int x, int y ); extern void fgPlatformWarpPointer ( int x, int y );
/* -- INTERNAL FUNCTIONS ---------------------------------------------------- */ /* -- INTERNAL FUNCTIONS ---------------------------------------------------- */
void fgSetCursor ( SFG_Window *window, int cursorID ) void fgSetCursor ( SFG_Window *window, int cursorID )
{ {
fgPlatformSetCursor ( window, cursorID ); fgPlatformSetCursor ( window, cursorID );
} }
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Set the cursor image to be used for the current window * Set the cursor image to be used for the current window
*/ */
void FGAPIENTRY glutSetCursor( int cursorID ) void FGAPIENTRY glutSetCursor( int cursorID )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" );
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" ); FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" );
fgPlatformSetCursor ( fgStructure.CurrentWindow, cursorID ); fgPlatformSetCursor ( fgStructure.CurrentWindow, cursorID );
fgStructure.CurrentWindow->State.Cursor = cursorID; fgStructure.CurrentWindow->State.Cursor = cursorID;
} }
/* /*
* Moves the mouse pointer to given window coordinates * Moves the mouse pointer to given window coordinates
*/ */
void FGAPIENTRY glutWarpPointer( int x, int y ) void FGAPIENTRY glutWarpPointer( int x, int y )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" );
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" ); FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" );
fgPlatformWarpPointer ( x, y ); fgPlatformWarpPointer ( x, y );
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -1,104 +1,104 @@
/* /*
* freeglut_display.c * freeglut_display.c
* *
* Display message posting, context buffer swapping. * Display message posting, context buffer swapping.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Fri Dec 3 1999 * Creation date: Fri Dec 3 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* Function prototypes */ /* Function prototypes */
extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow ); extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Marks the current window to have the redisplay performed when possible... * Marks the current window to have the redisplay performed when possible...
*/ */
void FGAPIENTRY glutPostRedisplay( void ) void FGAPIENTRY glutPostRedisplay( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
if ( ! fgStructure.CurrentWindow ) if ( ! fgStructure.CurrentWindow )
{ {
fgError ( " ERROR: Function <%s> called" fgError ( " ERROR: Function <%s> called"
" with no current window defined.", "glutPostRedisplay" ) ; " with no current window defined.", "glutPostRedisplay" ) ;
} }
fgStructure.CurrentWindow->State.Redisplay = GL_TRUE; fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
} }
/* /*
* Swaps the buffers for the current window (if any) * Swaps the buffers for the current window (if any)
*/ */
void FGAPIENTRY glutSwapBuffers( void ) void FGAPIENTRY glutSwapBuffers( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" ); FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
/* /*
* "glXSwapBuffers" already performs an implicit call to "glFlush". What * "glXSwapBuffers" already performs an implicit call to "glFlush". What
* about "SwapBuffers"? * about "SwapBuffers"?
*/ */
glFlush( ); glFlush( );
if( ! fgStructure.CurrentWindow->Window.DoubleBuffered ) if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
return; return;
fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow ); fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );
/* GLUT_FPS env var support */ /* GLUT_FPS env var support */
if( fgState.FPSInterval ) if( fgState.FPSInterval )
{ {
GLint t = glutGet( GLUT_ELAPSED_TIME ); GLint t = glutGet( GLUT_ELAPSED_TIME );
fgState.SwapCount++; fgState.SwapCount++;
if( fgState.SwapTime == 0 ) if( fgState.SwapTime == 0 )
fgState.SwapTime = t; fgState.SwapTime = t;
else if( t - fgState.SwapTime > fgState.FPSInterval ) else if( t - fgState.SwapTime > fgState.FPSInterval )
{ {
float time = 0.001f * ( t - fgState.SwapTime ); float time = 0.001f * ( t - fgState.SwapTime );
float fps = ( float )fgState.SwapCount / time; float fps = ( float )fgState.SwapCount / time;
fprintf( stderr, fprintf( stderr,
"freeglut: %d frames in %.2f seconds = %.2f FPS\n", "freeglut: %d frames in %.2f seconds = %.2f FPS\n",
fgState.SwapCount, time, fps ); fgState.SwapCount, time, fps );
fgState.SwapTime = t; fgState.SwapTime = t;
fgState.SwapCount = 0; fgState.SwapCount = 0;
} }
} }
} }
/* /*
* Mark appropriate window to be displayed * Mark appropriate window to be displayed
*/ */
void FGAPIENTRY glutPostWindowRedisplay( int windowID ) void FGAPIENTRY glutPostWindowRedisplay( int windowID )
{ {
SFG_Window* window; SFG_Window* window;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
window = fgWindowByID( windowID ); window = fgWindowByID( windowID );
freeglut_return_if_fail( window ); freeglut_return_if_fail( window );
window->State.Redisplay = GL_TRUE; window->State.Redisplay = GL_TRUE;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -1,221 +1,221 @@
/* /*
* freeglut_ext.c * freeglut_ext.c
* *
* Functions related to OpenGL extensions. * Functions related to OpenGL extensions.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 9 1999 * Creation date: Thu Dec 9 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define GLX_GLXEXT_PROTOTYPES #define GLX_GLXEXT_PROTOTYPES
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
extern SFG_Proc fgPlatformGetProcAddress( const char *procName ); extern SFG_Proc fgPlatformGetProcAddress( const char *procName );
extern GLUTproc fgPlatformGetGLUTProcAddress( const char *procName ); extern GLUTproc fgPlatformGetGLUTProcAddress( const char *procName );
static GLUTproc fghGetGLUTProcAddress( const char* procName ) static GLUTproc fghGetGLUTProcAddress( const char* procName )
{ {
/* optimization: quick initial check */ /* optimization: quick initial check */
if( strncmp( procName, "glut", 4 ) != 0 ) if( strncmp( procName, "glut", 4 ) != 0 )
return NULL; return NULL;
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x; #define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
CHECK_NAME(glutInit); CHECK_NAME(glutInit);
CHECK_NAME(glutInitDisplayMode); CHECK_NAME(glutInitDisplayMode);
CHECK_NAME(glutInitDisplayString); CHECK_NAME(glutInitDisplayString);
CHECK_NAME(glutInitWindowPosition); CHECK_NAME(glutInitWindowPosition);
CHECK_NAME(glutInitWindowSize); CHECK_NAME(glutInitWindowSize);
CHECK_NAME(glutMainLoop); CHECK_NAME(glutMainLoop);
CHECK_NAME(glutExit); CHECK_NAME(glutExit);
CHECK_NAME(glutCreateWindow); CHECK_NAME(glutCreateWindow);
CHECK_NAME(glutCreateSubWindow); CHECK_NAME(glutCreateSubWindow);
CHECK_NAME(glutDestroyWindow); CHECK_NAME(glutDestroyWindow);
CHECK_NAME(glutPostRedisplay); CHECK_NAME(glutPostRedisplay);
CHECK_NAME(glutPostWindowRedisplay); CHECK_NAME(glutPostWindowRedisplay);
CHECK_NAME(glutSwapBuffers); CHECK_NAME(glutSwapBuffers);
CHECK_NAME(glutGetWindow); CHECK_NAME(glutGetWindow);
CHECK_NAME(glutSetWindow); CHECK_NAME(glutSetWindow);
CHECK_NAME(glutSetWindowTitle); CHECK_NAME(glutSetWindowTitle);
CHECK_NAME(glutSetIconTitle); CHECK_NAME(glutSetIconTitle);
CHECK_NAME(glutPositionWindow); CHECK_NAME(glutPositionWindow);
CHECK_NAME(glutReshapeWindow); CHECK_NAME(glutReshapeWindow);
CHECK_NAME(glutPopWindow); CHECK_NAME(glutPopWindow);
CHECK_NAME(glutPushWindow); CHECK_NAME(glutPushWindow);
CHECK_NAME(glutIconifyWindow); CHECK_NAME(glutIconifyWindow);
CHECK_NAME(glutShowWindow); CHECK_NAME(glutShowWindow);
CHECK_NAME(glutHideWindow); CHECK_NAME(glutHideWindow);
CHECK_NAME(glutFullScreen); CHECK_NAME(glutFullScreen);
CHECK_NAME(glutSetCursor); CHECK_NAME(glutSetCursor);
CHECK_NAME(glutWarpPointer); CHECK_NAME(glutWarpPointer);
CHECK_NAME(glutEstablishOverlay); CHECK_NAME(glutEstablishOverlay);
CHECK_NAME(glutRemoveOverlay); CHECK_NAME(glutRemoveOverlay);
CHECK_NAME(glutUseLayer); CHECK_NAME(glutUseLayer);
CHECK_NAME(glutPostOverlayRedisplay); CHECK_NAME(glutPostOverlayRedisplay);
CHECK_NAME(glutPostWindowOverlayRedisplay); CHECK_NAME(glutPostWindowOverlayRedisplay);
CHECK_NAME(glutShowOverlay); CHECK_NAME(glutShowOverlay);
CHECK_NAME(glutHideOverlay); CHECK_NAME(glutHideOverlay);
CHECK_NAME(glutCreateMenu); CHECK_NAME(glutCreateMenu);
CHECK_NAME(glutDestroyMenu); CHECK_NAME(glutDestroyMenu);
CHECK_NAME(glutGetMenu); CHECK_NAME(glutGetMenu);
CHECK_NAME(glutSetMenu); CHECK_NAME(glutSetMenu);
CHECK_NAME(glutAddMenuEntry); CHECK_NAME(glutAddMenuEntry);
CHECK_NAME(glutAddSubMenu); CHECK_NAME(glutAddSubMenu);
CHECK_NAME(glutChangeToMenuEntry); CHECK_NAME(glutChangeToMenuEntry);
CHECK_NAME(glutChangeToSubMenu); CHECK_NAME(glutChangeToSubMenu);
CHECK_NAME(glutRemoveMenuItem); CHECK_NAME(glutRemoveMenuItem);
CHECK_NAME(glutAttachMenu); CHECK_NAME(glutAttachMenu);
CHECK_NAME(glutDetachMenu); CHECK_NAME(glutDetachMenu);
CHECK_NAME(glutDisplayFunc); CHECK_NAME(glutDisplayFunc);
CHECK_NAME(glutReshapeFunc); CHECK_NAME(glutReshapeFunc);
CHECK_NAME(glutKeyboardFunc); CHECK_NAME(glutKeyboardFunc);
CHECK_NAME(glutMouseFunc); CHECK_NAME(glutMouseFunc);
CHECK_NAME(glutMultiEntryFunc); CHECK_NAME(glutMultiEntryFunc);
CHECK_NAME(glutMultiMotionFunc); CHECK_NAME(glutMultiMotionFunc);
CHECK_NAME(glutMultiButtonFunc); CHECK_NAME(glutMultiButtonFunc);
CHECK_NAME(glutMultiPassiveFunc); CHECK_NAME(glutMultiPassiveFunc);
CHECK_NAME(glutMotionFunc); CHECK_NAME(glutMotionFunc);
CHECK_NAME(glutPassiveMotionFunc); CHECK_NAME(glutPassiveMotionFunc);
CHECK_NAME(glutEntryFunc); CHECK_NAME(glutEntryFunc);
CHECK_NAME(glutVisibilityFunc); CHECK_NAME(glutVisibilityFunc);
CHECK_NAME(glutIdleFunc); CHECK_NAME(glutIdleFunc);
CHECK_NAME(glutTimerFunc); CHECK_NAME(glutTimerFunc);
CHECK_NAME(glutMenuStateFunc); CHECK_NAME(glutMenuStateFunc);
CHECK_NAME(glutSpecialFunc); CHECK_NAME(glutSpecialFunc);
CHECK_NAME(glutSpaceballMotionFunc); CHECK_NAME(glutSpaceballMotionFunc);
CHECK_NAME(glutSpaceballRotateFunc); CHECK_NAME(glutSpaceballRotateFunc);
CHECK_NAME(glutSpaceballButtonFunc); CHECK_NAME(glutSpaceballButtonFunc);
CHECK_NAME(glutButtonBoxFunc); CHECK_NAME(glutButtonBoxFunc);
CHECK_NAME(glutDialsFunc); CHECK_NAME(glutDialsFunc);
CHECK_NAME(glutTabletMotionFunc); CHECK_NAME(glutTabletMotionFunc);
CHECK_NAME(glutTabletButtonFunc); CHECK_NAME(glutTabletButtonFunc);
CHECK_NAME(glutMenuStatusFunc); CHECK_NAME(glutMenuStatusFunc);
CHECK_NAME(glutOverlayDisplayFunc); CHECK_NAME(glutOverlayDisplayFunc);
CHECK_NAME(glutWindowStatusFunc); CHECK_NAME(glutWindowStatusFunc);
CHECK_NAME(glutKeyboardUpFunc); CHECK_NAME(glutKeyboardUpFunc);
CHECK_NAME(glutSpecialUpFunc); CHECK_NAME(glutSpecialUpFunc);
CHECK_NAME(glutSetColor); CHECK_NAME(glutSetColor);
CHECK_NAME(glutGetColor); CHECK_NAME(glutGetColor);
CHECK_NAME(glutCopyColormap); CHECK_NAME(glutCopyColormap);
CHECK_NAME(glutGet); CHECK_NAME(glutGet);
CHECK_NAME(glutDeviceGet); CHECK_NAME(glutDeviceGet);
CHECK_NAME(glutExtensionSupported); CHECK_NAME(glutExtensionSupported);
CHECK_NAME(glutGetModifiers); CHECK_NAME(glutGetModifiers);
CHECK_NAME(glutLayerGet); CHECK_NAME(glutLayerGet);
CHECK_NAME(glutBitmapCharacter); CHECK_NAME(glutBitmapCharacter);
CHECK_NAME(glutBitmapWidth); CHECK_NAME(glutBitmapWidth);
CHECK_NAME(glutStrokeCharacter); CHECK_NAME(glutStrokeCharacter);
CHECK_NAME(glutStrokeWidth); CHECK_NAME(glutStrokeWidth);
CHECK_NAME(glutBitmapLength); CHECK_NAME(glutBitmapLength);
CHECK_NAME(glutStrokeLength); CHECK_NAME(glutStrokeLength);
CHECK_NAME(glutWireSphere); CHECK_NAME(glutWireSphere);
CHECK_NAME(glutSolidSphere); CHECK_NAME(glutSolidSphere);
CHECK_NAME(glutWireCone); CHECK_NAME(glutWireCone);
CHECK_NAME(glutSolidCone); CHECK_NAME(glutSolidCone);
CHECK_NAME(glutWireCube); CHECK_NAME(glutWireCube);
CHECK_NAME(glutSolidCube); CHECK_NAME(glutSolidCube);
CHECK_NAME(glutWireTorus); CHECK_NAME(glutWireTorus);
CHECK_NAME(glutSolidTorus); CHECK_NAME(glutSolidTorus);
CHECK_NAME(glutWireDodecahedron); CHECK_NAME(glutWireDodecahedron);
CHECK_NAME(glutSolidDodecahedron); CHECK_NAME(glutSolidDodecahedron);
CHECK_NAME(glutWireTeapot); CHECK_NAME(glutWireTeapot);
CHECK_NAME(glutSolidTeapot); CHECK_NAME(glutSolidTeapot);
CHECK_NAME(glutWireOctahedron); CHECK_NAME(glutWireOctahedron);
CHECK_NAME(glutSolidOctahedron); CHECK_NAME(glutSolidOctahedron);
CHECK_NAME(glutWireTetrahedron); CHECK_NAME(glutWireTetrahedron);
CHECK_NAME(glutSolidTetrahedron); CHECK_NAME(glutSolidTetrahedron);
CHECK_NAME(glutWireIcosahedron); CHECK_NAME(glutWireIcosahedron);
CHECK_NAME(glutSolidIcosahedron); CHECK_NAME(glutSolidIcosahedron);
CHECK_NAME(glutVideoResizeGet); CHECK_NAME(glutVideoResizeGet);
CHECK_NAME(glutSetupVideoResizing); CHECK_NAME(glutSetupVideoResizing);
CHECK_NAME(glutStopVideoResizing); CHECK_NAME(glutStopVideoResizing);
CHECK_NAME(glutVideoResize); CHECK_NAME(glutVideoResize);
CHECK_NAME(glutVideoPan); CHECK_NAME(glutVideoPan);
CHECK_NAME(glutReportErrors); CHECK_NAME(glutReportErrors);
CHECK_NAME(glutIgnoreKeyRepeat); CHECK_NAME(glutIgnoreKeyRepeat);
CHECK_NAME(glutSetKeyRepeat); CHECK_NAME(glutSetKeyRepeat);
/* freeglut extensions */ /* freeglut extensions */
CHECK_NAME(glutMainLoopEvent); CHECK_NAME(glutMainLoopEvent);
CHECK_NAME(glutLeaveMainLoop); CHECK_NAME(glutLeaveMainLoop);
CHECK_NAME(glutCloseFunc); CHECK_NAME(glutCloseFunc);
CHECK_NAME(glutWMCloseFunc); CHECK_NAME(glutWMCloseFunc);
CHECK_NAME(glutMenuDestroyFunc); CHECK_NAME(glutMenuDestroyFunc);
CHECK_NAME(glutFullScreenToggle); CHECK_NAME(glutFullScreenToggle);
CHECK_NAME(glutLeaveFullScreen); CHECK_NAME(glutLeaveFullScreen);
CHECK_NAME(glutSetOption); CHECK_NAME(glutSetOption);
CHECK_NAME(glutGetModeValues); CHECK_NAME(glutGetModeValues);
CHECK_NAME(glutSetWindowData); CHECK_NAME(glutSetWindowData);
CHECK_NAME(glutGetWindowData); CHECK_NAME(glutGetWindowData);
CHECK_NAME(glutSetMenuData); CHECK_NAME(glutSetMenuData);
CHECK_NAME(glutGetMenuData); CHECK_NAME(glutGetMenuData);
CHECK_NAME(glutBitmapHeight); CHECK_NAME(glutBitmapHeight);
CHECK_NAME(glutStrokeHeight); CHECK_NAME(glutStrokeHeight);
CHECK_NAME(glutBitmapString); CHECK_NAME(glutBitmapString);
CHECK_NAME(glutStrokeString); CHECK_NAME(glutStrokeString);
CHECK_NAME(glutWireRhombicDodecahedron); CHECK_NAME(glutWireRhombicDodecahedron);
CHECK_NAME(glutSolidRhombicDodecahedron); CHECK_NAME(glutSolidRhombicDodecahedron);
CHECK_NAME(glutWireSierpinskiSponge); CHECK_NAME(glutWireSierpinskiSponge);
CHECK_NAME(glutSolidSierpinskiSponge); CHECK_NAME(glutSolidSierpinskiSponge);
CHECK_NAME(glutWireCylinder); CHECK_NAME(glutWireCylinder);
CHECK_NAME(glutSolidCylinder); CHECK_NAME(glutSolidCylinder);
CHECK_NAME(glutGetProcAddress); CHECK_NAME(glutGetProcAddress);
CHECK_NAME(glutMouseWheelFunc); CHECK_NAME(glutMouseWheelFunc);
CHECK_NAME(glutJoystickGetNumAxes); CHECK_NAME(glutJoystickGetNumAxes);
CHECK_NAME(glutJoystickGetNumButtons); CHECK_NAME(glutJoystickGetNumButtons);
CHECK_NAME(glutJoystickNotWorking); CHECK_NAME(glutJoystickNotWorking);
CHECK_NAME(glutJoystickGetDeadBand); CHECK_NAME(glutJoystickGetDeadBand);
CHECK_NAME(glutJoystickSetDeadBand); CHECK_NAME(glutJoystickSetDeadBand);
CHECK_NAME(glutJoystickGetSaturation); CHECK_NAME(glutJoystickGetSaturation);
CHECK_NAME(glutJoystickSetSaturation); CHECK_NAME(glutJoystickSetSaturation);
CHECK_NAME(glutJoystickSetMinRange); CHECK_NAME(glutJoystickSetMinRange);
CHECK_NAME(glutJoystickSetMaxRange); CHECK_NAME(glutJoystickSetMaxRange);
CHECK_NAME(glutJoystickSetCenter); CHECK_NAME(glutJoystickSetCenter);
CHECK_NAME(glutJoystickGetMinRange); CHECK_NAME(glutJoystickGetMinRange);
CHECK_NAME(glutJoystickGetMaxRange); CHECK_NAME(glutJoystickGetMaxRange);
CHECK_NAME(glutJoystickGetCenter); CHECK_NAME(glutJoystickGetCenter);
CHECK_NAME(glutInitContextVersion); CHECK_NAME(glutInitContextVersion);
CHECK_NAME(glutInitContextFlags); CHECK_NAME(glutInitContextFlags);
CHECK_NAME(glutInitContextProfile); CHECK_NAME(glutInitContextProfile);
CHECK_NAME(glutInitErrorFunc); CHECK_NAME(glutInitErrorFunc);
CHECK_NAME(glutInitWarningFunc); CHECK_NAME(glutInitWarningFunc);
#undef CHECK_NAME #undef CHECK_NAME
return NULL; return NULL;
} }
GLUTproc FGAPIENTRY GLUTproc FGAPIENTRY
glutGetProcAddress( const char *procName ) glutGetProcAddress( const char *procName )
{ {
GLUTproc p; GLUTproc p;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
/* Try GLUT functions first, then core GL functions */ /* Try GLUT functions first, then core GL functions */
p = fghGetGLUTProcAddress( procName ); p = fghGetGLUTProcAddress( procName );
/* Some GLUT functions are platform-specific: */ /* Some GLUT functions are platform-specific: */
if ( !p ) if ( !p )
p = fgPlatformGetGLUTProcAddress( procName ); p = fgPlatformGetGLUTProcAddress( procName );
return ( p != NULL ) ? p : fgPlatformGetProcAddress( procName ); return ( p != NULL ) ? p : fgPlatformGetProcAddress( procName );
} }

View File

@ -1,384 +1,384 @@
/* /*
* freeglut_font.c * freeglut_font.c
* *
* Bitmap and stroke fonts displaying. * Bitmap and stroke fonts displaying.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* *
* Test things out ... * Test things out ...
*/ */
/* -- IMPORT DECLARATIONS -------------------------------------------------- */ /* -- IMPORT DECLARATIONS -------------------------------------------------- */
/* /*
* These are the font faces defined in freeglut_font_data.c file: * These are the font faces defined in freeglut_font_data.c file:
*/ */
extern SFG_Font fgFontFixed8x13; extern SFG_Font fgFontFixed8x13;
extern SFG_Font fgFontFixed9x15; extern SFG_Font fgFontFixed9x15;
extern SFG_Font fgFontHelvetica10; extern SFG_Font fgFontHelvetica10;
extern SFG_Font fgFontHelvetica12; extern SFG_Font fgFontHelvetica12;
extern SFG_Font fgFontHelvetica18; extern SFG_Font fgFontHelvetica18;
extern SFG_Font fgFontTimesRoman10; extern SFG_Font fgFontTimesRoman10;
extern SFG_Font fgFontTimesRoman24; extern SFG_Font fgFontTimesRoman24;
extern SFG_StrokeFont fgStrokeRoman; extern SFG_StrokeFont fgStrokeRoman;
extern SFG_StrokeFont fgStrokeMonoRoman; extern SFG_StrokeFont fgStrokeMonoRoman;
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
/* /*
* Matches a font ID with a SFG_Font structure pointer. * Matches a font ID with a SFG_Font structure pointer.
* This was changed to match the GLUT header style. * This was changed to match the GLUT header style.
*/ */
static SFG_Font* fghFontByID( void* font ) static SFG_Font* fghFontByID( void* font )
{ {
if( font == GLUT_BITMAP_8_BY_13 ) if( font == GLUT_BITMAP_8_BY_13 )
return &fgFontFixed8x13; return &fgFontFixed8x13;
if( font == GLUT_BITMAP_9_BY_15 ) if( font == GLUT_BITMAP_9_BY_15 )
return &fgFontFixed9x15; return &fgFontFixed9x15;
if( font == GLUT_BITMAP_HELVETICA_10 ) if( font == GLUT_BITMAP_HELVETICA_10 )
return &fgFontHelvetica10; return &fgFontHelvetica10;
if( font == GLUT_BITMAP_HELVETICA_12 ) if( font == GLUT_BITMAP_HELVETICA_12 )
return &fgFontHelvetica12; return &fgFontHelvetica12;
if( font == GLUT_BITMAP_HELVETICA_18 ) if( font == GLUT_BITMAP_HELVETICA_18 )
return &fgFontHelvetica18; return &fgFontHelvetica18;
if( font == GLUT_BITMAP_TIMES_ROMAN_10 ) if( font == GLUT_BITMAP_TIMES_ROMAN_10 )
return &fgFontTimesRoman10; return &fgFontTimesRoman10;
if( font == GLUT_BITMAP_TIMES_ROMAN_24 ) if( font == GLUT_BITMAP_TIMES_ROMAN_24 )
return &fgFontTimesRoman24; return &fgFontTimesRoman24;
fgWarning( "font 0x%08x not found", font ); fgWarning( "font 0x%08x not found", font );
return 0; return 0;
} }
/* /*
* Matches a font ID with a SFG_StrokeFont structure pointer. * Matches a font ID with a SFG_StrokeFont structure pointer.
* This was changed to match the GLUT header style. * This was changed to match the GLUT header style.
*/ */
static SFG_StrokeFont* fghStrokeByID( void* font ) static SFG_StrokeFont* fghStrokeByID( void* font )
{ {
if( font == GLUT_STROKE_ROMAN ) if( font == GLUT_STROKE_ROMAN )
return &fgStrokeRoman; return &fgStrokeRoman;
if( font == GLUT_STROKE_MONO_ROMAN ) if( font == GLUT_STROKE_MONO_ROMAN )
return &fgStrokeMonoRoman; return &fgStrokeMonoRoman;
fgWarning( "stroke font 0x%08x not found", font ); fgWarning( "stroke font 0x%08x not found", font );
return 0; return 0;
} }
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Draw a bitmap character * Draw a bitmap character
*/ */
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character ) void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
{ {
const GLubyte* face; const GLubyte* face;
SFG_Font* font; SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" );
font = fghFontByID( fontID ); font = fghFontByID( fontID );
freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) ); freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) );
freeglut_return_if_fail( font ); freeglut_return_if_fail( font );
/* /*
* Find the character we want to draw (???) * Find the character we want to draw (???)
*/ */
face = font->Characters[ character ]; face = font->Characters[ character ];
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE ); glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE ); glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glBitmap( glBitmap(
face[ 0 ], font->Height, /* The bitmap's width and height */ face[ 0 ], font->Height, /* The bitmap's width and height */
font->xorig, font->yorig, /* The origin in the font glyph */ font->xorig, font->yorig, /* The origin in the font glyph */
( float )( face[ 0 ] ), 0.0, /* The raster advance -- inc. x,y */ ( float )( face[ 0 ] ), 0.0, /* The raster advance -- inc. x,y */
( face + 1 ) /* The packed bitmap data... */ ( face + 1 ) /* The packed bitmap data... */
); );
glPopClientAttrib( ); glPopClientAttrib( );
} }
void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string ) void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
{ {
unsigned char c; unsigned char c;
float x = 0.0f ; float x = 0.0f ;
SFG_Font* font; SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
font = fghFontByID( fontID ); font = fghFontByID( fontID );
freeglut_return_if_fail( font ); freeglut_return_if_fail( font );
if ( !string || ! *string ) if ( !string || ! *string )
return; return;
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT ); glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE ); glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE ); glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
/* /*
* Step through the string, drawing each character. * Step through the string, drawing each character.
* A newline will simply translate the next character's insertion * A newline will simply translate the next character's insertion
* point back to the start of the line and down one line. * point back to the start of the line and down one line.
*/ */
while( ( c = *string++) ) while( ( c = *string++) )
if( c == '\n' ) if( c == '\n' )
{ {
glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL ); glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL );
x = 0.0f; x = 0.0f;
} }
else /* Not an EOL, draw the bitmap character */ else /* Not an EOL, draw the bitmap character */
{ {
const GLubyte* face = font->Characters[ c ]; const GLubyte* face = font->Characters[ c ];
glBitmap( glBitmap(
face[ 0 ], font->Height, /* Bitmap's width and height */ face[ 0 ], font->Height, /* Bitmap's width and height */
font->xorig, font->yorig, /* The origin in the font glyph */ font->xorig, font->yorig, /* The origin in the font glyph */
( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */ ( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */
( face + 1 ) /* The packed bitmap data... */ ( face + 1 ) /* The packed bitmap data... */
); );
x += ( float )( face[ 0 ] ); x += ( float )( face[ 0 ] );
} }
glPopClientAttrib( ); glPopClientAttrib( );
} }
/* /*
* Returns the width in pixels of a font's character * Returns the width in pixels of a font's character
*/ */
int FGAPIENTRY glutBitmapWidth( void* fontID, int character ) int FGAPIENTRY glutBitmapWidth( void* fontID, int character )
{ {
SFG_Font* font; SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" );
font = fghFontByID( fontID ); font = fghFontByID( fontID );
freeglut_return_val_if_fail( character > 0 && character < 256, 0 ); freeglut_return_val_if_fail( character > 0 && character < 256, 0 );
freeglut_return_val_if_fail( font, 0 ); freeglut_return_val_if_fail( font, 0 );
return *( font->Characters[ character ] ); return *( font->Characters[ character ] );
} }
/* /*
* Return the width of a string drawn using a bitmap font * Return the width of a string drawn using a bitmap font
*/ */
int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string ) int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string )
{ {
unsigned char c; unsigned char c;
int length = 0, this_line_length = 0; int length = 0, this_line_length = 0;
SFG_Font* font; SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" );
font = fghFontByID( fontID ); font = fghFontByID( fontID );
freeglut_return_val_if_fail( font, 0 ); freeglut_return_val_if_fail( font, 0 );
if ( !string || ! *string ) if ( !string || ! *string )
return 0; return 0;
while( ( c = *string++) ) while( ( c = *string++) )
{ {
if( c != '\n' )/* Not an EOL, increment length of line */ if( c != '\n' )/* Not an EOL, increment length of line */
this_line_length += *( font->Characters[ c ]); this_line_length += *( font->Characters[ c ]);
else /* EOL; reset the length of this line */ else /* EOL; reset the length of this line */
{ {
if( length < this_line_length ) if( length < this_line_length )
length = this_line_length; length = this_line_length;
this_line_length = 0; this_line_length = 0;
} }
} }
if ( length < this_line_length ) if ( length < this_line_length )
length = this_line_length; length = this_line_length;
return length; return length;
} }
/* /*
* Returns the height of a bitmap font * Returns the height of a bitmap font
*/ */
int FGAPIENTRY glutBitmapHeight( void* fontID ) int FGAPIENTRY glutBitmapHeight( void* fontID )
{ {
SFG_Font* font; SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" );
font = fghFontByID( fontID ); font = fghFontByID( fontID );
freeglut_return_val_if_fail( font, 0 ); freeglut_return_val_if_fail( font, 0 );
return font->Height; return font->Height;
} }
/* /*
* Draw a stroke character * Draw a stroke character
*/ */
void FGAPIENTRY glutStrokeCharacter( void* fontID, int character ) void FGAPIENTRY glutStrokeCharacter( void* fontID, int character )
{ {
const SFG_StrokeChar *schar; const SFG_StrokeChar *schar;
const SFG_StrokeStrip *strip; const SFG_StrokeStrip *strip;
int i, j; int i, j;
SFG_StrokeFont* font; SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" );
font = fghStrokeByID( fontID ); font = fghStrokeByID( fontID );
freeglut_return_if_fail( character >= 0 ); freeglut_return_if_fail( character >= 0 );
freeglut_return_if_fail( character < font->Quantity ); freeglut_return_if_fail( character < font->Quantity );
freeglut_return_if_fail( font ); freeglut_return_if_fail( font );
schar = font->Characters[ character ]; schar = font->Characters[ character ];
freeglut_return_if_fail( schar ); freeglut_return_if_fail( schar );
strip = schar->Strips; strip = schar->Strips;
for( i = 0; i < schar->Number; i++, strip++ ) for( i = 0; i < schar->Number; i++, strip++ )
{ {
glBegin( GL_LINE_STRIP ); glBegin( GL_LINE_STRIP );
for( j = 0; j < strip->Number; j++ ) for( j = 0; j < strip->Number; j++ )
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
glEnd( ); glEnd( );
glBegin( GL_POINTS ); glBegin( GL_POINTS );
for( j = 0; j < strip->Number; j++ ) for( j = 0; j < strip->Number; j++ )
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y ); glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
glEnd( ); glEnd( );
} }
glTranslatef( schar->Right, 0.0, 0.0 ); glTranslatef( schar->Right, 0.0, 0.0 );
} }
void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string ) void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
{ {
unsigned char c; unsigned char c;
int i, j; int i, j;
float length = 0.0; float length = 0.0;
SFG_StrokeFont* font; SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" );
font = fghStrokeByID( fontID ); font = fghStrokeByID( fontID );
freeglut_return_if_fail( font ); freeglut_return_if_fail( font );
if ( !string || ! *string ) if ( !string || ! *string )
return; return;
/* /*
* Step through the string, drawing each character. * Step through the string, drawing each character.
* A newline will simply translate the next character's insertion * A newline will simply translate the next character's insertion
* point back to the start of the line and down one line. * point back to the start of the line and down one line.
*/ */
while( ( c = *string++) ) while( ( c = *string++) )
if( c < font->Quantity ) if( c < font->Quantity )
{ {
if( c == '\n' ) if( c == '\n' )
{ {
glTranslatef ( -length, -( float )( font->Height ), 0.0 ); glTranslatef ( -length, -( float )( font->Height ), 0.0 );
length = 0.0; length = 0.0;
} }
else /* Not an EOL, draw the bitmap character */ else /* Not an EOL, draw the bitmap character */
{ {
const SFG_StrokeChar *schar = font->Characters[ c ]; const SFG_StrokeChar *schar = font->Characters[ c ];
if( schar ) if( schar )
{ {
const SFG_StrokeStrip *strip = schar->Strips; const SFG_StrokeStrip *strip = schar->Strips;
for( i = 0; i < schar->Number; i++, strip++ ) for( i = 0; i < schar->Number; i++, strip++ )
{ {
glBegin( GL_LINE_STRIP ); glBegin( GL_LINE_STRIP );
for( j = 0; j < strip->Number; j++ ) for( j = 0; j < strip->Number; j++ )
glVertex2f( strip->Vertices[ j ].X, glVertex2f( strip->Vertices[ j ].X,
strip->Vertices[ j ].Y); strip->Vertices[ j ].Y);
glEnd( ); glEnd( );
} }
length += schar->Right; length += schar->Right;
glTranslatef( schar->Right, 0.0, 0.0 ); glTranslatef( schar->Right, 0.0, 0.0 );
} }
} }
} }
} }
/* /*
* Return the width in pixels of a stroke character * Return the width in pixels of a stroke character
*/ */
int FGAPIENTRY glutStrokeWidth( void* fontID, int character ) int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
{ {
const SFG_StrokeChar *schar; const SFG_StrokeChar *schar;
SFG_StrokeFont* font; SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" );
font = fghStrokeByID( fontID ); font = fghStrokeByID( fontID );
freeglut_return_val_if_fail( ( character >= 0 ) && freeglut_return_val_if_fail( ( character >= 0 ) &&
( character < font->Quantity ), ( character < font->Quantity ),
0 0
); );
freeglut_return_val_if_fail( font, 0 ); freeglut_return_val_if_fail( font, 0 );
schar = font->Characters[ character ]; schar = font->Characters[ character ];
freeglut_return_val_if_fail( schar, 0 ); freeglut_return_val_if_fail( schar, 0 );
return ( int )( schar->Right + 0.5 ); return ( int )( schar->Right + 0.5 );
} }
/* /*
* Return the width of a string drawn using a stroke font * Return the width of a string drawn using a stroke font
*/ */
int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string ) int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
{ {
unsigned char c; unsigned char c;
float length = 0.0; float length = 0.0;
float this_line_length = 0.0; float this_line_length = 0.0;
SFG_StrokeFont* font; SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" );
font = fghStrokeByID( fontID ); font = fghStrokeByID( fontID );
freeglut_return_val_if_fail( font, 0 ); freeglut_return_val_if_fail( font, 0 );
if ( !string || ! *string ) if ( !string || ! *string )
return 0; return 0;
while( ( c = *string++) ) while( ( c = *string++) )
if( c < font->Quantity ) if( c < font->Quantity )
{ {
if( c == '\n' ) /* EOL; reset the length of this line */ if( c == '\n' ) /* EOL; reset the length of this line */
{ {
if( length < this_line_length ) if( length < this_line_length )
length = this_line_length; length = this_line_length;
this_line_length = 0.0; this_line_length = 0.0;
} }
else /* Not an EOL, increment the length of this line */ else /* Not an EOL, increment the length of this line */
{ {
const SFG_StrokeChar *schar = font->Characters[ c ]; const SFG_StrokeChar *schar = font->Characters[ c ];
if( schar ) if( schar )
this_line_length += schar->Right; this_line_length += schar->Right;
} }
} }
if( length < this_line_length ) if( length < this_line_length )
length = this_line_length; length = this_line_length;
return( int )( length + 0.5 ); return( int )( length + 0.5 );
} }
/* /*
* Returns the height of a stroke font * Returns the height of a stroke font
*/ */
GLfloat FGAPIENTRY glutStrokeHeight( void* fontID ) GLfloat FGAPIENTRY glutStrokeHeight( void* fontID )
{ {
SFG_StrokeFont* font; SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" );
font = fghStrokeByID( fontID ); font = fghStrokeByID( fontID );
freeglut_return_val_if_fail( font, 0.0 ); freeglut_return_val_if_fail( font, 0.0 );
return font->Height; return font->Height;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

View File

@ -1,179 +1,179 @@
/* /*
* freeglut_gamemode.c * freeglut_gamemode.c
* *
* The game mode handling code. * The game mode handling code.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* *
* glutGameModeString() -- missing * glutGameModeString() -- missing
* glutEnterGameMode() -- X11 version * glutEnterGameMode() -- X11 version
* glutLeaveGameMode() -- is that correct? * glutLeaveGameMode() -- is that correct?
* glutGameModeGet() -- is that correct? * glutGameModeGet() -- is that correct?
*/ */
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
extern void fgPlatformRememberState( void ); extern void fgPlatformRememberState( void );
extern void fgPlatformRestoreState( void ); extern void fgPlatformRestoreState( void );
extern GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest ); extern GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest );
extern void fgPlatformEnterGameMode( void ); extern void fgPlatformEnterGameMode( void );
extern void fgPlatformLeaveGameMode( void ); extern void fgPlatformLeaveGameMode( void );
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Sets the game mode display string * Sets the game mode display string
*/ */
void FGAPIENTRY glutGameModeString( const char* string ) void FGAPIENTRY glutGameModeString( const char* string )
{ {
int width = -1, height = -1, depth = -1, refresh = -1; int width = -1, height = -1, depth = -1, refresh = -1;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );
/* /*
* This one seems a bit easier than glutInitDisplayString. The bad thing * This one seems a bit easier than glutInitDisplayString. The bad thing
* about it that I was unable to find the game mode string definition, so * about it that I was unable to find the game mode string definition, so
* that I assumed it is: "[width]x[height]:[depth]@[refresh rate]", which * that I assumed it is: "[width]x[height]:[depth]@[refresh rate]", which
* appears in all GLUT game mode programs I have seen to date. * appears in all GLUT game mode programs I have seen to date.
*/ */
if( sscanf( string, "%ix%i:%i@%i", &width, &height, &depth, &refresh ) != if( sscanf( string, "%ix%i:%i@%i", &width, &height, &depth, &refresh ) !=
4 ) 4 )
if( sscanf( string, "%ix%i:%i", &width, &height, &depth ) != 3 ) if( sscanf( string, "%ix%i:%i", &width, &height, &depth ) != 3 )
if( sscanf( string, "%ix%i@%i", &width, &height, &refresh ) != 3 ) if( sscanf( string, "%ix%i@%i", &width, &height, &refresh ) != 3 )
if( sscanf( string, "%ix%i", &width, &height ) != 2 ) if( sscanf( string, "%ix%i", &width, &height ) != 2 )
if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 ) if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 )
if( sscanf( string, ":%i", &depth ) != 1 ) if( sscanf( string, ":%i", &depth ) != 1 )
if( sscanf( string, "@%i", &refresh ) != 1 ) if( sscanf( string, "@%i", &refresh ) != 1 )
fgWarning( fgWarning(
"unable to parse game mode string `%s'", "unable to parse game mode string `%s'",
string string
); );
/* All values not specified are now set to -1, which means those /* All values not specified are now set to -1, which means those
* aspects of the current display mode are not changed in * aspects of the current display mode are not changed in
* fgPlatformChangeDisplayMode() above. * fgPlatformChangeDisplayMode() above.
*/ */
fgState.GameModeSize.X = width; fgState.GameModeSize.X = width;
fgState.GameModeSize.Y = height; fgState.GameModeSize.Y = height;
fgState.GameModeDepth = depth; fgState.GameModeDepth = depth;
fgState.GameModeRefresh = refresh; fgState.GameModeRefresh = refresh;
} }
/* /*
* Enters the game mode * Enters the game mode
*/ */
int FGAPIENTRY glutEnterGameMode( void ) int FGAPIENTRY glutEnterGameMode( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );
if( fgStructure.GameModeWindow ) if( fgStructure.GameModeWindow )
fgAddToWindowDestroyList( fgStructure.GameModeWindow ); fgAddToWindowDestroyList( fgStructure.GameModeWindow );
else else
fgPlatformRememberState( ); fgPlatformRememberState( );
if( ! fgPlatformChangeDisplayMode( GL_FALSE ) ) if( ! fgPlatformChangeDisplayMode( GL_FALSE ) )
{ {
fgWarning( "failed to change screen settings" ); fgWarning( "failed to change screen settings" );
return 0; return 0;
} }
fgStructure.GameModeWindow = fgCreateWindow( fgStructure.GameModeWindow = fgCreateWindow(
NULL, "FREEGLUT", GL_TRUE, 0, 0, NULL, "FREEGLUT", GL_TRUE, 0, 0,
GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y,
GL_TRUE, GL_FALSE GL_TRUE, GL_FALSE
); );
fgStructure.GameModeWindow->State.Width = fgState.GameModeSize.X; fgStructure.GameModeWindow->State.Width = fgState.GameModeSize.X;
fgStructure.GameModeWindow->State.Height = fgState.GameModeSize.Y; fgStructure.GameModeWindow->State.Height = fgState.GameModeSize.Y;
fgStructure.GameModeWindow->State.NeedToResize = GL_TRUE; fgStructure.GameModeWindow->State.NeedToResize = GL_TRUE;
fgPlatformEnterGameMode(); fgPlatformEnterGameMode();
return fgStructure.GameModeWindow->ID; return fgStructure.GameModeWindow->ID;
} }
/* /*
* Leaves the game mode * Leaves the game mode
*/ */
void FGAPIENTRY glutLeaveGameMode( void ) void FGAPIENTRY glutLeaveGameMode( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" );
freeglut_return_if_fail( fgStructure.GameModeWindow ); freeglut_return_if_fail( fgStructure.GameModeWindow );
fgAddToWindowDestroyList( fgStructure.GameModeWindow ); fgAddToWindowDestroyList( fgStructure.GameModeWindow );
fgStructure.GameModeWindow = NULL; fgStructure.GameModeWindow = NULL;
fgPlatformLeaveGameMode(); fgPlatformLeaveGameMode();
fgPlatformRestoreState(); fgPlatformRestoreState();
} }
/* /*
* Returns information concerning the freeglut game mode * Returns information concerning the freeglut game mode
*/ */
int FGAPIENTRY glutGameModeGet( GLenum eWhat ) int FGAPIENTRY glutGameModeGet( GLenum eWhat )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" );
switch( eWhat ) switch( eWhat )
{ {
case GLUT_GAME_MODE_ACTIVE: case GLUT_GAME_MODE_ACTIVE:
return !!fgStructure.GameModeWindow; return !!fgStructure.GameModeWindow;
case GLUT_GAME_MODE_POSSIBLE: case GLUT_GAME_MODE_POSSIBLE:
return fgPlatformChangeDisplayMode( GL_TRUE ); return fgPlatformChangeDisplayMode( GL_TRUE );
case GLUT_GAME_MODE_WIDTH: case GLUT_GAME_MODE_WIDTH:
return fgState.GameModeSize.X; return fgState.GameModeSize.X;
case GLUT_GAME_MODE_HEIGHT: case GLUT_GAME_MODE_HEIGHT:
return fgState.GameModeSize.Y; return fgState.GameModeSize.Y;
case GLUT_GAME_MODE_PIXEL_DEPTH: case GLUT_GAME_MODE_PIXEL_DEPTH:
return fgState.GameModeDepth; return fgState.GameModeDepth;
case GLUT_GAME_MODE_REFRESH_RATE: case GLUT_GAME_MODE_REFRESH_RATE:
return fgState.GameModeRefresh; return fgState.GameModeRefresh;
case GLUT_GAME_MODE_DISPLAY_CHANGED: case GLUT_GAME_MODE_DISPLAY_CHANGED:
/* /*
* This is true if the game mode has been activated successfully.. * This is true if the game mode has been activated successfully..
*/ */
return !!fgStructure.GameModeWindow; return !!fgStructure.GameModeWindow;
} }
fgWarning( "Unknown gamemode get: %d", eWhat ); fgWarning( "Unknown gamemode get: %d", eWhat );
return -1; return -1;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,213 +1,213 @@
/* /*
* freeglut_input_devices.c * freeglut_input_devices.c
* *
* Handles miscellaneous input devices via direct serial-port access. * Handles miscellaneous input devices via direct serial-port access.
* Proper X11 XInput device support is not yet supported. * Proper X11 XInput device support is not yet supported.
* Also lacks Mac support. * Also lacks Mac support.
* *
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005 * Written by Joe Krahn <krahn@niehs.nih.gov> 2005
* *
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA OR STEPHEN J. BAKER BE LIABLE FOR ANY CLAIM, DAMAGES OR * PAWEL W. OLSZTA OR STEPHEN J. BAKER BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 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 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
typedef struct _serialport SERIALPORT; typedef struct _serialport SERIALPORT;
/********************* Dialbox definitions ***********************/ /********************* Dialbox definitions ***********************/
#define DIAL_NUM_VALUATORS 8 #define DIAL_NUM_VALUATORS 8
/* dial parser state machine states */ /* dial parser state machine states */
#define DIAL_NEW (-1) #define DIAL_NEW (-1)
#define DIAL_WHICH_DEVICE 0 #define DIAL_WHICH_DEVICE 0
#define DIAL_VALUE_HIGH 1 #define DIAL_VALUE_HIGH 1
#define DIAL_VALUE_LOW 2 #define DIAL_VALUE_LOW 2
/* dial/button box commands */ /* dial/button box commands */
#define DIAL_INITIALIZE 0x20 #define DIAL_INITIALIZE 0x20
#define DIAL_SET_LEDS 0x75 #define DIAL_SET_LEDS 0x75
#define DIAL_SET_TEXT 0x61 #define DIAL_SET_TEXT 0x61
#define DIAL_SET_AUTO_DIALS 0x50 #define DIAL_SET_AUTO_DIALS 0x50
#define DIAL_SET_AUTO_DELTA_DIALS 0x51 #define DIAL_SET_AUTO_DELTA_DIALS 0x51
#define DIAL_SET_FILTER 0x53 #define DIAL_SET_FILTER 0x53
#define DIAL_SET_BUTTONS_MOM_TYPE 0x71 #define DIAL_SET_BUTTONS_MOM_TYPE 0x71
#define DIAL_SET_AUTO_MOM_BUTTONS 0x73 #define DIAL_SET_AUTO_MOM_BUTTONS 0x73
#define DIAL_SET_ALL_LEDS 0x4b #define DIAL_SET_ALL_LEDS 0x4b
#define DIAL_CLEAR_ALL_LEDS 0x4c #define DIAL_CLEAR_ALL_LEDS 0x4c
/* dial/button box replies and events */ /* dial/button box replies and events */
#define DIAL_INITIALIZED 0x20 #define DIAL_INITIALIZED 0x20
#define DIAL_BASE 0x30 #define DIAL_BASE 0x30
#define DIAL_DELTA_BASE 0x40 #define DIAL_DELTA_BASE 0x40
#define DIAL_PRESS_BASE 0xc0 #define DIAL_PRESS_BASE 0xc0
#define DIAL_RELEASE_BASE 0xe0 #define DIAL_RELEASE_BASE 0xe0
/* macros to determine reply type */ /* macros to determine reply type */
#define IS_DIAL_EVENT(ch) (((ch)>=DIAL_BASE)&&((ch)<DIAL_BASE+DIAL_NUM_VALUATORS)) #define IS_DIAL_EVENT(ch) (((ch)>=DIAL_BASE)&&((ch)<DIAL_BASE+DIAL_NUM_VALUATORS))
#define IS_KEY_PRESS(ch) (((ch)>=DIAL_PRESS_BASE)&&((ch)<DIAL_PRESS_BASE+DIAL_NUM_BUTTONS)) #define IS_KEY_PRESS(ch) (((ch)>=DIAL_PRESS_BASE)&&((ch)<DIAL_PRESS_BASE+DIAL_NUM_BUTTONS))
#define IS_KEY_RELEASE(ch) (((ch)>=DIAL_RELEASE_BASE)&&((ch)<DIAL_RELEASE_BASE+DIAL_NUM_BUTTONS)) #define IS_KEY_RELEASE(ch) (((ch)>=DIAL_RELEASE_BASE)&&((ch)<DIAL_RELEASE_BASE+DIAL_NUM_BUTTONS))
#define IS_INIT_EVENT(ch) ((ch)==DIAL_INITIALIZED) #define IS_INIT_EVENT(ch) ((ch)==DIAL_INITIALIZED)
/*****************************************************************/ /*****************************************************************/
extern SERIALPORT *serial_open ( const char *device ); extern SERIALPORT *serial_open ( const char *device );
extern void serial_close ( SERIALPORT *port ); extern void serial_close ( SERIALPORT *port );
extern int serial_getchar ( SERIALPORT *port ); extern int serial_getchar ( SERIALPORT *port );
extern int serial_putchar ( SERIALPORT *port, unsigned char ch ); extern int serial_putchar ( SERIALPORT *port, unsigned char ch );
extern void serial_flush ( SERIALPORT *port ); extern void serial_flush ( SERIALPORT *port );
extern void fgPlatformRegisterDialDevice ( const char *dial_device ); extern void fgPlatformRegisterDialDevice ( const char *dial_device );
static void send_dial_event(int dial, int value); static void send_dial_event(int dial, int value);
static void poll_dials(int id); static void poll_dials(int id);
/* local variables */ /* local variables */
static SERIALPORT *dialbox_port=NULL; static SERIALPORT *dialbox_port=NULL;
/*****************************************************************/ /*****************************************************************/
/* /*
* Implementation for glutDeviceGet(GLUT_HAS_DIAL_AND_BUTTON_BOX) * Implementation for glutDeviceGet(GLUT_HAS_DIAL_AND_BUTTON_BOX)
*/ */
int fgInputDeviceDetect( void ) int fgInputDeviceDetect( void )
{ {
fgInitialiseInputDevices (); fgInitialiseInputDevices ();
if ( !dialbox_port ) if ( !dialbox_port )
return 0; return 0;
if ( !fgState.InputDevsInitialised ) if ( !fgState.InputDevsInitialised )
return 0; return 0;
return 1; return 1;
} }
/* /*
* Try initializing the input device(s) * Try initializing the input device(s)
*/ */
void fgInitialiseInputDevices ( void ) void fgInitialiseInputDevices ( void )
{ {
if( !fgState.InputDevsInitialised ) if( !fgState.InputDevsInitialised )
{ {
const char *dial_device=NULL; const char *dial_device=NULL;
dial_device = getenv ( "GLUT_DIALS_SERIAL" ); dial_device = getenv ( "GLUT_DIALS_SERIAL" );
fgPlatformRegisterDialDevice ( dial_device ); fgPlatformRegisterDialDevice ( dial_device );
if ( !dial_device ) return; if ( !dial_device ) return;
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
serial_putchar(dialbox_port,DIAL_INITIALIZE); serial_putchar(dialbox_port,DIAL_INITIALIZE);
glutTimerFunc ( 10, poll_dials, 0 ); glutTimerFunc ( 10, poll_dials, 0 );
fgState.InputDevsInitialised = GL_TRUE; fgState.InputDevsInitialised = GL_TRUE;
} }
} }
/* /*
* *
*/ */
void fgInputDeviceClose( void ) void fgInputDeviceClose( void )
{ {
if ( fgState.InputDevsInitialised ) if ( fgState.InputDevsInitialised )
{ {
serial_close ( dialbox_port ); serial_close ( dialbox_port );
dialbox_port = NULL; dialbox_port = NULL;
fgState.InputDevsInitialised = GL_FALSE; fgState.InputDevsInitialised = GL_FALSE;
} }
} }
/********************************************************************/ /********************************************************************/
/* Check all windows for dialbox callbacks */ /* Check all windows for dialbox callbacks */
static void fghcbEnumDialCallbacks ( SFG_Window *window, SFG_Enumerator *enumerator ) static void fghcbEnumDialCallbacks ( SFG_Window *window, SFG_Enumerator *enumerator )
{ {
/* Built-in to INVOKE_WCB(): if window->Callbacks[CB_Dials] */ /* Built-in to INVOKE_WCB(): if window->Callbacks[CB_Dials] */
INVOKE_WCB ( *window,Dials, ( ((int*)enumerator->data)[0], ((int*)enumerator->data)[1]) ); INVOKE_WCB ( *window,Dials, ( ((int*)enumerator->data)[0], ((int*)enumerator->data)[1]) );
fgEnumSubWindows ( window, fghcbEnumDialCallbacks, enumerator ); fgEnumSubWindows ( window, fghcbEnumDialCallbacks, enumerator );
} }
static void send_dial_event ( int num, int value ) static void send_dial_event ( int num, int value )
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
int data[2]; int data[2];
data[0] = num; data[0] = num;
data[1] = value; data[1] = value;
enumerator.found = GL_FALSE; enumerator.found = GL_FALSE;
enumerator.data = data; enumerator.data = data;
fgEnumWindows ( fghcbEnumDialCallbacks, &enumerator ); fgEnumWindows ( fghcbEnumDialCallbacks, &enumerator );
} }
/********************************************************************/ /********************************************************************/
static void poll_dials ( int id ) static void poll_dials ( int id )
{ {
int data; int data;
static int dial_state = DIAL_NEW; static int dial_state = DIAL_NEW;
static int dial_which; static int dial_which;
static int dial_value; static int dial_value;
static int dials[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static int dials[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
if ( !dialbox_port ) return; if ( !dialbox_port ) return;
while ( (data=serial_getchar(dialbox_port)) != EOF ) while ( (data=serial_getchar(dialbox_port)) != EOF )
{ {
if ( ( dial_state > DIAL_WHICH_DEVICE ) || IS_DIAL_EVENT ( data ) ) if ( ( dial_state > DIAL_WHICH_DEVICE ) || IS_DIAL_EVENT ( data ) )
{ {
switch ( dial_state ) switch ( dial_state )
{ {
case DIAL_WHICH_DEVICE: case DIAL_WHICH_DEVICE:
dial_which = data - DIAL_BASE; dial_which = data - DIAL_BASE;
dial_state++; dial_state++;
break; break;
case DIAL_VALUE_HIGH: case DIAL_VALUE_HIGH:
dial_value = ( data << 8 ); dial_value = ( data << 8 );
dial_state++; dial_state++;
break; break;
case DIAL_VALUE_LOW: case DIAL_VALUE_LOW:
dial_value |= data; dial_value |= data;
if ( dial_value & 0x8000 ) dial_value -= 0x10000; if ( dial_value & 0x8000 ) dial_value -= 0x10000;
dials[dial_which] = dial_value; dials[dial_which] = dial_value;
send_dial_event ( dial_which + 1, dial_value * 360 / 256 ); send_dial_event ( dial_which + 1, dial_value * 360 / 256 );
dial_state = DIAL_WHICH_DEVICE; dial_state = DIAL_WHICH_DEVICE;
break; break;
default: default:
/* error: Impossible state value! */ /* error: Impossible state value! */
break; break;
} }
} }
else if ( data == DIAL_INITIALIZED ) else if ( data == DIAL_INITIALIZED )
{ {
fgState.InputDevsInitialised = GL_TRUE; fgState.InputDevsInitialised = GL_TRUE;
dial_state = DIAL_WHICH_DEVICE; dial_state = DIAL_WHICH_DEVICE;
serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS); serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS);
serial_putchar(dialbox_port,0xff); serial_putchar(dialbox_port,0xff);
serial_putchar(dialbox_port,0xff); serial_putchar(dialbox_port,0xff);
} }
else /* Unknown data; try flushing. */ else /* Unknown data; try flushing. */
serial_flush(dialbox_port); serial_flush(dialbox_port);
} }
glutTimerFunc ( 2, poll_dials, 0 ); glutTimerFunc ( 2, poll_dials, 0 );
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,476 +1,476 @@
/* /*
* freeglut_main.c * freeglut_main.c
* *
* The windows message processing methods. * The windows message processing methods.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Fri Dec 3 1999 * Creation date: Fri Dec 3 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
# include <errno.h> # include <errno.h>
#endif #endif
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_VFPRINTF #ifdef HAVE_VFPRINTF
# define VFPRINTF(s,f,a) vfprintf((s),(f),(a)) # define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
#elif defined(HAVE__DOPRNT) #elif defined(HAVE__DOPRNT)
# define VFPRINTF(s,f,a) _doprnt((f),(a),(s)) # define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
#else #else
# define VFPRINTF(s,f,a) # define VFPRINTF(s,f,a)
#endif #endif
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
typedef struct GXDisplayProperties GXDisplayProperties; typedef struct GXDisplayProperties GXDisplayProperties;
typedef struct GXKeyList GXKeyList; typedef struct GXKeyList GXKeyList;
#include <gx.h> #include <gx.h>
typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int); typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
typedef int (*GXOPENINPUT)(); typedef int (*GXOPENINPUT)();
GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL; GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
GXOPENINPUT GXOpenInput_ = NULL; GXOPENINPUT GXOpenInput_ = NULL;
struct GXKeyList gxKeyList; struct GXKeyList gxKeyList;
#endif /* _WIN32_WCE */ #endif /* _WIN32_WCE */
/* /*
* Try to get the maximum value allowed for ints, falling back to the minimum * Try to get the maximum value allowed for ints, falling back to the minimum
* guaranteed by ISO C99 if there is no suitable header. * guaranteed by ISO C99 if there is no suitable header.
*/ */
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
# include <limits.h> # include <limits.h>
#endif #endif
#ifndef INT_MAX #ifndef INT_MAX
# define INT_MAX 32767 # define INT_MAX 32767
#endif #endif
#ifndef MIN #ifndef MIN
# define MIN(a,b) (((a)<(b)) ? (a) : (b)) # define MIN(a,b) (((a)<(b)) ? (a) : (b))
#endif #endif
extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ); extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
extern void fgPlatformDisplayWindow ( SFG_Window *window ); extern void fgPlatformDisplayWindow ( SFG_Window *window );
extern unsigned long fgPlatformSystemTime ( void ); extern unsigned long fgPlatformSystemTime ( void );
extern void fgPlatformSleepForEvents( long msec ); extern void fgPlatformSleepForEvents( long msec );
extern void fgPlatformProcessSingleEvent ( void ); extern void fgPlatformProcessSingleEvent ( void );
extern void fgPlatformMainLoopPreliminaryWork ( void ); extern void fgPlatformMainLoopPreliminaryWork ( void );
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
static void fghReshapeWindow ( SFG_Window *window, int width, int height ) static void fghReshapeWindow ( SFG_Window *window, int width, int height )
{ {
SFG_Window *current_window = fgStructure.CurrentWindow; SFG_Window *current_window = fgStructure.CurrentWindow;
freeglut_return_if_fail( window != NULL ); freeglut_return_if_fail( window != NULL );
fgPlatformReshapeWindow ( window, width, height ); fgPlatformReshapeWindow ( window, width, height );
if( FETCH_WCB( *window, Reshape ) ) if( FETCH_WCB( *window, Reshape ) )
INVOKE_WCB( *window, Reshape, ( width, height ) ); INVOKE_WCB( *window, Reshape, ( width, height ) );
else else
{ {
fgSetWindow( window ); fgSetWindow( window );
glViewport( 0, 0, width, height ); glViewport( 0, 0, width, height );
} }
/* /*
* Force a window redraw. In Windows at least this is only a partial * Force a window redraw. In Windows at least this is only a partial
* solution: if the window is increasing in size in either dimension, * solution: if the window is increasing in size in either dimension,
* the already-drawn part does not get drawn again and things look funny. * the already-drawn part does not get drawn again and things look funny.
* But without this we get this bad behaviour whenever we resize the * But without this we get this bad behaviour whenever we resize the
* window. * window.
*/ */
window->State.Redisplay = GL_TRUE; window->State.Redisplay = GL_TRUE;
if( window->IsMenu ) if( window->IsMenu )
fgSetWindow( current_window ); fgSetWindow( current_window );
} }
/* /*
* Calls a window's redraw method. This is used when * Calls a window's redraw method. This is used when
* a redraw is forced by the incoming window messages. * a redraw is forced by the incoming window messages.
*/ */
void fghRedrawWindow ( SFG_Window *window ) void fghRedrawWindow ( SFG_Window *window )
{ {
SFG_Window *current_window = fgStructure.CurrentWindow; SFG_Window *current_window = fgStructure.CurrentWindow;
freeglut_return_if_fail( window ); freeglut_return_if_fail( window );
freeglut_return_if_fail( FETCH_WCB ( *window, Display ) ); freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
window->State.Redisplay = GL_FALSE; window->State.Redisplay = GL_FALSE;
freeglut_return_if_fail( window->State.Visible ); freeglut_return_if_fail( window->State.Visible );
fgSetWindow( window ); fgSetWindow( window );
if( window->State.NeedToResize ) if( window->State.NeedToResize )
{ {
fghReshapeWindow( fghReshapeWindow(
window, window,
window->State.Width, window->State.Width,
window->State.Height window->State.Height
); );
window->State.NeedToResize = GL_FALSE; window->State.NeedToResize = GL_FALSE;
} }
INVOKE_WCB( *window, Display, ( ) ); INVOKE_WCB( *window, Display, ( ) );
fgSetWindow( current_window ); fgSetWindow( current_window );
} }
static void fghcbDisplayWindow( SFG_Window *window, static void fghcbDisplayWindow( SFG_Window *window,
SFG_Enumerator *enumerator ) SFG_Enumerator *enumerator )
{ {
if( window->State.Redisplay && if( window->State.Redisplay &&
window->State.Visible ) window->State.Visible )
{ {
window->State.Redisplay = GL_FALSE; window->State.Redisplay = GL_FALSE;
fgPlatformDisplayWindow ( window ); fgPlatformDisplayWindow ( window );
} }
fgEnumSubWindows( window, fghcbDisplayWindow, enumerator ); fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
} }
/* /*
* Make all windows perform a display call * Make all windows perform a display call
*/ */
static void fghDisplayAll( void ) static void fghDisplayAll( void )
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
enumerator.found = GL_FALSE; enumerator.found = GL_FALSE;
enumerator.data = NULL; enumerator.data = NULL;
fgEnumWindows( fghcbDisplayWindow, &enumerator ); fgEnumWindows( fghcbDisplayWindow, &enumerator );
} }
/* /*
* Window enumerator callback to check for the joystick polling code * Window enumerator callback to check for the joystick polling code
*/ */
static void fghcbCheckJoystickPolls( SFG_Window *window, static void fghcbCheckJoystickPolls( SFG_Window *window,
SFG_Enumerator *enumerator ) SFG_Enumerator *enumerator )
{ {
long int checkTime = fgElapsedTime( ); long int checkTime = fgElapsedTime( );
if( window->State.JoystickLastPoll + window->State.JoystickPollRate <= if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
checkTime ) checkTime )
{ {
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
fgJoystickPollWindow( window ); fgJoystickPollWindow( window );
#endif /* !defined(_WIN32_WCE) */ #endif /* !defined(_WIN32_WCE) */
window->State.JoystickLastPoll = checkTime; window->State.JoystickLastPoll = checkTime;
} }
fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator ); fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
} }
/* /*
* Check all windows for joystick polling * Check all windows for joystick polling
*/ */
static void fghCheckJoystickPolls( void ) static void fghCheckJoystickPolls( void )
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
enumerator.found = GL_FALSE; enumerator.found = GL_FALSE;
enumerator.data = NULL; enumerator.data = NULL;
fgEnumWindows( fghcbCheckJoystickPolls, &enumerator ); fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
} }
/* /*
* Check the global timers * Check the global timers
*/ */
static void fghCheckTimers( void ) static void fghCheckTimers( void )
{ {
long checkTime = fgElapsedTime( ); long checkTime = fgElapsedTime( );
while( fgState.Timers.First ) while( fgState.Timers.First )
{ {
SFG_Timer *timer = fgState.Timers.First; SFG_Timer *timer = fgState.Timers.First;
if( timer->TriggerTime > checkTime ) if( timer->TriggerTime > checkTime )
break; break;
fgListRemove( &fgState.Timers, &timer->Node ); fgListRemove( &fgState.Timers, &timer->Node );
fgListAppend( &fgState.FreeTimers, &timer->Node ); fgListAppend( &fgState.FreeTimers, &timer->Node );
timer->Callback( timer->ID ); timer->Callback( timer->ID );
} }
} }
/* Platform-dependent time in milliseconds, as an unsigned 32-bit integer. /* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
* This value wraps every 49.7 days, but integer overflows cancel * This value wraps every 49.7 days, but integer overflows cancel
* when subtracting an initial start time, unless the total time exceeds * when subtracting an initial start time, unless the total time exceeds
* 32-bit, where the GLUT API return value is also overflowed. * 32-bit, where the GLUT API return value is also overflowed.
*/ */
unsigned long fgSystemTime(void) unsigned long fgSystemTime(void)
{ {
return fgPlatformSystemTime (); return fgPlatformSystemTime ();
} }
/* /*
* Elapsed Time * Elapsed Time
*/ */
long fgElapsedTime( void ) long fgElapsedTime( void )
{ {
return (long) (fgSystemTime() - fgState.Time); return (long) (fgSystemTime() - fgState.Time);
} }
/* /*
* Error Messages. * Error Messages.
*/ */
void fgError( const char *fmt, ... ) void fgError( const char *fmt, ... )
{ {
va_list ap; va_list ap;
if (fgState.ErrorFunc) { if (fgState.ErrorFunc) {
va_start( ap, fmt ); va_start( ap, fmt );
/* call user set error handler here */ /* call user set error handler here */
fgState.ErrorFunc(fmt, ap); fgState.ErrorFunc(fmt, ap);
va_end( ap ); va_end( ap );
} else { } else {
va_start( ap, fmt ); va_start( ap, fmt );
fprintf( stderr, "freeglut "); fprintf( stderr, "freeglut ");
if( fgState.ProgramName ) if( fgState.ProgramName )
fprintf( stderr, "(%s): ", fgState.ProgramName ); fprintf( stderr, "(%s): ", fgState.ProgramName );
VFPRINTF( stderr, fmt, ap ); VFPRINTF( stderr, fmt, ap );
fprintf( stderr, "\n" ); fprintf( stderr, "\n" );
va_end( ap ); va_end( ap );
if ( fgState.Initialised ) if ( fgState.Initialised )
fgDeinitialize (); fgDeinitialize ();
exit( 1 ); exit( 1 );
} }
} }
void fgWarning( const char *fmt, ... ) void fgWarning( const char *fmt, ... )
{ {
va_list ap; va_list ap;
if (fgState.WarningFunc) { if (fgState.WarningFunc) {
va_start( ap, fmt ); va_start( ap, fmt );
/* call user set warning handler here */ /* call user set warning handler here */
fgState.WarningFunc(fmt, ap); fgState.WarningFunc(fmt, ap);
va_end( ap ); va_end( ap );
} else { } else {
va_start( ap, fmt ); va_start( ap, fmt );
fprintf( stderr, "freeglut "); fprintf( stderr, "freeglut ");
if( fgState.ProgramName ) if( fgState.ProgramName )
fprintf( stderr, "(%s): ", fgState.ProgramName ); fprintf( stderr, "(%s): ", fgState.ProgramName );
VFPRINTF( stderr, fmt, ap ); VFPRINTF( stderr, fmt, ap );
fprintf( stderr, "\n" ); fprintf( stderr, "\n" );
va_end( ap ); va_end( ap );
} }
} }
/* /*
* Indicates whether Joystick events are being used by ANY window. * Indicates whether Joystick events are being used by ANY window.
* *
* The current mechanism is to walk all of the windows and ask if * The current mechanism is to walk all of the windows and ask if
* there is a joystick callback. We have a short-circuit early * there is a joystick callback. We have a short-circuit early
* return if we find any joystick handler registered. * return if we find any joystick handler registered.
* *
* The real way to do this is to make use of the glutTimer() API * The real way to do this is to make use of the glutTimer() API
* to more cleanly re-implement the joystick API. Then, this code * to more cleanly re-implement the joystick API. Then, this code
* and all other "joystick timer" code can be yanked. * and all other "joystick timer" code can be yanked.
* *
*/ */
static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e) static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
{ {
if( FETCH_WCB( *w, Joystick ) ) if( FETCH_WCB( *w, Joystick ) )
{ {
e->found = GL_TRUE; e->found = GL_TRUE;
e->data = w; e->data = w;
} }
fgEnumSubWindows( w, fghCheckJoystickCallback, e ); fgEnumSubWindows( w, fghCheckJoystickCallback, e );
} }
static int fghHaveJoystick( void ) static int fghHaveJoystick( void )
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
enumerator.found = GL_FALSE; enumerator.found = GL_FALSE;
enumerator.data = NULL; enumerator.data = NULL;
fgEnumWindows( fghCheckJoystickCallback, &enumerator ); fgEnumWindows( fghCheckJoystickCallback, &enumerator );
return !!enumerator.data; return !!enumerator.data;
} }
static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e) static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
{ {
if( w->State.Redisplay && w->State.Visible ) if( w->State.Redisplay && w->State.Visible )
{ {
e->found = GL_TRUE; e->found = GL_TRUE;
e->data = w; e->data = w;
} }
fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e ); fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
} }
static int fghHavePendingRedisplays (void) static int fghHavePendingRedisplays (void)
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
enumerator.found = GL_FALSE; enumerator.found = GL_FALSE;
enumerator.data = NULL; enumerator.data = NULL;
fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator ); fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
return !!enumerator.data; return !!enumerator.data;
} }
/* /*
* Returns the number of GLUT ticks (milliseconds) till the next timer event. * Returns the number of GLUT ticks (milliseconds) till the next timer event.
*/ */
static long fghNextTimer( void ) static long fghNextTimer( void )
{ {
long ret = INT_MAX; long ret = INT_MAX;
SFG_Timer *timer = fgState.Timers.First; SFG_Timer *timer = fgState.Timers.First;
if( timer ) if( timer )
ret = timer->TriggerTime - fgElapsedTime(); ret = timer->TriggerTime - fgElapsedTime();
if( ret < 0 ) if( ret < 0 )
ret = 0; ret = 0;
return ret; return ret;
} }
static void fghSleepForEvents( void ) static void fghSleepForEvents( void )
{ {
long msec; long msec;
if( fgState.IdleCallback || fghHavePendingRedisplays( ) ) if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
return; return;
msec = fghNextTimer( ); msec = fghNextTimer( );
/* XXX Use GLUT timers for joysticks... */ /* XXX Use GLUT timers for joysticks... */
/* XXX Dumb; forces granularity to .01sec */ /* XXX Dumb; forces granularity to .01sec */
if( fghHaveJoystick( ) && ( msec > 10 ) ) if( fghHaveJoystick( ) && ( msec > 10 ) )
msec = 10; msec = 10;
fgPlatformSleepForEvents ( msec ); fgPlatformSleepForEvents ( msec );
} }
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Executes a single iteration in the freeglut processing loop. * Executes a single iteration in the freeglut processing loop.
*/ */
void FGAPIENTRY glutMainLoopEvent( void ) void FGAPIENTRY glutMainLoopEvent( void )
{ {
fgPlatformProcessSingleEvent (); fgPlatformProcessSingleEvent ();
if( fgState.Timers.First ) if( fgState.Timers.First )
fghCheckTimers( ); fghCheckTimers( );
fghCheckJoystickPolls( ); fghCheckJoystickPolls( );
fghDisplayAll( ); fghDisplayAll( );
fgCloseWindows( ); fgCloseWindows( );
} }
/* /*
* Enters the freeglut processing loop. * Enters the freeglut processing loop.
* Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP". * Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
*/ */
void FGAPIENTRY glutMainLoop( void ) void FGAPIENTRY glutMainLoop( void )
{ {
int action; int action;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
fgPlatformMainLoopPreliminaryWork (); fgPlatformMainLoopPreliminaryWork ();
fgState.ExecState = GLUT_EXEC_STATE_RUNNING ; fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING ) while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
{ {
SFG_Window *window; SFG_Window *window;
glutMainLoopEvent( ); glutMainLoopEvent( );
/* /*
* Step through the list of windows, seeing if there are any * Step through the list of windows, seeing if there are any
* that are not menus * that are not menus
*/ */
for( window = ( SFG_Window * )fgStructure.Windows.First; for( window = ( SFG_Window * )fgStructure.Windows.First;
window; window;
window = ( SFG_Window * )window->Node.Next ) window = ( SFG_Window * )window->Node.Next )
if ( ! ( window->IsMenu ) ) if ( ! ( window->IsMenu ) )
break; break;
if( ! window ) if( ! window )
fgState.ExecState = GLUT_EXEC_STATE_STOP; fgState.ExecState = GLUT_EXEC_STATE_STOP;
else else
{ {
if( fgState.IdleCallback ) if( fgState.IdleCallback )
{ {
if( fgStructure.CurrentWindow && if( fgStructure.CurrentWindow &&
fgStructure.CurrentWindow->IsMenu ) fgStructure.CurrentWindow->IsMenu )
/* fail safe */ /* fail safe */
fgSetWindow( window ); fgSetWindow( window );
fgState.IdleCallback( ); fgState.IdleCallback( );
} }
fghSleepForEvents( ); fghSleepForEvents( );
} }
} }
/* /*
* When this loop terminates, destroy the display, state and structure * When this loop terminates, destroy the display, state and structure
* of a freeglut session, so that another glutInit() call can happen * of a freeglut session, so that another glutInit() call can happen
* *
* Save the "ActionOnWindowClose" because "fgDeinitialize" resets it. * Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
*/ */
action = fgState.ActionOnWindowClose; action = fgState.ActionOnWindowClose;
fgDeinitialize( ); fgDeinitialize( );
if( action == GLUT_ACTION_EXIT ) if( action == GLUT_ACTION_EXIT )
exit( 0 ); exit( 0 );
} }
/* /*
* Leaves the freeglut processing loop. * Leaves the freeglut processing loop.
*/ */
void FGAPIENTRY glutLeaveMainLoop( void ) void FGAPIENTRY glutLeaveMainLoop( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
fgState.ExecState = GLUT_EXEC_STATE_STOP ; fgState.ExecState = GLUT_EXEC_STATE_STOP ;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

View File

@ -1,214 +1,214 @@
/* /*
* freeglut_misc.c * freeglut_misc.c
* *
* Functions that didn't fit anywhere else... * Functions that didn't fit anywhere else...
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 9 1999 * Creation date: Thu Dec 9 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* *
* glutSetColor() -- * glutSetColor() --
* glutGetColor() -- * glutGetColor() --
* glutCopyColormap() -- * glutCopyColormap() --
* glutSetKeyRepeat() -- this is evil and should be removed from API * glutSetKeyRepeat() -- this is evil and should be removed from API
*/ */
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* This functions checks if an OpenGL extension is supported or not * This functions checks if an OpenGL extension is supported or not
* *
* XXX Wouldn't this be simpler and clearer if we used strtok()? * XXX Wouldn't this be simpler and clearer if we used strtok()?
*/ */
int FGAPIENTRY glutExtensionSupported( const char* extension ) int FGAPIENTRY glutExtensionSupported( const char* extension )
{ {
const char *extensions, *start; const char *extensions, *start;
const size_t len = strlen( extension ); const size_t len = strlen( extension );
/* Make sure there is a current window, and thus a current context available */ /* Make sure there is a current window, and thus a current context available */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" );
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 ); freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
if (strchr(extension, ' ')) if (strchr(extension, ' '))
return 0; return 0;
start = extensions = (const char *) glGetString(GL_EXTENSIONS); start = extensions = (const char *) glGetString(GL_EXTENSIONS);
/* XXX consider printing a warning to stderr that there's no current /* XXX consider printing a warning to stderr that there's no current
* rendering context. * rendering context.
*/ */
freeglut_return_val_if_fail( extensions != NULL, 0 ); freeglut_return_val_if_fail( extensions != NULL, 0 );
while (1) { while (1) {
const char *p = strstr(extensions, extension); const char *p = strstr(extensions, extension);
if (!p) if (!p)
return 0; /* not found */ return 0; /* not found */
/* check that the match isn't a super string */ /* check that the match isn't a super string */
if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0)) if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
return 1; return 1;
/* skip the false match and continue */ /* skip the false match and continue */
extensions = p + len; extensions = p + len;
} }
return 0 ; return 0 ;
} }
#ifndef GL_INVALID_FRAMEBUFFER_OPERATION #ifndef GL_INVALID_FRAMEBUFFER_OPERATION
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT #ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
#define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT #define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
#else #else
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
#endif #endif
#endif #endif
#ifndef GL_TABLE_TOO_LARGE #ifndef GL_TABLE_TOO_LARGE
#ifdef GL_TABLE_TOO_LARGE_EXT #ifdef GL_TABLE_TOO_LARGE_EXT
#define GL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE_EXT #define GL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE_EXT
#else #else
#define GL_TABLE_TOO_LARGE 0x8031 #define GL_TABLE_TOO_LARGE 0x8031
#endif #endif
#endif #endif
#ifndef GL_TEXTURE_TOO_LARGE #ifndef GL_TEXTURE_TOO_LARGE
#ifdef GL_TEXTURE_TOO_LARGE_EXT #ifdef GL_TEXTURE_TOO_LARGE_EXT
#define GL_TEXTURE_TOO_LARGE GL_TEXTURE_TOO_LARGE_EXT #define GL_TEXTURE_TOO_LARGE GL_TEXTURE_TOO_LARGE_EXT
#else #else
#define GL_TEXTURE_TOO_LARGE 0x8065 #define GL_TEXTURE_TOO_LARGE 0x8065
#endif #endif
#endif #endif
/* /*
* A cut-down local version of gluErrorString to avoid depending on GLU. * A cut-down local version of gluErrorString to avoid depending on GLU.
*/ */
static const char* fghErrorString( GLenum error ) static const char* fghErrorString( GLenum error )
{ {
switch ( error ) { switch ( error ) {
case GL_INVALID_ENUM: return "invalid enumerant"; case GL_INVALID_ENUM: return "invalid enumerant";
case GL_INVALID_VALUE: return "invalid value"; case GL_INVALID_VALUE: return "invalid value";
case GL_INVALID_OPERATION: return "invalid operation"; case GL_INVALID_OPERATION: return "invalid operation";
case GL_STACK_OVERFLOW: return "stack overflow"; case GL_STACK_OVERFLOW: return "stack overflow";
case GL_STACK_UNDERFLOW: return "stack underflow"; case GL_STACK_UNDERFLOW: return "stack underflow";
case GL_OUT_OF_MEMORY: return "out of memory"; case GL_OUT_OF_MEMORY: return "out of memory";
case GL_TABLE_TOO_LARGE: return "table too large"; case GL_TABLE_TOO_LARGE: return "table too large";
case GL_INVALID_FRAMEBUFFER_OPERATION: return "invalid framebuffer operation"; case GL_INVALID_FRAMEBUFFER_OPERATION: return "invalid framebuffer operation";
case GL_TEXTURE_TOO_LARGE: return "texture too large"; case GL_TEXTURE_TOO_LARGE: return "texture too large";
default: return "unknown GL error"; default: return "unknown GL error";
} }
} }
/* /*
* This function reports all the OpenGL errors that happened till now * This function reports all the OpenGL errors that happened till now
*/ */
void FGAPIENTRY glutReportErrors( void ) void FGAPIENTRY glutReportErrors( void )
{ {
GLenum error; GLenum error;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" );
while( ( error = glGetError() ) != GL_NO_ERROR ) while( ( error = glGetError() ) != GL_NO_ERROR )
fgWarning( "GL error: %s", fghErrorString( error ) ); fgWarning( "GL error: %s", fghErrorString( error ) );
} }
/* /*
* Control the auto-repeat of keystrokes to the current window * Control the auto-repeat of keystrokes to the current window
*/ */
void FGAPIENTRY glutIgnoreKeyRepeat( int ignore ) void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" );
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" ); FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" );
fgStructure.CurrentWindow->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE; fgStructure.CurrentWindow->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE;
} }
/* /*
* Set global auto-repeat of keystrokes * Set global auto-repeat of keystrokes
* *
* RepeatMode should be either: * RepeatMode should be either:
* GLUT_KEY_REPEAT_OFF * GLUT_KEY_REPEAT_OFF
* GLUT_KEY_REPEAT_ON * GLUT_KEY_REPEAT_ON
* GLUT_KEY_REPEAT_DEFAULT * GLUT_KEY_REPEAT_DEFAULT
*/ */
void FGAPIENTRY glutSetKeyRepeat( int repeatMode ) void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" );
switch( repeatMode ) switch( repeatMode )
{ {
case GLUT_KEY_REPEAT_OFF: case GLUT_KEY_REPEAT_OFF:
case GLUT_KEY_REPEAT_ON: case GLUT_KEY_REPEAT_ON:
fgState.KeyRepeat = repeatMode; fgState.KeyRepeat = repeatMode;
break; break;
case GLUT_KEY_REPEAT_DEFAULT: case GLUT_KEY_REPEAT_DEFAULT:
fgState.KeyRepeat = GLUT_KEY_REPEAT_ON; fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
break; break;
default: default:
fgError ("Invalid glutSetKeyRepeat mode: %d", repeatMode); fgError ("Invalid glutSetKeyRepeat mode: %d", repeatMode);
break; break;
} }
} }
/* /*
* Forces the joystick callback to be executed * Forces the joystick callback to be executed
*/ */
void FGAPIENTRY glutForceJoystickFunc( void ) void FGAPIENTRY glutForceJoystickFunc( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutForceJoystickFunc" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutForceJoystickFunc" );
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
freeglut_return_if_fail( fgStructure.CurrentWindow != NULL ); freeglut_return_if_fail( fgStructure.CurrentWindow != NULL );
freeglut_return_if_fail( FETCH_WCB( *( fgStructure.CurrentWindow ), Joystick ) ); freeglut_return_if_fail( FETCH_WCB( *( fgStructure.CurrentWindow ), Joystick ) );
fgJoystickPollWindow( fgStructure.CurrentWindow ); fgJoystickPollWindow( fgStructure.CurrentWindow );
#endif /* !defined(_WIN32_WCE) */ #endif /* !defined(_WIN32_WCE) */
} }
/* /*
* *
*/ */
void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue ) void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" );
/* We really need to do something here. */ /* We really need to do something here. */
} }
/* /*
* *
*/ */
GLfloat FGAPIENTRY glutGetColor( int color, int component ) GLfloat FGAPIENTRY glutGetColor( int color, int component )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" );
/* We really need to do something here. */ /* We really need to do something here. */
return( 0.0f ); return( 0.0f );
} }
/* /*
* *
*/ */
void FGAPIENTRY glutCopyColormap( int window ) void FGAPIENTRY glutCopyColormap( int window )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" );
/* We really need to do something here. */ /* We really need to do something here. */
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -1,45 +1,45 @@
/* /*
* freeglut_overlay.c * freeglut_overlay.c
* *
* Overlay management functions (as defined by GLUT API) * Overlay management functions (as defined by GLUT API)
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* NOTE: functions declared in this file probably will not be implemented. * NOTE: functions declared in this file probably will not be implemented.
*/ */
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
void FGAPIENTRY glutEstablishOverlay( void ) { /* Not implemented */ } void FGAPIENTRY glutEstablishOverlay( void ) { /* Not implemented */ }
void FGAPIENTRY glutRemoveOverlay( void ) { /* Not implemented */ } void FGAPIENTRY glutRemoveOverlay( void ) { /* Not implemented */ }
void FGAPIENTRY glutUseLayer( GLenum layer ) { /* Not implemented */ } void FGAPIENTRY glutUseLayer( GLenum layer ) { /* Not implemented */ }
void FGAPIENTRY glutPostOverlayRedisplay( void ) { /* Not implemented */ } void FGAPIENTRY glutPostOverlayRedisplay( void ) { /* Not implemented */ }
void FGAPIENTRY glutPostWindowOverlayRedisplay( int ID ) { /* Not implemented */ } void FGAPIENTRY glutPostWindowOverlayRedisplay( int ID ) { /* Not implemented */ }
void FGAPIENTRY glutShowOverlay( void ) { /* Not implemented */ } void FGAPIENTRY glutShowOverlay( void ) { /* Not implemented */ }
void FGAPIENTRY glutHideOverlay( void ) { /* Not implemented */ } void FGAPIENTRY glutHideOverlay( void ) { /* Not implemented */ }
/*** END OF FILE ***/ /*** END OF FILE ***/

View File

@ -1,76 +1,76 @@
/* Spaceball support for Linux. /* Spaceball support for Linux.
* Written by John Tsiombikas <nuclear@member.fsf.org> * Written by John Tsiombikas <nuclear@member.fsf.org>
* *
* This code supports 3Dconnexion's 6-dof space-whatever devices. * This code supports 3Dconnexion's 6-dof space-whatever devices.
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv) * It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
* free spacenavd (http://spacenav.sourceforge.net), through the "standard" * free spacenavd (http://spacenav.sourceforge.net), through the "standard"
* magellan X-based protocol. * magellan X-based protocol.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */ /* -- PRIVATE FUNCTIONS --------------------------------------------------- */
extern void fgPlatformInitializeSpaceball(void); extern void fgPlatformInitializeSpaceball(void);
extern void fgPlatformSpaceballClose(void); extern void fgPlatformSpaceballClose(void);
extern int fgPlatformHasSpaceball(void); extern int fgPlatformHasSpaceball(void);
extern int fgPlatformSpaceballNumButtons(void); extern int fgPlatformSpaceballNumButtons(void);
extern void fgPlatformSpaceballSetWindow(SFG_Window *window); extern void fgPlatformSpaceballSetWindow(SFG_Window *window);
int sball_initialized = 0; int sball_initialized = 0;
void fgInitialiseSpaceball(void) void fgInitialiseSpaceball(void)
{ {
if(sball_initialized != 0) { if(sball_initialized != 0) {
return; return;
} }
fgPlatformInitializeSpaceball(); fgPlatformInitializeSpaceball();
sball_initialized = 1; sball_initialized = 1;
} }
void fgSpaceballClose(void) void fgSpaceballClose(void)
{ {
fgPlatformSpaceballClose();} fgPlatformSpaceballClose();}
int fgHasSpaceball(void) int fgHasSpaceball(void)
{ {
if(sball_initialized == 0) { if(sball_initialized == 0) {
fgInitialiseSpaceball(); fgInitialiseSpaceball();
if(sball_initialized != 1) { if(sball_initialized != 1) {
fgWarning("fgInitialiseSpaceball failed\n"); fgWarning("fgInitialiseSpaceball failed\n");
return 0; return 0;
} }
} }
return fgPlatformHasSpaceball(); return fgPlatformHasSpaceball();
} }
int fgSpaceballNumButtons(void) int fgSpaceballNumButtons(void)
{ {
if(sball_initialized == 0) { if(sball_initialized == 0) {
fgInitialiseSpaceball(); fgInitialiseSpaceball();
if(sball_initialized != 1) { if(sball_initialized != 1) {
fgWarning("fgInitialiseSpaceball failed\n"); fgWarning("fgInitialiseSpaceball failed\n");
return 0; return 0;
} }
} }
return fgPlatformSpaceballNumButtons(); return fgPlatformSpaceballNumButtons();
} }
void fgSpaceballSetWindow(SFG_Window *window) void fgSpaceballSetWindow(SFG_Window *window)
{ {
if(sball_initialized == 0) { if(sball_initialized == 0) {
fgInitialiseSpaceball(); fgInitialiseSpaceball();
if(sball_initialized != 1) { if(sball_initialized != 1) {
return; return;
} }
} }
fgPlatformSpaceballSetWindow(window); fgPlatformSpaceballSetWindow(window);
} }

View File

@ -1,322 +1,322 @@
/* /*
* freeglut_state.c * freeglut_state.c
* *
* Freeglut state query methods. * Freeglut state query methods.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* *
* glutGet() -- X11 tests passed, but check if all enums * glutGet() -- X11 tests passed, but check if all enums
* handled (what about Win32?) * handled (what about Win32?)
* glutDeviceGet() -- X11 tests passed, but check if all enums * glutDeviceGet() -- X11 tests passed, but check if all enums
* handled (what about Win32?) * handled (what about Win32?)
* glutGetModifiers() -- OK, but could also remove the limitation * glutGetModifiers() -- OK, but could also remove the limitation
* glutLayerGet() -- what about GLUT_NORMAL_DAMAGED? * glutLayerGet() -- what about GLUT_NORMAL_DAMAGED?
* *
* The fail-on-call policy will help adding the most needed things imho. * The fail-on-call policy will help adding the most needed things imho.
*/ */
extern int fgPlatformGlutGet ( GLenum eWhat ); extern int fgPlatformGlutGet ( GLenum eWhat );
extern int fgPlatformGlutDeviceGet ( GLenum eWhat ); extern int fgPlatformGlutDeviceGet ( GLenum eWhat );
extern int fgPlatformGlutLayerGet ( GLenum eWhat ); extern int fgPlatformGlutLayerGet ( GLenum eWhat );
extern int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size); extern int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size);
/* -- LOCAL DEFINITIONS ---------------------------------------------------- */ /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* General settings assignment method * General settings assignment method
*/ */
void FGAPIENTRY glutSetOption( GLenum eWhat, int value ) void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
/* /*
* XXX In chronological code add order. (WHY in that order?) * XXX In chronological code add order. (WHY in that order?)
*/ */
switch( eWhat ) switch( eWhat )
{ {
case GLUT_INIT_WINDOW_X: case GLUT_INIT_WINDOW_X:
fgState.Position.X = (GLint)value; fgState.Position.X = (GLint)value;
break; break;
case GLUT_INIT_WINDOW_Y: case GLUT_INIT_WINDOW_Y:
fgState.Position.Y = (GLint)value; fgState.Position.Y = (GLint)value;
break; break;
case GLUT_INIT_WINDOW_WIDTH: case GLUT_INIT_WINDOW_WIDTH:
fgState.Size.X = (GLint)value; fgState.Size.X = (GLint)value;
break; break;
case GLUT_INIT_WINDOW_HEIGHT: case GLUT_INIT_WINDOW_HEIGHT:
fgState.Size.Y = (GLint)value; fgState.Size.Y = (GLint)value;
break; break;
case GLUT_INIT_DISPLAY_MODE: case GLUT_INIT_DISPLAY_MODE:
fgState.DisplayMode = (unsigned int)value; fgState.DisplayMode = (unsigned int)value;
break; break;
case GLUT_ACTION_ON_WINDOW_CLOSE: case GLUT_ACTION_ON_WINDOW_CLOSE:
fgState.ActionOnWindowClose = value; fgState.ActionOnWindowClose = value;
break; break;
case GLUT_RENDERING_CONTEXT: case GLUT_RENDERING_CONTEXT:
fgState.UseCurrentContext = fgState.UseCurrentContext =
( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE; ( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
break; break;
case GLUT_DIRECT_RENDERING: case GLUT_DIRECT_RENDERING:
fgState.DirectContext = value; fgState.DirectContext = value;
break; break;
case GLUT_WINDOW_CURSOR: case GLUT_WINDOW_CURSOR:
if( fgStructure.CurrentWindow != NULL ) if( fgStructure.CurrentWindow != NULL )
fgStructure.CurrentWindow->State.Cursor = value; fgStructure.CurrentWindow->State.Cursor = value;
break; break;
case GLUT_AUX: case GLUT_AUX:
fgState.AuxiliaryBufferNumber = value; fgState.AuxiliaryBufferNumber = value;
break; break;
case GLUT_MULTISAMPLE: case GLUT_MULTISAMPLE:
fgState.SampleNumber = value; fgState.SampleNumber = value;
break; break;
default: default:
fgWarning( "glutSetOption(): missing enum handle %d", eWhat ); fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
break; break;
} }
} }
/* /*
* General settings query method * General settings query method
*/ */
int FGAPIENTRY glutGet( GLenum eWhat ) int FGAPIENTRY glutGet( GLenum eWhat )
{ {
switch (eWhat) switch (eWhat)
{ {
case GLUT_INIT_STATE: case GLUT_INIT_STATE:
return fgState.Initialised; return fgState.Initialised;
case GLUT_ELAPSED_TIME: case GLUT_ELAPSED_TIME:
return fgElapsedTime(); return fgElapsedTime();
} }
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
/* XXX In chronological code add order. (WHY in that order?) */ /* XXX In chronological code add order. (WHY in that order?) */
switch( eWhat ) switch( eWhat )
{ {
/* Following values are stored in fgState and fgDisplay global structures */ /* Following values are stored in fgState and fgDisplay global structures */
case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ; case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ; case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ; case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM; case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
case GLUT_INIT_WINDOW_X: return fgState.Position.Use ? case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
fgState.Position.X : -1 ; fgState.Position.X : -1 ;
case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ? case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
fgState.Position.Y : -1 ; fgState.Position.Y : -1 ;
case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ? case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
fgState.Size.X : -1 ; fgState.Size.X : -1 ;
case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ? case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
fgState.Size.Y : -1 ; fgState.Size.Y : -1 ;
case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ; case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ; case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ;
case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ; case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ;
case GLUT_INIT_FLAGS: return fgState.ContextFlags ; case GLUT_INIT_FLAGS: return fgState.ContextFlags ;
case GLUT_INIT_PROFILE: return fgState.ContextProfile ; case GLUT_INIT_PROFILE: return fgState.ContextProfile ;
/* The window structure queries */ /* The window structure queries */
case GLUT_WINDOW_PARENT: case GLUT_WINDOW_PARENT:
if( fgStructure.CurrentWindow == NULL ) return 0; if( fgStructure.CurrentWindow == NULL ) return 0;
if( fgStructure.CurrentWindow->Parent == NULL ) return 0; if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
return fgStructure.CurrentWindow->Parent->ID; return fgStructure.CurrentWindow->Parent->ID;
case GLUT_WINDOW_NUM_CHILDREN: case GLUT_WINDOW_NUM_CHILDREN:
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
return fgListLength( &fgStructure.CurrentWindow->Children ); return fgListLength( &fgStructure.CurrentWindow->Children );
case GLUT_WINDOW_CURSOR: case GLUT_WINDOW_CURSOR:
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
return fgStructure.CurrentWindow->State.Cursor; return fgStructure.CurrentWindow->State.Cursor;
case GLUT_MENU_NUM_ITEMS: case GLUT_MENU_NUM_ITEMS:
if( fgStructure.CurrentMenu == NULL ) if( fgStructure.CurrentMenu == NULL )
return 0; return 0;
return fgListLength( &fgStructure.CurrentMenu->Entries ); return fgListLength( &fgStructure.CurrentMenu->Entries );
case GLUT_ACTION_ON_WINDOW_CLOSE: case GLUT_ACTION_ON_WINDOW_CLOSE:
return fgState.ActionOnWindowClose; return fgState.ActionOnWindowClose;
case GLUT_VERSION : case GLUT_VERSION :
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH; return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
case GLUT_RENDERING_CONTEXT: case GLUT_RENDERING_CONTEXT:
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
: GLUT_CREATE_NEW_CONTEXT; : GLUT_CREATE_NEW_CONTEXT;
case GLUT_DIRECT_RENDERING: case GLUT_DIRECT_RENDERING:
return fgState.DirectContext; return fgState.DirectContext;
case GLUT_FULL_SCREEN: case GLUT_FULL_SCREEN:
return fgStructure.CurrentWindow->State.IsFullscreen; return fgStructure.CurrentWindow->State.IsFullscreen;
case GLUT_AUX: case GLUT_AUX:
return fgState.AuxiliaryBufferNumber; return fgState.AuxiliaryBufferNumber;
case GLUT_MULTISAMPLE: case GLUT_MULTISAMPLE:
return fgState.SampleNumber; return fgState.SampleNumber;
default: default:
return fgPlatformGlutGet ( eWhat ); return fgPlatformGlutGet ( eWhat );
break; break;
} }
return -1; return -1;
} }
/* /*
* Returns various device information. * Returns various device information.
*/ */
int FGAPIENTRY glutDeviceGet( GLenum eWhat ) int FGAPIENTRY glutDeviceGet( GLenum eWhat )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
/* XXX WARNING: we are mostly lying in this function. */ /* XXX WARNING: we are mostly lying in this function. */
switch( eWhat ) switch( eWhat )
{ {
case GLUT_HAS_JOYSTICK: case GLUT_HAS_JOYSTICK:
return fgJoystickDetect (); return fgJoystickDetect ();
case GLUT_OWNS_JOYSTICK: case GLUT_OWNS_JOYSTICK:
return fgState.JoysticksInitialised; return fgState.JoysticksInitialised;
case GLUT_JOYSTICK_POLL_RATE: case GLUT_JOYSTICK_POLL_RATE:
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0; return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
/* XXX The following two are only for Joystick 0 but this is an improvement */ /* XXX The following two are only for Joystick 0 but this is an improvement */
case GLUT_JOYSTICK_BUTTONS: case GLUT_JOYSTICK_BUTTONS:
return glutJoystickGetNumButtons ( 0 ); return glutJoystickGetNumButtons ( 0 );
case GLUT_JOYSTICK_AXES: case GLUT_JOYSTICK_AXES:
return glutJoystickGetNumAxes ( 0 ); return glutJoystickGetNumAxes ( 0 );
case GLUT_HAS_DIAL_AND_BUTTON_BOX: case GLUT_HAS_DIAL_AND_BUTTON_BOX:
return fgInputDeviceDetect (); return fgInputDeviceDetect ();
case GLUT_NUM_DIALS: case GLUT_NUM_DIALS:
if ( fgState.InputDevsInitialised ) return 8; if ( fgState.InputDevsInitialised ) return 8;
return 0; return 0;
case GLUT_NUM_BUTTON_BOX_BUTTONS: case GLUT_NUM_BUTTON_BOX_BUTTONS:
return 0; return 0;
case GLUT_HAS_SPACEBALL: case GLUT_HAS_SPACEBALL:
return fgHasSpaceball(); return fgHasSpaceball();
case GLUT_HAS_TABLET: case GLUT_HAS_TABLET:
return 0; return 0;
case GLUT_NUM_SPACEBALL_BUTTONS: case GLUT_NUM_SPACEBALL_BUTTONS:
return fgSpaceballNumButtons(); return fgSpaceballNumButtons();
case GLUT_NUM_TABLET_BUTTONS: case GLUT_NUM_TABLET_BUTTONS:
return 0; return 0;
case GLUT_DEVICE_IGNORE_KEY_REPEAT: case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0; return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
case GLUT_DEVICE_KEY_REPEAT: case GLUT_DEVICE_KEY_REPEAT:
return fgState.KeyRepeat; return fgState.KeyRepeat;
default: default:
return fgPlatformGlutDeviceGet ( eWhat ); return fgPlatformGlutDeviceGet ( eWhat );
} }
/* And now -- the failure. */ /* And now -- the failure. */
return -1; return -1;
} }
/* /*
* This should return the current state of ALT, SHIFT and CTRL keys. * This should return the current state of ALT, SHIFT and CTRL keys.
*/ */
int FGAPIENTRY glutGetModifiers( void ) int FGAPIENTRY glutGetModifiers( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
if( fgState.Modifiers == INVALID_MODIFIERS ) if( fgState.Modifiers == INVALID_MODIFIERS )
{ {
fgWarning( "glutGetModifiers() called outside an input callback" ); fgWarning( "glutGetModifiers() called outside an input callback" );
return 0; return 0;
} }
return fgState.Modifiers; return fgState.Modifiers;
} }
/* /*
* Return the state of the GLUT API overlay subsystem. A misery ;-) * Return the state of the GLUT API overlay subsystem. A misery ;-)
*/ */
int FGAPIENTRY glutLayerGet( GLenum eWhat ) int FGAPIENTRY glutLayerGet( GLenum eWhat )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
/* /*
* This is easy as layers are not implemented ;-) * This is easy as layers are not implemented ;-)
* *
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or * XXX Can we merge the UNIX/X11 and WIN32 sections? Or
* XXX is overlay support planned? * XXX is overlay support planned?
*/ */
switch( eWhat ) switch( eWhat )
{ {
default: default:
return fgPlatformGlutLayerGet( eWhat ); return fgPlatformGlutLayerGet( eWhat );
} }
/* And fail. That's good. Programs do love failing. */ /* And fail. That's good. Programs do love failing. */
return -1; return -1;
} }
int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int *size) int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int *size)
{ {
int *array; int *array;
FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues"); FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
*size = 0; *size = 0;
array = fgPlatformGlutGetModeValues ( eWhat, size ); array = fgPlatformGlutGetModeValues ( eWhat, size );
return array; return array;
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +1,200 @@
/* /*
* freeglut_teapot.c * freeglut_teapot.c
* *
* Teapot(tm) rendering code. * Teapot(tm) rendering code.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Fri Dec 24 1999 * Creation date: Fri Dec 24 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* /*
* Original teapot code copyright follows: * Original teapot code copyright follows:
*/ */
/* /*
* (c) Copyright 1993, Silicon Graphics, Inc. * (c) Copyright 1993, Silicon Graphics, Inc.
* *
* ALL RIGHTS RESERVED * ALL RIGHTS RESERVED
* *
* Permission to use, copy, modify, and distribute this software * Permission to use, copy, modify, and distribute this software
* for any purpose and without fee is hereby granted, provided * for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that * that the above copyright notice appear in all copies and that
* both the copyright notice and this permission notice appear in * both the copyright notice and this permission notice appear in
* supporting documentation, and that the name of Silicon * supporting documentation, and that the name of Silicon
* Graphics, Inc. not be used in advertising or publicity * Graphics, Inc. not be used in advertising or publicity
* pertaining to distribution of the software without specific, * pertaining to distribution of the software without specific,
* written prior permission. * written prior permission.
* *
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
* "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR * "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
* OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF * OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
* EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE * EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
* ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR * ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
* INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, * INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
* SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR * SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
* NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY * NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR * ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
* *
* US Government Users Restricted Rights * US Government Users Restricted Rights
* *
* Use, duplication, or disclosure by the Government is subject to * Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer * (c)(1)(ii) of the Rights in Technical Data and Computer
* Software clause at DFARS 252.227-7013 and/or in similar or * Software clause at DFARS 252.227-7013 and/or in similar or
* successor clauses in the FAR or the DOD or NASA FAR * successor clauses in the FAR or the DOD or NASA FAR
* Supplement. Unpublished-- rights reserved under the copyright * Supplement. Unpublished-- rights reserved under the copyright
* laws of the United States. Contractor/manufacturer is Silicon * laws of the United States. Contractor/manufacturer is Silicon
* Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA * Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
* 94039-7311. * 94039-7311.
* *
* OpenGL(TM) is a trademark of Silicon Graphics, Inc. * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
#include "freeglut_teapot_data.h" #include "freeglut_teapot_data.h"
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
static void fghTeapot( GLint grid, GLdouble scale, GLenum type ) static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
{ {
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4; int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;
#else #else
double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3]; double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l; long i, j, k, l;
#endif #endif
glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT ); glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
glEnable( GL_AUTO_NORMAL ); glEnable( GL_AUTO_NORMAL );
glEnable( GL_NORMALIZE ); glEnable( GL_NORMALIZE );
glEnable( GL_MAP2_VERTEX_3 ); glEnable( GL_MAP2_VERTEX_3 );
glEnable( GL_MAP2_TEXTURE_COORD_2 ); glEnable( GL_MAP2_TEXTURE_COORD_2 );
glPushMatrix(); glPushMatrix();
glRotated( 270.0, 1.0, 0.0, 0.0 ); glRotated( 270.0, 1.0, 0.0, 0.0 );
glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale ); glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );
glTranslated( 0.0, 0.0, -1.5 ); glTranslated( 0.0, 0.0, -1.5 );
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
glRotated( 90.0, 1.0, 0.0, 0.0 ); glRotated( 90.0, 1.0, 0.0, 0.0 );
glBegin( GL_TRIANGLE_STRIP ); glBegin( GL_TRIANGLE_STRIP );
for( i = 0; i < numV-1; i++ ) for( i = 0; i < numV-1; i++ )
{ {
int vidx = strip_vertices[i], int vidx = strip_vertices[i],
nidx = strip_normals[i]; nidx = strip_normals[i];
if( vidx != -1 ) if( vidx != -1 )
{ {
glNormal3fv( normals[nidx] ); glNormal3fv( normals[nidx] );
glVertex3fv( vertices[vidx] ); glVertex3fv( vertices[vidx] );
} }
else else
{ {
glEnd(); glEnd();
glBegin( GL_TRIANGLE_STRIP ); glBegin( GL_TRIANGLE_STRIP );
} }
} }
glEnd(); glEnd();
#else #else
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
for (k = 0; k < 4; k++) { for (k = 0; k < 4; k++) {
for (l = 0; l < 3; l++) { for (l = 0; l < 3; l++) {
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l]; q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 1) if (l == 1)
q[j][k][l] *= -1.0; q[j][k][l] *= -1.0;
if (i < 6) { if (i < 6) {
r[j][k][l] = r[j][k][l] =
cpdata[patchdata[i][j * 4 + (3 - k)]][l]; cpdata[patchdata[i][j * 4 + (3 - k)]][l];
if (l == 0) if (l == 0)
r[j][k][l] *= -1.0; r[j][k][l] *= -1.0;
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l]; s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
if (l == 0) if (l == 0)
s[j][k][l] *= -1.0; s[j][k][l] *= -1.0;
if (l == 1) if (l == 1)
s[j][k][l] *= -1.0; s[j][k][l] *= -1.0;
} }
} }
} }
} }
glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2, glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,
&tex[0][0][0]); &tex[0][0][0]);
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
&p[0][0][0]); &p[0][0][0]);
glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0); glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);
glEvalMesh2(type, 0, grid, 0, grid); glEvalMesh2(type, 0, grid, 0, grid);
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
&q[0][0][0]); &q[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid); glEvalMesh2(type, 0, grid, 0, grid);
if (i < 6) { if (i < 6) {
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
&r[0][0][0]); &r[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid); glEvalMesh2(type, 0, grid, 0, grid);
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
&s[0][0][0]); &s[0][0][0]);
glEvalMesh2(type, 0, grid, 0, grid); glEvalMesh2(type, 0, grid, 0, grid);
} }
} }
#endif /* defined(_WIN32_WCE) */ #endif /* defined(_WIN32_WCE) */
glPopMatrix(); glPopMatrix();
glPopAttrib(); glPopAttrib();
} }
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
/* /*
* Renders a beautiful wired teapot... * Renders a beautiful wired teapot...
*/ */
void FGAPIENTRY glutWireTeapot( GLdouble size ) void FGAPIENTRY glutWireTeapot( GLdouble size )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );
/* We will use the general teapot rendering code */ /* We will use the general teapot rendering code */
fghTeapot( 10, size, GL_LINE ); fghTeapot( 10, size, GL_LINE );
} }
/* /*
* Renders a beautiful filled teapot... * Renders a beautiful filled teapot...
*/ */
void FGAPIENTRY glutSolidTeapot( GLdouble size ) void FGAPIENTRY glutSolidTeapot( GLdouble size )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );
/* We will use the general teapot rendering code */ /* We will use the general teapot rendering code */
fghTeapot( 7, size, GL_FILL ); fghTeapot( 7, size, GL_FILL );
} }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +1,50 @@
/* /*
* freeglut_videoresize.c * freeglut_videoresize.c
* *
* Video resize functions (as defined by GLUT API) * Video resize functions (as defined by GLUT API)
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Creation date: Thu Dec 16 1999 * Creation date: Thu Dec 16 1999
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
/* /*
* NOTE: functions declared in this file probably will not be implemented. * NOTE: functions declared in this file probably will not be implemented.
*/ */
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
int FGAPIENTRY glutVideoResizeGet( GLenum eWhat ) { return( 0x00 ); } int FGAPIENTRY glutVideoResizeGet( GLenum eWhat ) { return( 0x00 ); }
void FGAPIENTRY glutSetupVideoResizing( void ) { /* Not implemented */ } void FGAPIENTRY glutSetupVideoResizing( void ) { /* Not implemented */ }
void FGAPIENTRY glutStopVideoResizing( void ) { /* Not implemented */ } void FGAPIENTRY glutStopVideoResizing( void ) { /* Not implemented */ }
void FGAPIENTRY glutVideoResize( int x, int y, int w, int h ) { /* Not implemented */ } void FGAPIENTRY glutVideoResize( int x, int y, int w, int h ) { /* Not implemented */ }
void FGAPIENTRY glutVideoPan( int x, int y, int w, int h ) { /* Not implemented */ } void FGAPIENTRY glutVideoPan( int x, int y, int w, int h ) { /* Not implemented */ }
/*** END OF FILE ***/ /*** END OF FILE ***/

File diff suppressed because it is too large Load Diff

View File

@ -1,155 +1,155 @@
LIBRARY freeglut LIBRARY freeglut
VERSION 2.6 VERSION 2.6
EXPORTS EXPORTS
glutInit glutInit
glutInitWindowPosition glutInitWindowPosition
glutInitWindowSize glutInitWindowSize
glutInitDisplayMode glutInitDisplayMode
glutInitDisplayString glutInitDisplayString
glutMainLoop glutMainLoop
glutMainLoopEvent glutMainLoopEvent
glutLeaveMainLoop glutLeaveMainLoop
glutCreateWindow glutCreateWindow
glutCreateSubWindow glutCreateSubWindow
glutDestroyWindow glutDestroyWindow
glutSetWindow glutSetWindow
glutGetWindow glutGetWindow
glutSetWindowData glutSetWindowData
glutGetWindowData glutGetWindowData
glutSetWindowTitle glutSetWindowTitle
glutSetIconTitle glutSetIconTitle
glutReshapeWindow glutReshapeWindow
glutPositionWindow glutPositionWindow
glutShowWindow glutShowWindow
glutHideWindow glutHideWindow
glutIconifyWindow glutIconifyWindow
glutPushWindow glutPushWindow
glutPopWindow glutPopWindow
glutFullScreen glutFullScreen
glutPostWindowRedisplay glutPostWindowRedisplay
glutPostRedisplay glutPostRedisplay
glutSwapBuffers glutSwapBuffers
glutWarpPointer glutWarpPointer
glutSetCursor glutSetCursor
glutEstablishOverlay glutEstablishOverlay
glutRemoveOverlay glutRemoveOverlay
glutUseLayer glutUseLayer
glutPostOverlayRedisplay glutPostOverlayRedisplay
glutPostWindowOverlayRedisplay glutPostWindowOverlayRedisplay
glutShowOverlay glutShowOverlay
glutHideOverlay glutHideOverlay
glutCreateMenu glutCreateMenu
glutDestroyMenu glutDestroyMenu
glutGetMenu glutGetMenu
glutSetMenu glutSetMenu
glutGetMenuData glutGetMenuData
glutSetMenuData glutSetMenuData
glutAddMenuEntry glutAddMenuEntry
glutAddSubMenu glutAddSubMenu
glutChangeToMenuEntry glutChangeToMenuEntry
glutChangeToSubMenu glutChangeToSubMenu
glutRemoveMenuItem glutRemoveMenuItem
glutAttachMenu glutAttachMenu
glutDetachMenu glutDetachMenu
glutTimerFunc glutTimerFunc
glutIdleFunc glutIdleFunc
glutKeyboardFunc glutKeyboardFunc
glutSpecialFunc glutSpecialFunc
glutReshapeFunc glutReshapeFunc
glutVisibilityFunc glutVisibilityFunc
glutDisplayFunc glutDisplayFunc
glutMouseFunc glutMouseFunc
glutMouseWheelFunc glutMouseWheelFunc
glutMotionFunc glutMotionFunc
glutPassiveMotionFunc glutPassiveMotionFunc
glutEntryFunc glutEntryFunc
glutCloseFunc glutCloseFunc
glutWMCloseFunc glutWMCloseFunc
glutKeyboardUpFunc glutKeyboardUpFunc
glutSpecialUpFunc glutSpecialUpFunc
glutJoystickFunc glutJoystickFunc
glutMenuStateFunc glutMenuStateFunc
glutMenuStatusFunc glutMenuStatusFunc
glutMenuDestroyFunc glutMenuDestroyFunc
glutOverlayDisplayFunc glutOverlayDisplayFunc
glutWindowStatusFunc glutWindowStatusFunc
glutSpaceballMotionFunc glutSpaceballMotionFunc
glutSpaceballRotateFunc glutSpaceballRotateFunc
glutSpaceballButtonFunc glutSpaceballButtonFunc
glutButtonBoxFunc glutButtonBoxFunc
glutDialsFunc glutDialsFunc
glutTabletMotionFunc glutTabletMotionFunc
glutTabletButtonFunc glutTabletButtonFunc
glutSetOption glutSetOption
glutGet glutGet
glutDeviceGet glutDeviceGet
glutGetModifiers glutGetModifiers
glutLayerGet glutLayerGet
glutBitmapCharacter glutBitmapCharacter
glutBitmapWidth glutBitmapWidth
glutStrokeCharacter glutStrokeCharacter
glutStrokeWidth glutStrokeWidth
glutBitmapLength glutBitmapLength
glutStrokeLength glutStrokeLength
glutBitmapHeight glutBitmapHeight
glutStrokeHeight glutStrokeHeight
glutBitmapString glutBitmapString
glutStrokeString glutStrokeString
glutWireCube glutWireCube
glutSolidCube glutSolidCube
glutWireSphere glutWireSphere
glutSolidSphere glutSolidSphere
glutWireCone glutWireCone
glutSolidCone glutSolidCone
glutWireTorus glutWireTorus
glutSolidTorus glutSolidTorus
glutWireDodecahedron glutWireDodecahedron
glutSolidDodecahedron glutSolidDodecahedron
glutWireOctahedron glutWireOctahedron
glutSolidOctahedron glutSolidOctahedron
glutWireTetrahedron glutWireTetrahedron
glutSolidTetrahedron glutSolidTetrahedron
glutWireIcosahedron glutWireIcosahedron
glutSolidIcosahedron glutSolidIcosahedron
glutWireRhombicDodecahedron glutWireRhombicDodecahedron
glutSolidRhombicDodecahedron glutSolidRhombicDodecahedron
glutWireSierpinskiSponge glutWireSierpinskiSponge
glutSolidSierpinskiSponge glutSolidSierpinskiSponge
glutWireTeapot glutWireTeapot
glutSolidTeapot glutSolidTeapot
glutWireCylinder glutWireCylinder
glutSolidCylinder glutSolidCylinder
glutGameModeString glutGameModeString
glutEnterGameMode glutEnterGameMode
glutLeaveGameMode glutLeaveGameMode
glutGameModeGet glutGameModeGet
glutVideoResizeGet glutVideoResizeGet
glutSetupVideoResizing glutSetupVideoResizing
glutStopVideoResizing glutStopVideoResizing
glutVideoResize glutVideoResize
glutVideoPan glutVideoPan
glutSetColor glutSetColor
glutGetColor glutGetColor
glutCopyColormap glutCopyColormap
glutIgnoreKeyRepeat glutIgnoreKeyRepeat
glutSetKeyRepeat glutSetKeyRepeat
glutForceJoystickFunc glutForceJoystickFunc
glutExtensionSupported glutExtensionSupported
glutReportErrors glutReportErrors
glutGetProcAddress glutGetProcAddress
glutExit glutExit
glutFullScreenToggle glutFullScreenToggle
glutLeaveFullScreen glutLeaveFullScreen
glutGetModeValues glutGetModeValues
glutInitContextFlags glutInitContextFlags
glutInitContextVersion glutInitContextVersion
glutInitContextProfile glutInitContextProfile
glutInitErrorFunc glutInitErrorFunc
glutInitWarningFunc glutInitWarningFunc
__glutInitWithExit __glutInitWithExit
__glutCreateWindowWithExit __glutCreateWindowWithExit
__glutCreateMenuWithExit __glutCreateMenuWithExit
glutMultiButtonFunc glutMultiButtonFunc
glutMultiEntryFunc glutMultiEntryFunc
glutMultiMotionFunc glutMultiMotionFunc
glutMultiPassiveFunc glutMultiPassiveFunc

View File

@ -1,115 +1,115 @@
/* /*
* freeglut_cursor_mswin.c * freeglut_cursor_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Thu Jan 19, 2012 * Creation date: Thu Jan 19, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
void fgPlatformSetCursor ( SFG_Window *window, int cursorID ) void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
{ {
/* /*
* Joe Krahn is re-writing the following code. * Joe Krahn is re-writing the following code.
*/ */
/* Set the cursor AND change it for this window class. */ /* Set the cursor AND change it for this window class. */
#if !defined(__MINGW64__) && _MSC_VER <= 1200 #if !defined(__MINGW64__) && _MSC_VER <= 1200
# define MAP_CURSOR(a,b) \ # define MAP_CURSOR(a,b) \
case a: \ case a: \
SetCursor( LoadCursor( NULL, b ) ); \ SetCursor( LoadCursor( NULL, b ) ); \
SetClassLong( window->Window.Handle, \ SetClassLong( window->Window.Handle, \
GCL_HCURSOR, \ GCL_HCURSOR, \
( LONG )LoadCursor( NULL, b ) ); \ ( LONG )LoadCursor( NULL, b ) ); \
break; break;
/* Nuke the cursor AND change it for this window class. */ /* Nuke the cursor AND change it for this window class. */
# define ZAP_CURSOR(a,b) \ # define ZAP_CURSOR(a,b) \
case a: \ case a: \
SetCursor( NULL ); \ SetCursor( NULL ); \
SetClassLong( window->Window.Handle, \ SetClassLong( window->Window.Handle, \
GCL_HCURSOR, ( LONG )NULL ); \ GCL_HCURSOR, ( LONG )NULL ); \
break; break;
#else #else
# define MAP_CURSOR(a,b) \ # define MAP_CURSOR(a,b) \
case a: \ case a: \
SetCursor( LoadCursor( NULL, b ) ); \ SetCursor( LoadCursor( NULL, b ) ); \
SetClassLongPtr( window->Window.Handle, \ SetClassLongPtr( window->Window.Handle, \
GCLP_HCURSOR, \ GCLP_HCURSOR, \
( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \ ( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \
break; break;
/* Nuke the cursor AND change it for this window class. */ /* Nuke the cursor AND change it for this window class. */
# define ZAP_CURSOR(a,b) \ # define ZAP_CURSOR(a,b) \
case a: \ case a: \
SetCursor( NULL ); \ SetCursor( NULL ); \
SetClassLongPtr( window->Window.Handle, \ SetClassLongPtr( window->Window.Handle, \
GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \ GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \
break; break;
#endif #endif
switch( cursorID ) switch( cursorID )
{ {
MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW ); MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP ); MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL ); MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT ); MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM ); MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM );
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS ); MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS ); MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS );
MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE ); MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE );
MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, IDC_ARROW ); /* XXX ToDo */
MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, IDC_ARROW ); /* XXX ToDo */
MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, IDC_ARROW ); /* XXX ToDo */
MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */
MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE ); MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE );
MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW ); MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW );
MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE ); MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE );
MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW ); MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW );
MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL ); ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */ MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */
default: default:
fgError( "Unknown cursor type: %d", cursorID ); fgError( "Unknown cursor type: %d", cursorID );
break; break;
} }
} }
void fgPlatformWarpPointer ( int x, int y ) void fgPlatformWarpPointer ( int x, int y )
{ {
POINT coords; POINT coords;
coords.x = x; coords.x = x;
coords.y = y; coords.y = y;
/* ClientToScreen() translates {coords} for us. */ /* ClientToScreen() translates {coords} for us. */
ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords ); ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords );
SetCursorPos( coords.x, coords.y ); SetCursorPos( coords.x, coords.y );
} }

View File

@ -1,37 +1,37 @@
/* /*
* freeglut_display_mswin.c * freeglut_display_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sat Jan 28, 2012 * Creation date: Sat Jan 28, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow ) void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
{ {
SwapBuffers( CurrentWindow->Window.pContext.Device ); SwapBuffers( CurrentWindow->Window.pContext.Device );
} }

View File

@ -1,56 +1,56 @@
/* /*
* freeglut_ext_mswin.c * freeglut_ext_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Thu Jan 19, 2012 * Creation date: Thu Jan 19, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName ) GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
{ {
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
/* optimization: quick initial check */ /* optimization: quick initial check */
if( strncmp( procName, "glut", 4 ) != 0 ) if( strncmp( procName, "glut", 4 ) != 0 )
return NULL; return NULL;
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x; #define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
CHECK_NAME(glutJoystickFunc); CHECK_NAME(glutJoystickFunc);
CHECK_NAME(glutForceJoystickFunc); CHECK_NAME(glutForceJoystickFunc);
CHECK_NAME(glutGameModeString); CHECK_NAME(glutGameModeString);
CHECK_NAME(glutEnterGameMode); CHECK_NAME(glutEnterGameMode);
CHECK_NAME(glutLeaveGameMode); CHECK_NAME(glutLeaveGameMode);
CHECK_NAME(glutGameModeGet); CHECK_NAME(glutGameModeGet);
#undef CHECK_NAME #undef CHECK_NAME
#endif /* !defined(_WIN32_WCE) */ #endif /* !defined(_WIN32_WCE) */
return NULL; return NULL;
} }
SFG_Proc fgPlatformGetProcAddress( const char *procName ) SFG_Proc fgPlatformGetProcAddress( const char *procName )
{ {
return (SFG_Proc)wglGetProcAddress( ( LPCSTR )procName ); return (SFG_Proc)wglGetProcAddress( ( LPCSTR )procName );
} }

View File

@ -1,157 +1,157 @@
/* /*
* freeglut_gamemode_mswin.c * freeglut_gamemode_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Thu Jan 19, 2012 * Creation date: Thu Jan 19, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
/* /*
* Remembers the current visual settings, so that * Remembers the current visual settings, so that
* we can change them and restore later... * we can change them and restore later...
*/ */
void fgPlatformRememberState( void ) void fgPlatformRememberState( void )
{ {
/* DEVMODE devMode; */ /* DEVMODE devMode; */
/* Grab the current desktop settings... */ /* Grab the current desktop settings... */
/* hack to get around my stupid cross-gcc headers */ /* hack to get around my stupid cross-gcc headers */
#define FREEGLUT_ENUM_CURRENT_SETTINGS -1 #define FREEGLUT_ENUM_CURRENT_SETTINGS -1
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
&fgDisplay.pDisplay.DisplayMode ); &fgDisplay.pDisplay.DisplayMode );
/* Make sure we will be restoring all settings needed */ /* Make sure we will be restoring all settings needed */
fgDisplay.pDisplay.DisplayMode.dmFields |= fgDisplay.pDisplay.DisplayMode.dmFields |=
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
} }
/* /*
* Restores the previously remembered visual settings * Restores the previously remembered visual settings
*/ */
void fgPlatformRestoreState( void ) void fgPlatformRestoreState( void )
{ {
/* Restore the previously remembered desktop display settings */ /* Restore the previously remembered desktop display settings */
ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 ); ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 );
} }
/* /*
* Changes the current display mode to match user's settings * Changes the current display mode to match user's settings
*/ */
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest ) GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
{ {
GLboolean success = GL_FALSE; GLboolean success = GL_FALSE;
DEVMODE devMode; DEVMODE devMode;
char *fggmstr = NULL; char *fggmstr = NULL;
char displayMode[300]; char displayMode[300];
success = GL_FALSE; success = GL_FALSE;
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode ); EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode );
devMode.dmFields = 0; devMode.dmFields = 0;
if (fgState.GameModeSize.X!=-1) if (fgState.GameModeSize.X!=-1)
{ {
devMode.dmPelsWidth = fgState.GameModeSize.X; devMode.dmPelsWidth = fgState.GameModeSize.X;
devMode.dmFields |= DM_PELSWIDTH; devMode.dmFields |= DM_PELSWIDTH;
} }
if (fgState.GameModeSize.Y!=-1) if (fgState.GameModeSize.Y!=-1)
{ {
devMode.dmPelsHeight = fgState.GameModeSize.Y; devMode.dmPelsHeight = fgState.GameModeSize.Y;
devMode.dmFields |= DM_PELSHEIGHT; devMode.dmFields |= DM_PELSHEIGHT;
} }
if (fgState.GameModeDepth!=-1) if (fgState.GameModeDepth!=-1)
{ {
devMode.dmBitsPerPel = fgState.GameModeDepth; devMode.dmBitsPerPel = fgState.GameModeDepth;
devMode.dmFields |= DM_BITSPERPEL; devMode.dmFields |= DM_BITSPERPEL;
} }
if (fgState.GameModeRefresh!=-1) if (fgState.GameModeRefresh!=-1)
{ {
devMode.dmDisplayFrequency = fgState.GameModeRefresh; devMode.dmDisplayFrequency = fgState.GameModeRefresh;
devMode.dmFields |= DM_DISPLAYFREQUENCY; devMode.dmFields |= DM_DISPLAYFREQUENCY;
} }
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) ) switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
{ {
case DISP_CHANGE_SUCCESSFUL: case DISP_CHANGE_SUCCESSFUL:
success = GL_TRUE; success = GL_TRUE;
if (!haveToTest) if (!haveToTest)
{ {
/* update vars in case if windows switched to proper mode */ /* update vars in case if windows switched to proper mode */
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode ); EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
fgState.GameModeSize.X = devMode.dmPelsWidth; fgState.GameModeSize.X = devMode.dmPelsWidth;
fgState.GameModeSize.Y = devMode.dmPelsHeight; fgState.GameModeSize.Y = devMode.dmPelsHeight;
fgState.GameModeDepth = devMode.dmBitsPerPel; fgState.GameModeDepth = devMode.dmBitsPerPel;
fgState.GameModeRefresh = devMode.dmDisplayFrequency; fgState.GameModeRefresh = devMode.dmDisplayFrequency;
} }
break; break;
case DISP_CHANGE_RESTART: case DISP_CHANGE_RESTART:
fggmstr = "The computer must be restarted for the graphics mode to work."; fggmstr = "The computer must be restarted for the graphics mode to work.";
break; break;
case DISP_CHANGE_BADFLAGS: case DISP_CHANGE_BADFLAGS:
fggmstr = "An invalid set of flags was passed in."; fggmstr = "An invalid set of flags was passed in.";
break; break;
case DISP_CHANGE_BADPARAM: case DISP_CHANGE_BADPARAM:
fggmstr = "An invalid parameter was passed in. This can include an invalid flag or combination of flags."; fggmstr = "An invalid parameter was passed in. This can include an invalid flag or combination of flags.";
break; break;
case DISP_CHANGE_FAILED: case DISP_CHANGE_FAILED:
fggmstr = "The display driver failed the specified graphics mode."; fggmstr = "The display driver failed the specified graphics mode.";
break; break;
case DISP_CHANGE_BADMODE: case DISP_CHANGE_BADMODE:
fggmstr = "The graphics mode is not supported."; fggmstr = "The graphics mode is not supported.";
break; break;
default: default:
fggmstr = "Unknown error in graphics mode???"; /* dunno if it is possible,MSDN does not mention any other error */ fggmstr = "Unknown error in graphics mode???"; /* dunno if it is possible,MSDN does not mention any other error */
break; break;
} }
if ( !success ) if ( !success )
{ {
/* I'd rather get info whats going on in my program than wonder about */ /* I'd rather get info whats going on in my program than wonder about */
/* magic happenings behind my back, its lib for devels at last ;) */ /* magic happenings behind my back, its lib for devels at last ;) */
/* append display mode to error to make things more informative */ /* append display mode to error to make things more informative */
sprintf(displayMode,"%s Problem with requested mode: %ix%i:%i@%i", fggmstr, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmDisplayFrequency); sprintf(displayMode,"%s Problem with requested mode: %ix%i:%i@%i", fggmstr, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmBitsPerPel, devMode.dmDisplayFrequency);
fgWarning(displayMode); fgWarning(displayMode);
} }
return success; return success;
} }
void fgPlatformEnterGameMode( void ) void fgPlatformEnterGameMode( void )
{ {
} }
void fgPlatformLeaveGameMode( void ) void fgPlatformLeaveGameMode( void )
{ {
} }

View File

@ -1,345 +1,345 @@
/* /*
* freeglut_init_mswin.c * freeglut_init_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Thu Jan 19, 2012 * Creation date: Thu Jan 19, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define FREEGLUT_BUILDING_LIB #define FREEGLUT_BUILDING_LIB
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
extern LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, extern LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam ); WPARAM wParam, LPARAM lParam );
/* /*
* A call to this function should initialize all the display stuff... * A call to this function should initialize all the display stuff...
*/ */
void fgPlatformInitialize( const char* displayName ) void fgPlatformInitialize( const char* displayName )
{ {
WNDCLASS wc; WNDCLASS wc;
ATOM atom; ATOM atom;
/* What we need to do is to initialize the fgDisplay global structure here. */ /* What we need to do is to initialize the fgDisplay global structure here. */
fgDisplay.pDisplay.Instance = GetModuleHandle( NULL ); fgDisplay.pDisplay.Instance = GetModuleHandle( NULL );
fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ; fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc ); atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
if( atom == 0 ) if( atom == 0 )
{ {
ZeroMemory( &wc, sizeof(WNDCLASS) ); ZeroMemory( &wc, sizeof(WNDCLASS) );
/* /*
* Each of the windows should have its own device context, and we * Each of the windows should have its own device context, and we
* want redraw events during Vertical and Horizontal Resizes by * want redraw events during Vertical and Horizontal Resizes by
* the user. * the user.
* *
* XXX Old code had "| CS_DBCLCKS" commented out. Plans for the * XXX Old code had "| CS_DBCLCKS" commented out. Plans for the
* XXX future? Dead-end idea? * XXX future? Dead-end idea?
*/ */
wc.lpfnWndProc = fgPlatformWindowProc; wc.lpfnWndProc = fgPlatformWindowProc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = fgDisplay.pDisplay.Instance; wc.hInstance = fgDisplay.pDisplay.Instance;
wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") ); wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") );
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
#else #else
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
if (!wc.hIcon) if (!wc.hIcon)
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); wc.hIcon = LoadIcon( NULL, IDI_WINLOGO );
#endif #endif
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = NULL; wc.hbrBackground = NULL;
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = _T("FREEGLUT"); wc.lpszClassName = _T("FREEGLUT");
/* Register the window class */ /* Register the window class */
atom = RegisterClass( &wc ); atom = RegisterClass( &wc );
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fgPlatformInitialize" ); FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fgPlatformInitialize" );
} }
/* The screen dimensions can be obtained via GetSystemMetrics() calls */ /* The screen dimensions can be obtained via GetSystemMetrics() calls */
fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN ); fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN );
fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN ); fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
{ {
HWND desktop = GetDesktopWindow( ); HWND desktop = GetDesktopWindow( );
HDC context = GetDC( desktop ); HDC context = GetDC( desktop );
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE ); fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE ); fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
ReleaseDC( desktop, context ); ReleaseDC( desktop, context );
} }
/* If we have a DisplayName try to use it for metrics */ /* If we have a DisplayName try to use it for metrics */
if( fgDisplay.pDisplay.DisplayName ) if( fgDisplay.pDisplay.DisplayName )
{ {
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0); HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
if( context ) if( context )
{ {
fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES ); fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES ); fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE ); fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE ); fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
DeleteDC(context); DeleteDC(context);
} }
else else
fgWarning("fgPlatformInitialize: " fgWarning("fgPlatformInitialize: "
"CreateDC failed, Screen size info may be incorrect\n" "CreateDC failed, Screen size info may be incorrect\n"
"This is quite likely caused by a bad '-display' parameter"); "This is quite likely caused by a bad '-display' parameter");
} }
/* Set the timer granularity to 1 ms */ /* Set the timer granularity to 1 ms */
timeBeginPeriod ( 1 ); timeBeginPeriod ( 1 );
fgState.Initialised = GL_TRUE; fgState.Initialised = GL_TRUE;
/* Avoid registering atexit callback on Win32 as it results in an access /* Avoid registering atexit callback on Win32 as it results in an access
* violation due to calling into a module which has been unloaded. * violation due to calling into a module which has been unloaded.
* Any cleanup isn't needed on Windows anyway, the OS takes care of it.c * Any cleanup isn't needed on Windows anyway, the OS takes care of it.c
* see: http://blogs.msdn.com/b/oldnewthing/archive/2012/01/05/10253268.aspx * see: http://blogs.msdn.com/b/oldnewthing/archive/2012/01/05/10253268.aspx
*/ */
/* atexit(fgDeinitialize); */ /* atexit(fgDeinitialize); */
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */ /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
fgInitialiseInputDevices(); fgInitialiseInputDevices();
} }
/* Platform-Specific Deinitialization Functions: */ /* Platform-Specific Deinitialization Functions: */
extern void fghCloseInputDevices ( void ); extern void fghCloseInputDevices ( void );
void fgPlatformDeinitialiseInputDevices ( void ) void fgPlatformDeinitialiseInputDevices ( void )
{ {
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
fghCloseInputDevices (); fghCloseInputDevices ();
#endif /* !defined(_WIN32_WCE) */ #endif /* !defined(_WIN32_WCE) */
fgState.JoysticksInitialised = GL_FALSE; fgState.JoysticksInitialised = GL_FALSE;
fgState.InputDevsInitialised = GL_FALSE; fgState.InputDevsInitialised = GL_FALSE;
} }
void fgPlatformCloseDisplay ( void ) void fgPlatformCloseDisplay ( void )
{ {
if( fgDisplay.pDisplay.DisplayName ) if( fgDisplay.pDisplay.DisplayName )
{ {
free( fgDisplay.pDisplay.DisplayName ); free( fgDisplay.pDisplay.DisplayName );
fgDisplay.pDisplay.DisplayName = NULL; fgDisplay.pDisplay.DisplayName = NULL;
} }
/* Reset the timer granularity */ /* Reset the timer granularity */
timeEndPeriod ( 1 ); timeEndPeriod ( 1 );
} }
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext ) void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
{ {
/* Do nothing -- this is required for X11 */ /* Do nothing -- this is required for X11 */
} }
/* /*
* Everything down to the end of the next two functions is copied from the X sources. * Everything down to the end of the next two functions is copied from the X sources.
*/ */
/* /*
Copyright 1985, 1986, 1987,1998 The Open Group Copyright 1985, 1986, 1987,1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting copyright notice and this permission notice appear in supporting
documentation. documentation.
The above copyright notice and this permission notice shall be included The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software. in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 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 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization other dealings in this Software without prior written authorization
from The Open Group. from The Open Group.
*/ */
#define NoValue 0x0000 #define NoValue 0x0000
#define XValue 0x0001 #define XValue 0x0001
#define YValue 0x0002 #define YValue 0x0002
#define WidthValue 0x0004 #define WidthValue 0x0004
#define HeightValue 0x0008 #define HeightValue 0x0008
#define AllValues 0x000F #define AllValues 0x000F
#define XNegative 0x0010 #define XNegative 0x0010
#define YNegative 0x0020 #define YNegative 0x0020
/* /*
* XParseGeometry parses strings of the form * XParseGeometry parses strings of the form
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
* width, height, xoffset, and yoffset are unsigned integers. * width, height, xoffset, and yoffset are unsigned integers.
* Example: "=80x24+300-49" * Example: "=80x24+300-49"
* The equal sign is optional. * The equal sign is optional.
* It returns a bitmask that indicates which of the four values * It returns a bitmask that indicates which of the four values
* were actually found in the string. For each value found, * were actually found in the string. For each value found,
* the corresponding argument is updated; for each value * the corresponding argument is updated; for each value
* not found, the corresponding argument is left unchanged. * not found, the corresponding argument is left unchanged.
*/ */
static int static int
ReadInteger(char *string, char **NextString) ReadInteger(char *string, char **NextString)
{ {
register int Result = 0; register int Result = 0;
int Sign = 1; int Sign = 1;
if (*string == '+') if (*string == '+')
string++; string++;
else if (*string == '-') else if (*string == '-')
{ {
string++; string++;
Sign = -1; Sign = -1;
} }
for (; (*string >= '0') && (*string <= '9'); string++) for (; (*string >= '0') && (*string <= '9'); string++)
{ {
Result = (Result * 10) + (*string - '0'); Result = (Result * 10) + (*string - '0');
} }
*NextString = string; *NextString = string;
if (Sign >= 0) if (Sign >= 0)
return Result; return Result;
else else
return -Result; return -Result;
} }
int XParseGeometry ( int XParseGeometry (
const char *string, const char *string,
int *x, int *x,
int *y, int *y,
unsigned int *width, /* RETURN */ unsigned int *width, /* RETURN */
unsigned int *height) /* RETURN */ unsigned int *height) /* RETURN */
{ {
int mask = NoValue; int mask = NoValue;
register char *strind; register char *strind;
unsigned int tempWidth = 0, tempHeight = 0; unsigned int tempWidth = 0, tempHeight = 0;
int tempX = 0, tempY = 0; int tempX = 0, tempY = 0;
char *nextCharacter; char *nextCharacter;
if ( (string == NULL) || (*string == '\0')) if ( (string == NULL) || (*string == '\0'))
return mask; return mask;
if (*string == '=') if (*string == '=')
string++; /* ignore possible '=' at beg of geometry spec */ string++; /* ignore possible '=' at beg of geometry spec */
strind = (char *)string; strind = (char *)string;
if (*strind != '+' && *strind != '-' && *strind != 'x') { if (*strind != '+' && *strind != '-' && *strind != 'x') {
tempWidth = ReadInteger(strind, &nextCharacter); tempWidth = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
mask |= WidthValue; mask |= WidthValue;
} }
if (*strind == 'x' || *strind == 'X') { if (*strind == 'x' || *strind == 'X') {
strind++; strind++;
tempHeight = ReadInteger(strind, &nextCharacter); tempHeight = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
mask |= HeightValue; mask |= HeightValue;
} }
if ((*strind == '+') || (*strind == '-')) { if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') { if (*strind == '-') {
strind++; strind++;
tempX = -ReadInteger(strind, &nextCharacter); tempX = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
mask |= XNegative; mask |= XNegative;
} }
else else
{ {
strind++; strind++;
tempX = ReadInteger(strind, &nextCharacter); tempX = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
} }
mask |= XValue; mask |= XValue;
if ((*strind == '+') || (*strind == '-')) { if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') { if (*strind == '-') {
strind++; strind++;
tempY = -ReadInteger(strind, &nextCharacter); tempY = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
mask |= YNegative; mask |= YNegative;
} }
else else
{ {
strind++; strind++;
tempY = ReadInteger(strind, &nextCharacter); tempY = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter) if (strind == nextCharacter)
return 0; return 0;
strind = nextCharacter; strind = nextCharacter;
} }
mask |= YValue; mask |= YValue;
} }
} }
/* If strind isn't at the end of the string the it's an invalid /* If strind isn't at the end of the string the it's an invalid
geometry specification. */ geometry specification. */
if (*strind != '\0') return 0; if (*strind != '\0') return 0;
if (mask & XValue) if (mask & XValue)
*x = tempX; *x = tempX;
if (mask & YValue) if (mask & YValue)
*y = tempY; *y = tempY;
if (mask & WidthValue) if (mask & WidthValue)
*width = tempWidth; *width = tempWidth;
if (mask & HeightValue) if (mask & HeightValue)
*height = tempHeight; *height = tempHeight;
return mask; return mask;
} }
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */ /* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
void (__cdecl *__glutExitFunc)( int return_value ) = NULL; void (__cdecl *__glutExitFunc)( int return_value ) = NULL;
void FGAPIENTRY __glutInitWithExit( int *pargc, char **argv, void (__cdecl *exit_function)(int) ) void FGAPIENTRY __glutInitWithExit( int *pargc, char **argv, void (__cdecl *exit_function)(int) )
{ {
__glutExitFunc = exit_function; __glutExitFunc = exit_function;
glutInit(pargc, argv); glutInit(pargc, argv);
} }

View File

@ -1,127 +1,127 @@
/* /*
* freeglut_input_devices_mswin.c * freeglut_input_devices_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sat Jan 21, 2012 * Creation date: Sat Jan 21, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
#include <sys/types.h> #include <sys/types.h>
#include <winbase.h> #include <winbase.h>
typedef struct { typedef struct {
HANDLE fh; HANDLE fh;
COMMTIMEOUTS timeouts_save; COMMTIMEOUTS timeouts_save;
DCB dcb_save; DCB dcb_save;
} SERIALPORT; } SERIALPORT;
/* Serial Port Prototypes */ /* Serial Port Prototypes */
SERIALPORT *serial_open ( const char *device ); SERIALPORT *serial_open ( const char *device );
void serial_close ( SERIALPORT *port ); void serial_close ( SERIALPORT *port );
int serial_getchar ( SERIALPORT *port ); int serial_getchar ( SERIALPORT *port );
int serial_putchar ( SERIALPORT *port, unsigned char ch ); int serial_putchar ( SERIALPORT *port, unsigned char ch );
void serial_flush ( SERIALPORT *port ); void serial_flush ( SERIALPORT *port );
void fgPlatformRegisterDialDevice ( const char *dial_device ) void fgPlatformRegisterDialDevice ( const char *dial_device )
{ {
if (!dial_device){ if (!dial_device){
static char devname[256]; static char devname[256];
DWORD size=sizeof(devname); DWORD size=sizeof(devname);
DWORD type = REG_SZ; DWORD type = REG_SZ;
HKEY key; HKEY key;
if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) { if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) {
if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){ if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){
dial_device=devname; dial_device=devname;
} }
RegCloseKey(key); RegCloseKey(key);
} }
} }
} }
/* Serial Port Functions */ /* Serial Port Functions */
SERIALPORT *serial_open(const char *device){ SERIALPORT *serial_open(const char *device){
HANDLE fh; HANDLE fh;
DCB dcb={sizeof(DCB)}; DCB dcb={sizeof(DCB)};
COMMTIMEOUTS timeouts; COMMTIMEOUTS timeouts;
SERIALPORT *port; SERIALPORT *port;
fh = CreateFile(device,GENERIC_READ|GENERIC_WRITE,0,NULL, fh = CreateFile(device,GENERIC_READ|GENERIC_WRITE,0,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (!fh) return NULL; if (!fh) return NULL;
port = malloc(sizeof(SERIALPORT)); port = malloc(sizeof(SERIALPORT));
ZeroMemory(port, sizeof(SERIALPORT)); ZeroMemory(port, sizeof(SERIALPORT));
port->fh = fh; port->fh = fh;
/* save current port settings */ /* save current port settings */
GetCommState(fh,&port->dcb_save); GetCommState(fh,&port->dcb_save);
GetCommTimeouts(fh,&port->timeouts_save); GetCommTimeouts(fh,&port->timeouts_save);
dcb.DCBlength=sizeof(DCB); dcb.DCBlength=sizeof(DCB);
BuildCommDCB("96,n,8,1",&dcb); BuildCommDCB("96,n,8,1",&dcb);
SetCommState(fh,&dcb); SetCommState(fh,&dcb);
ZeroMemory(&timeouts,sizeof(timeouts)); ZeroMemory(&timeouts,sizeof(timeouts));
timeouts.ReadTotalTimeoutConstant=1; timeouts.ReadTotalTimeoutConstant=1;
timeouts.WriteTotalTimeoutConstant=1; timeouts.WriteTotalTimeoutConstant=1;
SetCommTimeouts(fh,&timeouts); SetCommTimeouts(fh,&timeouts);
serial_flush(port); serial_flush(port);
return port; return port;
} }
void serial_close(SERIALPORT *port){ void serial_close(SERIALPORT *port){
if (port){ if (port){
/* restore old port settings */ /* restore old port settings */
SetCommState(port->fh,&port->dcb_save); SetCommState(port->fh,&port->dcb_save);
SetCommTimeouts(port->fh,&port->timeouts_save); SetCommTimeouts(port->fh,&port->timeouts_save);
CloseHandle(port->fh); CloseHandle(port->fh);
free(port); free(port);
} }
} }
int serial_getchar(SERIALPORT *port){ int serial_getchar(SERIALPORT *port){
DWORD n; DWORD n;
unsigned char ch; unsigned char ch;
if (!port) return EOF; if (!port) return EOF;
if (!ReadFile(port->fh,&ch,1,&n,NULL)) return EOF; if (!ReadFile(port->fh,&ch,1,&n,NULL)) return EOF;
if (n==1) return ch; if (n==1) return ch;
return EOF; return EOF;
} }
int serial_putchar(SERIALPORT *port, unsigned char ch){ int serial_putchar(SERIALPORT *port, unsigned char ch){
DWORD n; DWORD n;
if (!port) return 0; if (!port) return 0;
return WriteFile(port->fh,&ch,1,&n,NULL); return WriteFile(port->fh,&ch,1,&n,NULL);
} }
void serial_flush ( SERIALPORT *port ) void serial_flush ( SERIALPORT *port )
{ {
FlushFileBuffers(port->fh); FlushFileBuffers(port->fh);
} }

View File

@ -1,124 +1,124 @@
/* /*
* freeglut_internal_mswin.h * freeglut_internal_mswin.h
* *
* The freeglut library private include file. * The freeglut library private include file.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Thu Jan 19, 2012 * Creation date: Thu Jan 19, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef FREEGLUT_INTERNAL_MSWIN_H #ifndef FREEGLUT_INTERNAL_MSWIN_H
#define FREEGLUT_INTERNAL_MSWIN_H #define FREEGLUT_INTERNAL_MSWIN_H
/* All Win32 headers depend on the huge windows.h recursive include. /* All Win32 headers depend on the huge windows.h recursive include.
* Note: Lower-case header names are used, for best cross-platform * Note: Lower-case header names are used, for best cross-platform
* compatibility. * compatibility.
*/ */
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
# include <windows.h> # include <windows.h>
# include <windowsx.h> # include <windowsx.h>
# include <mmsystem.h> # include <mmsystem.h>
/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */ /* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */
# ifndef __CYGWIN__ # ifndef __CYGWIN__
# include <tchar.h> # include <tchar.h>
# else # else
# define _TEXT(x) TEXT(x) # define _TEXT(x) TEXT(x)
# define _T(x) TEXT(x) # define _T(x) TEXT(x)
# endif # endif
#endif #endif
#define HAVE_VFPRINTF 1 #define HAVE_VFPRINTF 1
/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */ /* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */
#if !defined(ChangeDisplaySettingsEx) #if !defined(ChangeDisplaySettingsEx)
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID); LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID); LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
# ifdef UNICODE # ifdef UNICODE
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExW # define ChangeDisplaySettingsEx ChangeDisplaySettingsExW
# else # else
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExA # define ChangeDisplaySettingsEx ChangeDisplaySettingsExA
# endif # endif
#endif #endif
/* Structure Definitions */ /* Structure Definitions */
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay; typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
struct tagSFG_PlatformDisplay struct tagSFG_PlatformDisplay
{ {
HINSTANCE Instance; /* The application's instance */ HINSTANCE Instance; /* The application's instance */
DEVMODE DisplayMode; /* Desktop's display settings */ DEVMODE DisplayMode; /* Desktop's display settings */
char *DisplayName; /* Display name for multi display support*/ char *DisplayName; /* Display name for multi display support*/
}; };
/* /*
* Make "freeglut" window handle and context types so that we don't need so * Make "freeglut" window handle and context types so that we don't need so
* much conditionally-compiled code later in the library. * much conditionally-compiled code later in the library.
*/ */
typedef HWND SFG_WindowHandleType ; typedef HWND SFG_WindowHandleType ;
typedef HGLRC SFG_WindowContextType ; typedef HGLRC SFG_WindowContextType ;
typedef struct tagSFG_PlatformContext SFG_PlatformContext; typedef struct tagSFG_PlatformContext SFG_PlatformContext;
struct tagSFG_PlatformContext struct tagSFG_PlatformContext
{ {
HDC Device; /* The window's device context */ HDC Device; /* The window's device context */
}; };
/* Window's state description. This structure should be kept portable. */ /* Window's state description. This structure should be kept portable. */
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState struct tagSFG_PlatformWindowState
{ {
RECT OldRect; /* window rect - stored before the window is made fullscreen */ RECT OldRect; /* window rect - stored before the window is made fullscreen */
DWORD OldStyle; /* window style - stored before the window is made fullscreen */ DWORD OldStyle; /* window style - stored before the window is made fullscreen */
}; };
/* Joystick-Specific Definitions */ /* Joystick-Specific Definitions */
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
# define _JS_MAX_AXES 8 # define _JS_MAX_AXES 8
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
struct tagSFG_PlatformJoystick struct tagSFG_PlatformJoystick
{ {
JOYCAPS jsCaps; JOYCAPS jsCaps;
JOYINFOEX js; JOYINFOEX js;
UINT js_id; UINT js_id;
}; };
#endif #endif
/* Menu font and color definitions */ /* Menu font and color definitions */
#define FREEGLUT_MENU_FONT GLUT_BITMAP_8_BY_13 #define FREEGLUT_MENU_FONT GLUT_BITMAP_8_BY_13
#define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f} #define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
#define FREEGLUT_MENU_PEN_BACK_COLORS {0.85f, 0.85f, 0.85f, 1.0f} #define FREEGLUT_MENU_PEN_BACK_COLORS {0.85f, 0.85f, 0.85f, 1.0f}
#define FREEGLUT_MENU_PEN_HFORE_COLORS {1.0f, 1.0f, 1.0f, 1.0f} #define FREEGLUT_MENU_PEN_HFORE_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
#define FREEGLUT_MENU_PEN_HBACK_COLORS {0.15f, 0.15f, 0.45f, 1.0f} #define FREEGLUT_MENU_PEN_HBACK_COLORS {0.15f, 0.15f, 0.45f, 1.0f}
/* Function to be called on exit */ /* Function to be called on exit */
extern void (__cdecl *__glutExitFunc)( int return_value ); extern void (__cdecl *__glutExitFunc)( int return_value );
#endif /* FREEGLUT_INTERNAL_MSWIN_H */ #endif /* FREEGLUT_INTERNAL_MSWIN_H */

View File

@ -1,264 +1,264 @@
/* /*
* freeglut_joystick_mswin.c * freeglut_joystick_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sat Jan 28, 2012 * Creation date: Sat Jan 28, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
# include <windows.h> # include <windows.h>
# include <mmsystem.h> # include <mmsystem.h>
# include <regstr.h> # include <regstr.h>
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
{ {
MMRESULT status; MMRESULT status;
status = joyGetPosEx( joy->pJoystick.js_id, &joy->pJoystick.js ); status = joyGetPosEx( joy->pJoystick.js_id, &joy->pJoystick.js );
if ( status != JOYERR_NOERROR ) if ( status != JOYERR_NOERROR )
{ {
joy->error = GL_TRUE; joy->error = GL_TRUE;
return; return;
} }
if ( buttons ) if ( buttons )
*buttons = joy->pJoystick.js.dwButtons; *buttons = joy->pJoystick.js.dwButtons;
if ( axes ) if ( axes )
{ {
/* /*
* WARNING - Fall through case clauses!! * WARNING - Fall through case clauses!!
*/ */
switch ( joy->num_axes ) switch ( joy->num_axes )
{ {
case 8: case 8:
/* Generate two POV axes from the POV hat angle. /* Generate two POV axes from the POV hat angle.
* Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in * Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in
* hundredths of a degree, or 0xFFFF when idle. * hundredths of a degree, or 0xFFFF when idle.
*/ */
if ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) == 0xFFFF ) if ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) == 0xFFFF )
{ {
axes [ 6 ] = 0.0; axes [ 6 ] = 0.0;
axes [ 7 ] = 0.0; axes [ 7 ] = 0.0;
} }
else else
{ {
/* This is the contentious bit: how to convert angle to X/Y. /* This is the contentious bit: how to convert angle to X/Y.
* wk: I know of no define for PI that we could use here: * wk: I know of no define for PI that we could use here:
* SG_PI would pull in sg, M_PI is undefined for MSVC * SG_PI would pull in sg, M_PI is undefined for MSVC
* But the accuracy of the value of PI is very unimportant at * But the accuracy of the value of PI is very unimportant at
* this point. * this point.
*/ */
float s = (float) sin ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) * ( 0.01 * 3.1415926535f / 180.0f ) ); float s = (float) sin ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) * ( 0.01 * 3.1415926535f / 180.0f ) );
float c = (float) cos ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) * ( 0.01 * 3.1415926535f / 180.0f ) ); float c = (float) cos ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) * ( 0.01 * 3.1415926535f / 180.0f ) );
/* Convert to coordinates on a square so that North-East /* Convert to coordinates on a square so that North-East
* is (1,1) not (.7,.7), etc. * is (1,1) not (.7,.7), etc.
* s and c cannot both be zero so we won't divide by zero. * s and c cannot both be zero so we won't divide by zero.
*/ */
if ( fabs ( s ) < fabs ( c ) ) if ( fabs ( s ) < fabs ( c ) )
{ {
axes [ 6 ] = ( c < 0.0 ) ? -s/c : s/c ; axes [ 6 ] = ( c < 0.0 ) ? -s/c : s/c ;
axes [ 7 ] = ( c < 0.0 ) ? -1.0f : 1.0f; axes [ 7 ] = ( c < 0.0 ) ? -1.0f : 1.0f;
} }
else else
{ {
axes [ 6 ] = ( s < 0.0 ) ? -1.0f : 1.0f; axes [ 6 ] = ( s < 0.0 ) ? -1.0f : 1.0f;
axes [ 7 ] = ( s < 0.0 ) ? -c/s : c/s ; axes [ 7 ] = ( s < 0.0 ) ? -c/s : c/s ;
} }
} }
case 6: axes[5] = (float) joy->pJoystick.js.dwVpos; case 6: axes[5] = (float) joy->pJoystick.js.dwVpos;
case 5: axes[4] = (float) joy->pJoystick.js.dwUpos; case 5: axes[4] = (float) joy->pJoystick.js.dwUpos;
case 4: axes[3] = (float) joy->pJoystick.js.dwRpos; case 4: axes[3] = (float) joy->pJoystick.js.dwRpos;
case 3: axes[2] = (float) joy->pJoystick.js.dwZpos; case 3: axes[2] = (float) joy->pJoystick.js.dwZpos;
case 2: axes[1] = (float) joy->pJoystick.js.dwYpos; case 2: axes[1] = (float) joy->pJoystick.js.dwYpos;
case 1: axes[0] = (float) joy->pJoystick.js.dwXpos; case 1: axes[0] = (float) joy->pJoystick.js.dwXpos;
} }
} }
} }
/* Inspired by /* Inspired by
http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp
*/ */
# if FREEGLUT_LIB_PRAGMAS # if FREEGLUT_LIB_PRAGMAS
# pragma comment (lib, "advapi32.lib") # pragma comment (lib, "advapi32.lib")
# endif # endif
static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz ) static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz )
{ {
char buffer [ 256 ]; char buffer [ 256 ];
char OEMKey [ 256 ]; char OEMKey [ 256 ];
HKEY hKey; HKEY hKey;
DWORD dwcb; DWORD dwcb;
LONG lr; LONG lr;
if ( joy->error ) if ( joy->error )
return 0; return 0;
/* Open .. MediaResources\CurrentJoystickSettings */ /* Open .. MediaResources\CurrentJoystickSettings */
_snprintf ( buffer, sizeof(buffer), "%s\\%s\\%s", _snprintf ( buffer, sizeof(buffer), "%s\\%s\\%s",
REGSTR_PATH_JOYCONFIG, joy->pJoystick.jsCaps.szRegKey, REGSTR_PATH_JOYCONFIG, joy->pJoystick.jsCaps.szRegKey,
REGSTR_KEY_JOYCURR ); REGSTR_KEY_JOYCURR );
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey); lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
if ( lr != ERROR_SUCCESS ) return 0; if ( lr != ERROR_SUCCESS ) return 0;
/* Get OEM Key name */ /* Get OEM Key name */
dwcb = sizeof(OEMKey); dwcb = sizeof(OEMKey);
/* JOYSTICKID1-16 is zero-based; registry entries for VJOYD are 1-based. */ /* JOYSTICKID1-16 is zero-based; registry entries for VJOYD are 1-based. */
_snprintf ( buffer, sizeof(buffer), "Joystick%d%s", joy->pJoystick.js_id + 1, REGSTR_VAL_JOYOEMNAME ); _snprintf ( buffer, sizeof(buffer), "Joystick%d%s", joy->pJoystick.js_id + 1, REGSTR_VAL_JOYOEMNAME );
lr = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEMKey, &dwcb); lr = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEMKey, &dwcb);
RegCloseKey ( hKey ); RegCloseKey ( hKey );
if ( lr != ERROR_SUCCESS ) return 0; if ( lr != ERROR_SUCCESS ) return 0;
/* Open OEM Key from ...MediaProperties */ /* Open OEM Key from ...MediaProperties */
_snprintf ( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEMKey ); _snprintf ( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEMKey );
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey ); lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey );
if ( lr != ERROR_SUCCESS ) return 0; if ( lr != ERROR_SUCCESS ) return 0;
/* Get OEM Name */ /* Get OEM Name */
dwcb = buf_sz; dwcb = buf_sz;
lr = RegQueryValueEx ( hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buf, lr = RegQueryValueEx ( hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buf,
&dwcb ); &dwcb );
RegCloseKey ( hKey ); RegCloseKey ( hKey );
if ( lr != ERROR_SUCCESS ) return 0; if ( lr != ERROR_SUCCESS ) return 0;
return 1; return 1;
} }
void fgPlatformJoystickOpen( SFG_Joystick* joy ) void fgPlatformJoystickOpen( SFG_Joystick* joy )
{ {
int i = 0; int i = 0;
joy->pJoystick.js.dwFlags = JOY_RETURNALL; joy->pJoystick.js.dwFlags = JOY_RETURNALL;
joy->pJoystick.js.dwSize = sizeof( joy->pJoystick.js ); joy->pJoystick.js.dwSize = sizeof( joy->pJoystick.js );
memset( &joy->pJoystick.jsCaps, 0, sizeof( joy->pJoystick.jsCaps ) ); memset( &joy->pJoystick.jsCaps, 0, sizeof( joy->pJoystick.jsCaps ) );
joy->error = joy->error =
( joyGetDevCaps( joy->pJoystick.js_id, &joy->pJoystick.jsCaps, sizeof( joy->pJoystick.jsCaps ) ) != ( joyGetDevCaps( joy->pJoystick.js_id, &joy->pJoystick.jsCaps, sizeof( joy->pJoystick.jsCaps ) ) !=
JOYERR_NOERROR ); JOYERR_NOERROR );
if( joy->pJoystick.jsCaps.wNumAxes == 0 ) if( joy->pJoystick.jsCaps.wNumAxes == 0 )
{ {
joy->num_axes = 0; joy->num_axes = 0;
joy->error = GL_TRUE; joy->error = GL_TRUE;
} }
else else
{ {
/* Device name from jsCaps is often "Microsoft PC-joystick driver", /* Device name from jsCaps is often "Microsoft PC-joystick driver",
* at least for USB. Try to get the real name from the registry. * at least for USB. Try to get the real name from the registry.
*/ */
if ( ! fghJoystickGetOEMProductName( joy, joy->name, if ( ! fghJoystickGetOEMProductName( joy, joy->name,
sizeof( joy->name ) ) ) sizeof( joy->name ) ) )
{ {
fgWarning( "JS: Failed to read joystick name from registry" ); fgWarning( "JS: Failed to read joystick name from registry" );
strncpy( joy->name, joy->pJoystick.jsCaps.szPname, sizeof( joy->name ) ); strncpy( joy->name, joy->pJoystick.jsCaps.szPname, sizeof( joy->name ) );
} }
/* Windows joystick drivers may provide any combination of /* Windows joystick drivers may provide any combination of
* X,Y,Z,R,U,V,POV - not necessarily the first n of these. * X,Y,Z,R,U,V,POV - not necessarily the first n of these.
*/ */
if( joy->pJoystick.jsCaps.wCaps & JOYCAPS_HASPOV ) if( joy->pJoystick.jsCaps.wCaps & JOYCAPS_HASPOV )
{ {
joy->num_axes = _JS_MAX_AXES; joy->num_axes = _JS_MAX_AXES;
joy->min[ 7 ] = -1.0; joy->max[ 7 ] = 1.0; /* POV Y */ joy->min[ 7 ] = -1.0; joy->max[ 7 ] = 1.0; /* POV Y */
joy->min[ 6 ] = -1.0; joy->max[ 6 ] = 1.0; /* POV X */ joy->min[ 6 ] = -1.0; joy->max[ 6 ] = 1.0; /* POV X */
} }
else else
joy->num_axes = 6; joy->num_axes = 6;
joy->min[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmin; joy->min[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmin;
joy->max[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmax; joy->max[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmax;
joy->min[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmin; joy->min[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmin;
joy->max[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmax; joy->max[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmax;
joy->min[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmin; joy->min[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmin;
joy->max[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmax; joy->max[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmax;
joy->min[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmin; joy->min[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmin;
joy->max[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmax; joy->max[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmax;
joy->min[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmin; joy->min[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmin;
joy->max[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmax; joy->max[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmax;
joy->min[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmin; joy->min[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmin;
joy->max[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmax; joy->max[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmax;
} }
/* Guess all the rest judging on the axes extremals */ /* Guess all the rest judging on the axes extremals */
for( i = 0; i < joy->num_axes; i++ ) for( i = 0; i < joy->num_axes; i++ )
{ {
joy->center [ i ] = ( joy->max[ i ] + joy->min[ i ] ) * 0.5f; joy->center [ i ] = ( joy->max[ i ] + joy->min[ i ] ) * 0.5f;
joy->dead_band[ i ] = 0.0f; joy->dead_band[ i ] = 0.0f;
joy->saturate [ i ] = 1.0f; joy->saturate [ i ] = 1.0f;
} }
} }
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident ) void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
{ {
switch( ident ) switch( ident )
{ {
case 0: case 0:
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID1; fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID1;
fgJoystick[ ident ]->error = GL_FALSE; fgJoystick[ ident ]->error = GL_FALSE;
break; break;
case 1: case 1:
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID2; fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID2;
fgJoystick[ ident ]->error = GL_FALSE; fgJoystick[ ident ]->error = GL_FALSE;
break; break;
default: default:
fgJoystick[ ident ]->num_axes = 0; fgJoystick[ ident ]->num_axes = 0;
fgJoystick[ ident ]->error = GL_TRUE; fgJoystick[ ident ]->error = GL_TRUE;
return; return;
} }
} }
void fgPlatformJoystickClose ( int ident ) void fgPlatformJoystickClose ( int ident )
{ {
/* Do nothing special */ /* Do nothing special */
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +1,48 @@
/* /*
* freeglut_menu_mswin.c * freeglut_menu_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sun Jan 22, 2012 * Creation date: Sun Jan 22, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define FREEGLUT_BUILDING_LIB #define FREEGLUT_BUILDING_LIB
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y ) GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
{ {
*x = glutGet ( GLUT_SCREEN_WIDTH ); *x = glutGet ( GLUT_SCREEN_WIDTH );
*y = glutGet ( GLUT_SCREEN_HEIGHT ); *y = glutGet ( GLUT_SCREEN_HEIGHT );
} }
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */ /* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl *exit_function)(int) ) int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl *exit_function)(int) )
{ {
__glutExitFunc = exit_function; __glutExitFunc = exit_function;
return glutCreateMenu( callback ); return glutCreateMenu( callback );
} }

View File

@ -1,58 +1,58 @@
/* /*
* freeglut_spaceball_mswin.c * freeglut_spaceball_mswin.c
* *
* Spaceball support for Windows * Spaceball support for Windows
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by Evan Felix <karcaw at gmail.com> * Written by Evan Felix <karcaw at gmail.com>
* Creation date: Sat Feb 4, 2012 * Creation date: Sat Feb 4, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* /*
* This code is a very complicated way of doing nothing. * This code is a very complicated way of doing nothing.
* But is needed for mswindows platform builds. * But is needed for mswindows platform builds.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
void fgPlatformInitializeSpaceball(void) void fgPlatformInitializeSpaceball(void)
{ {
return; return;
} }
void fgPlatformSpaceballClose(void) void fgPlatformSpaceballClose(void)
{ {
return; return;
} }
int fgPlatformHasSpaceball(void) int fgPlatformHasSpaceball(void)
{ {
return 0; return 0;
} }
int fgPlatformSpaceballNumButtons(void) int fgPlatformSpaceballNumButtons(void)
{ {
return 0; return 0;
} }
void fgPlatformSpaceballSetWindow(SFG_Window *window) void fgPlatformSpaceballSetWindow(SFG_Window *window)
{ {
return; return;
} }

View File

@ -1,343 +1,343 @@
/* /*
* freeglut_state_mswin.c * freeglut_state_mswin.c
* *
* The Windows-specific state query methods. * The Windows-specific state query methods.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sun Jan 22, 2012 * Creation date: Sun Jan 22, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
unsigned char layer_type ); unsigned char layer_type );
/* /*
* Helper functions for getting client area from the window rect * Helper functions for getting client area from the window rect
* and the window rect from the client area given the style of the window * and the window rect from the client area given the style of the window
* (or a valid window pointer from which the style can be queried). * (or a valid window pointer from which the style can be queried).
*/ */
extern RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside ); extern RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside );
extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth); extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth);
/* The following include file is available from SGI but is not standard: /* The following include file is available from SGI but is not standard:
* #include <GL/wglext.h> * #include <GL/wglext.h>
* So we copy the necessary parts out of it to support the multisampling query * So we copy the necessary parts out of it to support the multisampling query
*/ */
#define WGL_SAMPLES_ARB 0x2042 #define WGL_SAMPLES_ARB 0x2042
int fgPlatformGlutGet ( GLenum eWhat ) int fgPlatformGlutGet ( GLenum eWhat )
{ {
int returnValue ; int returnValue ;
GLboolean boolValue ; GLboolean boolValue ;
int nsamples = 0; int nsamples = 0;
switch( eWhat ) switch( eWhat )
{ {
case GLUT_WINDOW_NUM_SAMPLES: case GLUT_WINDOW_NUM_SAMPLES:
glGetIntegerv(WGL_SAMPLES_ARB, &nsamples); glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
return nsamples; return nsamples;
/* Handle the OpenGL inquiries */ /* Handle the OpenGL inquiries */
case GLUT_WINDOW_RGBA: case GLUT_WINDOW_RGBA:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */ boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
#else #else
glGetBooleanv ( GL_RGBA_MODE, &boolValue ); glGetBooleanv ( GL_RGBA_MODE, &boolValue );
returnValue = boolValue ? 1 : 0; returnValue = boolValue ? 1 : 0;
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_DOUBLEBUFFER: case GLUT_WINDOW_DOUBLEBUFFER:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */ boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
#else #else
glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue ); glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
returnValue = boolValue ? 1 : 0; returnValue = boolValue ? 1 : 0;
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_STEREO: case GLUT_WINDOW_STEREO:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */ boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
#else #else
glGetBooleanv ( GL_STEREO, &boolValue ); glGetBooleanv ( GL_STEREO, &boolValue );
returnValue = boolValue ? 1 : 0; returnValue = boolValue ? 1 : 0;
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_RED_SIZE: case GLUT_WINDOW_RED_SIZE:
glGetIntegerv ( GL_RED_BITS, &returnValue ); glGetIntegerv ( GL_RED_BITS, &returnValue );
return returnValue; return returnValue;
case GLUT_WINDOW_GREEN_SIZE: case GLUT_WINDOW_GREEN_SIZE:
glGetIntegerv ( GL_GREEN_BITS, &returnValue ); glGetIntegerv ( GL_GREEN_BITS, &returnValue );
return returnValue; return returnValue;
case GLUT_WINDOW_BLUE_SIZE: case GLUT_WINDOW_BLUE_SIZE:
glGetIntegerv ( GL_BLUE_BITS, &returnValue ); glGetIntegerv ( GL_BLUE_BITS, &returnValue );
return returnValue; return returnValue;
case GLUT_WINDOW_ALPHA_SIZE: case GLUT_WINDOW_ALPHA_SIZE:
glGetIntegerv ( GL_ALPHA_BITS, &returnValue ); glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
return returnValue; return returnValue;
case GLUT_WINDOW_ACCUM_RED_SIZE: case GLUT_WINDOW_ACCUM_RED_SIZE:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
returnValue = 0; /* WinCE doesn't support this feature */ returnValue = 0; /* WinCE doesn't support this feature */
#else #else
glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue ); glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_ACCUM_GREEN_SIZE: case GLUT_WINDOW_ACCUM_GREEN_SIZE:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
returnValue = 0; /* WinCE doesn't support this feature */ returnValue = 0; /* WinCE doesn't support this feature */
#else #else
glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue ); glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_ACCUM_BLUE_SIZE: case GLUT_WINDOW_ACCUM_BLUE_SIZE:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
returnValue = 0; /* WinCE doesn't support this feature */ returnValue = 0; /* WinCE doesn't support this feature */
#else #else
glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue ); glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_ACCUM_ALPHA_SIZE: case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
returnValue = 0; /* WinCE doesn't support this feature */ returnValue = 0; /* WinCE doesn't support this feature */
#else #else
glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue ); glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
#endif #endif
return returnValue; return returnValue;
case GLUT_WINDOW_DEPTH_SIZE: case GLUT_WINDOW_DEPTH_SIZE:
glGetIntegerv ( GL_DEPTH_BITS, &returnValue ); glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
return returnValue; return returnValue;
case GLUT_WINDOW_BUFFER_SIZE: case GLUT_WINDOW_BUFFER_SIZE:
returnValue = 1 ; /* ????? */ returnValue = 1 ; /* ????? */
return returnValue; return returnValue;
case GLUT_WINDOW_STENCIL_SIZE: case GLUT_WINDOW_STENCIL_SIZE:
returnValue = 0 ; /* ????? */ returnValue = 0 ; /* ????? */
return returnValue; return returnValue;
case GLUT_WINDOW_X: case GLUT_WINDOW_X:
case GLUT_WINDOW_Y: case GLUT_WINDOW_Y:
case GLUT_WINDOW_WIDTH: case GLUT_WINDOW_WIDTH:
case GLUT_WINDOW_HEIGHT: case GLUT_WINDOW_HEIGHT:
{ {
/* /*
* There is considerable confusion about the "right thing to * There is considerable confusion about the "right thing to
* do" concerning window size and position. GLUT itself is * do" concerning window size and position. GLUT itself is
* not consistent between Windows and UNIX/X11; since * not consistent between Windows and UNIX/X11; since
* platform independence is a virtue for "freeglut", we * platform independence is a virtue for "freeglut", we
* decided to break with GLUT's behaviour. * decided to break with GLUT's behaviour.
* *
* Under UNIX/X11, it is apparently not possible to get the * Under UNIX/X11, it is apparently not possible to get the
* window border sizes in order to subtract them off the * window border sizes in order to subtract them off the
* window's initial position until some time after the window * window's initial position until some time after the window
* has been created. Therefore we decided on the following * has been created. Therefore we decided on the following
* behaviour, both under Windows and under UNIX/X11: * behaviour, both under Windows and under UNIX/X11:
* - When you create a window with position (x,y) and size * - When you create a window with position (x,y) and size
* (w,h), the upper left hand corner of the outside of the * (w,h), the upper left hand corner of the outside of the
* window is at (x,y) and the size of the drawable area is * window is at (x,y) and the size of the drawable area is
* (w,h). * (w,h).
* - When you query the size and position of the window--as * - When you query the size and position of the window--as
* is happening here for Windows--"freeglut" will return * is happening here for Windows--"freeglut" will return
* the size of the drawable area--the (w,h) that you * the size of the drawable area--the (w,h) that you
* specified when you created the window--and the coordinates * specified when you created the window--and the coordinates
* of the upper left hand corner of the drawable * of the upper left hand corner of the drawable
* area--which is NOT the (x,y) you specified. * area--which is NOT the (x,y) you specified.
*/ */
RECT winRect; RECT winRect;
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 ); freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect ); GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
#else #else
winRect = fghGetClientArea(fgStructure.CurrentWindow, FALSE); winRect = fghGetClientArea(fgStructure.CurrentWindow, FALSE);
#endif /* defined(_WIN32_WCE) */ #endif /* defined(_WIN32_WCE) */
switch( eWhat ) switch( eWhat )
{ {
case GLUT_WINDOW_X: return winRect.left ; case GLUT_WINDOW_X: return winRect.left ;
case GLUT_WINDOW_Y: return winRect.top ; case GLUT_WINDOW_Y: return winRect.top ;
case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left; case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top; case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
} }
} }
break; break;
case GLUT_WINDOW_BORDER_WIDTH : case GLUT_WINDOW_BORDER_WIDTH :
case GLUT_WINDOW_HEADER_HEIGHT : case GLUT_WINDOW_HEADER_HEIGHT :
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
return 0; return 0;
#else #else
{ {
DWORD windowStyle; DWORD windowStyle;
if (fgStructure.CurrentWindow && fgStructure.CurrentWindow->Window.Handle) if (fgStructure.CurrentWindow && fgStructure.CurrentWindow->Window.Handle)
windowStyle = GetWindowLong(fgStructure.CurrentWindow->Window.Handle, GWL_STYLE); windowStyle = GetWindowLong(fgStructure.CurrentWindow->Window.Handle, GWL_STYLE);
else else
/* If no window, return sizes for a default window with title bar and border */ /* If no window, return sizes for a default window with title bar and border */
windowStyle = WS_OVERLAPPEDWINDOW; windowStyle = WS_OVERLAPPEDWINDOW;
switch( eWhat ) switch( eWhat )
{ {
case GLUT_WINDOW_BORDER_WIDTH: case GLUT_WINDOW_BORDER_WIDTH:
{ {
int xBorderWidth, yBorderWidth; int xBorderWidth, yBorderWidth;
fghGetBorderWidth(windowStyle, &xBorderWidth, &yBorderWidth); fghGetBorderWidth(windowStyle, &xBorderWidth, &yBorderWidth);
return xBorderWidth; return xBorderWidth;
} }
case GLUT_WINDOW_HEADER_HEIGHT: case GLUT_WINDOW_HEADER_HEIGHT:
/* Need to query for WS_MAXIMIZEBOX to see if we have a title bar, the WS_CAPTION query is also true for a WS_DLGFRAME only... */ /* Need to query for WS_MAXIMIZEBOX to see if we have a title bar, the WS_CAPTION query is also true for a WS_DLGFRAME only... */
return (windowStyle & WS_MAXIMIZEBOX)? GetSystemMetrics( SM_CYCAPTION ) : 0; return (windowStyle & WS_MAXIMIZEBOX)? GetSystemMetrics( SM_CYCAPTION ) : 0;
} }
} }
#endif /* defined(_WIN32_WCE) */ #endif /* defined(_WIN32_WCE) */
case GLUT_DISPLAY_MODE_POSSIBLE: case GLUT_DISPLAY_MODE_POSSIBLE:
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
return 0; return 0;
#else #else
return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE, return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
PFD_MAIN_PLANE ); PFD_MAIN_PLANE );
#endif /* defined(_WIN32_WCE) */ #endif /* defined(_WIN32_WCE) */
case GLUT_WINDOW_FORMAT_ID: case GLUT_WINDOW_FORMAT_ID:
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
if( fgStructure.CurrentWindow != NULL ) if( fgStructure.CurrentWindow != NULL )
return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device ); return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device );
#endif /* defined(_WIN32_WCE) */ #endif /* defined(_WIN32_WCE) */
return 0; return 0;
default: default:
fgWarning( "glutGet(): missing enum handle %d", eWhat ); fgWarning( "glutGet(): missing enum handle %d", eWhat );
break; break;
} }
return -1; return -1;
} }
int fgPlatformGlutDeviceGet ( GLenum eWhat ) int fgPlatformGlutDeviceGet ( GLenum eWhat )
{ {
switch( eWhat ) switch( eWhat )
{ {
case GLUT_HAS_KEYBOARD: case GLUT_HAS_KEYBOARD:
/* /*
* Win32 is assumed a keyboard, and this cannot be queried, * Win32 is assumed a keyboard, and this cannot be queried,
* except for WindowsCE. * except for WindowsCE.
* *
* X11 has a core keyboard by definition, although it can * X11 has a core keyboard by definition, although it can
* be present as a virtual/dummy keyboard. For now, there * be present as a virtual/dummy keyboard. For now, there
* is no reliable way to tell if a real keyboard is present. * is no reliable way to tell if a real keyboard is present.
*/ */
#if defined(_WIN32_CE) #if defined(_WIN32_CE)
return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0; return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
# if FREEGLUT_LIB_PRAGMAS # if FREEGLUT_LIB_PRAGMAS
# pragma comment (lib,"Kbdui.lib") # pragma comment (lib,"Kbdui.lib")
# endif # endif
#else #else
return 1; return 1;
#endif #endif
case GLUT_HAS_MOUSE: case GLUT_HAS_MOUSE:
/* /*
* MS Windows can be booted without a mouse. * MS Windows can be booted without a mouse.
*/ */
return GetSystemMetrics( SM_MOUSEPRESENT ); return GetSystemMetrics( SM_MOUSEPRESENT );
case GLUT_NUM_MOUSE_BUTTONS: case GLUT_NUM_MOUSE_BUTTONS:
# if defined(_WIN32_WCE) # if defined(_WIN32_WCE)
return 1; return 1;
# else # else
return GetSystemMetrics( SM_CMOUSEBUTTONS ); return GetSystemMetrics( SM_CMOUSEBUTTONS );
# endif # endif
default: default:
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat ); fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
break; break;
} }
/* And now -- the failure. */ /* And now -- the failure. */
return -1; return -1;
} }
int fgPlatformGlutLayerGet( GLenum eWhat ) int fgPlatformGlutLayerGet( GLenum eWhat )
{ {
/* /*
* This is easy as layers are not implemented ;-) * This is easy as layers are not implemented ;-)
* *
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or * XXX Can we merge the UNIX/X11 and WIN32 sections? Or
* XXX is overlay support planned? * XXX is overlay support planned?
*/ */
switch( eWhat ) switch( eWhat )
{ {
case GLUT_OVERLAY_POSSIBLE: case GLUT_OVERLAY_POSSIBLE:
/* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE, /* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
PFD_OVERLAY_PLANE ); */ PFD_OVERLAY_PLANE ); */
return 0 ; return 0 ;
case GLUT_LAYER_IN_USE: case GLUT_LAYER_IN_USE:
return GLUT_NORMAL; return GLUT_NORMAL;
case GLUT_HAS_OVERLAY: case GLUT_HAS_OVERLAY:
return 0; return 0;
case GLUT_TRANSPARENT_INDEX: case GLUT_TRANSPARENT_INDEX:
/* /*
* Return just anything, which is always defined as zero * Return just anything, which is always defined as zero
* *
* XXX HUH? * XXX HUH?
*/ */
return 0; return 0;
case GLUT_NORMAL_DAMAGED: case GLUT_NORMAL_DAMAGED:
/* XXX Actually I do not know. Maybe. */ /* XXX Actually I do not know. Maybe. */
return 0; return 0;
case GLUT_OVERLAY_DAMAGED: case GLUT_OVERLAY_DAMAGED:
return -1; return -1;
default: default:
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat ); fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
break; break;
} }
/* And fail. That's good. Programs do love failing. */ /* And fail. That's good. Programs do love failing. */
return -1; return -1;
} }
/* MSwin does not currently have any Mode values? */ /* MSwin does not currently have any Mode values? */
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size) int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
{ {
*size = 0; *size = 0;
return NULL; return NULL;
} }

View File

@ -1,34 +1,34 @@
/* /*
* freeglut_structure_mswin.c * freeglut_structure_mswin.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sun Jan 22, 2012 * Creation date: Sun Jan 22, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
void fgPlatformCreateWindow ( SFG_Window *window ) void fgPlatformCreateWindow ( SFG_Window *window )
{ {
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,151 +1,151 @@
/* /*
* freeglut_cursor_x11.c * freeglut_cursor_x11.c
* *
* The Windows-specific mouse cursor related stuff. * The Windows-specific mouse cursor related stuff.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sun Feb 5, 2012 * Creation date: Sun Feb 5, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
/* This code is for Posix/X11, Solaris, and OSX */ /* This code is for Posix/X11, Solaris, and OSX */
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
/* /*
* A factory method for an empty cursor * A factory method for an empty cursor
*/ */
static Cursor getEmptyCursor( void ) static Cursor getEmptyCursor( void )
{ {
static Cursor cursorNone = None; static Cursor cursorNone = None;
if( cursorNone == None ) { if( cursorNone == None ) {
char cursorNoneBits[ 32 ]; char cursorNoneBits[ 32 ];
XColor dontCare; XColor dontCare;
Pixmap cursorNonePixmap; Pixmap cursorNonePixmap;
memset( cursorNoneBits, 0, sizeof( cursorNoneBits ) ); memset( cursorNoneBits, 0, sizeof( cursorNoneBits ) );
memset( &dontCare, 0, sizeof( dontCare ) ); memset( &dontCare, 0, sizeof( dontCare ) );
cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.pDisplay.Display, cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.RootWindow, fgDisplay.pDisplay.RootWindow,
cursorNoneBits, 16, 16 ); cursorNoneBits, 16, 16 );
if( cursorNonePixmap != None ) { if( cursorNonePixmap != None ) {
cursorNone = XCreatePixmapCursor( fgDisplay.pDisplay.Display, cursorNone = XCreatePixmapCursor( fgDisplay.pDisplay.Display,
cursorNonePixmap, cursorNonePixmap, cursorNonePixmap, cursorNonePixmap,
&dontCare, &dontCare, 0, 0 ); &dontCare, &dontCare, 0, 0 );
XFreePixmap( fgDisplay.pDisplay.Display, cursorNonePixmap ); XFreePixmap( fgDisplay.pDisplay.Display, cursorNonePixmap );
} }
} }
return cursorNone; return cursorNone;
} }
typedef struct tag_cursorCacheEntry cursorCacheEntry; typedef struct tag_cursorCacheEntry cursorCacheEntry;
struct tag_cursorCacheEntry { struct tag_cursorCacheEntry {
unsigned int cursorShape; /* an XC_foo value */ unsigned int cursorShape; /* an XC_foo value */
Cursor cachedCursor; /* None if the corresponding cursor has Cursor cachedCursor; /* None if the corresponding cursor has
not been created yet */ not been created yet */
}; };
/* /*
* Note: The arrangement of the table below depends on the fact that * Note: The arrangement of the table below depends on the fact that
* the "normal" GLUT_CURSOR_* values start a 0 and are consecutive. * the "normal" GLUT_CURSOR_* values start a 0 and are consecutive.
*/ */
static cursorCacheEntry cursorCache[] = { static cursorCacheEntry cursorCache[] = {
{ XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */ { XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */
{ XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */ { XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */
{ XC_hand1, None }, /* GLUT_CURSOR_INFO */ { XC_hand1, None }, /* GLUT_CURSOR_INFO */
{ XC_pirate, None }, /* GLUT_CURSOR_DESTROY */ { XC_pirate, None }, /* GLUT_CURSOR_DESTROY */
{ XC_question_arrow, None }, /* GLUT_CURSOR_HELP */ { XC_question_arrow, None }, /* GLUT_CURSOR_HELP */
{ XC_exchange, None }, /* GLUT_CURSOR_CYCLE */ { XC_exchange, None }, /* GLUT_CURSOR_CYCLE */
{ XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */ { XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */
{ XC_watch, None }, /* GLUT_CURSOR_WAIT */ { XC_watch, None }, /* GLUT_CURSOR_WAIT */
{ XC_xterm, None }, /* GLUT_CURSOR_TEXT */ { XC_xterm, None }, /* GLUT_CURSOR_TEXT */
{ XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */ { XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */
{ XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */ { XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */
{ XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */ { XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */
{ XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */ { XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */
{ XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */ { XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */
{ XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */ { XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */
{ XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */ { XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */
{ XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */ { XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */
{ XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */ { XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
{ XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */ { XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
{ XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */ { XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
}; };
void fgPlatformSetCursor ( SFG_Window *window, int cursorID ) void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
{ {
Cursor cursor; Cursor cursor;
/* /*
* XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows * XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows
* for this, but if there is a system that easily supports a full- * for this, but if there is a system that easily supports a full-
* window (or full-screen) crosshair, we might consider it. * window (or full-screen) crosshair, we might consider it.
*/ */
int cursorIDToUse = int cursorIDToUse =
( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID; ( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID;
if( ( cursorIDToUse >= 0 ) && if( ( cursorIDToUse >= 0 ) &&
( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) { ( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) {
cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ]; cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ];
if( entry->cachedCursor == None ) { if( entry->cachedCursor == None ) {
entry->cachedCursor = entry->cachedCursor =
XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape ); XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape );
} }
cursor = entry->cachedCursor; cursor = entry->cachedCursor;
} else { } else {
switch( cursorIDToUse ) switch( cursorIDToUse )
{ {
case GLUT_CURSOR_NONE: case GLUT_CURSOR_NONE:
cursor = getEmptyCursor( ); cursor = getEmptyCursor( );
break; break;
case GLUT_CURSOR_INHERIT: case GLUT_CURSOR_INHERIT:
cursor = None; cursor = None;
break; break;
default: default:
fgError( "Unknown cursor type: %d", cursorIDToUse ); fgError( "Unknown cursor type: %d", cursorIDToUse );
return; return;
} }
} }
if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) { if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) {
XUndefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle ); XUndefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle );
} else if ( cursor != None ) { } else if ( cursor != None ) {
XDefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle, cursor ); XDefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle, cursor );
} else if ( cursorIDToUse != GLUT_CURSOR_NONE ) { } else if ( cursorIDToUse != GLUT_CURSOR_NONE ) {
fgError( "Failed to create cursor" ); fgError( "Failed to create cursor" );
} }
} }
void fgPlatformWarpPointer ( int x, int y ) void fgPlatformWarpPointer ( int x, int y )
{ {
XWarpPointer( XWarpPointer(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
None, None,
fgStructure.CurrentWindow->Window.Handle, fgStructure.CurrentWindow->Window.Handle,
0, 0, 0, 0, 0, 0, 0, 0,
x, y x, y
); );
/* Make the warp visible immediately. */ /* Make the warp visible immediately. */
XFlush( fgDisplay.pDisplay.Display ); XFlush( fgDisplay.pDisplay.Display );
} }

View File

@ -1,36 +1,36 @@
/* /*
* freeglut_display_x11.c * freeglut_display_x11.c
* *
* Display message posting, context buffer swapping. * Display message posting, context buffer swapping.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow ) void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
{ {
glXSwapBuffers( pDisplayPtr->Display, CurrentWindow->Window.Handle ); glXSwapBuffers( pDisplayPtr->Display, CurrentWindow->Window.Handle );
} }

View File

@ -1,60 +1,60 @@
/* /*
* freeglut_ext.c * freeglut_ext.c
* *
* Functions related to OpenGL extensions. * Functions related to OpenGL extensions.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define GLX_GLXEXT_PROTOTYPES #define GLX_GLXEXT_PROTOTYPES
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName ) GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
{ {
/* optimization: quick initial check */ /* optimization: quick initial check */
if( strncmp( procName, "glut", 4 ) != 0 ) if( strncmp( procName, "glut", 4 ) != 0 )
return NULL; return NULL;
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x; #define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
CHECK_NAME(glutJoystickFunc); CHECK_NAME(glutJoystickFunc);
CHECK_NAME(glutForceJoystickFunc); CHECK_NAME(glutForceJoystickFunc);
CHECK_NAME(glutGameModeString); CHECK_NAME(glutGameModeString);
CHECK_NAME(glutEnterGameMode); CHECK_NAME(glutEnterGameMode);
CHECK_NAME(glutLeaveGameMode); CHECK_NAME(glutLeaveGameMode);
CHECK_NAME(glutGameModeGet); CHECK_NAME(glutGameModeGet);
#undef CHECK_NAME #undef CHECK_NAME
return NULL; return NULL;
} }
SFG_Proc fgPlatformGetProcAddress( const char *procName ) SFG_Proc fgPlatformGetProcAddress( const char *procName )
{ {
#if defined( GLX_ARB_get_proc_address ) #if defined( GLX_ARB_get_proc_address )
return (SFG_Proc)glXGetProcAddressARB( ( const GLubyte * )procName ); return (SFG_Proc)glXGetProcAddressARB( ( const GLubyte * )procName );
#else #else
return NULL; return NULL;
#endif #endif
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,104 @@
/* /*
* freeglut_glutfont_definitions_x11.c * freeglut_glutfont_definitions_x11.c
* *
* Bitmap and stroke fonts displaying. * Bitmap and stroke fonts displaying.
* *
* Copyright (c) 2003 Stephen J. Baker (whether he wants it or not). * Copyright (c) 2003 Stephen J. Baker (whether he wants it or not).
* All Rights Reserved. * All Rights Reserved.
* Written by John F. Fay <fayjf@sourceforge.net>, who releases the * Written by John F. Fay <fayjf@sourceforge.net>, who releases the
* copyright over to the "freeglut" project lead. * copyright over to the "freeglut" project lead.
* Creation date: Mon July 21 2003 * Creation date: Mon July 21 2003
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* /*
* This file is necessary for the *nix version of "freeglut" because the * This file is necessary for the *nix version of "freeglut" because the
* original GLUT defined its font variables in rather an unusual way. * original GLUT defined its font variables in rather an unusual way.
* Publicly, in "glut.h", they were defined as "void *". Privately, * Publicly, in "glut.h", they were defined as "void *". Privately,
* in one of the source code files, they were defined as pointers to a * in one of the source code files, they were defined as pointers to a
* structure. Most compilers and linkers are satisfied with the "void *" * structure. Most compilers and linkers are satisfied with the "void *"
* and don't go any farther, but some of them balked. In particular, * and don't go any farther, but some of them balked. In particular,
* when compiling with "freeglut" and then trying to run using the GLUT * when compiling with "freeglut" and then trying to run using the GLUT
* ".so" library, some of them would give an error. So we are having to * ".so" library, some of them would give an error. So we are having to
* create this file to define the variables as pointers to an unusual * create this file to define the variables as pointers to an unusual
* structure to match GLUT. * structure to match GLUT.
*/ */
/* /*
* freeglut_internal.h uses some GL types, but including the GL header portably * freeglut_internal.h uses some GL types, but including the GL header portably
* is a bit tricky, so we include freeglut_std.h here, which contains the * is a bit tricky, so we include freeglut_std.h here, which contains the
* necessary machinery. But this poses another problem, caused by the ugly * necessary machinery. But this poses another problem, caused by the ugly
* original defintion of the font constants in "classic" GLUT: They are defined * original defintion of the font constants in "classic" GLUT: They are defined
* as void* externally, so we move them temporarily out of the way by AN EXTREME * as void* externally, so we move them temporarily out of the way by AN EXTREME
* CPP HACK. * CPP HACK.
*/ */
#define glutStrokeRoman glutStrokeRomanIGNOREME #define glutStrokeRoman glutStrokeRomanIGNOREME
#define glutStrokeMonoRoman glutStrokeMonoRomanIGNOREME #define glutStrokeMonoRoman glutStrokeMonoRomanIGNOREME
#define glutBitmap9By15 glutBitmap9By15IGNOREME #define glutBitmap9By15 glutBitmap9By15IGNOREME
#define glutBitmap8By13 glutBitmap8By13IGNOREME #define glutBitmap8By13 glutBitmap8By13IGNOREME
#define glutBitmapTimesRoman10 glutBitmapTimesRoman10IGNOREME #define glutBitmapTimesRoman10 glutBitmapTimesRoman10IGNOREME
#define glutBitmapTimesRoman24 glutBitmapTimesRoman24IGNOREME #define glutBitmapTimesRoman24 glutBitmapTimesRoman24IGNOREME
#define glutBitmapHelvetica10 glutBitmapHelvetica10IGNOREME #define glutBitmapHelvetica10 glutBitmapHelvetica10IGNOREME
#define glutBitmapHelvetica12 glutBitmapHelvetica12IGNOREME #define glutBitmapHelvetica12 glutBitmapHelvetica12IGNOREME
#define glutBitmapHelvetica18 glutBitmapHelvetica18IGNOREME #define glutBitmapHelvetica18 glutBitmapHelvetica18IGNOREME
#include <GL/freeglut_std.h> #include <GL/freeglut_std.h>
#undef glutStrokeRoman #undef glutStrokeRoman
#undef glutStrokeMonoRoman #undef glutStrokeMonoRoman
#undef glutBitmap9By15 #undef glutBitmap9By15
#undef glutBitmap8By13 #undef glutBitmap8By13
#undef glutBitmapTimesRoman10 #undef glutBitmapTimesRoman10
#undef glutBitmapTimesRoman24 #undef glutBitmapTimesRoman24
#undef glutBitmapHelvetica10 #undef glutBitmapHelvetica10
#undef glutBitmapHelvetica12 #undef glutBitmapHelvetica12
#undef glutBitmapHelvetica18 #undef glutBitmapHelvetica18
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
struct freeglutStrokeFont struct freeglutStrokeFont
{ {
const char *name ; const char *name ;
int num_chars ; int num_chars ;
void *ch ; void *ch ;
float top ; float top ;
float bottom ; float bottom ;
}; };
struct freeglutBitmapFont struct freeglutBitmapFont
{ {
const char *name ; const char *name ;
const int num_chars ; const int num_chars ;
const int first ; const int first ;
const void *ch ; const void *ch ;
}; };
struct freeglutStrokeFont glutStrokeRoman ; struct freeglutStrokeFont glutStrokeRoman ;
struct freeglutStrokeFont glutStrokeMonoRoman ; struct freeglutStrokeFont glutStrokeMonoRoman ;
struct freeglutBitmapFont glutBitmap9By15 ; struct freeglutBitmapFont glutBitmap9By15 ;
struct freeglutBitmapFont glutBitmap8By13 ; struct freeglutBitmapFont glutBitmap8By13 ;
struct freeglutBitmapFont glutBitmapTimesRoman10 ; struct freeglutBitmapFont glutBitmapTimesRoman10 ;
struct freeglutBitmapFont glutBitmapTimesRoman24 ; struct freeglutBitmapFont glutBitmapTimesRoman24 ;
struct freeglutBitmapFont glutBitmapHelvetica10 ; struct freeglutBitmapFont glutBitmapHelvetica10 ;
struct freeglutBitmapFont glutBitmapHelvetica12 ; struct freeglutBitmapFont glutBitmapHelvetica12 ;
struct freeglutBitmapFont glutBitmapHelvetica18 ; struct freeglutBitmapFont glutBitmapHelvetica18 ;

View File

@ -1,273 +1,273 @@
/* /*
* freeglut_init_x11.c * freeglut_init_x11.c
* *
* Various freeglut initialization functions. * Various freeglut initialization functions.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define FREEGLUT_BUILDING_LIB #define FREEGLUT_BUILDING_LIB
#include <limits.h> /* LONG_MAX */ #include <limits.h> /* LONG_MAX */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
/* Return the atom associated with "name". */ /* Return the atom associated with "name". */
static Atom fghGetAtom(const char * name) static Atom fghGetAtom(const char * name)
{ {
return XInternAtom(fgDisplay.pDisplay.Display, name, False); return XInternAtom(fgDisplay.pDisplay.Display, name, False);
} }
/* /*
* Check if "property" is set on "window". The property's values are returned * Check if "property" is set on "window". The property's values are returned
* through "data". If the property is set and is of type "type", return the * through "data". If the property is set and is of type "type", return the
* number of elements in "data". Return zero otherwise. In both cases, use * number of elements in "data". Return zero otherwise. In both cases, use
* "Xfree()" to free "data". * "Xfree()" to free "data".
*/ */
static int fghGetWindowProperty(Window window, static int fghGetWindowProperty(Window window,
Atom property, Atom property,
Atom type, Atom type,
unsigned char ** data) unsigned char ** data)
{ {
/* /*
* Caller always has to use "Xfree()" to free "data", since * Caller always has to use "Xfree()" to free "data", since
* "XGetWindowProperty() always allocates one extra byte in prop_return * "XGetWindowProperty() always allocates one extra byte in prop_return
* [i.e. "data"] (even if the property is zero length) [..]". * [i.e. "data"] (even if the property is zero length) [..]".
*/ */
int status; /* Returned by "XGetWindowProperty". */ int status; /* Returned by "XGetWindowProperty". */
Atom type_returned; Atom type_returned;
int temp_format; /* Not used. */ int temp_format; /* Not used. */
unsigned long number_of_elements; unsigned long number_of_elements;
unsigned long temp_bytes_after; /* Not used. */ unsigned long temp_bytes_after; /* Not used. */
status = XGetWindowProperty(fgDisplay.pDisplay.Display, status = XGetWindowProperty(fgDisplay.pDisplay.Display,
window, window,
property, property,
0, 0,
LONG_MAX, LONG_MAX,
False, False,
type, type,
&type_returned, &type_returned,
&temp_format, &temp_format,
&number_of_elements, &number_of_elements,
&temp_bytes_after, &temp_bytes_after,
data); data);
FREEGLUT_INTERNAL_ERROR_EXIT(status == Success, FREEGLUT_INTERNAL_ERROR_EXIT(status == Success,
"XGetWindowProperty failled", "XGetWindowProperty failled",
"fghGetWindowProperty"); "fghGetWindowProperty");
if (type_returned != type) if (type_returned != type)
{ {
number_of_elements = 0; number_of_elements = 0;
} }
return number_of_elements; return number_of_elements;
} }
/* Check if the window manager is NET WM compliant. */ /* Check if the window manager is NET WM compliant. */
static int fghNetWMSupported(void) static int fghNetWMSupported(void)
{ {
Atom wm_check; Atom wm_check;
Window ** window_ptr_1; Window ** window_ptr_1;
int number_of_windows; int number_of_windows;
int net_wm_supported; int net_wm_supported;
net_wm_supported = 0; net_wm_supported = 0;
wm_check = fghGetAtom("_NET_SUPPORTING_WM_CHECK"); wm_check = fghGetAtom("_NET_SUPPORTING_WM_CHECK");
window_ptr_1 = malloc(sizeof(Window *)); window_ptr_1 = malloc(sizeof(Window *));
/* /*
* Check that the window manager has set this property on the root window. * Check that the window manager has set this property on the root window.
* The property must be the ID of a child window. * The property must be the ID of a child window.
*/ */
number_of_windows = fghGetWindowProperty(fgDisplay.pDisplay.RootWindow, number_of_windows = fghGetWindowProperty(fgDisplay.pDisplay.RootWindow,
wm_check, wm_check,
XA_WINDOW, XA_WINDOW,
(unsigned char **) window_ptr_1); (unsigned char **) window_ptr_1);
if (number_of_windows == 1) if (number_of_windows == 1)
{ {
Window ** window_ptr_2; Window ** window_ptr_2;
window_ptr_2 = malloc(sizeof(Window *)); window_ptr_2 = malloc(sizeof(Window *));
/* Check that the window has the same property set to the same value. */ /* Check that the window has the same property set to the same value. */
number_of_windows = fghGetWindowProperty(**window_ptr_1, number_of_windows = fghGetWindowProperty(**window_ptr_1,
wm_check, wm_check,
XA_WINDOW, XA_WINDOW,
(unsigned char **) window_ptr_2); (unsigned char **) window_ptr_2);
if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2)) if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2))
{ {
/* NET WM compliant */ /* NET WM compliant */
net_wm_supported = 1; net_wm_supported = 1;
} }
XFree(*window_ptr_2); XFree(*window_ptr_2);
free(window_ptr_2); free(window_ptr_2);
} }
XFree(*window_ptr_1); XFree(*window_ptr_1);
free(window_ptr_1); free(window_ptr_1);
return net_wm_supported; return net_wm_supported;
} }
/* Check if "hint" is present in "property" for "window". */ /* Check if "hint" is present in "property" for "window". */
int fgHintPresent(Window window, Atom property, Atom hint) int fgHintPresent(Window window, Atom property, Atom hint)
{ {
Atom *atoms; Atom *atoms;
int number_of_atoms; int number_of_atoms;
int supported; int supported;
int i; int i;
supported = 0; supported = 0;
number_of_atoms = fghGetWindowProperty(window, number_of_atoms = fghGetWindowProperty(window,
property, property,
XA_ATOM, XA_ATOM,
(unsigned char **) &atoms); (unsigned char **) &atoms);
for (i = 0; i < number_of_atoms; i++) for (i = 0; i < number_of_atoms; i++)
{ {
if (atoms[i] == hint) if (atoms[i] == hint)
{ {
supported = 1; supported = 1;
break; break;
} }
} }
XFree(atoms); XFree(atoms);
return supported; return supported;
} }
/* /*
* A call to this function should initialize all the display stuff... * A call to this function should initialize all the display stuff...
*/ */
void fgPlatformInitialize( const char* displayName ) void fgPlatformInitialize( const char* displayName )
{ {
fgDisplay.pDisplay.Display = XOpenDisplay( displayName ); fgDisplay.pDisplay.Display = XOpenDisplay( displayName );
if( fgDisplay.pDisplay.Display == NULL ) if( fgDisplay.pDisplay.Display == NULL )
fgError( "failed to open display '%s'", XDisplayName( displayName ) ); fgError( "failed to open display '%s'", XDisplayName( displayName ) );
if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) ) if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
fgError( "OpenGL GLX extension not supported by display '%s'", fgError( "OpenGL GLX extension not supported by display '%s'",
XDisplayName( displayName ) ); XDisplayName( displayName ) );
fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display ); fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
fgDisplay.pDisplay.RootWindow = RootWindow( fgDisplay.pDisplay.RootWindow = RootWindow(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen fgDisplay.pDisplay.Screen
); );
fgDisplay.ScreenWidth = DisplayWidth( fgDisplay.ScreenWidth = DisplayWidth(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen fgDisplay.pDisplay.Screen
); );
fgDisplay.ScreenHeight = DisplayHeight( fgDisplay.ScreenHeight = DisplayHeight(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen fgDisplay.pDisplay.Screen
); );
fgDisplay.ScreenWidthMM = DisplayWidthMM( fgDisplay.ScreenWidthMM = DisplayWidthMM(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen fgDisplay.pDisplay.Screen
); );
fgDisplay.ScreenHeightMM = DisplayHeightMM( fgDisplay.ScreenHeightMM = DisplayHeightMM(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen fgDisplay.pDisplay.Screen
); );
fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display ); fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );
/* Create the window deletion atom */ /* Create the window deletion atom */
fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW"); fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");
/* Create the state and full screen atoms */ /* Create the state and full screen atoms */
fgDisplay.pDisplay.State = None; fgDisplay.pDisplay.State = None;
fgDisplay.pDisplay.StateFullScreen = None; fgDisplay.pDisplay.StateFullScreen = None;
if (fghNetWMSupported()) if (fghNetWMSupported())
{ {
const Atom supported = fghGetAtom("_NET_SUPPORTED"); const Atom supported = fghGetAtom("_NET_SUPPORTED");
const Atom state = fghGetAtom("_NET_WM_STATE"); const Atom state = fghGetAtom("_NET_WM_STATE");
/* Check if the state hint is supported. */ /* Check if the state hint is supported. */
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state)) if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
{ {
const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN"); const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
fgDisplay.pDisplay.State = state; fgDisplay.pDisplay.State = state;
/* Check if the window manager supports full screen. */ /* Check if the window manager supports full screen. */
/** Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/ /** Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen)) if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
{ {
fgDisplay.pDisplay.StateFullScreen = full_screen; fgDisplay.pDisplay.StateFullScreen = full_screen;
} }
} }
} }
fgState.Initialised = GL_TRUE; fgState.Initialised = GL_TRUE;
atexit(fgDeinitialize); atexit(fgDeinitialize);
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */ /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
fgInitialiseInputDevices(); fgInitialiseInputDevices();
} }
void fgPlatformDeinitialiseInputDevices ( void ) void fgPlatformDeinitialiseInputDevices ( void )
{ {
fghCloseInputDevices (); fghCloseInputDevices ();
fgState.JoysticksInitialised = GL_FALSE; fgState.JoysticksInitialised = GL_FALSE;
fgState.InputDevsInitialised = GL_FALSE; fgState.InputDevsInitialised = GL_FALSE;
} }
void fgPlatformCloseDisplay ( void ) void fgPlatformCloseDisplay ( void )
{ {
/* /*
* Make sure all X-client data we have created will be destroyed on * Make sure all X-client data we have created will be destroyed on
* display closing * display closing
*/ */
XSetCloseDownMode( fgDisplay.pDisplay.Display, DestroyAll ); XSetCloseDownMode( fgDisplay.pDisplay.Display, DestroyAll );
/* /*
* Close the display connection, destroying all windows we have * Close the display connection, destroying all windows we have
* created so far * created so far
*/ */
XCloseDisplay( fgDisplay.pDisplay.Display ); XCloseDisplay( fgDisplay.pDisplay.Display );
} }
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext ) void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
{ {
/* Note that the MVisualInfo is not owned by the MenuContext! */ /* Note that the MVisualInfo is not owned by the MenuContext! */
glXDestroyContext( pDisplay.Display, MContext ); glXDestroyContext( pDisplay.Display, MContext );
} }

View File

@ -1,132 +1,132 @@
/* /*
* freeglut_input_devices_x11.c * freeglut_input_devices_x11.c
* *
* Handles miscellaneous input devices via direct serial-port access. * Handles miscellaneous input devices via direct serial-port access.
* Proper X11 XInput device support is not yet supported. * Proper X11 XInput device support is not yet supported.
* Also lacks Mac support. * Also lacks Mac support.
* *
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005 * Written by Joe Krahn <krahn@niehs.nih.gov> 2005
* *
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA OR STEPHEN J. BAKER BE LIABLE FOR ANY CLAIM, DAMAGES OR * PAWEL W. OLSZTA OR STEPHEN J. BAKER BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 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 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
#include <errno.h> #include <errno.h>
#endif #endif
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <fcntl.h> #include <fcntl.h>
struct _serialport { struct _serialport {
int fd; int fd;
struct termios termio, termio_save; struct termios termio, termio_save;
}; };
typedef struct _serialport SERIALPORT; typedef struct _serialport SERIALPORT;
void serial_flush ( SERIALPORT *port ); void serial_flush ( SERIALPORT *port );
/* local variables */ /* local variables */
static SERIALPORT *dialbox_port=NULL; static SERIALPORT *dialbox_port=NULL;
/*****************************************************************/ /*****************************************************************/
/* /*
* Try initializing the input device(s) * Try initializing the input device(s)
*/ */
void fgPlatformRegisterDialDevice ( const char *dial_device ) void fgPlatformRegisterDialDevice ( const char *dial_device )
{ {
} }
SERIALPORT *serial_open ( const char *device ) SERIALPORT *serial_open ( const char *device )
{ {
int fd; int fd;
struct termios termio; struct termios termio;
SERIALPORT *port; SERIALPORT *port;
fd = open(device, O_RDWR | O_NONBLOCK ); fd = open(device, O_RDWR | O_NONBLOCK );
if (fd <0) { if (fd <0) {
perror(device); perror(device);
return NULL; return NULL;
} }
port = malloc(sizeof(SERIALPORT)); port = malloc(sizeof(SERIALPORT));
memset(port, 0, sizeof(SERIALPORT)); memset(port, 0, sizeof(SERIALPORT));
port->fd = fd; port->fd = fd;
/* save current port settings */ /* save current port settings */
tcgetattr(fd,&port->termio_save); tcgetattr(fd,&port->termio_save);
memset(&termio, 0, sizeof(termio)); memset(&termio, 0, sizeof(termio));
termio.c_cflag = CS8 | CREAD | HUPCL ; termio.c_cflag = CS8 | CREAD | HUPCL ;
termio.c_iflag = IGNPAR | IGNBRK ; termio.c_iflag = IGNPAR | IGNBRK ;
termio.c_cc[VTIME] = 0; /* inter-character timer */ termio.c_cc[VTIME] = 0; /* inter-character timer */
termio.c_cc[VMIN] = 1; /* block read until 1 chars received, when blocking I/O */ termio.c_cc[VMIN] = 1; /* block read until 1 chars received, when blocking I/O */
cfsetispeed(&termio, B9600); cfsetispeed(&termio, B9600);
cfsetospeed(&termio, B9600); cfsetospeed(&termio, B9600);
tcsetattr(fd,TCSANOW,&termio); tcsetattr(fd,TCSANOW,&termio);
serial_flush(port); serial_flush(port);
return port; return port;
} }
void serial_close(SERIALPORT *port) void serial_close(SERIALPORT *port)
{ {
if (port) if (port)
{ {
/* restore old port settings */ /* restore old port settings */
tcsetattr(port->fd,TCSANOW,&port->termio_save); tcsetattr(port->fd,TCSANOW,&port->termio_save);
close(port->fd); close(port->fd);
free(port); free(port);
} }
} }
int serial_getchar(SERIALPORT *port) int serial_getchar(SERIALPORT *port)
{ {
unsigned char ch; unsigned char ch;
if (!port) return EOF; if (!port) return EOF;
if (read(port->fd,&ch,1)) return ch; if (read(port->fd,&ch,1)) return ch;
return EOF; return EOF;
} }
int serial_putchar(SERIALPORT *port, unsigned char ch) int serial_putchar(SERIALPORT *port, unsigned char ch)
{ {
if (!port) return 0; if (!port) return 0;
return write(port->fd,&ch,1); return write(port->fd,&ch,1);
} }
void serial_flush ( SERIALPORT *port ) void serial_flush ( SERIALPORT *port )
{ {
tcflush ( port->fd, TCIOFLUSH ); tcflush ( port->fd, TCIOFLUSH );
} }

View File

@ -1,229 +1,229 @@
/* /*
* freeglut_internal_x11.h * freeglut_internal_x11.h
* *
* The freeglut library private include file. * The freeglut library private include file.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by Diederick C. Niehorster, <dcnieho@gmail.com> * Written by Diederick C. Niehorster, <dcnieho@gmail.com>
* Creation date: Fri Jan 20, 2012 * Creation date: Fri Jan 20, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef FREEGLUT_INTERNAL_X11_H #ifndef FREEGLUT_INTERNAL_X11_H
#define FREEGLUT_INTERNAL_X11_H #define FREEGLUT_INTERNAL_X11_H
/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */ /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
#include <GL/glx.h> #include <GL/glx.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/extensions/XInput.h> #include <X11/extensions/XInput.h>
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
# include <X11/extensions/xf86vmode.h> # include <X11/extensions/xf86vmode.h>
#endif #endif
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
# include <X11/extensions/Xrandr.h> # include <X11/extensions/Xrandr.h>
#endif #endif
/* If GLX is too old, we will fail during runtime when multisampling /* If GLX is too old, we will fail during runtime when multisampling
is requested, but at least freeglut compiles. */ is requested, but at least freeglut compiles. */
#ifndef GLX_SAMPLE_BUFFERS #ifndef GLX_SAMPLE_BUFFERS
# define GLX_SAMPLE_BUFFERS 0x80A8 # define GLX_SAMPLE_BUFFERS 0x80A8
#endif #endif
#ifndef GLX_SAMPLES #ifndef GLX_SAMPLES
# define GLX_SAMPLES 0x80A9 # define GLX_SAMPLES 0x80A9
#endif #endif
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */ /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
/* The structure used by display initialization in freeglut_init.c */ /* The structure used by display initialization in freeglut_init.c */
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay; typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
struct tagSFG_PlatformDisplay struct tagSFG_PlatformDisplay
{ {
Display* Display; /* The display we are being run in. */ Display* Display; /* The display we are being run in. */
int Screen; /* The screen we are about to use. */ int Screen; /* The screen we are about to use. */
Window RootWindow; /* The screen's root window. */ Window RootWindow; /* The screen's root window. */
int Connection; /* The display's connection number */ int Connection; /* The display's connection number */
Atom DeleteWindow; /* The window deletion atom */ Atom DeleteWindow; /* The window deletion atom */
Atom State; /* The state atom */ Atom State; /* The state atom */
Atom StateFullScreen; /* The full screen atom */ Atom StateFullScreen; /* The full screen atom */
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
int prev_xsz, prev_ysz; int prev_xsz, prev_ysz;
int prev_refresh; int prev_refresh;
int prev_size_valid; int prev_size_valid;
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */ #endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H #ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
/* /*
* XF86VidMode may be compilable even if it fails at runtime. Therefore, * XF86VidMode may be compilable even if it fails at runtime. Therefore,
* the validity of the VidMode has to be tracked * the validity of the VidMode has to be tracked
*/ */
int DisplayModeValid; /* Flag that indicates runtime status*/ int DisplayModeValid; /* Flag that indicates runtime status*/
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */ XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
int DisplayModeClock; /* The display mode's refresh rate */ int DisplayModeClock; /* The display mode's refresh rate */
int DisplayViewPortX; /* saved X location of the viewport */ int DisplayViewPortX; /* saved X location of the viewport */
int DisplayViewPortY; /* saved Y location of the viewport */ int DisplayViewPortY; /* saved Y location of the viewport */
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */ #endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
int DisplayPointerX; /* saved X location of the pointer */ int DisplayPointerX; /* saved X location of the pointer */
int DisplayPointerY; /* saved Y location of the pointer */ int DisplayPointerY; /* saved Y location of the pointer */
}; };
/* /*
* Make "freeglut" window handle and context types so that we don't need so * Make "freeglut" window handle and context types so that we don't need so
* much conditionally-compiled code later in the library. * much conditionally-compiled code later in the library.
*/ */
typedef Window SFG_WindowHandleType ; typedef Window SFG_WindowHandleType ;
typedef GLXContext SFG_WindowContextType ; typedef GLXContext SFG_WindowContextType ;
typedef struct tagSFG_PlatformContext SFG_PlatformContext; typedef struct tagSFG_PlatformContext SFG_PlatformContext;
struct tagSFG_PlatformContext struct tagSFG_PlatformContext
{ {
GLXFBConfig* FBConfig; /* The window's FBConfig */ GLXFBConfig* FBConfig; /* The window's FBConfig */
}; };
/* Window's state description. This structure should be kept portable. */ /* Window's state description. This structure should be kept portable. */
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
struct tagSFG_PlatformWindowState struct tagSFG_PlatformWindowState
{ {
int OldWidth; /* Window width from before a resize */ int OldWidth; /* Window width from before a resize */
int OldHeight; /* " height " " " " */ int OldHeight; /* " height " " " " */
}; };
/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */ /* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
/* /*
* Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c" * Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
* interspersed * interspersed
*/ */
# ifdef HAVE_SYS_IOCTL_H # ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h> # include <sys/ioctl.h>
# endif # endif
# ifdef HAVE_FCNTL_H # ifdef HAVE_FCNTL_H
# include <fcntl.h> # include <fcntl.h>
# endif # endif
# ifdef HAVE_ERRNO_H # ifdef HAVE_ERRNO_H
# include <errno.h> # include <errno.h>
# include <string.h> # include <string.h>
# endif # endif
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
/* XXX The below hack is done until freeglut's autoconf is updated. */ /* XXX The below hack is done until freeglut's autoconf is updated. */
# define HAVE_USB_JS 1 # define HAVE_USB_JS 1
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
# include <sys/joystick.h> # include <sys/joystick.h>
# else # else
/* /*
* XXX NetBSD/amd64 systems may find that they have to steal the * XXX NetBSD/amd64 systems may find that they have to steal the
* XXX /usr/include/machine/joystick.h from a NetBSD/i386 system. * XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
* XXX I cannot comment whether that works for the interface, but * 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 it lets you compile...(^& I do not think that we can do away
* XXX with this header. * XXX with this header.
*/ */
# include <machine/joystick.h> /* For analog joysticks */ # include <machine/joystick.h> /* For analog joysticks */
# endif # endif
# define JS_DATA_TYPE joystick # define JS_DATA_TYPE joystick
# define JS_RETURN (sizeof(struct JS_DATA_TYPE)) # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
# endif # endif
# if defined(__linux__) # if defined(__linux__)
# include <linux/joystick.h> # include <linux/joystick.h>
/* check the joystick driver version */ /* check the joystick driver version */
# if defined(JS_VERSION) && JS_VERSION >= 0x010000 # if defined(JS_VERSION) && JS_VERSION >= 0x010000
# define JS_NEW # define JS_NEW
# endif # endif
# else /* Not BSD or Linux */ # else /* Not BSD or Linux */
# ifndef JS_RETURN # ifndef JS_RETURN
/* /*
* We'll put these values in and that should * We'll put these values in and that should
* allow the code to at least compile when there is * allow the code to at least compile when there is
* no support. The JS open routine should error out * no support. The JS open routine should error out
* and shut off all the code downstream anyway and if * and shut off all the code downstream anyway and if
* the application doesn't use a joystick we'll be fine. * the application doesn't use a joystick we'll be fine.
*/ */
struct JS_DATA_TYPE struct JS_DATA_TYPE
{ {
int buttons; int buttons;
int x; int x;
int y; int y;
}; };
# define JS_RETURN (sizeof(struct JS_DATA_TYPE)) # define JS_RETURN (sizeof(struct JS_DATA_TYPE))
# endif # endif
# endif # endif
/* XXX It might be better to poll the operating system for the numbers of buttons and /* XXX It might be better to poll the operating system for the numbers of buttons and
* XXX axes and then dynamically allocate the arrays. * XXX axes and then dynamically allocate the arrays.
*/ */
# define _JS_MAX_AXES 16 # define _JS_MAX_AXES 16
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
struct tagSFG_PlatformJoystick struct tagSFG_PlatformJoystick
{ {
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
struct os_specific_s *os; struct os_specific_s *os;
# endif # endif
# ifdef JS_NEW # ifdef JS_NEW
struct js_event js; struct js_event js;
int tmp_buttons; int tmp_buttons;
float tmp_axes [ _JS_MAX_AXES ]; float tmp_axes [ _JS_MAX_AXES ];
# else # else
struct JS_DATA_TYPE js; struct JS_DATA_TYPE js;
# endif # endif
char fname [ 128 ]; char fname [ 128 ];
int fd; int fd;
}; };
/* Menu font and color definitions */ /* Menu font and color definitions */
#define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18 #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_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_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_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
#define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f} #define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
/* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */ /* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
/* spaceball device functions, defined in freeglut_spaceball.c */ /* spaceball device functions, defined in freeglut_spaceball.c */
int fgIsSpaceballXEvent( const XEvent *ev ); int fgIsSpaceballXEvent( const XEvent *ev );
void fgSpaceballHandleXEvent( const XEvent *ev ); void fgSpaceballHandleXEvent( const XEvent *ev );
/* /*
* Check if "hint" is present in "property" for "window". See freeglut_init.c * Check if "hint" is present in "property" for "window". See freeglut_init.c
*/ */
int fgHintPresent(Window window, Atom property, Atom hint); int fgHintPresent(Window window, Atom property, Atom hint);
/* Handler for X extension Events */ /* Handler for X extension Events */
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
void fgHandleExtensionEvents( XEvent * ev ); void fgHandleExtensionEvents( XEvent * ev );
void fgRegisterDevices( Display* dpy, Window* win ); void fgRegisterDevices( Display* dpy, Window* win );
#endif #endif
#endif /* FREEGLUT_INTERNAL_X11_H */ #endif /* FREEGLUT_INTERNAL_X11_H */

View File

@ -1,465 +1,465 @@
/* /*
* freeglut_joystick_x11.c * freeglut_joystick_x11.c
* *
* Joystick handling code * Joystick handling code
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Steve Baker, <sjbaker1@airmail.net> * Written by Steve Baker, <sjbaker1@airmail.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* /*
* FreeBSD port by Stephen Montgomery-Smith <stephen@math.missouri.edu> * FreeBSD port by Stephen Montgomery-Smith <stephen@math.missouri.edu>
* *
* Redone by John Fay 2/4/04 with another look from the PLIB "js" library. * Redone by John Fay 2/4/04 with another look from the PLIB "js" library.
* Many thanks for Steve Baker for permission to pull from that library. * Many thanks for Steve Baker for permission to pull from that library.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
# include <sys/param.h> # include <sys/param.h>
#endif #endif
/*this should be defined in a header file */ /*this should be defined in a header file */
#define MAX_NUM_JOYSTICKS 2 #define MAX_NUM_JOYSTICKS 2
extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ]; extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
{ {
int status; int status;
int i; int i;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
int len; int len;
if ( joy->pJoystick.os->is_analog ) if ( joy->pJoystick.os->is_analog )
{ {
int status = read ( joy->pJoystick.os->fd, &joy->pJoystick.os->ajs, sizeof(joy->pJoystick.os->ajs) ); int status = read ( joy->pJoystick.os->fd, &joy->pJoystick.os->ajs, sizeof(joy->pJoystick.os->ajs) );
if ( status != sizeof(joy->pJoystick.os->ajs) ) { if ( status != sizeof(joy->pJoystick.os->ajs) ) {
perror ( joy->pJoystick.os->fname ); perror ( joy->pJoystick.os->fname );
joy->error = GL_TRUE; joy->error = GL_TRUE;
return; return;
} }
if ( buttons != NULL ) if ( buttons != NULL )
*buttons = ( joy->pJoystick.os->ajs.b1 ? 1 : 0 ) | ( joy->pJoystick.os->ajs.b2 ? 2 : 0 ); *buttons = ( joy->pJoystick.os->ajs.b1 ? 1 : 0 ) | ( joy->pJoystick.os->ajs.b2 ? 2 : 0 );
if ( axes != NULL ) if ( axes != NULL )
{ {
axes[0] = (float) joy->pJoystick.os->ajs.x; axes[0] = (float) joy->pJoystick.os->ajs.x;
axes[1] = (float) joy->pJoystick.os->ajs.y; axes[1] = (float) joy->pJoystick.os->ajs.y;
} }
return; return;
} }
# ifdef HAVE_USB_JS # ifdef HAVE_USB_JS
while ( ( len = read ( joy->pJoystick.os->fd, joy->pJoystick.os->hid_data_buf, joy->pJoystick.os->hid_dlen ) ) == joy->pJoystick.os->hid_dlen ) while ( ( len = read ( joy->pJoystick.os->fd, joy->pJoystick.os->hid_data_buf, joy->pJoystick.os->hid_dlen ) ) == joy->pJoystick.os->hid_dlen )
{ {
struct hid_item *h; struct hid_item *h;
for ( h = joy->pJoystick.os->hids; h; h = h->next ) for ( h = joy->pJoystick.os->hids; h; h = h->next )
{ {
int d = hid_get_data ( joy->pJoystick.os->hid_data_buf, h ); int d = hid_get_data ( joy->pJoystick.os->hid_data_buf, h );
int page = HID_PAGE ( h->usage ); int page = HID_PAGE ( h->usage );
int usage = HID_USAGE ( h->usage ); int usage = HID_USAGE ( h->usage );
if ( page == HUP_GENERIC_DESKTOP ) if ( page == HUP_GENERIC_DESKTOP )
{ {
int i; int i;
for ( i = 0; i < joy->num_axes; i++ ) for ( i = 0; i < joy->num_axes; i++ )
if (joy->pJoystick.os->axes_usage[i] == usage) if (joy->pJoystick.os->axes_usage[i] == usage)
{ {
if (usage == HUG_HAT_SWITCH) if (usage == HUG_HAT_SWITCH)
{ {
if (d < 0 || d > 8) if (d < 0 || d > 8)
d = 0; /* safety */ d = 0; /* safety */
joy->pJoystick.os->cache_axes[i] = (float)hatmap_x[d]; joy->pJoystick.os->cache_axes[i] = (float)hatmap_x[d];
joy->pJoystick.os->cache_axes[i + 1] = (float)hatmap_y[d]; joy->pJoystick.os->cache_axes[i + 1] = (float)hatmap_y[d];
} }
else else
{ {
joy->pJoystick.os->cache_axes[i] = (float)d; joy->pJoystick.os->cache_axes[i] = (float)d;
} }
break; break;
} }
} }
else if (page == HUP_BUTTON) else if (page == HUP_BUTTON)
{ {
if (usage > 0 && usage < _JS_MAX_BUTTONS + 1) if (usage > 0 && usage < _JS_MAX_BUTTONS + 1)
{ {
if (d) if (d)
joy->pJoystick.os->cache_buttons |= (1 << ( usage - 1 )); joy->pJoystick.os->cache_buttons |= (1 << ( usage - 1 ));
else else
joy->pJoystick.os->cache_buttons &= ~(1 << ( usage - 1 )); joy->pJoystick.os->cache_buttons &= ~(1 << ( usage - 1 ));
} }
} }
} }
} }
# ifdef HAVE_ERRNO_H # ifdef HAVE_ERRNO_H
if ( len < 0 && errno != EAGAIN ) if ( len < 0 && errno != EAGAIN )
# else # else
if ( len < 0 ) if ( len < 0 )
# endif # endif
{ {
perror( joy->pJoystick.os->fname ); perror( joy->pJoystick.os->fname );
joy->error = 1; joy->error = 1;
} }
if ( buttons != NULL ) *buttons = joy->pJoystick.os->cache_buttons; if ( buttons != NULL ) *buttons = joy->pJoystick.os->cache_buttons;
if ( axes != NULL ) if ( axes != NULL )
memcpy ( axes, joy->pJoystick.os->cache_axes, sizeof(float) * joy->num_axes ); memcpy ( axes, joy->pJoystick.os->cache_axes, sizeof(float) * joy->num_axes );
# endif # endif
#endif #endif
#ifdef JS_NEW #ifdef JS_NEW
while ( 1 ) while ( 1 )
{ {
status = read ( joy->pJoystick.fd, &joy->pJoystick.js, sizeof(struct js_event) ); status = read ( joy->pJoystick.fd, &joy->pJoystick.js, sizeof(struct js_event) );
if ( status != sizeof( struct js_event ) ) if ( status != sizeof( struct js_event ) )
{ {
# ifdef HAVE_ERRNO_H # ifdef HAVE_ERRNO_H
if ( errno == EAGAIN ) if ( errno == EAGAIN )
{ {
/* Use the old values */ /* Use the old values */
if ( buttons ) if ( buttons )
*buttons = joy->pJoystick.tmp_buttons; *buttons = joy->pJoystick.tmp_buttons;
if ( axes ) if ( axes )
memcpy( axes, joy->pJoystick.tmp_axes, memcpy( axes, joy->pJoystick.tmp_axes,
sizeof( float ) * joy->num_axes ); sizeof( float ) * joy->num_axes );
return; return;
} }
# endif # endif
fgWarning ( "%s", joy->pJoystick.fname ); fgWarning ( "%s", joy->pJoystick.fname );
joy->error = GL_TRUE; joy->error = GL_TRUE;
return; return;
} }
switch ( joy->pJoystick.js.type & ~JS_EVENT_INIT ) switch ( joy->pJoystick.js.type & ~JS_EVENT_INIT )
{ {
case JS_EVENT_BUTTON: case JS_EVENT_BUTTON:
if( joy->pJoystick.js.value == 0 ) /* clear the flag */ if( joy->pJoystick.js.value == 0 ) /* clear the flag */
joy->pJoystick.tmp_buttons &= ~( 1 << joy->pJoystick.js.number ); joy->pJoystick.tmp_buttons &= ~( 1 << joy->pJoystick.js.number );
else else
joy->pJoystick.tmp_buttons |= ( 1 << joy->pJoystick.js.number ); joy->pJoystick.tmp_buttons |= ( 1 << joy->pJoystick.js.number );
break; break;
case JS_EVENT_AXIS: case JS_EVENT_AXIS:
if ( joy->pJoystick.js.number < joy->num_axes ) if ( joy->pJoystick.js.number < joy->num_axes )
{ {
joy->pJoystick.tmp_axes[ joy->pJoystick.js.number ] = ( float )joy->pJoystick.js.value; joy->pJoystick.tmp_axes[ joy->pJoystick.js.number ] = ( float )joy->pJoystick.js.value;
if( axes ) if( axes )
memcpy( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes ); memcpy( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
} }
break; break;
default: default:
fgWarning ( "PLIB_JS: Unrecognised /dev/js return!?!" ); fgWarning ( "PLIB_JS: Unrecognised /dev/js return!?!" );
/* use the old values */ /* use the old values */
if ( buttons != NULL ) *buttons = joy->pJoystick.tmp_buttons; if ( buttons != NULL ) *buttons = joy->pJoystick.tmp_buttons;
if ( axes != NULL ) if ( axes != NULL )
memcpy ( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes ); memcpy ( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
return; return;
} }
if( buttons ) if( buttons )
*buttons = joy->pJoystick.tmp_buttons; *buttons = joy->pJoystick.tmp_buttons;
} }
#else #else
status = read( joy->pJoystick.fd, &joy->pJoystick.js, JS_RETURN ); status = read( joy->pJoystick.fd, &joy->pJoystick.js, JS_RETURN );
if ( status != JS_RETURN ) if ( status != JS_RETURN )
{ {
fgWarning( "%s", joy->pJoystick.fname ); fgWarning( "%s", joy->pJoystick.fname );
joy->error = GL_TRUE; joy->error = GL_TRUE;
return; return;
} }
if ( buttons ) if ( buttons )
# if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) # if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
*buttons = ( joy->pJoystick.js.b1 ? 1 : 0 ) | ( joy->pJoystick.js.b2 ? 2 : 0 ); /* XXX Should not be here -- BSD is handled earlier */ *buttons = ( joy->pJoystick.js.b1 ? 1 : 0 ) | ( joy->pJoystick.js.b2 ? 2 : 0 ); /* XXX Should not be here -- BSD is handled earlier */
# else # else
*buttons = joy->pJoystick.js.buttons; *buttons = joy->pJoystick.js.buttons;
# endif # endif
if ( axes ) if ( axes )
{ {
axes[ 0 ] = (float) joy->pJoystick.js.x; axes[ 0 ] = (float) joy->pJoystick.js.x;
axes[ 1 ] = (float) joy->pJoystick.js.y; axes[ 1 ] = (float) joy->pJoystick.js.y;
} }
#endif #endif
} }
void fgPlatformJoystickOpen( SFG_Joystick* joy ) void fgPlatformJoystickOpen( SFG_Joystick* joy )
{ {
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) #if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
int i = 0; int i = 0;
char *cp; char *cp;
#endif #endif
#ifdef JS_NEW #ifdef JS_NEW
unsigned char u; unsigned char u;
int i=0; int i=0;
#else #else
# if defined( __linux__ ) || TARGET_HOST_SOLARIS # if defined( __linux__ ) || TARGET_HOST_SOLARIS
int i = 0; int i = 0;
int counter = 0; int counter = 0;
# endif # endif
#endif #endif
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) #if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
for( i = 0; i < _JS_MAX_AXES; i++ ) for( i = 0; i < _JS_MAX_AXES; i++ )
joy->pJoystick.os->cache_axes[ i ] = 0.0f; joy->pJoystick.os->cache_axes[ i ] = 0.0f;
joy->pJoystick.os->cache_buttons = 0; joy->pJoystick.os->cache_buttons = 0;
joy->pJoystick.os->fd = open( joy->pJoystick.os->fname, O_RDONLY | O_NONBLOCK); joy->pJoystick.os->fd = open( joy->pJoystick.os->fname, O_RDONLY | O_NONBLOCK);
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
if( joy->pJoystick.os->fd < 0 && errno == EACCES ) if( joy->pJoystick.os->fd < 0 && errno == EACCES )
fgWarning ( "%s exists but is not readable by you", joy->pJoystick.os->fname ); fgWarning ( "%s exists but is not readable by you", joy->pJoystick.os->fname );
#endif #endif
joy->error =( joy->pJoystick.os->fd < 0 ); joy->error =( joy->pJoystick.os->fd < 0 );
if( joy->error ) if( joy->error )
return; return;
joy->num_axes = 0; joy->num_axes = 0;
joy->num_buttons = 0; joy->num_buttons = 0;
if( joy->pJoystick.os->is_analog ) if( joy->pJoystick.os->is_analog )
{ {
FILE *joyfile; FILE *joyfile;
char joyfname[ 1024 ]; char joyfname[ 1024 ];
int noargs, in_no_axes; int noargs, in_no_axes;
float axes [ _JS_MAX_AXES ]; float axes [ _JS_MAX_AXES ];
int buttons[ _JS_MAX_AXES ]; int buttons[ _JS_MAX_AXES ];
joy->num_axes = 2; joy->num_axes = 2;
joy->num_buttons = 32; joy->num_buttons = 32;
fghJoystickRawRead( joy, buttons, axes ); fghJoystickRawRead( joy, buttons, axes );
joy->error = axes[ 0 ] < -1000000000.0f; joy->error = axes[ 0 ] < -1000000000.0f;
if( joy->error ) if( joy->error )
return; return;
snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id ); snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id );
joyfile = fopen( joyfname, "r" ); joyfile = fopen( joyfname, "r" );
joy->error =( joyfile == NULL ); joy->error =( joyfile == NULL );
if( joy->error ) if( joy->error )
return; return;
noargs = fscanf( joyfile, "%d%f%f%f%f%f%f", &in_no_axes, noargs = fscanf( joyfile, "%d%f%f%f%f%f%f", &in_no_axes,
&joy->min[ 0 ], &joy->center[ 0 ], &joy->max[ 0 ], &joy->min[ 0 ], &joy->center[ 0 ], &joy->max[ 0 ],
&joy->min[ 1 ], &joy->center[ 1 ], &joy->max[ 1 ] ); &joy->min[ 1 ], &joy->center[ 1 ], &joy->max[ 1 ] );
joy->error = noargs != 7 || in_no_axes != _JS_MAX_AXES; joy->error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
fclose( joyfile ); fclose( joyfile );
if( joy->error ) if( joy->error )
return; return;
for( i = 0; i < _JS_MAX_AXES; i++ ) for( i = 0; i < _JS_MAX_AXES; i++ )
{ {
joy->dead_band[ i ] = 0.0f; joy->dead_band[ i ] = 0.0f;
joy->saturate [ i ] = 1.0f; joy->saturate [ i ] = 1.0f;
} }
return; /* End of analog code */ return; /* End of analog code */
} }
# ifdef HAVE_USB_JS # ifdef HAVE_USB_JS
if( ! fghJoystickInitializeHID( joy->pJoystick.os, &joy->num_axes, if( ! fghJoystickInitializeHID( joy->pJoystick.os, &joy->num_axes,
&joy->num_buttons ) ) &joy->num_buttons ) )
{ {
close( joy->pJoystick.os->fd ); close( joy->pJoystick.os->fd );
joy->error = GL_TRUE; joy->error = GL_TRUE;
return; return;
} }
cp = strrchr( joy->pJoystick.os->fname, '/' ); cp = strrchr( joy->pJoystick.os->fname, '/' );
if( cp ) if( cp )
{ {
if( fghJoystickFindUSBdev( &cp[1], joy->name, sizeof( joy->name ) ) == if( fghJoystickFindUSBdev( &cp[1], joy->name, sizeof( joy->name ) ) ==
0 ) 0 )
strcpy( joy->name, &cp[1] ); strcpy( joy->name, &cp[1] );
} }
if( joy->num_axes > _JS_MAX_AXES ) if( joy->num_axes > _JS_MAX_AXES )
joy->num_axes = _JS_MAX_AXES; joy->num_axes = _JS_MAX_AXES;
for( i = 0; i < _JS_MAX_AXES; i++ ) for( i = 0; i < _JS_MAX_AXES; i++ )
{ {
/* We really should get this from the HID, but that data seems /* We really should get this from the HID, but that data seems
* to be quite unreliable for analog-to-USB converters. Punt for * to be quite unreliable for analog-to-USB converters. Punt for
* now. * now.
*/ */
if( joy->pJoystick.os->axes_usage[ i ] == HUG_HAT_SWITCH ) if( joy->pJoystick.os->axes_usage[ i ] == HUG_HAT_SWITCH )
{ {
joy->max [ i ] = 1.0f; joy->max [ i ] = 1.0f;
joy->center[ i ] = 0.0f; joy->center[ i ] = 0.0f;
joy->min [ i ] = -1.0f; joy->min [ i ] = -1.0f;
} }
else else
{ {
joy->max [ i ] = 255.0f; joy->max [ i ] = 255.0f;
joy->center[ i ] = 127.0f; joy->center[ i ] = 127.0f;
joy->min [ i ] = 0.0f; joy->min [ i ] = 0.0f;
} }
joy->dead_band[ i ] = 0.0f; joy->dead_band[ i ] = 0.0f;
joy->saturate[ i ] = 1.0f; joy->saturate[ i ] = 1.0f;
} }
# endif # endif
#endif #endif
#if defined( __linux__ ) || TARGET_HOST_SOLARIS #if defined( __linux__ ) || TARGET_HOST_SOLARIS
/* Default for older Linux systems. */ /* Default for older Linux systems. */
joy->num_axes = 2; joy->num_axes = 2;
joy->num_buttons = 32; joy->num_buttons = 32;
# ifdef JS_NEW # ifdef JS_NEW
for( i = 0; i < _JS_MAX_AXES; i++ ) for( i = 0; i < _JS_MAX_AXES; i++ )
joy->pJoystick.tmp_axes[ i ] = 0.0f; joy->pJoystick.tmp_axes[ i ] = 0.0f;
joy->pJoystick.tmp_buttons = 0; joy->pJoystick.tmp_buttons = 0;
# endif # endif
joy->pJoystick.fd = open( joy->pJoystick.fname, O_RDONLY ); joy->pJoystick.fd = open( joy->pJoystick.fname, O_RDONLY );
joy->error =( joy->pJoystick.fd < 0 ); joy->error =( joy->pJoystick.fd < 0 );
if( joy->error ) if( joy->error )
return; return;
/* Set the correct number of axes for the linux driver */ /* Set the correct number of axes for the linux driver */
# ifdef JS_NEW # ifdef JS_NEW
/* Melchior Franz's fixes for big-endian Linuxes since writing /* Melchior Franz's fixes for big-endian Linuxes since writing
* to the upper byte of an uninitialized word doesn't work. * to the upper byte of an uninitialized word doesn't work.
* 9 April 2003 * 9 April 2003
*/ */
ioctl( joy->pJoystick.fd, JSIOCGAXES, &u ); ioctl( joy->pJoystick.fd, JSIOCGAXES, &u );
joy->num_axes = u; joy->num_axes = u;
ioctl( joy->pJoystick.fd, JSIOCGBUTTONS, &u ); ioctl( joy->pJoystick.fd, JSIOCGBUTTONS, &u );
joy->num_buttons = u; joy->num_buttons = u;
ioctl( joy->pJoystick.fd, JSIOCGNAME( sizeof( joy->name ) ), joy->name ); ioctl( joy->pJoystick.fd, JSIOCGNAME( sizeof( joy->name ) ), joy->name );
fcntl( joy->pJoystick.fd, F_SETFL, O_NONBLOCK ); fcntl( joy->pJoystick.fd, F_SETFL, O_NONBLOCK );
# endif # endif
/* /*
* The Linux driver seems to return 512 for all axes * The Linux driver seems to return 512 for all axes
* when no stick is present - but there is a chance * when no stick is present - but there is a chance
* that could happen by accident - so it's gotta happen * that could happen by accident - so it's gotta happen
* on both axes for at least 100 attempts. * on both axes for at least 100 attempts.
* *
* PWO: shouldn't be that done somehow wiser on the kernel level? * PWO: shouldn't be that done somehow wiser on the kernel level?
*/ */
# ifndef JS_NEW # ifndef JS_NEW
counter = 0; counter = 0;
do do
{ {
fghJoystickRawRead( joy, NULL, joy->center ); fghJoystickRawRead( joy, NULL, joy->center );
counter++; counter++;
} while( !joy->error && } while( !joy->error &&
counter < 100 && counter < 100 &&
joy->center[ 0 ] == 512.0f && joy->center[ 0 ] == 512.0f &&
joy->center[ 1 ] == 512.0f ); joy->center[ 1 ] == 512.0f );
if ( counter >= 100 ) if ( counter >= 100 )
joy->error = GL_TRUE; joy->error = GL_TRUE;
# endif # endif
for( i = 0; i < _JS_MAX_AXES; i++ ) for( i = 0; i < _JS_MAX_AXES; i++ )
{ {
# ifdef JS_NEW # ifdef JS_NEW
joy->max [ i ] = 32767.0f; joy->max [ i ] = 32767.0f;
joy->center[ i ] = 0.0f; joy->center[ i ] = 0.0f;
joy->min [ i ] = -32767.0f; joy->min [ i ] = -32767.0f;
# else # else
joy->max[ i ] = joy->center[ i ] * 2.0f; joy->max[ i ] = joy->center[ i ] * 2.0f;
joy->min[ i ] = 0.0f; joy->min[ i ] = 0.0f;
# endif # endif
joy->dead_band[ i ] = 0.0f; joy->dead_band[ i ] = 0.0f;
joy->saturate [ i ] = 1.0f; joy->saturate [ i ] = 1.0f;
} }
#endif #endif
} }
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident ) void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
{ {
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) #if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
fgJoystick[ ident ]->id = ident; fgJoystick[ ident ]->id = ident;
fgJoystick[ ident ]->error = GL_FALSE; fgJoystick[ ident ]->error = GL_FALSE;
fgJoystick[ ident ]->pJoystick.os = calloc( 1, sizeof( struct os_specific_s ) ); fgJoystick[ ident ]->pJoystick.os = calloc( 1, sizeof( struct os_specific_s ) );
memset( fgJoystick[ ident ]->pJoystick.os, 0, sizeof( struct os_specific_s ) ); memset( fgJoystick[ ident ]->pJoystick.os, 0, sizeof( struct os_specific_s ) );
if( ident < USB_IDENT_OFFSET ) if( ident < USB_IDENT_OFFSET )
fgJoystick[ ident ]->pJoystick.os->is_analog = 1; fgJoystick[ ident ]->pJoystick.os->is_analog = 1;
if( fgJoystick[ ident ]->pJoystick.os->is_analog ) if( fgJoystick[ ident ]->pJoystick.os->is_analog )
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", AJSDEV, ident ); snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", AJSDEV, ident );
else else
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", UHIDDEV, snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", UHIDDEV,
ident - USB_IDENT_OFFSET ); ident - USB_IDENT_OFFSET );
#elif defined( __linux__ ) #elif defined( __linux__ )
fgJoystick[ ident ]->id = ident; fgJoystick[ ident ]->id = ident;
fgJoystick[ ident ]->error = GL_FALSE; fgJoystick[ ident ]->error = GL_FALSE;
snprintf( fgJoystick[ident]->pJoystick.fname, sizeof(fgJoystick[ident]->pJoystick.fname), "/dev/input/js%d", ident ); snprintf( fgJoystick[ident]->pJoystick.fname, sizeof(fgJoystick[ident]->pJoystick.fname), "/dev/input/js%d", ident );
if( access( fgJoystick[ ident ]->pJoystick.fname, F_OK ) != 0 ) if( access( fgJoystick[ ident ]->pJoystick.fname, F_OK ) != 0 )
snprintf( fgJoystick[ ident ]->pJoystick.fname, sizeof(fgJoystick[ ident ]->pJoystick.fname), "/dev/js%d", ident ); snprintf( fgJoystick[ ident ]->pJoystick.fname, sizeof(fgJoystick[ ident ]->pJoystick.fname), "/dev/js%d", ident );
#endif #endif
} }
void fgPlatformJoystickClose ( int ident ) void fgPlatformJoystickClose ( int ident )
{ {
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ ) #if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
if( fgJoystick[ident]->pJoystick.os ) if( fgJoystick[ident]->pJoystick.os )
{ {
if( ! fgJoystick[ ident ]->error ) if( ! fgJoystick[ ident ]->error )
close( fgJoystick[ ident ]->pJoystick.os->fd ); close( fgJoystick[ ident ]->pJoystick.os->fd );
#ifdef HAVE_USB_JS #ifdef HAVE_USB_JS
if( fgJoystick[ ident ]->pJoystick.os->hids ) if( fgJoystick[ ident ]->pJoystick.os->hids )
free (fgJoystick[ ident ]->pJoystick.os->hids); free (fgJoystick[ ident ]->pJoystick.os->hids);
if( fgJoystick[ ident ]->pJoystick.os->hid_data_buf ) if( fgJoystick[ ident ]->pJoystick.os->hid_data_buf )
free( fgJoystick[ ident ]->pJoystick.os->hid_data_buf ); free( fgJoystick[ ident ]->pJoystick.os->hid_data_buf );
#endif #endif
free( fgJoystick[ident]->pJoystick.os ); free( fgJoystick[ident]->pJoystick.os );
} }
#endif #endif
if( ! fgJoystick[ident]->error ) if( ! fgJoystick[ident]->error )
close( fgJoystick[ ident ]->pJoystick.fd ); close( fgJoystick[ ident ]->pJoystick.fd );
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +1,49 @@
/* /*
* freeglut_menu_x11.c * freeglut_menu_x11.c
* *
* Pull-down menu creation and handling. * Pull-down menu creation and handling.
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Wed Feb 1, 2012 * Creation date: Wed Feb 1, 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
/* /*
* * Private function to get the virtual maximum screen extent * * Private function to get the virtual maximum screen extent
* */ * */
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y ) GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
{ {
int wx, wy; int wx, wy;
Window w; Window w;
XTranslateCoordinates( XTranslateCoordinates(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
window->Window.Handle, window->Window.Handle,
fgDisplay.pDisplay.RootWindow, fgDisplay.pDisplay.RootWindow,
0, 0, &wx, &wy, &w); 0, 0, &wx, &wy, &w);
*x = fgState.GameModeSize.X + wx; *x = fgState.GameModeSize.X + wx;
*y = fgState.GameModeSize.Y + wy; *y = fgState.GameModeSize.Y + wy;
} }

View File

@ -1,415 +1,415 @@
/* Spaceball support for Linux. /* Spaceball support for Linux.
* Written by John Tsiombikas <nuclear@member.fsf.org> * Written by John Tsiombikas <nuclear@member.fsf.org>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* This code supports 3Dconnexion's 6-dof space-whatever devices. * This code supports 3Dconnexion's 6-dof space-whatever devices.
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv) * It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
* free spacenavd (http://spacenav.sourceforge.net), through the "standard" * free spacenavd (http://spacenav.sourceforge.net), through the "standard"
* magellan X-based protocol. * magellan X-based protocol.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
extern int sball_initialized; extern int sball_initialized;
enum { enum {
SPNAV_EVENT_ANY, /* used by spnav_remove_events() */ SPNAV_EVENT_ANY, /* used by spnav_remove_events() */
SPNAV_EVENT_MOTION, SPNAV_EVENT_MOTION,
SPNAV_EVENT_BUTTON /* includes both press and release */ SPNAV_EVENT_BUTTON /* includes both press and release */
}; };
struct spnav_event_motion { struct spnav_event_motion {
int type; int type;
int x, y, z; int x, y, z;
int rx, ry, rz; int rx, ry, rz;
unsigned int period; unsigned int period;
int *data; int *data;
}; };
struct spnav_event_button { struct spnav_event_button {
int type; int type;
int press; int press;
int bnum; int bnum;
}; };
typedef union spnav_event { typedef union spnav_event {
int type; int type;
struct spnav_event_motion motion; struct spnav_event_motion motion;
struct spnav_event_button button; struct spnav_event_button button;
} spnav_event; } spnav_event;
static int spnav_x11_open(Display *dpy, Window win); static int spnav_x11_open(Display *dpy, Window win);
static int spnav_x11_window(Window win); static int spnav_x11_window(Window win);
static int spnav_x11_event(const XEvent *xev, spnav_event *event); static int spnav_x11_event(const XEvent *xev, spnav_event *event);
static int spnav_close(void); static int spnav_close(void);
static int spnav_fd(void); static int spnav_fd(void);
static int spnav_remove_events(int type); static int spnav_remove_events(int type);
static SFG_Window *spnav_win; static SFG_Window *spnav_win;
void fgPlatformInitializeSpaceball(void) void fgPlatformInitializeSpaceball(void)
{ {
Window w; Window w;
sball_initialized = 1; sball_initialized = 1;
if(!fgStructure.CurrentWindow) if(!fgStructure.CurrentWindow)
{ {
sball_initialized = -1; sball_initialized = -1;
return; return;
} }
w = fgStructure.CurrentWindow->Window.Handle; w = fgStructure.CurrentWindow->Window.Handle;
if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1) if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1)
{ {
sball_initialized = -1; sball_initialized = -1;
return; return;
} }
} }
void fgPlatformSpaceballClose(void) void fgPlatformSpaceballClose(void)
{ {
spnav_close(); spnav_close();
} }
int fgPlatformHasSpaceball(void) int fgPlatformHasSpaceball(void)
{ {
/* XXX this function should somehow query the driver if there's a device /* XXX this function should somehow query the driver if there's a device
* plugged in, as opposed to just checking if there's a driver to talk to. * plugged in, as opposed to just checking if there's a driver to talk to.
*/ */
return spnav_fd() == -1 ? 0 : 1; return spnav_fd() == -1 ? 0 : 1;
} }
int fgPlatformSpaceballNumButtons(void) { int fgPlatformSpaceballNumButtons(void) {
return 2; return 2;
} }
void fgPlatformSpaceballSetWindow(SFG_Window *window) void fgPlatformSpaceballSetWindow(SFG_Window *window)
{ {
if(spnav_win != window) { if(spnav_win != window) {
spnav_x11_window(window->Window.Handle); spnav_x11_window(window->Window.Handle);
spnav_win = window; spnav_win = window;
} }
} }
int fgIsSpaceballXEvent(const XEvent *xev) int fgIsSpaceballXEvent(const XEvent *xev)
{ {
spnav_event sev; spnav_event sev;
if(spnav_win != fgStructure.CurrentWindow) { if(spnav_win != fgStructure.CurrentWindow) {
/* this will also initialize spaceball if needed (first call) */ /* this will also initialize spaceball if needed (first call) */
fgSpaceballSetWindow(fgStructure.CurrentWindow); fgSpaceballSetWindow(fgStructure.CurrentWindow);
} }
if(sball_initialized != 1) { if(sball_initialized != 1) {
return 0; return 0;
} }
return spnav_x11_event(xev, &sev); return spnav_x11_event(xev, &sev);
} }
void fgSpaceballHandleXEvent(const XEvent *xev) void fgSpaceballHandleXEvent(const XEvent *xev)
{ {
spnav_event sev; spnav_event sev;
if(sball_initialized == 0) { if(sball_initialized == 0) {
fgInitialiseSpaceball(); fgInitialiseSpaceball();
if(sball_initialized != 1) { if(sball_initialized != 1) {
return; return;
} }
} }
if(spnav_x11_event(xev, &sev)) { if(spnav_x11_event(xev, &sev)) {
switch(sev.type) { switch(sev.type) {
case SPNAV_EVENT_MOTION: case SPNAV_EVENT_MOTION:
if(sev.motion.x | sev.motion.y | sev.motion.z) { if(sev.motion.x | sev.motion.y | sev.motion.z) {
INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z)); INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z));
} }
if(sev.motion.rx | sev.motion.ry | sev.motion.rz) { if(sev.motion.rx | sev.motion.ry | sev.motion.rz) {
INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz)); INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz));
} }
spnav_remove_events(SPNAV_EVENT_MOTION); spnav_remove_events(SPNAV_EVENT_MOTION);
break; break;
case SPNAV_EVENT_BUTTON: case SPNAV_EVENT_BUTTON:
INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum, sev.button.press ? GLUT_DOWN : GLUT_UP)); INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum, sev.button.press ? GLUT_DOWN : GLUT_UP));
break; break;
default: default:
break; break;
} }
} }
} }
/* /*
The following code is part of libspnav, part of the spacenav project (spacenav.sf.net) The following code is part of libspnav, part of the spacenav project (spacenav.sf.net)
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org> Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution. and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products 3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE. OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
#include <errno.h> #include <errno.h>
#endif #endif
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
static Window get_daemon_window(Display *dpy); static Window get_daemon_window(Display *dpy);
static int catch_badwin(Display *dpy, XErrorEvent *err); static int catch_badwin(Display *dpy, XErrorEvent *err);
static Display *dpy; static Display *dpy;
static Window app_win; static Window app_win;
static Atom motion_event, button_press_event, button_release_event, command_event; static Atom motion_event, button_press_event, button_release_event, command_event;
enum { enum {
CMD_APP_WINDOW = 27695, CMD_APP_WINDOW = 27695,
CMD_APP_SENS CMD_APP_SENS
}; };
#define IS_OPEN dpy #define IS_OPEN dpy
struct event_node { struct event_node {
spnav_event event; spnav_event event;
struct event_node *next; struct event_node *next;
}; };
static int spnav_x11_open(Display *display, Window win) static int spnav_x11_open(Display *display, Window win)
{ {
if(IS_OPEN) { if(IS_OPEN) {
return -1; return -1;
} }
dpy = display; dpy = display;
motion_event = XInternAtom(dpy, "MotionEvent", True); motion_event = XInternAtom(dpy, "MotionEvent", True);
button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); button_press_event = XInternAtom(dpy, "ButtonPressEvent", True);
button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True);
command_event = XInternAtom(dpy, "CommandEvent", True); command_event = XInternAtom(dpy, "CommandEvent", True);
if(!motion_event || !button_press_event || !button_release_event || !command_event) { if(!motion_event || !button_press_event || !button_release_event || !command_event) {
dpy = 0; dpy = 0;
return -1; /* daemon not started */ return -1; /* daemon not started */
} }
if(spnav_x11_window(win) == -1) { if(spnav_x11_window(win) == -1) {
dpy = 0; dpy = 0;
return -1; /* daemon not started */ return -1; /* daemon not started */
} }
app_win = win; app_win = win;
return 0; return 0;
} }
static int spnav_close(void) static int spnav_close(void)
{ {
if(dpy) { if(dpy) {
spnav_x11_window(DefaultRootWindow(dpy)); spnav_x11_window(DefaultRootWindow(dpy));
app_win = 0; app_win = 0;
dpy = 0; dpy = 0;
return 0; return 0;
} }
return -1; return -1;
} }
static int spnav_x11_window(Window win) static int spnav_x11_window(Window win)
{ {
int (*prev_xerr_handler)(Display*, XErrorEvent*); int (*prev_xerr_handler)(Display*, XErrorEvent*);
XEvent xev; XEvent xev;
Window daemon_win; Window daemon_win;
if(!IS_OPEN) { if(!IS_OPEN) {
return -1; return -1;
} }
if(!(daemon_win = get_daemon_window(dpy))) { if(!(daemon_win = get_daemon_window(dpy))) {
return -1; return -1;
} }
prev_xerr_handler = XSetErrorHandler(catch_badwin); prev_xerr_handler = XSetErrorHandler(catch_badwin);
xev.type = ClientMessage; xev.type = ClientMessage;
xev.xclient.send_event = False; xev.xclient.send_event = False;
xev.xclient.display = dpy; xev.xclient.display = dpy;
xev.xclient.window = win; xev.xclient.window = win;
xev.xclient.message_type = command_event; xev.xclient.message_type = command_event;
xev.xclient.format = 16; xev.xclient.format = 16;
xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16; xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16;
xev.xclient.data.s[1] = (unsigned int)win & 0xffff; xev.xclient.data.s[1] = (unsigned int)win & 0xffff;
xev.xclient.data.s[2] = CMD_APP_WINDOW; xev.xclient.data.s[2] = CMD_APP_WINDOW;
XSendEvent(dpy, daemon_win, False, 0, &xev); XSendEvent(dpy, daemon_win, False, 0, &xev);
XSync(dpy, False); XSync(dpy, False);
XSetErrorHandler(prev_xerr_handler); XSetErrorHandler(prev_xerr_handler);
return 0; return 0;
} }
static int spnav_fd(void) static int spnav_fd(void)
{ {
if(dpy) { if(dpy) {
return ConnectionNumber(dpy); return ConnectionNumber(dpy);
} }
return -1; return -1;
} }
/*static int spnav_wait_event(spnav_event *event) /*static int spnav_wait_event(spnav_event *event)
{ {
if(dpy) { if(dpy) {
for(;;) { for(;;) {
XEvent xev; XEvent xev;
XNextEvent(dpy, &xev); XNextEvent(dpy, &xev);
if(spnav_x11_event(&xev, event) > 0) { if(spnav_x11_event(&xev, event) > 0) {
return event->type; return event->type;
} }
} }
} }
return 0; return 0;
} }
static int spnav_poll_event(spnav_event *event) static int spnav_poll_event(spnav_event *event)
{ {
if(dpy) { if(dpy) {
if(XPending(dpy)) { if(XPending(dpy)) {
XEvent xev; XEvent xev;
XNextEvent(dpy, &xev); XNextEvent(dpy, &xev);
return spnav_x11_event(&xev, event); return spnav_x11_event(&xev, event);
} }
} }
return 0; return 0;
}*/ }*/
static Bool match_events(Display *dpy, XEvent *xev, char *arg) static Bool match_events(Display *dpy, XEvent *xev, char *arg)
{ {
int evtype = *(int*)arg; int evtype = *(int*)arg;
if(xev->type != ClientMessage) { if(xev->type != ClientMessage) {
return False; return False;
} }
if(xev->xclient.message_type == motion_event) { if(xev->xclient.message_type == motion_event) {
return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False; return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False;
} }
if(xev->xclient.message_type == button_press_event || if(xev->xclient.message_type == button_press_event ||
xev->xclient.message_type == button_release_event) { xev->xclient.message_type == button_release_event) {
return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False; return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False;
} }
return False; return False;
} }
static int spnav_remove_events(int type) static int spnav_remove_events(int type)
{ {
int rm_count = 0; int rm_count = 0;
if(dpy) { if(dpy) {
XEvent xev; XEvent xev;
while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) { while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) {
rm_count++; rm_count++;
} }
return rm_count; return rm_count;
} }
return 0; return 0;
} }
static int spnav_x11_event(const XEvent *xev, spnav_event *event) static int spnav_x11_event(const XEvent *xev, spnav_event *event)
{ {
int i; int i;
int xmsg_type; int xmsg_type;
if(xev->type != ClientMessage) { if(xev->type != ClientMessage) {
return 0; return 0;
} }
xmsg_type = xev->xclient.message_type; xmsg_type = xev->xclient.message_type;
if(xmsg_type != motion_event && xmsg_type != button_press_event && if(xmsg_type != motion_event && xmsg_type != button_press_event &&
xmsg_type != button_release_event) { xmsg_type != button_release_event) {
return 0; return 0;
} }
if(xmsg_type == motion_event) { if(xmsg_type == motion_event) {
event->type = SPNAV_EVENT_MOTION; event->type = SPNAV_EVENT_MOTION;
event->motion.data = &event->motion.x; event->motion.data = &event->motion.x;
for(i=0; i<6; i++) { for(i=0; i<6; i++) {
event->motion.data[i] = xev->xclient.data.s[i + 2]; event->motion.data[i] = xev->xclient.data.s[i + 2];
} }
event->motion.period = xev->xclient.data.s[8]; event->motion.period = xev->xclient.data.s[8];
} else { } else {
event->type = SPNAV_EVENT_BUTTON; event->type = SPNAV_EVENT_BUTTON;
event->button.press = xmsg_type == button_press_event ? 1 : 0; event->button.press = xmsg_type == button_press_event ? 1 : 0;
event->button.bnum = xev->xclient.data.s[2]; event->button.bnum = xev->xclient.data.s[2];
} }
return event->type; return event->type;
} }
static Window get_daemon_window(Display *dpy) static Window get_daemon_window(Display *dpy)
{ {
Window win, root_win; Window win, root_win;
XTextProperty wname; XTextProperty wname;
Atom type; Atom type;
int fmt; int fmt;
unsigned long nitems, bytes_after; unsigned long nitems, bytes_after;
unsigned char *prop; unsigned char *prop;
root_win = DefaultRootWindow(dpy); root_win = DefaultRootWindow(dpy);
XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop); XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop);
if(!prop) { if(!prop) {
return 0; return 0;
} }
win = *(Window*)prop; win = *(Window*)prop;
XFree(prop); XFree(prop);
if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) { if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) {
return 0; return 0;
} }
return win; return win;
} }
static int catch_badwin(Display *dpy, XErrorEvent *err) static int catch_badwin(Display *dpy, XErrorEvent *err)
{ {
char buf[256]; char buf[256];
if(err->error_code == BadWindow) { if(err->error_code == BadWindow) {
/* do nothing? */ /* do nothing? */
} else { } else {
XGetErrorText(dpy, err->error_code, buf, sizeof buf); XGetErrorText(dpy, err->error_code, buf, sizeof buf);
fprintf(stderr, "Caught unexpected X error: %s\n", buf); fprintf(stderr, "Caught unexpected X error: %s\n", buf);
} }
return 0; return 0;
} }

View File

@ -1,406 +1,406 @@
/* /*
* freeglut_state_x11.c * freeglut_state_x11.c
* *
* X11-specific freeglut state query methods. * X11-specific freeglut state query methods.
* *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by John F. Fay, <fayjf@sourceforge.net> * Written by John F. Fay, <fayjf@sourceforge.net>
* Creation date: Sat Feb 4 2012 * Creation date: Sat Feb 4 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
/* /*
* TODO BEFORE THE STABLE RELEASE: * TODO BEFORE THE STABLE RELEASE:
* *
* fgPlatformChooseFBConfig() -- OK, but what about glutInitDisplayString()? * fgPlatformChooseFBConfig() -- OK, but what about glutInitDisplayString()?
*/ */
/* A helper function to check if a display mode is possible to use */ /* A helper function to check if a display mode is possible to use */
GLXFBConfig* fgPlatformChooseFBConfig( int* numcfgs ); GLXFBConfig* fgPlatformChooseFBConfig( int* numcfgs );
/* /*
* Queries the GL context about some attributes * Queries the GL context about some attributes
*/ */
int fgPlatformGetConfig( int attribute ) int fgPlatformGetConfig( int attribute )
{ {
int returnValue = 0; int returnValue = 0;
int result; /* Not checked */ int result; /* Not checked */
if( fgStructure.CurrentWindow ) if( fgStructure.CurrentWindow )
result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display, result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
*(fgStructure.CurrentWindow->Window.pContext.FBConfig), *(fgStructure.CurrentWindow->Window.pContext.FBConfig),
attribute, attribute,
&returnValue ); &returnValue );
return returnValue; return returnValue;
} }
int fgPlatformGlutGet ( GLenum eWhat ) int fgPlatformGlutGet ( GLenum eWhat )
{ {
int nsamples = 0; int nsamples = 0;
switch( eWhat ) switch( eWhat )
{ {
/* /*
* The window/context specific queries are handled mostly by * The window/context specific queries are handled mostly by
* fgPlatformGetConfig(). * fgPlatformGetConfig().
*/ */
case GLUT_WINDOW_NUM_SAMPLES: case GLUT_WINDOW_NUM_SAMPLES:
#ifdef GLX_VERSION_1_3 #ifdef GLX_VERSION_1_3
glGetIntegerv(GL_SAMPLES, &nsamples); glGetIntegerv(GL_SAMPLES, &nsamples);
#endif #endif
return nsamples; return nsamples;
/* /*
* The rest of GLX queries under X are general enough to use a macro to * The rest of GLX queries under X are general enough to use a macro to
* check them * check them
*/ */
# define GLX_QUERY(a,b) case a: return fgPlatformGetConfig( b ); # define GLX_QUERY(a,b) case a: return fgPlatformGetConfig( b );
GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA ); GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER ); GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE ); GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE ); GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE ); GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE ); GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE ); GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_SIZE ); GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_SIZE );
GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE, GLX_ALPHA_SIZE ); GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE, GLX_ALPHA_SIZE );
GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE, GLX_ACCUM_RED_SIZE ); GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE, GLX_ACCUM_RED_SIZE );
GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE, GLX_ACCUM_GREEN_SIZE ); GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE, GLX_ACCUM_GREEN_SIZE );
GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE, GLX_ACCUM_BLUE_SIZE ); GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE, GLX_ACCUM_BLUE_SIZE );
GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE, GLX_ACCUM_ALPHA_SIZE ); GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE, GLX_ACCUM_ALPHA_SIZE );
GLX_QUERY( GLUT_WINDOW_STEREO, GLX_STEREO ); GLX_QUERY( GLUT_WINDOW_STEREO, GLX_STEREO );
# undef GLX_QUERY # undef GLX_QUERY
/* Colormap size is handled in a bit different way than all the rest */ /* Colormap size is handled in a bit different way than all the rest */
case GLUT_WINDOW_COLORMAP_SIZE: case GLUT_WINDOW_COLORMAP_SIZE:
if( (fgPlatformGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) ) if( (fgPlatformGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
{ {
/* /*
* We've got a RGBA visual, so there is no colormap at all. * We've got a RGBA visual, so there is no colormap at all.
* The other possibility is that we have no current window set. * The other possibility is that we have no current window set.
*/ */
return 0; return 0;
} }
else else
{ {
const GLXFBConfig * fbconfig = const GLXFBConfig * fbconfig =
fgStructure.CurrentWindow->Window.pContext.FBConfig; fgStructure.CurrentWindow->Window.pContext.FBConfig;
XVisualInfo * visualInfo = XVisualInfo * visualInfo =
glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, *fbconfig ); glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, *fbconfig );
const int result = visualInfo->visual->map_entries; const int result = visualInfo->visual->map_entries;
XFree(visualInfo); XFree(visualInfo);
return result; return result;
} }
/* /*
* Those calls are somewhat similiar, as they use XGetWindowAttributes() * Those calls are somewhat similiar, as they use XGetWindowAttributes()
* function * function
*/ */
case GLUT_WINDOW_X: case GLUT_WINDOW_X:
case GLUT_WINDOW_Y: case GLUT_WINDOW_Y:
case GLUT_WINDOW_BORDER_WIDTH: case GLUT_WINDOW_BORDER_WIDTH:
case GLUT_WINDOW_HEADER_HEIGHT: case GLUT_WINDOW_HEADER_HEIGHT:
{ {
int x, y; int x, y;
Window w; Window w;
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
XTranslateCoordinates( XTranslateCoordinates(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgStructure.CurrentWindow->Window.Handle, fgStructure.CurrentWindow->Window.Handle,
fgDisplay.pDisplay.RootWindow, fgDisplay.pDisplay.RootWindow,
0, 0, &x, &y, &w); 0, 0, &x, &y, &w);
switch ( eWhat ) switch ( eWhat )
{ {
case GLUT_WINDOW_X: return x; case GLUT_WINDOW_X: return x;
case GLUT_WINDOW_Y: return y; case GLUT_WINDOW_Y: return y;
} }
if ( w == 0 ) if ( w == 0 )
return 0; return 0;
XTranslateCoordinates( XTranslateCoordinates(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgStructure.CurrentWindow->Window.Handle, fgStructure.CurrentWindow->Window.Handle,
w, 0, 0, &x, &y, &w); w, 0, 0, &x, &y, &w);
switch ( eWhat ) switch ( eWhat )
{ {
case GLUT_WINDOW_BORDER_WIDTH: return x; case GLUT_WINDOW_BORDER_WIDTH: return x;
case GLUT_WINDOW_HEADER_HEIGHT: return y; case GLUT_WINDOW_HEADER_HEIGHT: return y;
} }
} }
case GLUT_WINDOW_WIDTH: case GLUT_WINDOW_WIDTH:
case GLUT_WINDOW_HEIGHT: case GLUT_WINDOW_HEIGHT:
{ {
XWindowAttributes winAttributes; XWindowAttributes winAttributes;
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
XGetWindowAttributes( XGetWindowAttributes(
fgDisplay.pDisplay.Display, fgDisplay.pDisplay.Display,
fgStructure.CurrentWindow->Window.Handle, fgStructure.CurrentWindow->Window.Handle,
&winAttributes &winAttributes
); );
switch ( eWhat ) switch ( eWhat )
{ {
case GLUT_WINDOW_WIDTH: return winAttributes.width ; case GLUT_WINDOW_WIDTH: return winAttributes.width ;
case GLUT_WINDOW_HEIGHT: return winAttributes.height ; case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
} }
} }
/* I do not know yet if there will be a fgChooseVisual() function for Win32 */ /* I do not know yet if there will be a fgChooseVisual() function for Win32 */
case GLUT_DISPLAY_MODE_POSSIBLE: case GLUT_DISPLAY_MODE_POSSIBLE:
{ {
/* We should not have to call fgPlatformChooseFBConfig again here. */ /* We should not have to call fgPlatformChooseFBConfig again here. */
GLXFBConfig * fbconfig; GLXFBConfig * fbconfig;
int isPossible; int isPossible;
fbconfig = fgPlatformChooseFBConfig(NULL); fbconfig = fgPlatformChooseFBConfig(NULL);
if (fbconfig == NULL) if (fbconfig == NULL)
{ {
isPossible = 0; isPossible = 0;
} }
else else
{ {
isPossible = 1; isPossible = 1;
XFree(fbconfig); XFree(fbconfig);
} }
return isPossible; return isPossible;
} }
/* This is system-dependant */ /* This is system-dependant */
case GLUT_WINDOW_FORMAT_ID: case GLUT_WINDOW_FORMAT_ID:
if( fgStructure.CurrentWindow == NULL ) if( fgStructure.CurrentWindow == NULL )
return 0; return 0;
return fgPlatformGetConfig( GLX_VISUAL_ID ); return fgPlatformGetConfig( GLX_VISUAL_ID );
default: default:
fgWarning( "glutGet(): missing enum handle %d", eWhat ); fgWarning( "glutGet(): missing enum handle %d", eWhat );
break; break;
} }
return -1; return -1;
} }
int fgPlatformGlutDeviceGet ( GLenum eWhat ) int fgPlatformGlutDeviceGet ( GLenum eWhat )
{ {
switch( eWhat ) switch( eWhat )
{ {
case GLUT_HAS_KEYBOARD: case GLUT_HAS_KEYBOARD:
/* /*
* X11 has a core keyboard by definition, although it can * X11 has a core keyboard by definition, although it can
* be present as a virtual/dummy keyboard. For now, there * be present as a virtual/dummy keyboard. For now, there
* is no reliable way to tell if a real keyboard is present. * is no reliable way to tell if a real keyboard is present.
*/ */
return 1; return 1;
/* X11 has a mouse by definition */ /* X11 has a mouse by definition */
case GLUT_HAS_MOUSE: case GLUT_HAS_MOUSE:
return 1 ; return 1 ;
case GLUT_NUM_MOUSE_BUTTONS: case GLUT_NUM_MOUSE_BUTTONS:
/* We should be able to pass NULL when the last argument is zero, /* We should be able to pass NULL when the last argument is zero,
* but at least one X server has a bug where this causes a segfault. * but at least one X server has a bug where this causes a segfault.
* *
* In XFree86/Xorg servers, a mouse wheel is seen as two buttons * In XFree86/Xorg servers, a mouse wheel is seen as two buttons
* rather than an Axis; "freeglut_main.c" expects this when * rather than an Axis; "freeglut_main.c" expects this when
* checking for a wheel event. * checking for a wheel event.
*/ */
{ {
unsigned char map; unsigned char map;
int nbuttons = XGetPointerMapping(fgDisplay.pDisplay.Display, &map,0); int nbuttons = XGetPointerMapping(fgDisplay.pDisplay.Display, &map,0);
return nbuttons; return nbuttons;
} }
default: default:
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat ); fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
break; break;
} }
/* And now -- the failure. */ /* And now -- the failure. */
return -1; return -1;
} }
int fgPlatformGlutLayerGet( GLenum eWhat ) int fgPlatformGlutLayerGet( GLenum eWhat )
{ {
/* /*
* This is easy as layers are not implemented ;-) * This is easy as layers are not implemented ;-)
* *
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or * XXX Can we merge the UNIX/X11 and WIN32 sections? Or
* XXX is overlay support planned? * XXX is overlay support planned?
*/ */
switch( eWhat ) switch( eWhat )
{ {
case GLUT_OVERLAY_POSSIBLE: case GLUT_OVERLAY_POSSIBLE:
return 0; return 0;
case GLUT_LAYER_IN_USE: case GLUT_LAYER_IN_USE:
return GLUT_NORMAL; return GLUT_NORMAL;
case GLUT_HAS_OVERLAY: case GLUT_HAS_OVERLAY:
return 0; return 0;
case GLUT_TRANSPARENT_INDEX: case GLUT_TRANSPARENT_INDEX:
/* /*
* Return just anything, which is always defined as zero * Return just anything, which is always defined as zero
* *
* XXX HUH? * XXX HUH?
*/ */
return 0; return 0;
case GLUT_NORMAL_DAMAGED: case GLUT_NORMAL_DAMAGED:
/* XXX Actually I do not know. Maybe. */ /* XXX Actually I do not know. Maybe. */
return 0; return 0;
case GLUT_OVERLAY_DAMAGED: case GLUT_OVERLAY_DAMAGED:
return -1; return -1;
default: default:
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat ); fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
break; break;
} }
/* And fail. That's good. Programs do love failing. */ /* And fail. That's good. Programs do love failing. */
return -1; return -1;
} }
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size) int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
{ {
int *array; int *array;
int attributes[9]; int attributes[9];
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */ GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
int fbconfigArraySize; /* Number of FBConfigs in the array */ int fbconfigArraySize; /* Number of FBConfigs in the array */
int attribute_name = 0; int attribute_name = 0;
array = NULL; array = NULL;
*size = 0; *size = 0;
switch (eWhat) switch (eWhat)
{ {
case GLUT_AUX: case GLUT_AUX:
case GLUT_MULTISAMPLE: case GLUT_MULTISAMPLE:
attributes[0] = GLX_BUFFER_SIZE; attributes[0] = GLX_BUFFER_SIZE;
attributes[1] = GLX_DONT_CARE; attributes[1] = GLX_DONT_CARE;
switch (eWhat) switch (eWhat)
{ {
case GLUT_AUX: case GLUT_AUX:
/* /*
FBConfigs are now sorted by increasing number of auxiliary FBConfigs are now sorted by increasing number of auxiliary
buffers. We want at least one buffer. buffers. We want at least one buffer.
*/ */
attributes[2] = GLX_AUX_BUFFERS; attributes[2] = GLX_AUX_BUFFERS;
attributes[3] = 1; attributes[3] = 1;
attributes[4] = None; attributes[4] = None;
attribute_name = GLX_AUX_BUFFERS; attribute_name = GLX_AUX_BUFFERS;
break; break;
case GLUT_MULTISAMPLE: case GLUT_MULTISAMPLE:
attributes[2] = GLX_AUX_BUFFERS; attributes[2] = GLX_AUX_BUFFERS;
attributes[3] = GLX_DONT_CARE; attributes[3] = GLX_DONT_CARE;
attributes[4] = GLX_SAMPLE_BUFFERS; attributes[4] = GLX_SAMPLE_BUFFERS;
attributes[5] = 1; attributes[5] = 1;
/* /*
FBConfigs are now sorted by increasing number of samples per FBConfigs are now sorted by increasing number of samples per
pixel. We want at least one sample. pixel. We want at least one sample.
*/ */
attributes[6] = GLX_SAMPLES; attributes[6] = GLX_SAMPLES;
attributes[7] = 1; attributes[7] = 1;
attributes[8] = None; attributes[8] = None;
attribute_name = GLX_SAMPLES; attribute_name = GLX_SAMPLES;
break; break;
} }
fbconfigArray = glXChooseFBConfig(fgDisplay.pDisplay.Display, fbconfigArray = glXChooseFBConfig(fgDisplay.pDisplay.Display,
fgDisplay.pDisplay.Screen, fgDisplay.pDisplay.Screen,
attributes, attributes,
&fbconfigArraySize); &fbconfigArraySize);
if (fbconfigArray != NULL) if (fbconfigArray != NULL)
{ {
int * temp_array; int * temp_array;
int result; /* Returned by glXGetFBConfigAttrib. Not checked. */ int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
int previous_value; int previous_value;
int i; int i;
temp_array = malloc(sizeof(int) * fbconfigArraySize); temp_array = malloc(sizeof(int) * fbconfigArraySize);
previous_value = 0; previous_value = 0;
for (i = 0; i < fbconfigArraySize; i++) for (i = 0; i < fbconfigArraySize; i++)
{ {
int value; int value;
result = glXGetFBConfigAttrib(fgDisplay.pDisplay.Display, result = glXGetFBConfigAttrib(fgDisplay.pDisplay.Display,
fbconfigArray[i], fbconfigArray[i],
attribute_name, attribute_name,
&value); &value);
if (value > previous_value) if (value > previous_value)
{ {
temp_array[*size] = value; temp_array[*size] = value;
previous_value = value; previous_value = value;
(*size)++; (*size)++;
} }
} }
array = malloc(sizeof(int) * (*size)); array = malloc(sizeof(int) * (*size));
for (i = 0; i < *size; i++) for (i = 0; i < *size; i++)
{ {
array[i] = temp_array[i]; array[i] = temp_array[i];
} }
free(temp_array); free(temp_array);
XFree(fbconfigArray); XFree(fbconfigArray);
} }
break; break;
default: default:
break; break;
} }
return array; return array;
} }

View File

@ -1,40 +1,40 @@
/* /*
* freeglut_structure.c * freeglut_structure.c
* *
* Windows and menus need tree structure * Windows and menus need tree structure
* *
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
* Written by Pawel W. Olszta, <olszta@sourceforge.net> * Written by Pawel W. Olszta, <olszta@sourceforge.net>
* Copied for Platform code by Evan Felix <karcaw at gmail.com> * Copied for Platform code by Evan Felix <karcaw at gmail.com>
* Creation date: Thur Feb 2 2012 * Creation date: Thur Feb 2 2012
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "../Common/freeglut_internal.h" #include "../Common/freeglut_internal.h"
extern SFG_Structure fgStructure; extern SFG_Structure fgStructure;
void fgPlatformCreateWindow ( SFG_Window *window ) void fgPlatformCreateWindow ( SFG_Window *window )
{ {
window->Window.pContext.FBConfig = NULL; window->Window.pContext.FBConfig = NULL;
window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1; window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;
} }

File diff suppressed because it is too large Load Diff