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:
parent
b40d212cfb
commit
3eca89fc14
125
.gitattributes
vendored
125
.gitattributes
vendored
@ -1,18 +1,18 @@
|
||||
* text=auto !eol
|
||||
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/ChangeLog svn_keywords=Author+Date+Id+Revision
|
||||
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/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/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.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/TODO svn_keywords=Author+Date+Id+Revision
|
||||
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.filters -text
|
||||
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/doc/Makefile.am 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.dsp -text
|
||||
freeglut/freeglut/progs/demos/subwin/subwinStatic.dsp -text
|
||||
freeglut/freeglut/src/Common/freeglut_callbacks.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_cursor.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_display.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_ext.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_font.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_font_data.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_gamemode.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_geometry.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_init.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_input_devices.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_internal.h -text
|
||||
freeglut/freeglut/src/Common/freeglut_joystick.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_main.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_menu.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_misc.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_overlay.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_spaceball.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_state.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_stroke_mono_roman.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_stroke_roman.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_structure.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_teapot.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_teapot_data.h -text
|
||||
freeglut/freeglut/src/Common/freeglut_videoresize.c -text
|
||||
freeglut/freeglut/src/Common/freeglut_window.c -text
|
||||
freeglut/freeglut/src/Common/freeglutdll.def -text
|
||||
freeglut/freeglut/src/Common/freeglut_callbacks.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_cursor.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_display.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_ext.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_font.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_font_data.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_gamemode.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_geometry.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_init.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_input_devices.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_internal.h svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_joystick.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_main.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_menu.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_misc.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_overlay.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_spaceball.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_state.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_stroke_mono_roman.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_stroke_roman.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_structure.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_teapot.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_teapot_data.h svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_videoresize.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/Common/freeglut_window.c svn_keywords=Author+Date+Id+Revision
|
||||
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/mswin/freeglut_cursor_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_display_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_ext_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_gamemode_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_init_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_input_devices_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_internal_mswin.h -text
|
||||
freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_main_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_menu_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_spaceball_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_state_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_structure_mswin.c -text
|
||||
freeglut/freeglut/src/mswin/freeglut_window_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 svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_ext_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_gamemode_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_init_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_input_devices_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_internal_mswin.h svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_joystick_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_main_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_menu_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_spaceball_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_state_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/mswin/freeglut_structure_mswin.c svn_keywords=Author+Date+Id+Revision
|
||||
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/header_template svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_cursor_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_display_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_ext_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_gamemode_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_glutfont_definitions_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_init_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_input_devices_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_internal_x11.h -text
|
||||
freeglut/freeglut/src/x11/freeglut_joystick_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_main_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_menu_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_spaceball_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_state_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_structure_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_window_x11.c -text
|
||||
freeglut/freeglut/src/x11/freeglut_xinput_x11.c -text
|
||||
freeglut/freeglut/src/x11 svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_cursor_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_display_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_ext_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_gamemode_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_glutfont_definitions_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_init_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_input_devices_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_internal_x11.h svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_joystick_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_main_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_menu_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_spaceball_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_state_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
freeglut/freeglut/src/x11/freeglut_structure_x11.c svnc_svn_005fkeywords=Author+Date+Id+Revision
|
||||
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/docs/api.php svn_keywords=Author+Date+Id+Revision
|
||||
freeglut/web-src/docs/install.php svn_keywords=Author+Date+Id+Revision
|
||||
|
@ -1,194 +1,194 @@
|
||||
PROJECT(freeglut)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
SET(FREEGLUT_HEADERS
|
||||
include/GL/freeglut.h
|
||||
include/GL/freeglut_ext.h
|
||||
include/GL/freeglut_std.h
|
||||
include/GL/glut.h
|
||||
)
|
||||
SET(FREEGLUT_SRCS
|
||||
${FREEGLUT_HEADERS}
|
||||
src/Common/freeglut_callbacks.c
|
||||
src/Common/freeglut_cursor.c
|
||||
src/Common/freeglut_display.c
|
||||
src/Common/freeglut_ext.c
|
||||
src/Common/freeglut_font.c
|
||||
src/Common/freeglut_font_data.c
|
||||
src/Common/freeglut_gamemode.c
|
||||
src/Common/freeglut_geometry.c
|
||||
src/Common/freeglut_init.c
|
||||
src/Common/freeglut_internal.h
|
||||
src/Common/freeglut_input_devices.c
|
||||
src/Common/freeglut_joystick.c
|
||||
src/Common/freeglut_main.c
|
||||
src/Common/freeglut_menu.c
|
||||
src/Common/freeglut_misc.c
|
||||
src/Common/freeglut_overlay.c
|
||||
src/Common/freeglut_spaceball.c
|
||||
src/Common/freeglut_state.c
|
||||
src/Common/freeglut_stroke_mono_roman.c
|
||||
src/Common/freeglut_stroke_roman.c
|
||||
src/Common/freeglut_structure.c
|
||||
src/Common/freeglut_teapot.c
|
||||
src/Common/freeglut_videoresize.c
|
||||
src/Common/freeglut_window.c
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
LIST(APPEND FREEGLUT_SRCS
|
||||
src/mswin/freeglut_cursor_mswin.c
|
||||
src/mswin/freeglut_display_mswin.c
|
||||
src/mswin/freeglut_ext_mswin.c
|
||||
src/mswin/freeglut_gamemode_mswin.c
|
||||
src/mswin/freeglut_init_mswin.c
|
||||
src/mswin/freeglut_internal_mswin.h
|
||||
src/mswin/freeglut_input_devices_mswin.c
|
||||
src/mswin/freeglut_joystick_mswin.c
|
||||
src/mswin/freeglut_main_mswin.c
|
||||
src/mswin/freeglut_menu_mswin.c
|
||||
src/mswin/freeglut_spaceball_mswin.c
|
||||
src/mswin/freeglut_state_mswin.c
|
||||
src/mswin/freeglut_structure_mswin.c
|
||||
src/mswin/freeglut_window_mswin.c
|
||||
)
|
||||
ELSE()
|
||||
LIST(APPEND FREEGLUT_SRCS
|
||||
src/x11/freeglut_cursor_x11.c
|
||||
src/x11/freeglut_display_x11.c
|
||||
src/x11/freeglut_ext_x11.c
|
||||
src/x11/freeglut_gamemode_x11.c
|
||||
src/x11/freeglut_glutfont_definitions_x11.c
|
||||
src/x11/freeglut_init_x11.c
|
||||
src/x11/freeglut_internal_x11.h
|
||||
src/x11/freeglut_input_devices_x11.c
|
||||
src/x11/freeglut_joystick_x11.c
|
||||
src/x11/freeglut_main_x11.c
|
||||
src/x11/freeglut_menu_x11.c
|
||||
src/x11/freeglut_spaceball_x11.c
|
||||
src/x11/freeglut_state_x11.c
|
||||
src/x11/freeglut_structure_x11.c
|
||||
src/x11/freeglut_window_x11.c
|
||||
src/x11/freeglut_xinput_x11.c
|
||||
)
|
||||
|
||||
|
||||
ENDIF()
|
||||
|
||||
# Neatly organize all of the output files in the build directory
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
# 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.
|
||||
OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
|
||||
OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
|
||||
|
||||
FIND_PACKAGE(OpenGL REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
IF(WIN32)
|
||||
MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF()
|
||||
|
||||
if(UNIX)
|
||||
FIND_PACKAGE(X11 REQUIRED)
|
||||
LIST(APPEND LIBS ${X11_LIBRARIES})
|
||||
IF(X11_Xrandr_FOUND)
|
||||
SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE)
|
||||
LIST(APPEND LIBS ${X11_Xrandr_LIB})
|
||||
ENDIF()
|
||||
IF(X11_xf86vmode_FOUND)
|
||||
SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE)
|
||||
LIST(APPEND LIBS ${X11_xf86vmode_LIB})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
|
||||
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
||||
CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
|
||||
CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
|
||||
CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H)
|
||||
CHECK_INCLUDE_FILES(usbhid.h HAVE_USBHID_H)
|
||||
|
||||
# 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.
|
||||
# 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)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
|
||||
# by default, at least on UNIX, we want to build both
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_LIBRARY(freeglut SHARED ${FREEGLUT_SRCS})
|
||||
ENDIF()
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
ADD_LIBRARY(freeglut_static STATIC ${FREEGLUT_SRCS})
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(WIN32)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
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
|
||||
ADD_DEFINITIONS(-DFREEGLUT_EXPORTS)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DFREEGLUT_STATIC)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
# on UNIX we need to make sure:
|
||||
# - all shared libraries must have a soname/version
|
||||
# - 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
|
||||
# won't have to link them explicitly (they shouldn't have to know that we depend
|
||||
# on Xrandr or Xxf86vm)
|
||||
SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
|
||||
SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
|
||||
TARGET_LINK_LIBRARIES(freeglut ${LIBS})
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
INSTALL(TARGETS freeglut DESTINATION lib)
|
||||
ENDIF()
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
INSTALL(TARGETS freeglut_static DESTINATION lib)
|
||||
ENDIF()
|
||||
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
|
||||
|
||||
|
||||
|
||||
# Optionally build demos, on by default.
|
||||
option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
|
||||
|
||||
SET(DEMO_LIBS ${OPENGL_LIBRARY} ${LIBS})
|
||||
MACRO(ADD_DEMO name)
|
||||
if( FREEGLUT_BUILD_DEMOS )
|
||||
ADD_EXECUTABLE(${name} ${ARGN})
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static)
|
||||
ENDIF()
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c)
|
||||
ADD_DEMO(Fractals progs/demos/Fractals/fractals.c)
|
||||
ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c)
|
||||
ADD_DEMO(Lorenz progs/demos/Lorenz/lorenz.c)
|
||||
ADD_DEMO(One progs/demos/One/one.c)
|
||||
ADD_DEMO(Resizer progs/demos/Resizer/Resizer.cpp)
|
||||
ADD_DEMO(shapes progs/demos/shapes/shapes.c)
|
||||
ADD_DEMO(smooth_opengl3 progs/demos/smooth_opengl3/smooth_opengl3.c)
|
||||
ADD_DEMO(spaceball progs/demos/spaceball/spaceball.c
|
||||
progs/demos/spaceball/vmath.c
|
||||
progs/demos/spaceball/vmath.h)
|
||||
ADD_DEMO(subwin progs/demos/subwin/subwin.c)
|
||||
|
||||
|
||||
PROJECT(freeglut)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
SET(FREEGLUT_HEADERS
|
||||
include/GL/freeglut.h
|
||||
include/GL/freeglut_ext.h
|
||||
include/GL/freeglut_std.h
|
||||
include/GL/glut.h
|
||||
)
|
||||
SET(FREEGLUT_SRCS
|
||||
${FREEGLUT_HEADERS}
|
||||
src/Common/freeglut_callbacks.c
|
||||
src/Common/freeglut_cursor.c
|
||||
src/Common/freeglut_display.c
|
||||
src/Common/freeglut_ext.c
|
||||
src/Common/freeglut_font.c
|
||||
src/Common/freeglut_font_data.c
|
||||
src/Common/freeglut_gamemode.c
|
||||
src/Common/freeglut_geometry.c
|
||||
src/Common/freeglut_init.c
|
||||
src/Common/freeglut_internal.h
|
||||
src/Common/freeglut_input_devices.c
|
||||
src/Common/freeglut_joystick.c
|
||||
src/Common/freeglut_main.c
|
||||
src/Common/freeglut_menu.c
|
||||
src/Common/freeglut_misc.c
|
||||
src/Common/freeglut_overlay.c
|
||||
src/Common/freeglut_spaceball.c
|
||||
src/Common/freeglut_state.c
|
||||
src/Common/freeglut_stroke_mono_roman.c
|
||||
src/Common/freeglut_stroke_roman.c
|
||||
src/Common/freeglut_structure.c
|
||||
src/Common/freeglut_teapot.c
|
||||
src/Common/freeglut_videoresize.c
|
||||
src/Common/freeglut_window.c
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
LIST(APPEND FREEGLUT_SRCS
|
||||
src/mswin/freeglut_cursor_mswin.c
|
||||
src/mswin/freeglut_display_mswin.c
|
||||
src/mswin/freeglut_ext_mswin.c
|
||||
src/mswin/freeglut_gamemode_mswin.c
|
||||
src/mswin/freeglut_init_mswin.c
|
||||
src/mswin/freeglut_internal_mswin.h
|
||||
src/mswin/freeglut_input_devices_mswin.c
|
||||
src/mswin/freeglut_joystick_mswin.c
|
||||
src/mswin/freeglut_main_mswin.c
|
||||
src/mswin/freeglut_menu_mswin.c
|
||||
src/mswin/freeglut_spaceball_mswin.c
|
||||
src/mswin/freeglut_state_mswin.c
|
||||
src/mswin/freeglut_structure_mswin.c
|
||||
src/mswin/freeglut_window_mswin.c
|
||||
)
|
||||
ELSE()
|
||||
LIST(APPEND FREEGLUT_SRCS
|
||||
src/x11/freeglut_cursor_x11.c
|
||||
src/x11/freeglut_display_x11.c
|
||||
src/x11/freeglut_ext_x11.c
|
||||
src/x11/freeglut_gamemode_x11.c
|
||||
src/x11/freeglut_glutfont_definitions_x11.c
|
||||
src/x11/freeglut_init_x11.c
|
||||
src/x11/freeglut_internal_x11.h
|
||||
src/x11/freeglut_input_devices_x11.c
|
||||
src/x11/freeglut_joystick_x11.c
|
||||
src/x11/freeglut_main_x11.c
|
||||
src/x11/freeglut_menu_x11.c
|
||||
src/x11/freeglut_spaceball_x11.c
|
||||
src/x11/freeglut_state_x11.c
|
||||
src/x11/freeglut_structure_x11.c
|
||||
src/x11/freeglut_window_x11.c
|
||||
src/x11/freeglut_xinput_x11.c
|
||||
)
|
||||
|
||||
|
||||
ENDIF()
|
||||
|
||||
# Neatly organize all of the output files in the build directory
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
# 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.
|
||||
OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
|
||||
OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
|
||||
|
||||
FIND_PACKAGE(OpenGL REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
IF(WIN32)
|
||||
MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF()
|
||||
|
||||
if(UNIX)
|
||||
FIND_PACKAGE(X11 REQUIRED)
|
||||
LIST(APPEND LIBS ${X11_LIBRARIES})
|
||||
IF(X11_Xrandr_FOUND)
|
||||
SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE)
|
||||
LIST(APPEND LIBS ${X11_Xrandr_LIB})
|
||||
ENDIF()
|
||||
IF(X11_xf86vmode_FOUND)
|
||||
SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE)
|
||||
LIST(APPEND LIBS ${X11_xf86vmode_LIB})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
|
||||
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
||||
CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
|
||||
CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
|
||||
CHECK_INCLUDE_FILES(errno.h HAVE_ERRNO_H)
|
||||
CHECK_INCLUDE_FILES(usbhid.h HAVE_USBHID_H)
|
||||
|
||||
# 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.
|
||||
# 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)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
|
||||
# by default, at least on UNIX, we want to build both
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_LIBRARY(freeglut SHARED ${FREEGLUT_SRCS})
|
||||
ENDIF()
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
ADD_LIBRARY(freeglut_static STATIC ${FREEGLUT_SRCS})
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(WIN32)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
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
|
||||
ADD_DEFINITIONS(-DFREEGLUT_EXPORTS)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DFREEGLUT_STATIC)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
# on UNIX we need to make sure:
|
||||
# - all shared libraries must have a soname/version
|
||||
# - 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
|
||||
# won't have to link them explicitly (they shouldn't have to know that we depend
|
||||
# on Xrandr or Xxf86vm)
|
||||
SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
|
||||
SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
|
||||
TARGET_LINK_LIBRARIES(freeglut ${LIBS})
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
INSTALL(TARGETS freeglut DESTINATION lib)
|
||||
ENDIF()
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
INSTALL(TARGETS freeglut_static DESTINATION lib)
|
||||
ENDIF()
|
||||
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
|
||||
|
||||
|
||||
|
||||
# Optionally build demos, on by default.
|
||||
option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
|
||||
|
||||
SET(DEMO_LIBS ${OPENGL_LIBRARY} ${LIBS})
|
||||
MACRO(ADD_DEMO name)
|
||||
if( FREEGLUT_BUILD_DEMOS )
|
||||
ADD_EXECUTABLE(${name} ${ARGN})
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static)
|
||||
ENDIF()
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c)
|
||||
ADD_DEMO(Fractals progs/demos/Fractals/fractals.c)
|
||||
ADD_DEMO(Fractals_random progs/demos/Fractals_random/fractals_random.c)
|
||||
ADD_DEMO(Lorenz progs/demos/Lorenz/lorenz.c)
|
||||
ADD_DEMO(One progs/demos/One/one.c)
|
||||
ADD_DEMO(Resizer progs/demos/Resizer/Resizer.cpp)
|
||||
ADD_DEMO(shapes progs/demos/shapes/shapes.c)
|
||||
ADD_DEMO(smooth_opengl3 progs/demos/smooth_opengl3/smooth_opengl3.c)
|
||||
ADD_DEMO(spaceball progs/demos/spaceball/spaceball.c
|
||||
progs/demos/spaceball/vmath.c
|
||||
progs/demos/spaceball/vmath.h)
|
||||
ADD_DEMO(subwin progs/demos/subwin/subwin.c)
|
||||
|
||||
|
||||
|
@ -1,218 +1,218 @@
|
||||
Glut alors!
|
||||
|
||||
Par Jean-Seb le vendredi 10 juillet 2009, 00:18
|
||||
|
||||
|
||||
Freeglut est une évolution open-source de Glut.
|
||||
Sous Windows, on peut l'utiliser avec Cygwin.
|
||||
Facile ? Oui, si on accepte de distribuer "cygwin1.dll"
|
||||
Aidons Freeglut à conquérir son indépendance !
|
||||
m.à.j 10/7/2009 : génération d'une librairie pour linker depuis la dll.
|
||||
|
||||
|
||||
Récupération des sources
|
||||
|
||||
* Reprenez les sources de la version 2.6.0 qui intègre les changements
|
||||
récents.
|
||||
* Pour l'instant, il s'agit d'une RC (Release Candidate), mais la version
|
||||
finale ne saurait tarder.
|
||||
* L'utilisation de la 2.6 est préférable à la branche 2.4-stable, de
|
||||
nombreux bugs étant corrigés.
|
||||
* Vous trouverez les sources sur le site de Freeglut:
|
||||
o http://freeglut.sourceforge.net/
|
||||
|
||||
|
||||
Principe
|
||||
Objectif
|
||||
|
||||
* Nous allons créer une dll liée à Cygwin, et une bibliothèque statique
|
||||
indépendante
|
||||
* Nous créerons également une librairie dynamique, permettant de linker avec
|
||||
la dll.
|
||||
|
||||
Liste des fichiers générés
|
||||
|
||||
* freeglut.dll : une dll classique pour le linkage dynamique.
|
||||
* libfreeglut.a : la bibliothèque statique. Le programme final est autonome
|
||||
(du moins pour OpenGL).
|
||||
* libfreeglutdll.a : la bibliothèque dynamique. Le programme final a besoin
|
||||
de freeglut.dll.
|
||||
|
||||
|
||||
Préparation
|
||||
|
||||
* Dépliez l'archive freeglut.
|
||||
* Allez dans le répertoire src (situé à la racine du répertoire Freeglut),
|
||||
et créez un sous-répertoire "Gl"
|
||||
o Dans ce sous-répertoire, copiez les fichiers du répertoire
|
||||
"include/Gl"
|
||||
|
||||
* Pourquoi faut-il créer un répertoire "Gl" pour la compilation ?
|
||||
o C'était juste pour simplifier les choses lors de mes essais.
|
||||
o Sinon vous pouvez créer directement les répertoires, et copier les
|
||||
fichiers comme indiqué au point installation (lire plus loin).
|
||||
|
||||
* Faites un peu de ménage dans /lib :
|
||||
o Effacez toutes les références à la glut, pour ne pas avoir de
|
||||
conflit au linkage.
|
||||
o Cette étape est facultative, vous pouvez également choisir de ne
|
||||
faire le ménage qu' après une compilation réussie de Freeglut.
|
||||
o Attention à ne pas effacer, dans un enthousiasme rédempteur, la
|
||||
bibliothèque glu32.lib (à ne pas confondre avec glut32.lib).
|
||||
|
||||
|
||||
Compilation
|
||||
|
||||
* Oubliez le triptyque ./configure , make , make install.
|
||||
o Ca ne marche pas du tout avec Cygwin.
|
||||
|
||||
* Voici un Makefile qui fera l'affaire:
|
||||
|
||||
#Makefile pour Freeglut 2.6.0-rc et Cygwin
|
||||
#A placer dans le répertoire "src/Common"
|
||||
|
||||
sources=$(wildcard *.c)
|
||||
objs=$(sources:.c=.o)
|
||||
libname=freeglut
|
||||
|
||||
|
||||
CFLAGS=-O2 -DTARGET_HOST_MS_WINDOWS -DX_DISPLAY_MISSING -DFREEGLUT_STATIC -I./
|
||||
LDFLAGS=-lopengl32 -lgdi32 -lwinmm
|
||||
|
||||
nocyg=-mno-cygwin -mwindows
|
||||
|
||||
all: $(objs)
|
||||
#construction dll liée à cygwin1.dll
|
||||
gcc $(nocyg) $(objs) -shared $(LDFLAGS) -o $(libname).dll
|
||||
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
|
||||
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
|
||||
|
||||
#construction bibliothèque statique indépendante de cygwin
|
||||
ar cr lib$(libname).a $(objs)
|
||||
#pas forcément obligatoire (création d'un index pour accélérer les accès)
|
||||
ranlib lib$(libname).a
|
||||
|
||||
%.o: %.c
|
||||
gcc $(nocyg) -c $(CFLAGS) $<
|
||||
|
||||
clean:
|
||||
rm -f *.o $(libname).dll $(libname).def lib$(libname)dll.a lib$(libname).a
|
||||
|
||||
|
||||
|
||||
|
||||
Quelques remarques sur le makefile
|
||||
|
||||
* Ce makefile crée une dll, une bibliothèque statique (une archive, en
|
||||
d'autres termes) et la bibliothèque dynamique qui permettra l'utilisation
|
||||
de la dll.
|
||||
|
||||
* Ne cherchez pas à stripper la bibliothèque statique! Vous ne pourriez plus
|
||||
compiler en statique.
|
||||
o Par contre, vous pouvez stripper l'exécutable final obtenu lors de
|
||||
la compilation de votre application.
|
||||
|
||||
* J'ai choisi d'appeller la dll et les bibliothèques par leurs "vrais noms":
|
||||
freeglut.dll libfreeglutdll.a et libfreeglut.a.
|
||||
o Le script configure recréait (pour des raisons de compatibilité avec
|
||||
l'ancienne bibliothèque Glut) glut.dll et libglut.a.
|
||||
o Lors des mes essais, j'ai eu des conflits avec une authentique
|
||||
"glut" qui trainait dans mon "/lib". J'ai décidé d'appeller les
|
||||
choses par leur nom, afin d'éviter les confusions.
|
||||
o Rien ne vous empêche de renommer la dll, si vous avez besoin
|
||||
d'utiliser des programmes Glut que vous ne pouvez pas recompiler.
|
||||
|
||||
* La bibliothèque dynamique est générée à partir de la dll.
|
||||
o Par souci de concision, j'ai utilisé awk. Il génère le fichier
|
||||
d'exports utilisé par dlltool.
|
||||
o La seule chose notable est la sélection des fonctions dont le nom
|
||||
commence par _glut, afin d'éviter d'inclure dans la librairie
|
||||
dynamique des fonctions sans rapport avec freeglut.
|
||||
o ensuite, on utilise dlltool de façon très classique.
|
||||
|
||||
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
|
||||
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
* Copiez libfreeglut.a, libfreeglutdll.a dans le répertoire /lib de Cygwin.
|
||||
* Copiez freglut.dll dans le system32 de Windows (ce qui est pratique, mais
|
||||
pas propre!).
|
||||
* Copiez les fichiers headers de Freeglut (/include/gl) dans /usr/include/Gl
|
||||
de Cygwin.
|
||||
* Copiez les fichiers headers (toujours /include/gl) dans
|
||||
/usr/include/mingw/Gl : ceci sert aux compilations avec le flag
|
||||
-mno-cygwin, qui utilise alors les includes de mingw.
|
||||
o Vous aurez éventuellement besoin d'écraser d'anciens fichiers
|
||||
include, correspondants à Glut, si vous l'avez installé avec Cygwin.
|
||||
|
||||
|
||||
Utilisation de la librairie
|
||||
|
||||
* Nous allons tester avec le programme shapes, présent dans
|
||||
progs/demos/shapes
|
||||
o -mno-cygwin sert à forcer l'utilisation de Mingw sans la grosse
|
||||
dépendance cygwin1.dll.
|
||||
o -mwindows sert uniquement à enlever l'horrible fenêtre shell (très
|
||||
utile pour la mise au point, par contre).
|
||||
o -L. (notez le point après le "L") : j'ai laissé libfreeglut.a,
|
||||
libfreeglutdll.a et freeglut.dll dans le répertoire de test, le
|
||||
temps des tests justement.
|
||||
|
||||
|
||||
Compilation en librairie statique freeglut, sans cygwin
|
||||
|
||||
* Toute l'astuce réside dans le define : -DFREEGLUT_STATIC
|
||||
o Il sert à obtenir la bonne décoration des noms de fonctions dans les
|
||||
imports de la lib Freeglut.
|
||||
o Vous pouvez essayer sans et prendre un éditeur hexa pour voir les
|
||||
différences dans l'objet.
|
||||
* attention à l'ordre des bibliothèques : -lfreeglut (statique) doit se
|
||||
trouver avant la déclaration des bibliothèques dynamiques.
|
||||
|
||||
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin
|
||||
-mwindows -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation avec dll freeglut, sans cygwin
|
||||
|
||||
* Pour le define, même remarque que ci-dessus
|
||||
* L'ordre des bibliothèques n'a plus d'importance.
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin
|
||||
-DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation avec dll freeglut, avec Cygwin
|
||||
|
||||
* Cet exemple est donné uniquement pour référence, le thème de ce billet étant de se débarrasser de Cygwin.
|
||||
o Disons que ça peut servir pendant la mise au point (et encore).
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
|
||||
|
||||
|
||||
|
||||
Où sont les dooooocs ?
|
||||
|
||||
* Freeglut est livré avec sa documentation, plus très à jour.
|
||||
o Il semble qu'il y ait un problème avec la doc Glut originale. Non
|
||||
seulement elle ne correspond pas forcément au fonctionnement de
|
||||
Freeglut, mais de plus, son auteur (Mark Kilgard) l'a copyrighté. Sa
|
||||
distribution est donc difficile.
|
||||
|
||||
* Jocelyn Fréchot a entrepris une mise à niveau des docs pour la version
|
||||
2.6.0. On peut les trouver sur son site pour l'instant:
|
||||
o http://jocelyn.frechot.free.fr/freeglut/
|
||||
|
||||
|
||||
Quelque chose a survécu ...
|
||||
|
||||
* J'ai également testé la recompilation des démos de la lib Glut originelle
|
||||
(paix à ses cendres).
|
||||
o Rien de particulier à signaler.
|
||||
|
||||
* Merci à tous les mainteneurs courageux de Freeglut, qu'on croyait mort,
|
||||
mais qui bouge encore.
|
||||
Glut alors!
|
||||
|
||||
Par Jean-Seb le vendredi 10 juillet 2009, 00:18
|
||||
|
||||
|
||||
Freeglut est une évolution open-source de Glut.
|
||||
Sous Windows, on peut l'utiliser avec Cygwin.
|
||||
Facile ? Oui, si on accepte de distribuer "cygwin1.dll"
|
||||
Aidons Freeglut à conquérir son indépendance !
|
||||
m.à.j 10/7/2009 : génération d'une librairie pour linker depuis la dll.
|
||||
|
||||
|
||||
Récupération des sources
|
||||
|
||||
* Reprenez les sources de la version 2.6.0 qui intègre les changements
|
||||
récents.
|
||||
* Pour l'instant, il s'agit d'une RC (Release Candidate), mais la version
|
||||
finale ne saurait tarder.
|
||||
* L'utilisation de la 2.6 est préférable à la branche 2.4-stable, de
|
||||
nombreux bugs étant corrigés.
|
||||
* Vous trouverez les sources sur le site de Freeglut:
|
||||
o http://freeglut.sourceforge.net/
|
||||
|
||||
|
||||
Principe
|
||||
Objectif
|
||||
|
||||
* Nous allons créer une dll liée à Cygwin, et une bibliothèque statique
|
||||
indépendante
|
||||
* Nous créerons également une librairie dynamique, permettant de linker avec
|
||||
la dll.
|
||||
|
||||
Liste des fichiers générés
|
||||
|
||||
* freeglut.dll : une dll classique pour le linkage dynamique.
|
||||
* libfreeglut.a : la bibliothèque statique. Le programme final est autonome
|
||||
(du moins pour OpenGL).
|
||||
* libfreeglutdll.a : la bibliothèque dynamique. Le programme final a besoin
|
||||
de freeglut.dll.
|
||||
|
||||
|
||||
Préparation
|
||||
|
||||
* Dépliez l'archive freeglut.
|
||||
* Allez dans le répertoire src (situé à la racine du répertoire Freeglut),
|
||||
et créez un sous-répertoire "Gl"
|
||||
o Dans ce sous-répertoire, copiez les fichiers du répertoire
|
||||
"include/Gl"
|
||||
|
||||
* Pourquoi faut-il créer un répertoire "Gl" pour la compilation ?
|
||||
o C'était juste pour simplifier les choses lors de mes essais.
|
||||
o Sinon vous pouvez créer directement les répertoires, et copier les
|
||||
fichiers comme indiqué au point installation (lire plus loin).
|
||||
|
||||
* Faites un peu de ménage dans /lib :
|
||||
o Effacez toutes les références à la glut, pour ne pas avoir de
|
||||
conflit au linkage.
|
||||
o Cette étape est facultative, vous pouvez également choisir de ne
|
||||
faire le ménage qu' après une compilation réussie de Freeglut.
|
||||
o Attention à ne pas effacer, dans un enthousiasme rédempteur, la
|
||||
bibliothèque glu32.lib (à ne pas confondre avec glut32.lib).
|
||||
|
||||
|
||||
Compilation
|
||||
|
||||
* Oubliez le triptyque ./configure , make , make install.
|
||||
o Ca ne marche pas du tout avec Cygwin.
|
||||
|
||||
* Voici un Makefile qui fera l'affaire:
|
||||
|
||||
#Makefile pour Freeglut 2.6.0-rc et Cygwin
|
||||
#A placer dans le répertoire "src/Common"
|
||||
|
||||
sources=$(wildcard *.c)
|
||||
objs=$(sources:.c=.o)
|
||||
libname=freeglut
|
||||
|
||||
|
||||
CFLAGS=-O2 -DTARGET_HOST_MS_WINDOWS -DX_DISPLAY_MISSING -DFREEGLUT_STATIC -I./
|
||||
LDFLAGS=-lopengl32 -lgdi32 -lwinmm
|
||||
|
||||
nocyg=-mno-cygwin -mwindows
|
||||
|
||||
all: $(objs)
|
||||
#construction dll liée à cygwin1.dll
|
||||
gcc $(nocyg) $(objs) -shared $(LDFLAGS) -o $(libname).dll
|
||||
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
|
||||
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
|
||||
|
||||
#construction bibliothèque statique indépendante de cygwin
|
||||
ar cr lib$(libname).a $(objs)
|
||||
#pas forcément obligatoire (création d'un index pour accélérer les accès)
|
||||
ranlib lib$(libname).a
|
||||
|
||||
%.o: %.c
|
||||
gcc $(nocyg) -c $(CFLAGS) $<
|
||||
|
||||
clean:
|
||||
rm -f *.o $(libname).dll $(libname).def lib$(libname)dll.a lib$(libname).a
|
||||
|
||||
|
||||
|
||||
|
||||
Quelques remarques sur le makefile
|
||||
|
||||
* Ce makefile crée une dll, une bibliothèque statique (une archive, en
|
||||
d'autres termes) et la bibliothèque dynamique qui permettra l'utilisation
|
||||
de la dll.
|
||||
|
||||
* Ne cherchez pas à stripper la bibliothèque statique! Vous ne pourriez plus
|
||||
compiler en statique.
|
||||
o Par contre, vous pouvez stripper l'exécutable final obtenu lors de
|
||||
la compilation de votre application.
|
||||
|
||||
* J'ai choisi d'appeller la dll et les bibliothèques par leurs "vrais noms":
|
||||
freeglut.dll libfreeglutdll.a et libfreeglut.a.
|
||||
o Le script configure recréait (pour des raisons de compatibilité avec
|
||||
l'ancienne bibliothèque Glut) glut.dll et libglut.a.
|
||||
o Lors des mes essais, j'ai eu des conflits avec une authentique
|
||||
"glut" qui trainait dans mon "/lib". J'ai décidé d'appeller les
|
||||
choses par leur nom, afin d'éviter les confusions.
|
||||
o Rien ne vous empêche de renommer la dll, si vous avez besoin
|
||||
d'utiliser des programmes Glut que vous ne pouvez pas recompiler.
|
||||
|
||||
* La bibliothèque dynamique est générée à partir de la dll.
|
||||
o Par souci de concision, j'ai utilisé awk. Il génère le fichier
|
||||
d'exports utilisé par dlltool.
|
||||
o La seule chose notable est la sélection des fonctions dont le nom
|
||||
commence par _glut, afin d'éviter d'inclure dans la librairie
|
||||
dynamique des fonctions sans rapport avec freeglut.
|
||||
o ensuite, on utilise dlltool de façon très classique.
|
||||
|
||||
nm $(libname).dll | awk 'BEGIN { print "EXPORTS" } /T _glut/ {sub( /^.*T _/, "\t"); print}' > $(libname).def
|
||||
dlltool --dllname $(libname).dll --input-def $(libname).def --output-lib lib$(libname)dll.a
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
* Copiez libfreeglut.a, libfreeglutdll.a dans le répertoire /lib de Cygwin.
|
||||
* Copiez freglut.dll dans le system32 de Windows (ce qui est pratique, mais
|
||||
pas propre!).
|
||||
* Copiez les fichiers headers de Freeglut (/include/gl) dans /usr/include/Gl
|
||||
de Cygwin.
|
||||
* Copiez les fichiers headers (toujours /include/gl) dans
|
||||
/usr/include/mingw/Gl : ceci sert aux compilations avec le flag
|
||||
-mno-cygwin, qui utilise alors les includes de mingw.
|
||||
o Vous aurez éventuellement besoin d'écraser d'anciens fichiers
|
||||
include, correspondants à Glut, si vous l'avez installé avec Cygwin.
|
||||
|
||||
|
||||
Utilisation de la librairie
|
||||
|
||||
* Nous allons tester avec le programme shapes, présent dans
|
||||
progs/demos/shapes
|
||||
o -mno-cygwin sert à forcer l'utilisation de Mingw sans la grosse
|
||||
dépendance cygwin1.dll.
|
||||
o -mwindows sert uniquement à enlever l'horrible fenêtre shell (très
|
||||
utile pour la mise au point, par contre).
|
||||
o -L. (notez le point après le "L") : j'ai laissé libfreeglut.a,
|
||||
libfreeglutdll.a et freeglut.dll dans le répertoire de test, le
|
||||
temps des tests justement.
|
||||
|
||||
|
||||
Compilation en librairie statique freeglut, sans cygwin
|
||||
|
||||
* Toute l'astuce réside dans le define : -DFREEGLUT_STATIC
|
||||
o Il sert à obtenir la bonne décoration des noms de fonctions dans les
|
||||
imports de la lib Freeglut.
|
||||
o Vous pouvez essayer sans et prendre un éditeur hexa pour voir les
|
||||
différences dans l'objet.
|
||||
* attention à l'ordre des bibliothèques : -lfreeglut (statique) doit se
|
||||
trouver avant la déclaration des bibliothèques dynamiques.
|
||||
|
||||
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin
|
||||
-mwindows -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation avec dll freeglut, sans cygwin
|
||||
|
||||
* Pour le define, même remarque que ci-dessus
|
||||
* L'ordre des bibliothèques n'a plus d'importance.
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin
|
||||
-DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation avec dll freeglut, avec Cygwin
|
||||
|
||||
* Cet exemple est donné uniquement pour référence, le thème de ce billet étant de se débarrasser de Cygwin.
|
||||
o Disons que ça peut servir pendant la mise au point (et encore).
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
|
||||
|
||||
|
||||
|
||||
Où sont les dooooocs ?
|
||||
|
||||
* Freeglut est livré avec sa documentation, plus très à jour.
|
||||
o Il semble qu'il y ait un problème avec la doc Glut originale. Non
|
||||
seulement elle ne correspond pas forcément au fonctionnement de
|
||||
Freeglut, mais de plus, son auteur (Mark Kilgard) l'a copyrighté. Sa
|
||||
distribution est donc difficile.
|
||||
|
||||
* Jocelyn Fréchot a entrepris une mise à niveau des docs pour la version
|
||||
2.6.0. On peut les trouver sur son site pour l'instant:
|
||||
o http://jocelyn.frechot.free.fr/freeglut/
|
||||
|
||||
|
||||
Quelque chose a survécu ...
|
||||
|
||||
* J'ai également testé la recompilation des démos de la lib Glut originelle
|
||||
(paix à ses cendres).
|
||||
o Rien de particulier à signaler.
|
||||
|
||||
* Merci à tous les mainteneurs courageux de Freeglut, qu'on croyait mort,
|
||||
mais qui bouge encore.
|
||||
|
0
freeglut/freeglut/LISEZ_MOI
Executable file → Normal file
0
freeglut/freeglut/LISEZ_MOI
Executable file → Normal file
@ -1,210 +1,210 @@
|
||||
#
|
||||
# Makefile.wat
|
||||
# Open Watcom makefile for Freeglut
|
||||
# Usage:
|
||||
# wmake -f Makefile.wat {target}
|
||||
# Where target is one of:
|
||||
# debug-static
|
||||
# debug-dynamic
|
||||
# release-static
|
||||
# release-dynamic
|
||||
# debug
|
||||
# release
|
||||
# all
|
||||
# clean
|
||||
# Assumes:
|
||||
# WATCOM enviroment variable points to your Watcom installation directory
|
||||
# %WATCOM%\BINNT and %WATCOM%\BINW are in your path
|
||||
#
|
||||
RELEASE_STATIC_DIR = release-static
|
||||
RELEASE_DYNAMIC_DIR = release-dynamic
|
||||
DEBUG_STATIC_DIR = debug-static
|
||||
DEBUG_DYNAMIC_DIR = debug-dynamic
|
||||
|
||||
INCLUDE_DIR = ..\include
|
||||
SRC_DIR = ..\src\Common
|
||||
COMPILER = wcc386
|
||||
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_RELEASE_OPTIONS = -d0 -otexanh
|
||||
COMPILE_STATIC_OPTIONS = -DFREEGLUT_STATIC -6r
|
||||
COMPILE_DYNAMIC_OPTIONS = -DFREEGLUT_EXPORTS -6s -bd -bm
|
||||
COMPILE_OPTIONS = $(COMPILE_COMMON_OPTIONS) $(COMPILE_$(MODE)_OPTIONS) $(COMPILE_$(TYPE)_OPTIONS)
|
||||
|
||||
LINKER = wlink
|
||||
LINK_OPTIONS = SYS nt_dll op m op maxe=25 op q op symf FIL
|
||||
|
||||
LIB_TOOL = wlib
|
||||
LIB_COMMON_OPTIONS = -q -n -b
|
||||
LIB_DYNAMIC_OPTIONS =
|
||||
LIB_STATIC_OPTIONS = -c -p=512
|
||||
LIB_OPTIONS = $(LIB_COMMON_OPTIONS) $(LIB_$(TYPE)_OPTIONS)
|
||||
|
||||
MAKE = wmake -h -f ..\Makefile.wat
|
||||
|
||||
OBJ_FILES = &
|
||||
freeglut_callbacks.obj &
|
||||
freeglut_cursor.obj &
|
||||
freeglut_display.obj &
|
||||
freeglut_ext.obj &
|
||||
freeglut_font.obj &
|
||||
freeglut_font_data.obj &
|
||||
freeglut_gamemode.obj &
|
||||
freeglut_geometry.obj &
|
||||
freeglut_glutfont_definitions.obj &
|
||||
freeglut_init.obj &
|
||||
freeglut_input_devices.obj &
|
||||
freeglut_joystick.obj &
|
||||
freeglut_main.obj &
|
||||
freeglut_menu.obj &
|
||||
freeglut_misc.obj &
|
||||
freeglut_overlay.obj &
|
||||
freeglut_spaceball.obj &
|
||||
freeglut_state.obj &
|
||||
freeglut_stroke_mono_roman.obj &
|
||||
freeglut_stroke_roman.obj &
|
||||
freeglut_structure.obj &
|
||||
freeglut_teapot.obj &
|
||||
freeglut_videoresize.obj &
|
||||
freeglut_window.obj
|
||||
|
||||
default : .SYMBOLIC
|
||||
@echo Usage:
|
||||
@echo wmake -f Makefile.wat {target}
|
||||
@echo Where target is one of:
|
||||
@echo debug-static
|
||||
@echo debug-dynamic
|
||||
@echo release-static
|
||||
@echo release-dynamic
|
||||
@echo debug
|
||||
@echo release
|
||||
@echo all
|
||||
@echo clean
|
||||
|
||||
# static library
|
||||
freeglut_static.lib : $(OBJ_FILES)
|
||||
$(LIB_TOOL) $(LIB_OPTIONS) $^* $(OBJ_FILES)
|
||||
|
||||
# dynamic link library
|
||||
freeglut.dll : $(OBJ_FILES)
|
||||
$(LINKER) name $^* $(LINK_OPTIONS) $(OBJ_FILES: =,)
|
||||
|
||||
freeglut.lib : freeglut.dll
|
||||
$(LIB_TOOL) $(LIB_OPTIONS) $^. +$[.
|
||||
|
||||
|
||||
freeglut_callbacks.obj : $(SRC_DIR)\freeglut_callbacks.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_cursor.obj : $(SRC_DIR)\freeglut_cursor.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_display.obj : $(SRC_DIR)\freeglut_display.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_ext.obj : $(SRC_DIR)\freeglut_ext.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_font.obj : $(SRC_DIR)\freeglut_font.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_font_data.obj : $(SRC_DIR)\freeglut_font_data.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_gamemode.obj : $(SRC_DIR)\freeglut_gamemode.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_geometry.obj : $(SRC_DIR)\freeglut_geometry.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_glutfont_definitions.obj : $(SRC_DIR)\freeglut_glutfont_definitions.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_init.obj : $(SRC_DIR)\freeglut_init.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_input_devices.obj : $(SRC_DIR)\freeglut_input_devices.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_joystick.obj : $(SRC_DIR)\freeglut_joystick.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_main.obj : $(SRC_DIR)\freeglut_main.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_menu.obj : $(SRC_DIR)\freeglut_menu.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_misc.obj : $(SRC_DIR)\freeglut_misc.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_overlay.obj : $(SRC_DIR)\freeglut_overlay.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_spaceball.obj : $(SRC_DIR)\freeglut_spaceball.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_state.obj : $(SRC_DIR)\freeglut_state.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_stroke_mono_roman.obj : $(SRC_DIR)\freeglut_stroke_mono_roman.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_stroke_roman.obj : $(SRC_DIR)\freeglut_stroke_roman.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_structure.obj : $(SRC_DIR)\freeglut_structure.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_teapot.obj : $(SRC_DIR)\freeglut_teapot.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_videoresize.obj : $(SRC_DIR)\freeglut_videoresize.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_window.obj : $(SRC_DIR)\freeglut_window.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
clean : .SYMBOLIC
|
||||
@-del $(DEBUG_STATIC_DIR)\*.obj
|
||||
@-del $(DEBUG_DYNAMIC_DIR)\*.obj
|
||||
@-del $(RELEASE_STATIC_DIR)\*.obj
|
||||
@-del $(RELEASE_DYNAMIC_DIR)\*.obj
|
||||
@echo All object files removed
|
||||
|
||||
debug-static : .SYMBOLIC
|
||||
@-if not exist $(DEBUG_STATIC_DIR)\. mkdir $(DEBUG_STATIC_DIR)
|
||||
@-cd $(DEBUG_STATIC_DIR)
|
||||
@$(MAKE) MODE=DEBUG TYPE=STATIC freeglut_static.lib
|
||||
@-cd ..
|
||||
@echo Debug static library up to date
|
||||
|
||||
debug-dynamic : .SYMBOLIC
|
||||
@-if not exist $(DEBUG_DYNAMIC_DIR)\. mkdir $(DEBUG_DYNAMIC_DIR)
|
||||
@-cd $(DEBUG_DYNAMIC_DIR)
|
||||
@$(MAKE) MODE=DEBUG TYPE=DYNAMIC freeglut.lib
|
||||
@-cd ..
|
||||
@echo Debug dynamic link library up to date
|
||||
|
||||
release-static : .SYMBOLIC
|
||||
@-if not exist $(RELEASE_STATIC_DIR)\. mkdir $(RELEASE_STATIC_DIR)
|
||||
@-cd $(RELEASE_STATIC_DIR)
|
||||
@$(MAKE) MODE=RELEASE TYPE=STATIC freeglut_static.lib
|
||||
@-cd ..
|
||||
@echo Release static library up to date
|
||||
|
||||
release-dynamic : .SYMBOLIC
|
||||
@-if not exist $(RELEASE_DYNAMIC_DIR)\. mkdir $(RELEASE_DYNAMIC_DIR)
|
||||
@-cd $(RELEASE_DYNAMIC_DIR)
|
||||
@$(MAKE) MODE=RELEASE TYPE=DYNAMIC freeglut.lib
|
||||
@-cd ..
|
||||
@echo Release dynamic link library up to date
|
||||
|
||||
debug : debug-static debug-dynamic .SYMBOLIC
|
||||
@echo Debug targets up to date
|
||||
|
||||
release : release-static release-dynamic .SYMBOLIC
|
||||
@echo Release targets up to date
|
||||
|
||||
all : debug release .SYMBOLIC
|
||||
@echo All targets up to date
|
||||
#
|
||||
# Makefile.wat
|
||||
# Open Watcom makefile for Freeglut
|
||||
# Usage:
|
||||
# wmake -f Makefile.wat {target}
|
||||
# Where target is one of:
|
||||
# debug-static
|
||||
# debug-dynamic
|
||||
# release-static
|
||||
# release-dynamic
|
||||
# debug
|
||||
# release
|
||||
# all
|
||||
# clean
|
||||
# Assumes:
|
||||
# WATCOM enviroment variable points to your Watcom installation directory
|
||||
# %WATCOM%\BINNT and %WATCOM%\BINW are in your path
|
||||
#
|
||||
RELEASE_STATIC_DIR = release-static
|
||||
RELEASE_DYNAMIC_DIR = release-dynamic
|
||||
DEBUG_STATIC_DIR = debug-static
|
||||
DEBUG_DYNAMIC_DIR = debug-dynamic
|
||||
|
||||
INCLUDE_DIR = ..\include
|
||||
SRC_DIR = ..\src\Common
|
||||
COMPILER = wcc386
|
||||
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_RELEASE_OPTIONS = -d0 -otexanh
|
||||
COMPILE_STATIC_OPTIONS = -DFREEGLUT_STATIC -6r
|
||||
COMPILE_DYNAMIC_OPTIONS = -DFREEGLUT_EXPORTS -6s -bd -bm
|
||||
COMPILE_OPTIONS = $(COMPILE_COMMON_OPTIONS) $(COMPILE_$(MODE)_OPTIONS) $(COMPILE_$(TYPE)_OPTIONS)
|
||||
|
||||
LINKER = wlink
|
||||
LINK_OPTIONS = SYS nt_dll op m op maxe=25 op q op symf FIL
|
||||
|
||||
LIB_TOOL = wlib
|
||||
LIB_COMMON_OPTIONS = -q -n -b
|
||||
LIB_DYNAMIC_OPTIONS =
|
||||
LIB_STATIC_OPTIONS = -c -p=512
|
||||
LIB_OPTIONS = $(LIB_COMMON_OPTIONS) $(LIB_$(TYPE)_OPTIONS)
|
||||
|
||||
MAKE = wmake -h -f ..\Makefile.wat
|
||||
|
||||
OBJ_FILES = &
|
||||
freeglut_callbacks.obj &
|
||||
freeglut_cursor.obj &
|
||||
freeglut_display.obj &
|
||||
freeglut_ext.obj &
|
||||
freeglut_font.obj &
|
||||
freeglut_font_data.obj &
|
||||
freeglut_gamemode.obj &
|
||||
freeglut_geometry.obj &
|
||||
freeglut_glutfont_definitions.obj &
|
||||
freeglut_init.obj &
|
||||
freeglut_input_devices.obj &
|
||||
freeglut_joystick.obj &
|
||||
freeglut_main.obj &
|
||||
freeglut_menu.obj &
|
||||
freeglut_misc.obj &
|
||||
freeglut_overlay.obj &
|
||||
freeglut_spaceball.obj &
|
||||
freeglut_state.obj &
|
||||
freeglut_stroke_mono_roman.obj &
|
||||
freeglut_stroke_roman.obj &
|
||||
freeglut_structure.obj &
|
||||
freeglut_teapot.obj &
|
||||
freeglut_videoresize.obj &
|
||||
freeglut_window.obj
|
||||
|
||||
default : .SYMBOLIC
|
||||
@echo Usage:
|
||||
@echo wmake -f Makefile.wat {target}
|
||||
@echo Where target is one of:
|
||||
@echo debug-static
|
||||
@echo debug-dynamic
|
||||
@echo release-static
|
||||
@echo release-dynamic
|
||||
@echo debug
|
||||
@echo release
|
||||
@echo all
|
||||
@echo clean
|
||||
|
||||
# static library
|
||||
freeglut_static.lib : $(OBJ_FILES)
|
||||
$(LIB_TOOL) $(LIB_OPTIONS) $^* $(OBJ_FILES)
|
||||
|
||||
# dynamic link library
|
||||
freeglut.dll : $(OBJ_FILES)
|
||||
$(LINKER) name $^* $(LINK_OPTIONS) $(OBJ_FILES: =,)
|
||||
|
||||
freeglut.lib : freeglut.dll
|
||||
$(LIB_TOOL) $(LIB_OPTIONS) $^. +$[.
|
||||
|
||||
|
||||
freeglut_callbacks.obj : $(SRC_DIR)\freeglut_callbacks.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_cursor.obj : $(SRC_DIR)\freeglut_cursor.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_display.obj : $(SRC_DIR)\freeglut_display.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_ext.obj : $(SRC_DIR)\freeglut_ext.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_font.obj : $(SRC_DIR)\freeglut_font.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_font_data.obj : $(SRC_DIR)\freeglut_font_data.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_gamemode.obj : $(SRC_DIR)\freeglut_gamemode.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_geometry.obj : $(SRC_DIR)\freeglut_geometry.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_glutfont_definitions.obj : $(SRC_DIR)\freeglut_glutfont_definitions.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_init.obj : $(SRC_DIR)\freeglut_init.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_input_devices.obj : $(SRC_DIR)\freeglut_input_devices.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_joystick.obj : $(SRC_DIR)\freeglut_joystick.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_main.obj : $(SRC_DIR)\freeglut_main.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_menu.obj : $(SRC_DIR)\freeglut_menu.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_misc.obj : $(SRC_DIR)\freeglut_misc.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_overlay.obj : $(SRC_DIR)\freeglut_overlay.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_spaceball.obj : $(SRC_DIR)\freeglut_spaceball.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_state.obj : $(SRC_DIR)\freeglut_state.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_stroke_mono_roman.obj : $(SRC_DIR)\freeglut_stroke_mono_roman.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_stroke_roman.obj : $(SRC_DIR)\freeglut_stroke_roman.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_structure.obj : $(SRC_DIR)\freeglut_structure.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_teapot.obj : $(SRC_DIR)\freeglut_teapot.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_videoresize.obj : $(SRC_DIR)\freeglut_videoresize.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
freeglut_window.obj : $(SRC_DIR)\freeglut_window.c
|
||||
$(COMPILER) $(SRC_DIR)\$[. $(COMPILE_OPTIONS)
|
||||
|
||||
clean : .SYMBOLIC
|
||||
@-del $(DEBUG_STATIC_DIR)\*.obj
|
||||
@-del $(DEBUG_DYNAMIC_DIR)\*.obj
|
||||
@-del $(RELEASE_STATIC_DIR)\*.obj
|
||||
@-del $(RELEASE_DYNAMIC_DIR)\*.obj
|
||||
@echo All object files removed
|
||||
|
||||
debug-static : .SYMBOLIC
|
||||
@-if not exist $(DEBUG_STATIC_DIR)\. mkdir $(DEBUG_STATIC_DIR)
|
||||
@-cd $(DEBUG_STATIC_DIR)
|
||||
@$(MAKE) MODE=DEBUG TYPE=STATIC freeglut_static.lib
|
||||
@-cd ..
|
||||
@echo Debug static library up to date
|
||||
|
||||
debug-dynamic : .SYMBOLIC
|
||||
@-if not exist $(DEBUG_DYNAMIC_DIR)\. mkdir $(DEBUG_DYNAMIC_DIR)
|
||||
@-cd $(DEBUG_DYNAMIC_DIR)
|
||||
@$(MAKE) MODE=DEBUG TYPE=DYNAMIC freeglut.lib
|
||||
@-cd ..
|
||||
@echo Debug dynamic link library up to date
|
||||
|
||||
release-static : .SYMBOLIC
|
||||
@-if not exist $(RELEASE_STATIC_DIR)\. mkdir $(RELEASE_STATIC_DIR)
|
||||
@-cd $(RELEASE_STATIC_DIR)
|
||||
@$(MAKE) MODE=RELEASE TYPE=STATIC freeglut_static.lib
|
||||
@-cd ..
|
||||
@echo Release static library up to date
|
||||
|
||||
release-dynamic : .SYMBOLIC
|
||||
@-if not exist $(RELEASE_DYNAMIC_DIR)\. mkdir $(RELEASE_DYNAMIC_DIR)
|
||||
@-cd $(RELEASE_DYNAMIC_DIR)
|
||||
@$(MAKE) MODE=RELEASE TYPE=DYNAMIC freeglut.lib
|
||||
@-cd ..
|
||||
@echo Release dynamic link library up to date
|
||||
|
||||
debug : debug-static debug-dynamic .SYMBOLIC
|
||||
@echo Debug targets up to date
|
||||
|
||||
release : release-static release-dynamic .SYMBOLIC
|
||||
@echo Release targets up to date
|
||||
|
||||
all : debug release .SYMBOLIC
|
||||
@echo All targets up to date
|
||||
|
@ -1,212 +1,212 @@
|
||||
Glut then!
|
||||
|
||||
By Jean-Seb on Friday July 10, 2009, 00:18
|
||||
Translated by Babelfish with a scrub from John F. Fay. For points of confusion
|
||||
please refer to the original French version.
|
||||
|
||||
Freeglut is an open-source evolution of GLUT.
|
||||
Under Windows, one can use it with Cygwin.
|
||||
Easy? Yes, if one agrees to distribute "cygwin1.dll".
|
||||
Let us help freeglut gain its independence !
|
||||
m.à.j 10/7/2009: generation of a library for linking without the DLL.
|
||||
|
||||
|
||||
Recovery of the sources
|
||||
|
||||
* 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
|
||||
should not delay.
|
||||
* The use of the 2.6 is preferable with the 2.4-stable branch because many
|
||||
bugs have been corrected.
|
||||
* You will find the sources on the site of Freeglut:
|
||||
o http://freeglut.sourceforge.net/
|
||||
|
||||
|
||||
Objectives and preparation
|
||||
Objectives
|
||||
|
||||
* 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.
|
||||
|
||||
|
||||
List of generated files
|
||||
|
||||
* freeglut.dll: a traditional DLL for the dynamic linkage.
|
||||
* libfreeglut.a: the static library. The final program is autonomous (at
|
||||
least for OpenGL).
|
||||
* libfreeglutdll.a: the dynamic library. The final program needs
|
||||
freeglut.dll.
|
||||
|
||||
|
||||
Preparation
|
||||
|
||||
* Extract the files from the freeglut archive.
|
||||
* Go in the directory src (located at the root of the Freeglut directory),
|
||||
and create a "Gl" sub-directory
|
||||
o In this sub-directory, copy the files of the directory "include/Gl"
|
||||
|
||||
* Why is it necessary to create a "Gl" directory for compilation?
|
||||
o I needed it to simplify things during my tests.
|
||||
o If not you can create the repertories directly, and copy the files
|
||||
as indicated in the point installation (see below).
|
||||
|
||||
* Do a little housekeeping in /lib:
|
||||
o Erase all the references to the glut, so as not to conflict with the
|
||||
linking.
|
||||
o This stage is optional, you can also choose to do the housekeeping
|
||||
only after a successful compilation of Freeglut.
|
||||
o In your enthusiasm to clean things up, be careful not to erase the
|
||||
library glu32.lib (not to be confused with glut32.lib).
|
||||
|
||||
|
||||
Compilation
|
||||
|
||||
* Forget the "./configure, make, make install" triptych.
|
||||
o It does not go at all with Cygwin.
|
||||
|
||||
* Here Makefile which will make the deal:
|
||||
|
||||
#Makefile for Freeglut 2.6.0-rc and Cygwin
|
||||
#To place in the directory “src/Common”
|
||||
|
||||
sources=$ (wildcard *.c)
|
||||
objs=$ (sources: .c=.o)
|
||||
libname=freeglut
|
||||
|
||||
|
||||
CFLAGS=-O2 - DTARGET_HOST_MS_WINDOWS - DX_DISPLAY_MISSING - DFREEGLUT_STATIC - I./
|
||||
LDFLAGS=-lopengl32 - lgdi32 - lwinmm
|
||||
|
||||
nocyg=-mno-cygwin - mwindows
|
||||
|
||||
all: $ (objs)
|
||||
#construction DLL related to cygwin1.dll
|
||||
GCC $ (nocyg) $ (objs) - shared $ (LDFLAGS) - O $ (libname) .dll
|
||||
Nm $ (libname) .dll | awk “BEGIN {print “EXPORTS”} /T _glut/{sub (/^.*T _/,” \ T "); print}” > $ (libname) .def
|
||||
dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
|
||||
|
||||
#construction static library independent of cygwin
|
||||
rear Cr lib$ (libname) .a $ (objs)
|
||||
#pas inevitably obligatory (creation of an index to accelerate the accesses)
|
||||
ranlib lib$ (libname) .a
|
||||
|
||||
%.o: %.c
|
||||
GCC $ (nocyg) - C $ (CFLAGS) $<
|
||||
|
||||
clean:
|
||||
rm - F *.o $ (libname) .dll $ (libname) .def lib$ (libname) dll.a lib$ (libname) .a
|
||||
|
||||
|
||||
|
||||
|
||||
Some remarks on the makefile
|
||||
|
||||
* 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.
|
||||
|
||||
* Do not try to strip the static library! You may not be able to compile
|
||||
applications with static library any more.
|
||||
o On the other hand, you can strip the final executable obtained after
|
||||
compiling your application.
|
||||
|
||||
* I chose to call the DLL and the libraries by their "true names":
|
||||
freeglut.dll libfreeglutdll.a and libfreeglut.a.
|
||||
o Script configures recreated (for reasons of compatibility with the
|
||||
old GLUT library) glut.dll and libglut.a.
|
||||
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
|
||||
order to avoid confusions.
|
||||
o Nothing prevents you from renaming the DLL, if you need to use GLUT
|
||||
programs which you cannot recompile.
|
||||
|
||||
* The dynamic library is generated starting from the DLL.
|
||||
o For reasons of brevity, I used awk. It generates the export file
|
||||
used by dlltool.
|
||||
o The only notable thing is the selection of the functions whose name
|
||||
starts with _glut, in order to avoid including in the dynamic
|
||||
library the functions that are not related to freeglut.
|
||||
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
|
||||
dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
* Copy libfreeglut.a, libfreeglutdll.a into the Cygwin directory /lib.
|
||||
* Copy freglut.dll in the system32 of Windows (this is practical, but not
|
||||
clean!).
|
||||
* Copy the files headers of Freeglut (/include/gl) into the Cygwin directory
|
||||
/usr/include/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
|
||||
includes in mingw.
|
||||
o You may need to erase the old GLUT include files if you installed it
|
||||
with Cygwin.
|
||||
|
||||
|
||||
Use of the library
|
||||
|
||||
* 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
|
||||
dependence cygwin1.dll.
|
||||
o -mwindows is only used to remove the horrible Shell window (very
|
||||
useful for the settling, on the other hand).
|
||||
o -L. (note the period after the "L"): I left libfreeglut.a,
|
||||
libfreeglutdll.a and freeglut.dll in the test directory, at the time
|
||||
of the tests.
|
||||
|
||||
|
||||
Compilation of the static freeglut library, without cygwin
|
||||
|
||||
* All the simplicity lies in the define: -DFREEGLUT_STATIC
|
||||
o It serves to obtain good decoration of the function names in the
|
||||
imports of the lib Freeglut.
|
||||
o You can test without and use a hex editor to see the differences
|
||||
in the objects.
|
||||
* attention with the order of the libraries: -lfreeglut (static) must be
|
||||
before the declaration of the dynamic libraries.
|
||||
|
||||
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin -mwindows -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation with DLL freeglut, without cygwin
|
||||
|
||||
* For the define, see the notices above
|
||||
* The order of the libraries is no longer important.
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation with DLL freeglut, Cygwin
|
||||
|
||||
* This example is given only for reference, the topic of this ticket being
|
||||
to get rid of Cygwin.
|
||||
o Let us say that can be used to make the point (and later).
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
|
||||
|
||||
|
||||
|
||||
Where are the dooooocs?
|
||||
|
||||
* Freeglut is delivered with its documentation, more very up to date.
|
||||
o It seems that there is a problem with the original GLUT
|
||||
documentation. Not only it does not correspond completely to the
|
||||
operation of Freeglut, but moreover, its author (Mark Kilgard)
|
||||
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:
|
||||
o http://jocelyn.frechot.free.fr/freeglut/
|
||||
|
||||
|
||||
Something survived…
|
||||
|
||||
* I also tested the recompiling of the demonstrations of the original lib
|
||||
GLUT (peace with its ashes).
|
||||
o Nothing in particular to be announced.
|
||||
|
||||
* Thank you with all the courageous maintainers for Freeglut, that one
|
||||
believed dead, but which still move.
|
||||
Glut then!
|
||||
|
||||
By Jean-Seb on Friday July 10, 2009, 00:18
|
||||
Translated by Babelfish with a scrub from John F. Fay. For points of confusion
|
||||
please refer to the original French version.
|
||||
|
||||
Freeglut is an open-source evolution of GLUT.
|
||||
Under Windows, one can use it with Cygwin.
|
||||
Easy? Yes, if one agrees to distribute "cygwin1.dll".
|
||||
Let us help freeglut gain its independence !
|
||||
m.à.j 10/7/2009: generation of a library for linking without the DLL.
|
||||
|
||||
|
||||
Recovery of the sources
|
||||
|
||||
* 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
|
||||
should not delay.
|
||||
* The use of the 2.6 is preferable with the 2.4-stable branch because many
|
||||
bugs have been corrected.
|
||||
* You will find the sources on the site of Freeglut:
|
||||
o http://freeglut.sourceforge.net/
|
||||
|
||||
|
||||
Objectives and preparation
|
||||
Objectives
|
||||
|
||||
* 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.
|
||||
|
||||
|
||||
List of generated files
|
||||
|
||||
* freeglut.dll: a traditional DLL for the dynamic linkage.
|
||||
* libfreeglut.a: the static library. The final program is autonomous (at
|
||||
least for OpenGL).
|
||||
* libfreeglutdll.a: the dynamic library. The final program needs
|
||||
freeglut.dll.
|
||||
|
||||
|
||||
Preparation
|
||||
|
||||
* Extract the files from the freeglut archive.
|
||||
* Go in the directory src (located at the root of the Freeglut directory),
|
||||
and create a "Gl" sub-directory
|
||||
o In this sub-directory, copy the files of the directory "include/Gl"
|
||||
|
||||
* Why is it necessary to create a "Gl" directory for compilation?
|
||||
o I needed it to simplify things during my tests.
|
||||
o If not you can create the repertories directly, and copy the files
|
||||
as indicated in the point installation (see below).
|
||||
|
||||
* Do a little housekeeping in /lib:
|
||||
o Erase all the references to the glut, so as not to conflict with the
|
||||
linking.
|
||||
o This stage is optional, you can also choose to do the housekeeping
|
||||
only after a successful compilation of Freeglut.
|
||||
o In your enthusiasm to clean things up, be careful not to erase the
|
||||
library glu32.lib (not to be confused with glut32.lib).
|
||||
|
||||
|
||||
Compilation
|
||||
|
||||
* Forget the "./configure, make, make install" triptych.
|
||||
o It does not go at all with Cygwin.
|
||||
|
||||
* Here Makefile which will make the deal:
|
||||
|
||||
#Makefile for Freeglut 2.6.0-rc and Cygwin
|
||||
#To place in the directory “src/Common”
|
||||
|
||||
sources=$ (wildcard *.c)
|
||||
objs=$ (sources: .c=.o)
|
||||
libname=freeglut
|
||||
|
||||
|
||||
CFLAGS=-O2 - DTARGET_HOST_MS_WINDOWS - DX_DISPLAY_MISSING - DFREEGLUT_STATIC - I./
|
||||
LDFLAGS=-lopengl32 - lgdi32 - lwinmm
|
||||
|
||||
nocyg=-mno-cygwin - mwindows
|
||||
|
||||
all: $ (objs)
|
||||
#construction DLL related to cygwin1.dll
|
||||
GCC $ (nocyg) $ (objs) - shared $ (LDFLAGS) - O $ (libname) .dll
|
||||
Nm $ (libname) .dll | awk “BEGIN {print “EXPORTS”} /T _glut/{sub (/^.*T _/,” \ T "); print}” > $ (libname) .def
|
||||
dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
|
||||
|
||||
#construction static library independent of cygwin
|
||||
rear Cr lib$ (libname) .a $ (objs)
|
||||
#pas inevitably obligatory (creation of an index to accelerate the accesses)
|
||||
ranlib lib$ (libname) .a
|
||||
|
||||
%.o: %.c
|
||||
GCC $ (nocyg) - C $ (CFLAGS) $<
|
||||
|
||||
clean:
|
||||
rm - F *.o $ (libname) .dll $ (libname) .def lib$ (libname) dll.a lib$ (libname) .a
|
||||
|
||||
|
||||
|
||||
|
||||
Some remarks on the makefile
|
||||
|
||||
* 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.
|
||||
|
||||
* Do not try to strip the static library! You may not be able to compile
|
||||
applications with static library any more.
|
||||
o On the other hand, you can strip the final executable obtained after
|
||||
compiling your application.
|
||||
|
||||
* I chose to call the DLL and the libraries by their "true names":
|
||||
freeglut.dll libfreeglutdll.a and libfreeglut.a.
|
||||
o Script configures recreated (for reasons of compatibility with the
|
||||
old GLUT library) glut.dll and libglut.a.
|
||||
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
|
||||
order to avoid confusions.
|
||||
o Nothing prevents you from renaming the DLL, if you need to use GLUT
|
||||
programs which you cannot recompile.
|
||||
|
||||
* The dynamic library is generated starting from the DLL.
|
||||
o For reasons of brevity, I used awk. It generates the export file
|
||||
used by dlltool.
|
||||
o The only notable thing is the selection of the functions whose name
|
||||
starts with _glut, in order to avoid including in the dynamic
|
||||
library the functions that are not related to freeglut.
|
||||
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
|
||||
dlltool --dllname $ (libname) .dll --input-def $ (libname) .def --output-lib lib$ (libname) dll.a
|
||||
|
||||
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
* Copy libfreeglut.a, libfreeglutdll.a into the Cygwin directory /lib.
|
||||
* Copy freglut.dll in the system32 of Windows (this is practical, but not
|
||||
clean!).
|
||||
* Copy the files headers of Freeglut (/include/gl) into the Cygwin directory
|
||||
/usr/include/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
|
||||
includes in mingw.
|
||||
o You may need to erase the old GLUT include files if you installed it
|
||||
with Cygwin.
|
||||
|
||||
|
||||
Use of the library
|
||||
|
||||
* 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
|
||||
dependence cygwin1.dll.
|
||||
o -mwindows is only used to remove the horrible Shell window (very
|
||||
useful for the settling, on the other hand).
|
||||
o -L. (note the period after the "L"): I left libfreeglut.a,
|
||||
libfreeglutdll.a and freeglut.dll in the test directory, at the time
|
||||
of the tests.
|
||||
|
||||
|
||||
Compilation of the static freeglut library, without cygwin
|
||||
|
||||
* All the simplicity lies in the define: -DFREEGLUT_STATIC
|
||||
o It serves to obtain good decoration of the function names in the
|
||||
imports of the lib Freeglut.
|
||||
o You can test without and use a hex editor to see the differences
|
||||
in the objects.
|
||||
* attention with the order of the libraries: -lfreeglut (static) must be
|
||||
before the declaration of the dynamic libraries.
|
||||
|
||||
* gcc shapes.c -L. -lfreeglut -lopengl32 -lwinmm -lgdi32 -mno-cygwin -mwindows -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation with DLL freeglut, without cygwin
|
||||
|
||||
* For the define, see the notices above
|
||||
* The order of the libraries is no longer important.
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut -mno-cygwin -DFREEGLUT_STATIC
|
||||
|
||||
|
||||
Compilation with DLL freeglut, Cygwin
|
||||
|
||||
* This example is given only for reference, the topic of this ticket being
|
||||
to get rid of Cygwin.
|
||||
o Let us say that can be used to make the point (and later).
|
||||
|
||||
* gcc shapes.c -L. -lopengl32 -lwinmm -lgdi32 -lfreeglut
|
||||
|
||||
|
||||
|
||||
Where are the dooooocs?
|
||||
|
||||
* Freeglut is delivered with its documentation, more very up to date.
|
||||
o It seems that there is a problem with the original GLUT
|
||||
documentation. Not only it does not correspond completely to the
|
||||
operation of Freeglut, but moreover, its author (Mark Kilgard)
|
||||
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:
|
||||
o http://jocelyn.frechot.free.fr/freeglut/
|
||||
|
||||
|
||||
Something survived…
|
||||
|
||||
* I also tested the recompiling of the demonstrations of the original lib
|
||||
GLUT (peace with its ashes).
|
||||
o Nothing in particular to be announced.
|
||||
|
||||
* Thank you with all the courageous maintainers for Freeglut, that one
|
||||
believed dead, but which still move.
|
||||
|
@ -1,24 +1,24 @@
|
||||
Cross-compilation from GNU/Linux (static and shared DLL)
|
||||
========================================================
|
||||
|
||||
Install MinGW32 and prepare FreeGLUT on Debian/Ubuntu:
|
||||
|
||||
apt-get install mingw32
|
||||
./configure --host=i586-mingw32msvc --prefix=/freeglut
|
||||
|
||||
Install MinGW32 and prepare FreeGLUT on Fedora:
|
||||
|
||||
yum install mingw32-gcc
|
||||
./configure --host=i686-pc-mingw32 --prefix=/freeglut
|
||||
|
||||
Cross-compile!
|
||||
|
||||
make
|
||||
make install DESTDIR=$(pwd)
|
||||
|
||||
Everything is in the new freeglut/ directory.
|
||||
The .dll is in the freeglut/bin/.
|
||||
|
||||
|
||||
Compilation of your own programs is done as usual.
|
||||
See README.cygwin_mingw for details.
|
||||
Cross-compilation from GNU/Linux (static and shared DLL)
|
||||
========================================================
|
||||
|
||||
Install MinGW32 and prepare FreeGLUT on Debian/Ubuntu:
|
||||
|
||||
apt-get install mingw32
|
||||
./configure --host=i586-mingw32msvc --prefix=/freeglut
|
||||
|
||||
Install MinGW32 and prepare FreeGLUT on Fedora:
|
||||
|
||||
yum install mingw32-gcc
|
||||
./configure --host=i686-pc-mingw32 --prefix=/freeglut
|
||||
|
||||
Cross-compile!
|
||||
|
||||
make
|
||||
make install DESTDIR=$(pwd)
|
||||
|
||||
Everything is in the new freeglut/ directory.
|
||||
The .dll is in the freeglut/bin/.
|
||||
|
||||
|
||||
Compilation of your own programs is done as usual.
|
||||
See README.cygwin_mingw for details.
|
||||
|
0
freeglut/freeglut/README.win32
Executable file → Normal file
0
freeglut/freeglut/README.win32
Executable file → Normal file
@ -1,412 +1,412 @@
|
||||
/*
|
||||
* freeglut_callbacks.c
|
||||
*
|
||||
* The callbacks setting methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* All of the callbacks setting methods can be generalized to this:
|
||||
*/
|
||||
#define SET_CALLBACK(a) \
|
||||
do \
|
||||
{ \
|
||||
if( fgStructure.CurrentWindow == NULL ) \
|
||||
return; \
|
||||
SET_WCB( ( *( fgStructure.CurrentWindow ) ), a, callback ); \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Sets the Display callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
|
||||
if( !callback )
|
||||
fgError( "Fatal error in program. NULL display callback not "
|
||||
"permitted in GLUT 3.0+ or freeglut 2.0.1+" );
|
||||
SET_CALLBACK( Display );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Reshape callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
|
||||
SET_CALLBACK( Reshape );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Keyboard callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutKeyboardFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
|
||||
SET_CALLBACK( Keyboard );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Special callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
|
||||
SET_CALLBACK( Special );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the global idle callback
|
||||
*/
|
||||
void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
|
||||
fgState.IdleCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Timer callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
|
||||
int timerID )
|
||||
{
|
||||
SFG_Timer *timer, *node;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
|
||||
|
||||
if( (timer = fgState.FreeTimers.Last) )
|
||||
{
|
||||
fgListRemove( &fgState.FreeTimers, &timer->Node );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! (timer = malloc(sizeof(SFG_Timer))) )
|
||||
fgError( "Fatal error: "
|
||||
"Memory allocation failure in glutTimerFunc()" );
|
||||
}
|
||||
|
||||
timer->Callback = callback;
|
||||
timer->ID = timerID;
|
||||
timer->TriggerTime = fgElapsedTime() + timeOut;
|
||||
|
||||
for( node = fgState.Timers.First; node; node = node->Node.Next )
|
||||
{
|
||||
if( node->TriggerTime > timer->TriggerTime )
|
||||
break;
|
||||
}
|
||||
|
||||
fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Visibility callback for the current window.
|
||||
*/
|
||||
static void fghVisibility( int status )
|
||||
{
|
||||
int glut_status = GLUT_VISIBLE;
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" );
|
||||
freeglut_return_if_fail( fgStructure.CurrentWindow );
|
||||
|
||||
if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) )
|
||||
glut_status = GLUT_NOT_VISIBLE;
|
||||
INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
|
||||
SET_CALLBACK( Visibility );
|
||||
|
||||
if( callback )
|
||||
glutWindowStatusFunc( fghVisibility );
|
||||
else
|
||||
glutWindowStatusFunc( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the keyboard key release callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
|
||||
SET_CALLBACK( KeyboardUp );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the special key release callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
|
||||
SET_CALLBACK( SpecialUp );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the joystick callback and polling rate for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutJoystickFunc( void (* callback)
|
||||
( unsigned int, int, int, int ),
|
||||
int pollInterval )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
||||
fgInitialiseJoysticks ();
|
||||
|
||||
if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
|
||||
!FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was disabled */
|
||||
( callback && ( pollInterval >= 0 ) ) ) /* but is now enabled */
|
||||
++fgState.NumActiveJoysticks;
|
||||
else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
|
||||
FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was enabled */
|
||||
( !callback || ( pollInterval < 0 ) ) ) /* but is now disabled */
|
||||
--fgState.NumActiveJoysticks;
|
||||
|
||||
SET_CALLBACK( Joystick );
|
||||
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
|
||||
|
||||
fgStructure.CurrentWindow->State.JoystickLastPoll =
|
||||
fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
|
||||
|
||||
if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
|
||||
fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
|
||||
SET_CALLBACK( Mouse );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse wheel callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
|
||||
SET_CALLBACK( MouseWheel );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse motion callback for the current window (one or more buttons
|
||||
* are pressed)
|
||||
*/
|
||||
void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
|
||||
SET_CALLBACK( Motion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the passive mouse motion callback for the current window (no mouse
|
||||
* buttons are pressed)
|
||||
*/
|
||||
void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
|
||||
SET_CALLBACK( Passive );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window mouse entry/leave callback
|
||||
*/
|
||||
void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
|
||||
SET_CALLBACK( Entry );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window destruction callbacks
|
||||
*/
|
||||
void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
|
||||
SET_CALLBACK( Destroy );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
|
||||
glutCloseFunc( callback );
|
||||
}
|
||||
|
||||
/* A. Donev: Destruction callback for menus */
|
||||
void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
|
||||
if( fgStructure.CurrentMenu )
|
||||
fgStructure.CurrentMenu->Destroy = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deprecated version of glutMenuStatusFunc callback setting method
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
|
||||
fgState.MenuStateCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the global menu status callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
|
||||
fgState.MenuStatusCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the overlay display callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
|
||||
SET_CALLBACK( OverlayDisplay );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the window status callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
|
||||
SET_CALLBACK( WindowStatus );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball rotate callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceRotation );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball button callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the button box callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
|
||||
SET_CALLBACK( ButtonBox );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the dials box callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
|
||||
SET_CALLBACK( Dials );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the tablet motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
|
||||
SET_CALLBACK( TabletMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the tablet buttons callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
|
||||
SET_CALLBACK( TabletButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer entry callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" );
|
||||
SET_CALLBACK( MultiEntry );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer button callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" );
|
||||
SET_CALLBACK( MultiButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" );
|
||||
SET_CALLBACK( MultiMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer passive motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
|
||||
SET_CALLBACK( MultiPassive );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_callbacks.c
|
||||
*
|
||||
* The callbacks setting methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* All of the callbacks setting methods can be generalized to this:
|
||||
*/
|
||||
#define SET_CALLBACK(a) \
|
||||
do \
|
||||
{ \
|
||||
if( fgStructure.CurrentWindow == NULL ) \
|
||||
return; \
|
||||
SET_WCB( ( *( fgStructure.CurrentWindow ) ), a, callback ); \
|
||||
} while( 0 )
|
||||
|
||||
/*
|
||||
* Sets the Display callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
|
||||
if( !callback )
|
||||
fgError( "Fatal error in program. NULL display callback not "
|
||||
"permitted in GLUT 3.0+ or freeglut 2.0.1+" );
|
||||
SET_CALLBACK( Display );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Reshape callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
|
||||
SET_CALLBACK( Reshape );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Keyboard callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutKeyboardFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
|
||||
SET_CALLBACK( Keyboard );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Special callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
|
||||
SET_CALLBACK( Special );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the global idle callback
|
||||
*/
|
||||
void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
|
||||
fgState.IdleCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Timer callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
|
||||
int timerID )
|
||||
{
|
||||
SFG_Timer *timer, *node;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
|
||||
|
||||
if( (timer = fgState.FreeTimers.Last) )
|
||||
{
|
||||
fgListRemove( &fgState.FreeTimers, &timer->Node );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! (timer = malloc(sizeof(SFG_Timer))) )
|
||||
fgError( "Fatal error: "
|
||||
"Memory allocation failure in glutTimerFunc()" );
|
||||
}
|
||||
|
||||
timer->Callback = callback;
|
||||
timer->ID = timerID;
|
||||
timer->TriggerTime = fgElapsedTime() + timeOut;
|
||||
|
||||
for( node = fgState.Timers.First; node; node = node->Node.Next )
|
||||
{
|
||||
if( node->TriggerTime > timer->TriggerTime )
|
||||
break;
|
||||
}
|
||||
|
||||
fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the Visibility callback for the current window.
|
||||
*/
|
||||
static void fghVisibility( int status )
|
||||
{
|
||||
int glut_status = GLUT_VISIBLE;
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" );
|
||||
freeglut_return_if_fail( fgStructure.CurrentWindow );
|
||||
|
||||
if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) )
|
||||
glut_status = GLUT_NOT_VISIBLE;
|
||||
INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
|
||||
SET_CALLBACK( Visibility );
|
||||
|
||||
if( callback )
|
||||
glutWindowStatusFunc( fghVisibility );
|
||||
else
|
||||
glutWindowStatusFunc( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the keyboard key release callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
|
||||
SET_CALLBACK( KeyboardUp );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the special key release callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
|
||||
SET_CALLBACK( SpecialUp );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the joystick callback and polling rate for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutJoystickFunc( void (* callback)
|
||||
( unsigned int, int, int, int ),
|
||||
int pollInterval )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
||||
fgInitialiseJoysticks ();
|
||||
|
||||
if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
|
||||
!FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was disabled */
|
||||
( callback && ( pollInterval >= 0 ) ) ) /* but is now enabled */
|
||||
++fgState.NumActiveJoysticks;
|
||||
else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
|
||||
FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) && /* Joystick callback was enabled */
|
||||
( !callback || ( pollInterval < 0 ) ) ) /* but is now disabled */
|
||||
--fgState.NumActiveJoysticks;
|
||||
|
||||
SET_CALLBACK( Joystick );
|
||||
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
|
||||
|
||||
fgStructure.CurrentWindow->State.JoystickLastPoll =
|
||||
fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
|
||||
|
||||
if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
|
||||
fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
|
||||
SET_CALLBACK( Mouse );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse wheel callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
|
||||
SET_CALLBACK( MouseWheel );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the mouse motion callback for the current window (one or more buttons
|
||||
* are pressed)
|
||||
*/
|
||||
void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
|
||||
SET_CALLBACK( Motion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the passive mouse motion callback for the current window (no mouse
|
||||
* buttons are pressed)
|
||||
*/
|
||||
void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
|
||||
SET_CALLBACK( Passive );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window mouse entry/leave callback
|
||||
*/
|
||||
void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
|
||||
SET_CALLBACK( Entry );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window destruction callbacks
|
||||
*/
|
||||
void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
|
||||
SET_CALLBACK( Destroy );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
|
||||
glutCloseFunc( callback );
|
||||
}
|
||||
|
||||
/* A. Donev: Destruction callback for menus */
|
||||
void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
|
||||
if( fgStructure.CurrentMenu )
|
||||
fgStructure.CurrentMenu->Destroy = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deprecated version of glutMenuStatusFunc callback setting method
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
|
||||
fgState.MenuStateCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the global menu status callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
|
||||
fgState.MenuStatusCallback = callback;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the overlay display callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
|
||||
SET_CALLBACK( OverlayDisplay );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the window status callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
|
||||
SET_CALLBACK( WindowStatus );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball rotate callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceRotation );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the spaceball button callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
|
||||
fgInitialiseSpaceball();
|
||||
|
||||
SET_CALLBACK( SpaceButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the button box callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
|
||||
SET_CALLBACK( ButtonBox );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the dials box callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
|
||||
SET_CALLBACK( Dials );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the tablet motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
|
||||
SET_CALLBACK( TabletMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the tablet buttons callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
|
||||
SET_CALLBACK( TabletButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer entry callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" );
|
||||
SET_CALLBACK( MultiEntry );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer button callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" );
|
||||
SET_CALLBACK( MultiButton );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" );
|
||||
SET_CALLBACK( MultiMotion );
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the multi-pointer passive motion callback for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
|
||||
SET_CALLBACK( MultiPassive );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -1,79 +1,79 @@
|
||||
/*
|
||||
* freeglut_cursor.c
|
||||
*
|
||||
* The mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
* glutSetCursor() -- Win32 mappings are incomplete.
|
||||
*
|
||||
* It would be good to use custom mouse cursor shapes, and introduce
|
||||
* an option to display them using glBitmap() and/or texture mapping,
|
||||
* apart from the windowing system version.
|
||||
*/
|
||||
|
||||
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */
|
||||
|
||||
extern void fgPlatformSetCursor ( SFG_Window *window, int cursorID );
|
||||
extern void fgPlatformWarpPointer ( int x, int y );
|
||||
|
||||
|
||||
|
||||
/* -- INTERNAL FUNCTIONS ---------------------------------------------------- */
|
||||
void fgSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
fgPlatformSetCursor ( window, cursorID );
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Set the cursor image to be used for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSetCursor( int cursorID )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" );
|
||||
|
||||
fgPlatformSetCursor ( fgStructure.CurrentWindow, cursorID );
|
||||
fgStructure.CurrentWindow->State.Cursor = cursorID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Moves the mouse pointer to given window coordinates
|
||||
*/
|
||||
void FGAPIENTRY glutWarpPointer( int x, int y )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" );
|
||||
|
||||
fgPlatformWarpPointer ( x, y );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_cursor.c
|
||||
*
|
||||
* The mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
* glutSetCursor() -- Win32 mappings are incomplete.
|
||||
*
|
||||
* It would be good to use custom mouse cursor shapes, and introduce
|
||||
* an option to display them using glBitmap() and/or texture mapping,
|
||||
* apart from the windowing system version.
|
||||
*/
|
||||
|
||||
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */
|
||||
|
||||
extern void fgPlatformSetCursor ( SFG_Window *window, int cursorID );
|
||||
extern void fgPlatformWarpPointer ( int x, int y );
|
||||
|
||||
|
||||
|
||||
/* -- INTERNAL FUNCTIONS ---------------------------------------------------- */
|
||||
void fgSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
fgPlatformSetCursor ( window, cursorID );
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Set the cursor image to be used for the current window
|
||||
*/
|
||||
void FGAPIENTRY glutSetCursor( int cursorID )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" );
|
||||
|
||||
fgPlatformSetCursor ( fgStructure.CurrentWindow, cursorID );
|
||||
fgStructure.CurrentWindow->State.Cursor = cursorID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Moves the mouse pointer to given window coordinates
|
||||
*/
|
||||
void FGAPIENTRY glutWarpPointer( int x, int y )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" );
|
||||
|
||||
fgPlatformWarpPointer ( x, y );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -1,104 +1,104 @@
|
||||
/*
|
||||
* freeglut_display.c
|
||||
*
|
||||
* Display message posting, context buffer swapping.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Marks the current window to have the redisplay performed when possible...
|
||||
*/
|
||||
void FGAPIENTRY glutPostRedisplay( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
|
||||
if ( ! fgStructure.CurrentWindow )
|
||||
{
|
||||
fgError ( " ERROR: Function <%s> called"
|
||||
" with no current window defined.", "glutPostRedisplay" ) ;
|
||||
}
|
||||
|
||||
fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Swaps the buffers for the current window (if any)
|
||||
*/
|
||||
void FGAPIENTRY glutSwapBuffers( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
|
||||
|
||||
/*
|
||||
* "glXSwapBuffers" already performs an implicit call to "glFlush". What
|
||||
* about "SwapBuffers"?
|
||||
*/
|
||||
glFlush( );
|
||||
if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
|
||||
return;
|
||||
|
||||
fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );
|
||||
|
||||
/* GLUT_FPS env var support */
|
||||
if( fgState.FPSInterval )
|
||||
{
|
||||
GLint t = glutGet( GLUT_ELAPSED_TIME );
|
||||
fgState.SwapCount++;
|
||||
if( fgState.SwapTime == 0 )
|
||||
fgState.SwapTime = t;
|
||||
else if( t - fgState.SwapTime > fgState.FPSInterval )
|
||||
{
|
||||
float time = 0.001f * ( t - fgState.SwapTime );
|
||||
float fps = ( float )fgState.SwapCount / time;
|
||||
fprintf( stderr,
|
||||
"freeglut: %d frames in %.2f seconds = %.2f FPS\n",
|
||||
fgState.SwapCount, time, fps );
|
||||
fgState.SwapTime = t;
|
||||
fgState.SwapCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark appropriate window to be displayed
|
||||
*/
|
||||
void FGAPIENTRY glutPostWindowRedisplay( int windowID )
|
||||
{
|
||||
SFG_Window* window;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
|
||||
window = fgWindowByID( windowID );
|
||||
freeglut_return_if_fail( window );
|
||||
window->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_display.c
|
||||
*
|
||||
* Display message posting, context buffer swapping.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
extern void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow );
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Marks the current window to have the redisplay performed when possible...
|
||||
*/
|
||||
void FGAPIENTRY glutPostRedisplay( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
|
||||
if ( ! fgStructure.CurrentWindow )
|
||||
{
|
||||
fgError ( " ERROR: Function <%s> called"
|
||||
" with no current window defined.", "glutPostRedisplay" ) ;
|
||||
}
|
||||
|
||||
fgStructure.CurrentWindow->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Swaps the buffers for the current window (if any)
|
||||
*/
|
||||
void FGAPIENTRY glutSwapBuffers( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
|
||||
|
||||
/*
|
||||
* "glXSwapBuffers" already performs an implicit call to "glFlush". What
|
||||
* about "SwapBuffers"?
|
||||
*/
|
||||
glFlush( );
|
||||
if( ! fgStructure.CurrentWindow->Window.DoubleBuffered )
|
||||
return;
|
||||
|
||||
fgPlatformGlutSwapBuffers( &fgDisplay.pDisplay, fgStructure.CurrentWindow );
|
||||
|
||||
/* GLUT_FPS env var support */
|
||||
if( fgState.FPSInterval )
|
||||
{
|
||||
GLint t = glutGet( GLUT_ELAPSED_TIME );
|
||||
fgState.SwapCount++;
|
||||
if( fgState.SwapTime == 0 )
|
||||
fgState.SwapTime = t;
|
||||
else if( t - fgState.SwapTime > fgState.FPSInterval )
|
||||
{
|
||||
float time = 0.001f * ( t - fgState.SwapTime );
|
||||
float fps = ( float )fgState.SwapCount / time;
|
||||
fprintf( stderr,
|
||||
"freeglut: %d frames in %.2f seconds = %.2f FPS\n",
|
||||
fgState.SwapCount, time, fps );
|
||||
fgState.SwapTime = t;
|
||||
fgState.SwapCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark appropriate window to be displayed
|
||||
*/
|
||||
void FGAPIENTRY glutPostWindowRedisplay( int windowID )
|
||||
{
|
||||
SFG_Window* window;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
|
||||
window = fgWindowByID( windowID );
|
||||
freeglut_return_if_fail( window );
|
||||
window->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -1,221 +1,221 @@
|
||||
/*
|
||||
* freeglut_ext.c
|
||||
*
|
||||
* Functions related to OpenGL extensions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 9 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
extern SFG_Proc fgPlatformGetProcAddress( const char *procName );
|
||||
extern GLUTproc fgPlatformGetGLUTProcAddress( const char *procName );
|
||||
|
||||
static GLUTproc fghGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutInit);
|
||||
CHECK_NAME(glutInitDisplayMode);
|
||||
CHECK_NAME(glutInitDisplayString);
|
||||
CHECK_NAME(glutInitWindowPosition);
|
||||
CHECK_NAME(glutInitWindowSize);
|
||||
CHECK_NAME(glutMainLoop);
|
||||
CHECK_NAME(glutExit);
|
||||
CHECK_NAME(glutCreateWindow);
|
||||
CHECK_NAME(glutCreateSubWindow);
|
||||
CHECK_NAME(glutDestroyWindow);
|
||||
CHECK_NAME(glutPostRedisplay);
|
||||
CHECK_NAME(glutPostWindowRedisplay);
|
||||
CHECK_NAME(glutSwapBuffers);
|
||||
CHECK_NAME(glutGetWindow);
|
||||
CHECK_NAME(glutSetWindow);
|
||||
CHECK_NAME(glutSetWindowTitle);
|
||||
CHECK_NAME(glutSetIconTitle);
|
||||
CHECK_NAME(glutPositionWindow);
|
||||
CHECK_NAME(glutReshapeWindow);
|
||||
CHECK_NAME(glutPopWindow);
|
||||
CHECK_NAME(glutPushWindow);
|
||||
CHECK_NAME(glutIconifyWindow);
|
||||
CHECK_NAME(glutShowWindow);
|
||||
CHECK_NAME(glutHideWindow);
|
||||
CHECK_NAME(glutFullScreen);
|
||||
CHECK_NAME(glutSetCursor);
|
||||
CHECK_NAME(glutWarpPointer);
|
||||
CHECK_NAME(glutEstablishOverlay);
|
||||
CHECK_NAME(glutRemoveOverlay);
|
||||
CHECK_NAME(glutUseLayer);
|
||||
CHECK_NAME(glutPostOverlayRedisplay);
|
||||
CHECK_NAME(glutPostWindowOverlayRedisplay);
|
||||
CHECK_NAME(glutShowOverlay);
|
||||
CHECK_NAME(glutHideOverlay);
|
||||
CHECK_NAME(glutCreateMenu);
|
||||
CHECK_NAME(glutDestroyMenu);
|
||||
CHECK_NAME(glutGetMenu);
|
||||
CHECK_NAME(glutSetMenu);
|
||||
CHECK_NAME(glutAddMenuEntry);
|
||||
CHECK_NAME(glutAddSubMenu);
|
||||
CHECK_NAME(glutChangeToMenuEntry);
|
||||
CHECK_NAME(glutChangeToSubMenu);
|
||||
CHECK_NAME(glutRemoveMenuItem);
|
||||
CHECK_NAME(glutAttachMenu);
|
||||
CHECK_NAME(glutDetachMenu);
|
||||
CHECK_NAME(glutDisplayFunc);
|
||||
CHECK_NAME(glutReshapeFunc);
|
||||
CHECK_NAME(glutKeyboardFunc);
|
||||
CHECK_NAME(glutMouseFunc);
|
||||
CHECK_NAME(glutMultiEntryFunc);
|
||||
CHECK_NAME(glutMultiMotionFunc);
|
||||
CHECK_NAME(glutMultiButtonFunc);
|
||||
CHECK_NAME(glutMultiPassiveFunc);
|
||||
CHECK_NAME(glutMotionFunc);
|
||||
CHECK_NAME(glutPassiveMotionFunc);
|
||||
CHECK_NAME(glutEntryFunc);
|
||||
CHECK_NAME(glutVisibilityFunc);
|
||||
CHECK_NAME(glutIdleFunc);
|
||||
CHECK_NAME(glutTimerFunc);
|
||||
CHECK_NAME(glutMenuStateFunc);
|
||||
CHECK_NAME(glutSpecialFunc);
|
||||
CHECK_NAME(glutSpaceballMotionFunc);
|
||||
CHECK_NAME(glutSpaceballRotateFunc);
|
||||
CHECK_NAME(glutSpaceballButtonFunc);
|
||||
CHECK_NAME(glutButtonBoxFunc);
|
||||
CHECK_NAME(glutDialsFunc);
|
||||
CHECK_NAME(glutTabletMotionFunc);
|
||||
CHECK_NAME(glutTabletButtonFunc);
|
||||
CHECK_NAME(glutMenuStatusFunc);
|
||||
CHECK_NAME(glutOverlayDisplayFunc);
|
||||
CHECK_NAME(glutWindowStatusFunc);
|
||||
CHECK_NAME(glutKeyboardUpFunc);
|
||||
CHECK_NAME(glutSpecialUpFunc);
|
||||
CHECK_NAME(glutSetColor);
|
||||
CHECK_NAME(glutGetColor);
|
||||
CHECK_NAME(glutCopyColormap);
|
||||
CHECK_NAME(glutGet);
|
||||
CHECK_NAME(glutDeviceGet);
|
||||
CHECK_NAME(glutExtensionSupported);
|
||||
CHECK_NAME(glutGetModifiers);
|
||||
CHECK_NAME(glutLayerGet);
|
||||
CHECK_NAME(glutBitmapCharacter);
|
||||
CHECK_NAME(glutBitmapWidth);
|
||||
CHECK_NAME(glutStrokeCharacter);
|
||||
CHECK_NAME(glutStrokeWidth);
|
||||
CHECK_NAME(glutBitmapLength);
|
||||
CHECK_NAME(glutStrokeLength);
|
||||
CHECK_NAME(glutWireSphere);
|
||||
CHECK_NAME(glutSolidSphere);
|
||||
CHECK_NAME(glutWireCone);
|
||||
CHECK_NAME(glutSolidCone);
|
||||
CHECK_NAME(glutWireCube);
|
||||
CHECK_NAME(glutSolidCube);
|
||||
CHECK_NAME(glutWireTorus);
|
||||
CHECK_NAME(glutSolidTorus);
|
||||
CHECK_NAME(glutWireDodecahedron);
|
||||
CHECK_NAME(glutSolidDodecahedron);
|
||||
CHECK_NAME(glutWireTeapot);
|
||||
CHECK_NAME(glutSolidTeapot);
|
||||
CHECK_NAME(glutWireOctahedron);
|
||||
CHECK_NAME(glutSolidOctahedron);
|
||||
CHECK_NAME(glutWireTetrahedron);
|
||||
CHECK_NAME(glutSolidTetrahedron);
|
||||
CHECK_NAME(glutWireIcosahedron);
|
||||
CHECK_NAME(glutSolidIcosahedron);
|
||||
CHECK_NAME(glutVideoResizeGet);
|
||||
CHECK_NAME(glutSetupVideoResizing);
|
||||
CHECK_NAME(glutStopVideoResizing);
|
||||
CHECK_NAME(glutVideoResize);
|
||||
CHECK_NAME(glutVideoPan);
|
||||
CHECK_NAME(glutReportErrors);
|
||||
CHECK_NAME(glutIgnoreKeyRepeat);
|
||||
CHECK_NAME(glutSetKeyRepeat);
|
||||
|
||||
/* freeglut extensions */
|
||||
CHECK_NAME(glutMainLoopEvent);
|
||||
CHECK_NAME(glutLeaveMainLoop);
|
||||
CHECK_NAME(glutCloseFunc);
|
||||
CHECK_NAME(glutWMCloseFunc);
|
||||
CHECK_NAME(glutMenuDestroyFunc);
|
||||
CHECK_NAME(glutFullScreenToggle);
|
||||
CHECK_NAME(glutLeaveFullScreen);
|
||||
CHECK_NAME(glutSetOption);
|
||||
CHECK_NAME(glutGetModeValues);
|
||||
CHECK_NAME(glutSetWindowData);
|
||||
CHECK_NAME(glutGetWindowData);
|
||||
CHECK_NAME(glutSetMenuData);
|
||||
CHECK_NAME(glutGetMenuData);
|
||||
CHECK_NAME(glutBitmapHeight);
|
||||
CHECK_NAME(glutStrokeHeight);
|
||||
CHECK_NAME(glutBitmapString);
|
||||
CHECK_NAME(glutStrokeString);
|
||||
CHECK_NAME(glutWireRhombicDodecahedron);
|
||||
CHECK_NAME(glutSolidRhombicDodecahedron);
|
||||
CHECK_NAME(glutWireSierpinskiSponge);
|
||||
CHECK_NAME(glutSolidSierpinskiSponge);
|
||||
CHECK_NAME(glutWireCylinder);
|
||||
CHECK_NAME(glutSolidCylinder);
|
||||
CHECK_NAME(glutGetProcAddress);
|
||||
CHECK_NAME(glutMouseWheelFunc);
|
||||
CHECK_NAME(glutJoystickGetNumAxes);
|
||||
CHECK_NAME(glutJoystickGetNumButtons);
|
||||
CHECK_NAME(glutJoystickNotWorking);
|
||||
CHECK_NAME(glutJoystickGetDeadBand);
|
||||
CHECK_NAME(glutJoystickSetDeadBand);
|
||||
CHECK_NAME(glutJoystickGetSaturation);
|
||||
CHECK_NAME(glutJoystickSetSaturation);
|
||||
CHECK_NAME(glutJoystickSetMinRange);
|
||||
CHECK_NAME(glutJoystickSetMaxRange);
|
||||
CHECK_NAME(glutJoystickSetCenter);
|
||||
CHECK_NAME(glutJoystickGetMinRange);
|
||||
CHECK_NAME(glutJoystickGetMaxRange);
|
||||
CHECK_NAME(glutJoystickGetCenter);
|
||||
CHECK_NAME(glutInitContextVersion);
|
||||
CHECK_NAME(glutInitContextFlags);
|
||||
CHECK_NAME(glutInitContextProfile);
|
||||
CHECK_NAME(glutInitErrorFunc);
|
||||
CHECK_NAME(glutInitWarningFunc);
|
||||
#undef CHECK_NAME
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLUTproc FGAPIENTRY
|
||||
glutGetProcAddress( const char *procName )
|
||||
{
|
||||
GLUTproc p;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
|
||||
|
||||
/* Try GLUT functions first, then core GL functions */
|
||||
p = fghGetGLUTProcAddress( procName );
|
||||
|
||||
/* Some GLUT functions are platform-specific: */
|
||||
if ( !p )
|
||||
p = fgPlatformGetGLUTProcAddress( procName );
|
||||
|
||||
return ( p != NULL ) ? p : fgPlatformGetProcAddress( procName );
|
||||
}
|
||||
/*
|
||||
* freeglut_ext.c
|
||||
*
|
||||
* Functions related to OpenGL extensions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 9 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
extern SFG_Proc fgPlatformGetProcAddress( const char *procName );
|
||||
extern GLUTproc fgPlatformGetGLUTProcAddress( const char *procName );
|
||||
|
||||
static GLUTproc fghGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutInit);
|
||||
CHECK_NAME(glutInitDisplayMode);
|
||||
CHECK_NAME(glutInitDisplayString);
|
||||
CHECK_NAME(glutInitWindowPosition);
|
||||
CHECK_NAME(glutInitWindowSize);
|
||||
CHECK_NAME(glutMainLoop);
|
||||
CHECK_NAME(glutExit);
|
||||
CHECK_NAME(glutCreateWindow);
|
||||
CHECK_NAME(glutCreateSubWindow);
|
||||
CHECK_NAME(glutDestroyWindow);
|
||||
CHECK_NAME(glutPostRedisplay);
|
||||
CHECK_NAME(glutPostWindowRedisplay);
|
||||
CHECK_NAME(glutSwapBuffers);
|
||||
CHECK_NAME(glutGetWindow);
|
||||
CHECK_NAME(glutSetWindow);
|
||||
CHECK_NAME(glutSetWindowTitle);
|
||||
CHECK_NAME(glutSetIconTitle);
|
||||
CHECK_NAME(glutPositionWindow);
|
||||
CHECK_NAME(glutReshapeWindow);
|
||||
CHECK_NAME(glutPopWindow);
|
||||
CHECK_NAME(glutPushWindow);
|
||||
CHECK_NAME(glutIconifyWindow);
|
||||
CHECK_NAME(glutShowWindow);
|
||||
CHECK_NAME(glutHideWindow);
|
||||
CHECK_NAME(glutFullScreen);
|
||||
CHECK_NAME(glutSetCursor);
|
||||
CHECK_NAME(glutWarpPointer);
|
||||
CHECK_NAME(glutEstablishOverlay);
|
||||
CHECK_NAME(glutRemoveOverlay);
|
||||
CHECK_NAME(glutUseLayer);
|
||||
CHECK_NAME(glutPostOverlayRedisplay);
|
||||
CHECK_NAME(glutPostWindowOverlayRedisplay);
|
||||
CHECK_NAME(glutShowOverlay);
|
||||
CHECK_NAME(glutHideOverlay);
|
||||
CHECK_NAME(glutCreateMenu);
|
||||
CHECK_NAME(glutDestroyMenu);
|
||||
CHECK_NAME(glutGetMenu);
|
||||
CHECK_NAME(glutSetMenu);
|
||||
CHECK_NAME(glutAddMenuEntry);
|
||||
CHECK_NAME(glutAddSubMenu);
|
||||
CHECK_NAME(glutChangeToMenuEntry);
|
||||
CHECK_NAME(glutChangeToSubMenu);
|
||||
CHECK_NAME(glutRemoveMenuItem);
|
||||
CHECK_NAME(glutAttachMenu);
|
||||
CHECK_NAME(glutDetachMenu);
|
||||
CHECK_NAME(glutDisplayFunc);
|
||||
CHECK_NAME(glutReshapeFunc);
|
||||
CHECK_NAME(glutKeyboardFunc);
|
||||
CHECK_NAME(glutMouseFunc);
|
||||
CHECK_NAME(glutMultiEntryFunc);
|
||||
CHECK_NAME(glutMultiMotionFunc);
|
||||
CHECK_NAME(glutMultiButtonFunc);
|
||||
CHECK_NAME(glutMultiPassiveFunc);
|
||||
CHECK_NAME(glutMotionFunc);
|
||||
CHECK_NAME(glutPassiveMotionFunc);
|
||||
CHECK_NAME(glutEntryFunc);
|
||||
CHECK_NAME(glutVisibilityFunc);
|
||||
CHECK_NAME(glutIdleFunc);
|
||||
CHECK_NAME(glutTimerFunc);
|
||||
CHECK_NAME(glutMenuStateFunc);
|
||||
CHECK_NAME(glutSpecialFunc);
|
||||
CHECK_NAME(glutSpaceballMotionFunc);
|
||||
CHECK_NAME(glutSpaceballRotateFunc);
|
||||
CHECK_NAME(glutSpaceballButtonFunc);
|
||||
CHECK_NAME(glutButtonBoxFunc);
|
||||
CHECK_NAME(glutDialsFunc);
|
||||
CHECK_NAME(glutTabletMotionFunc);
|
||||
CHECK_NAME(glutTabletButtonFunc);
|
||||
CHECK_NAME(glutMenuStatusFunc);
|
||||
CHECK_NAME(glutOverlayDisplayFunc);
|
||||
CHECK_NAME(glutWindowStatusFunc);
|
||||
CHECK_NAME(glutKeyboardUpFunc);
|
||||
CHECK_NAME(glutSpecialUpFunc);
|
||||
CHECK_NAME(glutSetColor);
|
||||
CHECK_NAME(glutGetColor);
|
||||
CHECK_NAME(glutCopyColormap);
|
||||
CHECK_NAME(glutGet);
|
||||
CHECK_NAME(glutDeviceGet);
|
||||
CHECK_NAME(glutExtensionSupported);
|
||||
CHECK_NAME(glutGetModifiers);
|
||||
CHECK_NAME(glutLayerGet);
|
||||
CHECK_NAME(glutBitmapCharacter);
|
||||
CHECK_NAME(glutBitmapWidth);
|
||||
CHECK_NAME(glutStrokeCharacter);
|
||||
CHECK_NAME(glutStrokeWidth);
|
||||
CHECK_NAME(glutBitmapLength);
|
||||
CHECK_NAME(glutStrokeLength);
|
||||
CHECK_NAME(glutWireSphere);
|
||||
CHECK_NAME(glutSolidSphere);
|
||||
CHECK_NAME(glutWireCone);
|
||||
CHECK_NAME(glutSolidCone);
|
||||
CHECK_NAME(glutWireCube);
|
||||
CHECK_NAME(glutSolidCube);
|
||||
CHECK_NAME(glutWireTorus);
|
||||
CHECK_NAME(glutSolidTorus);
|
||||
CHECK_NAME(glutWireDodecahedron);
|
||||
CHECK_NAME(glutSolidDodecahedron);
|
||||
CHECK_NAME(glutWireTeapot);
|
||||
CHECK_NAME(glutSolidTeapot);
|
||||
CHECK_NAME(glutWireOctahedron);
|
||||
CHECK_NAME(glutSolidOctahedron);
|
||||
CHECK_NAME(glutWireTetrahedron);
|
||||
CHECK_NAME(glutSolidTetrahedron);
|
||||
CHECK_NAME(glutWireIcosahedron);
|
||||
CHECK_NAME(glutSolidIcosahedron);
|
||||
CHECK_NAME(glutVideoResizeGet);
|
||||
CHECK_NAME(glutSetupVideoResizing);
|
||||
CHECK_NAME(glutStopVideoResizing);
|
||||
CHECK_NAME(glutVideoResize);
|
||||
CHECK_NAME(glutVideoPan);
|
||||
CHECK_NAME(glutReportErrors);
|
||||
CHECK_NAME(glutIgnoreKeyRepeat);
|
||||
CHECK_NAME(glutSetKeyRepeat);
|
||||
|
||||
/* freeglut extensions */
|
||||
CHECK_NAME(glutMainLoopEvent);
|
||||
CHECK_NAME(glutLeaveMainLoop);
|
||||
CHECK_NAME(glutCloseFunc);
|
||||
CHECK_NAME(glutWMCloseFunc);
|
||||
CHECK_NAME(glutMenuDestroyFunc);
|
||||
CHECK_NAME(glutFullScreenToggle);
|
||||
CHECK_NAME(glutLeaveFullScreen);
|
||||
CHECK_NAME(glutSetOption);
|
||||
CHECK_NAME(glutGetModeValues);
|
||||
CHECK_NAME(glutSetWindowData);
|
||||
CHECK_NAME(glutGetWindowData);
|
||||
CHECK_NAME(glutSetMenuData);
|
||||
CHECK_NAME(glutGetMenuData);
|
||||
CHECK_NAME(glutBitmapHeight);
|
||||
CHECK_NAME(glutStrokeHeight);
|
||||
CHECK_NAME(glutBitmapString);
|
||||
CHECK_NAME(glutStrokeString);
|
||||
CHECK_NAME(glutWireRhombicDodecahedron);
|
||||
CHECK_NAME(glutSolidRhombicDodecahedron);
|
||||
CHECK_NAME(glutWireSierpinskiSponge);
|
||||
CHECK_NAME(glutSolidSierpinskiSponge);
|
||||
CHECK_NAME(glutWireCylinder);
|
||||
CHECK_NAME(glutSolidCylinder);
|
||||
CHECK_NAME(glutGetProcAddress);
|
||||
CHECK_NAME(glutMouseWheelFunc);
|
||||
CHECK_NAME(glutJoystickGetNumAxes);
|
||||
CHECK_NAME(glutJoystickGetNumButtons);
|
||||
CHECK_NAME(glutJoystickNotWorking);
|
||||
CHECK_NAME(glutJoystickGetDeadBand);
|
||||
CHECK_NAME(glutJoystickSetDeadBand);
|
||||
CHECK_NAME(glutJoystickGetSaturation);
|
||||
CHECK_NAME(glutJoystickSetSaturation);
|
||||
CHECK_NAME(glutJoystickSetMinRange);
|
||||
CHECK_NAME(glutJoystickSetMaxRange);
|
||||
CHECK_NAME(glutJoystickSetCenter);
|
||||
CHECK_NAME(glutJoystickGetMinRange);
|
||||
CHECK_NAME(glutJoystickGetMaxRange);
|
||||
CHECK_NAME(glutJoystickGetCenter);
|
||||
CHECK_NAME(glutInitContextVersion);
|
||||
CHECK_NAME(glutInitContextFlags);
|
||||
CHECK_NAME(glutInitContextProfile);
|
||||
CHECK_NAME(glutInitErrorFunc);
|
||||
CHECK_NAME(glutInitWarningFunc);
|
||||
#undef CHECK_NAME
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLUTproc FGAPIENTRY
|
||||
glutGetProcAddress( const char *procName )
|
||||
{
|
||||
GLUTproc p;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
|
||||
|
||||
/* Try GLUT functions first, then core GL functions */
|
||||
p = fghGetGLUTProcAddress( procName );
|
||||
|
||||
/* Some GLUT functions are platform-specific: */
|
||||
if ( !p )
|
||||
p = fgPlatformGetGLUTProcAddress( procName );
|
||||
|
||||
return ( p != NULL ) ? p : fgPlatformGetProcAddress( procName );
|
||||
}
|
||||
|
@ -1,384 +1,384 @@
|
||||
/*
|
||||
* freeglut_font.c
|
||||
*
|
||||
* Bitmap and stroke fonts displaying.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* Test things out ...
|
||||
*/
|
||||
|
||||
/* -- IMPORT DECLARATIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* These are the font faces defined in freeglut_font_data.c file:
|
||||
*/
|
||||
extern SFG_Font fgFontFixed8x13;
|
||||
extern SFG_Font fgFontFixed9x15;
|
||||
extern SFG_Font fgFontHelvetica10;
|
||||
extern SFG_Font fgFontHelvetica12;
|
||||
extern SFG_Font fgFontHelvetica18;
|
||||
extern SFG_Font fgFontTimesRoman10;
|
||||
extern SFG_Font fgFontTimesRoman24;
|
||||
extern SFG_StrokeFont fgStrokeRoman;
|
||||
extern SFG_StrokeFont fgStrokeMonoRoman;
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Matches a font ID with a SFG_Font structure pointer.
|
||||
* This was changed to match the GLUT header style.
|
||||
*/
|
||||
static SFG_Font* fghFontByID( void* font )
|
||||
{
|
||||
if( font == GLUT_BITMAP_8_BY_13 )
|
||||
return &fgFontFixed8x13;
|
||||
if( font == GLUT_BITMAP_9_BY_15 )
|
||||
return &fgFontFixed9x15;
|
||||
if( font == GLUT_BITMAP_HELVETICA_10 )
|
||||
return &fgFontHelvetica10;
|
||||
if( font == GLUT_BITMAP_HELVETICA_12 )
|
||||
return &fgFontHelvetica12;
|
||||
if( font == GLUT_BITMAP_HELVETICA_18 )
|
||||
return &fgFontHelvetica18;
|
||||
if( font == GLUT_BITMAP_TIMES_ROMAN_10 )
|
||||
return &fgFontTimesRoman10;
|
||||
if( font == GLUT_BITMAP_TIMES_ROMAN_24 )
|
||||
return &fgFontTimesRoman24;
|
||||
|
||||
fgWarning( "font 0x%08x not found", font );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Matches a font ID with a SFG_StrokeFont structure pointer.
|
||||
* This was changed to match the GLUT header style.
|
||||
*/
|
||||
static SFG_StrokeFont* fghStrokeByID( void* font )
|
||||
{
|
||||
if( font == GLUT_STROKE_ROMAN )
|
||||
return &fgStrokeRoman;
|
||||
if( font == GLUT_STROKE_MONO_ROMAN )
|
||||
return &fgStrokeMonoRoman;
|
||||
|
||||
fgWarning( "stroke font 0x%08x not found", font );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Draw a bitmap character
|
||||
*/
|
||||
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
||||
{
|
||||
const GLubyte* face;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) );
|
||||
freeglut_return_if_fail( font );
|
||||
|
||||
/*
|
||||
* Find the character we want to draw (???)
|
||||
*/
|
||||
face = font->Characters[ character ];
|
||||
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
|
||||
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||
glBitmap(
|
||||
face[ 0 ], font->Height, /* The bitmap's width and height */
|
||||
font->xorig, font->yorig, /* The origin in the font glyph */
|
||||
( float )( face[ 0 ] ), 0.0, /* The raster advance -- inc. x,y */
|
||||
( face + 1 ) /* The packed bitmap data... */
|
||||
);
|
||||
glPopClientAttrib( );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
|
||||
{
|
||||
unsigned char c;
|
||||
float x = 0.0f ;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
|
||||
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||
|
||||
/*
|
||||
* Step through the string, drawing each character.
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++) )
|
||||
if( c == '\n' )
|
||||
{
|
||||
glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL );
|
||||
x = 0.0f;
|
||||
}
|
||||
else /* Not an EOL, draw the bitmap character */
|
||||
{
|
||||
const GLubyte* face = font->Characters[ c ];
|
||||
|
||||
glBitmap(
|
||||
face[ 0 ], font->Height, /* Bitmap's width and height */
|
||||
font->xorig, font->yorig, /* The origin in the font glyph */
|
||||
( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */
|
||||
( face + 1 ) /* The packed bitmap data... */
|
||||
);
|
||||
|
||||
x += ( float )( face[ 0 ] );
|
||||
}
|
||||
|
||||
glPopClientAttrib( );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the width in pixels of a font's character
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapWidth( void* fontID, int character )
|
||||
{
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( character > 0 && character < 256, 0 );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return *( font->Characters[ character ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width of a string drawn using a bitmap font
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string )
|
||||
{
|
||||
unsigned char c;
|
||||
int length = 0, this_line_length = 0;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++) )
|
||||
{
|
||||
if( c != '\n' )/* Not an EOL, increment length of line */
|
||||
this_line_length += *( font->Characters[ c ]);
|
||||
else /* EOL; reset the length of this line */
|
||||
{
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
this_line_length = 0;
|
||||
}
|
||||
}
|
||||
if ( length < this_line_length )
|
||||
length = this_line_length;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of a bitmap font
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapHeight( void* fontID )
|
||||
{
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return font->Height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw a stroke character
|
||||
*/
|
||||
void FGAPIENTRY glutStrokeCharacter( void* fontID, int character )
|
||||
{
|
||||
const SFG_StrokeChar *schar;
|
||||
const SFG_StrokeStrip *strip;
|
||||
int i, j;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( character >= 0 );
|
||||
freeglut_return_if_fail( character < font->Quantity );
|
||||
freeglut_return_if_fail( font );
|
||||
|
||||
schar = font->Characters[ character ];
|
||||
freeglut_return_if_fail( schar );
|
||||
strip = schar->Strips;
|
||||
|
||||
for( i = 0; i < schar->Number; i++, strip++ )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
|
||||
glEnd( );
|
||||
glBegin( GL_POINTS );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
|
||||
glEnd( );
|
||||
}
|
||||
glTranslatef( schar->Right, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
|
||||
{
|
||||
unsigned char c;
|
||||
int i, j;
|
||||
float length = 0.0;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
|
||||
/*
|
||||
* Step through the string, drawing each character.
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++) )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' )
|
||||
{
|
||||
glTranslatef ( -length, -( float )( font->Height ), 0.0 );
|
||||
length = 0.0;
|
||||
}
|
||||
else /* Not an EOL, draw the bitmap character */
|
||||
{
|
||||
const SFG_StrokeChar *schar = font->Characters[ c ];
|
||||
if( schar )
|
||||
{
|
||||
const SFG_StrokeStrip *strip = schar->Strips;
|
||||
|
||||
for( i = 0; i < schar->Number; i++, strip++ )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X,
|
||||
strip->Vertices[ j ].Y);
|
||||
|
||||
glEnd( );
|
||||
}
|
||||
|
||||
length += schar->Right;
|
||||
glTranslatef( schar->Right, 0.0, 0.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width in pixels of a stroke character
|
||||
*/
|
||||
int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
|
||||
{
|
||||
const SFG_StrokeChar *schar;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( ( character >= 0 ) &&
|
||||
( character < font->Quantity ),
|
||||
0
|
||||
);
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
schar = font->Characters[ character ];
|
||||
freeglut_return_val_if_fail( schar, 0 );
|
||||
|
||||
return ( int )( schar->Right + 0.5 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width of a string drawn using a stroke font
|
||||
*/
|
||||
int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
|
||||
{
|
||||
unsigned char c;
|
||||
float length = 0.0;
|
||||
float this_line_length = 0.0;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++) )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' ) /* EOL; reset the length of this line */
|
||||
{
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
this_line_length = 0.0;
|
||||
}
|
||||
else /* Not an EOL, increment the length of this line */
|
||||
{
|
||||
const SFG_StrokeChar *schar = font->Characters[ c ];
|
||||
if( schar )
|
||||
this_line_length += schar->Right;
|
||||
}
|
||||
}
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
return( int )( length + 0.5 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of a stroke font
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutStrokeHeight( void* fontID )
|
||||
{
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0.0 );
|
||||
return font->Height;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_font.c
|
||||
*
|
||||
* Bitmap and stroke fonts displaying.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* Test things out ...
|
||||
*/
|
||||
|
||||
/* -- IMPORT DECLARATIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* These are the font faces defined in freeglut_font_data.c file:
|
||||
*/
|
||||
extern SFG_Font fgFontFixed8x13;
|
||||
extern SFG_Font fgFontFixed9x15;
|
||||
extern SFG_Font fgFontHelvetica10;
|
||||
extern SFG_Font fgFontHelvetica12;
|
||||
extern SFG_Font fgFontHelvetica18;
|
||||
extern SFG_Font fgFontTimesRoman10;
|
||||
extern SFG_Font fgFontTimesRoman24;
|
||||
extern SFG_StrokeFont fgStrokeRoman;
|
||||
extern SFG_StrokeFont fgStrokeMonoRoman;
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Matches a font ID with a SFG_Font structure pointer.
|
||||
* This was changed to match the GLUT header style.
|
||||
*/
|
||||
static SFG_Font* fghFontByID( void* font )
|
||||
{
|
||||
if( font == GLUT_BITMAP_8_BY_13 )
|
||||
return &fgFontFixed8x13;
|
||||
if( font == GLUT_BITMAP_9_BY_15 )
|
||||
return &fgFontFixed9x15;
|
||||
if( font == GLUT_BITMAP_HELVETICA_10 )
|
||||
return &fgFontHelvetica10;
|
||||
if( font == GLUT_BITMAP_HELVETICA_12 )
|
||||
return &fgFontHelvetica12;
|
||||
if( font == GLUT_BITMAP_HELVETICA_18 )
|
||||
return &fgFontHelvetica18;
|
||||
if( font == GLUT_BITMAP_TIMES_ROMAN_10 )
|
||||
return &fgFontTimesRoman10;
|
||||
if( font == GLUT_BITMAP_TIMES_ROMAN_24 )
|
||||
return &fgFontTimesRoman24;
|
||||
|
||||
fgWarning( "font 0x%08x not found", font );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Matches a font ID with a SFG_StrokeFont structure pointer.
|
||||
* This was changed to match the GLUT header style.
|
||||
*/
|
||||
static SFG_StrokeFont* fghStrokeByID( void* font )
|
||||
{
|
||||
if( font == GLUT_STROKE_ROMAN )
|
||||
return &fgStrokeRoman;
|
||||
if( font == GLUT_STROKE_MONO_ROMAN )
|
||||
return &fgStrokeMonoRoman;
|
||||
|
||||
fgWarning( "stroke font 0x%08x not found", font );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Draw a bitmap character
|
||||
*/
|
||||
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
||||
{
|
||||
const GLubyte* face;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) );
|
||||
freeglut_return_if_fail( font );
|
||||
|
||||
/*
|
||||
* Find the character we want to draw (???)
|
||||
*/
|
||||
face = font->Characters[ character ];
|
||||
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
|
||||
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||
glBitmap(
|
||||
face[ 0 ], font->Height, /* The bitmap's width and height */
|
||||
font->xorig, font->yorig, /* The origin in the font glyph */
|
||||
( float )( face[ 0 ] ), 0.0, /* The raster advance -- inc. x,y */
|
||||
( face + 1 ) /* The packed bitmap data... */
|
||||
);
|
||||
glPopClientAttrib( );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
|
||||
{
|
||||
unsigned char c;
|
||||
float x = 0.0f ;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
|
||||
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
|
||||
glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE );
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
|
||||
|
||||
/*
|
||||
* Step through the string, drawing each character.
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++) )
|
||||
if( c == '\n' )
|
||||
{
|
||||
glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL );
|
||||
x = 0.0f;
|
||||
}
|
||||
else /* Not an EOL, draw the bitmap character */
|
||||
{
|
||||
const GLubyte* face = font->Characters[ c ];
|
||||
|
||||
glBitmap(
|
||||
face[ 0 ], font->Height, /* Bitmap's width and height */
|
||||
font->xorig, font->yorig, /* The origin in the font glyph */
|
||||
( float )( face[ 0 ] ), 0.0, /* The raster advance; inc. x,y */
|
||||
( face + 1 ) /* The packed bitmap data... */
|
||||
);
|
||||
|
||||
x += ( float )( face[ 0 ] );
|
||||
}
|
||||
|
||||
glPopClientAttrib( );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the width in pixels of a font's character
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapWidth( void* fontID, int character )
|
||||
{
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( character > 0 && character < 256, 0 );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return *( font->Characters[ character ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width of a string drawn using a bitmap font
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string )
|
||||
{
|
||||
unsigned char c;
|
||||
int length = 0, this_line_length = 0;
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++) )
|
||||
{
|
||||
if( c != '\n' )/* Not an EOL, increment length of line */
|
||||
this_line_length += *( font->Characters[ c ]);
|
||||
else /* EOL; reset the length of this line */
|
||||
{
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
this_line_length = 0;
|
||||
}
|
||||
}
|
||||
if ( length < this_line_length )
|
||||
length = this_line_length;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of a bitmap font
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapHeight( void* fontID )
|
||||
{
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return font->Height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw a stroke character
|
||||
*/
|
||||
void FGAPIENTRY glutStrokeCharacter( void* fontID, int character )
|
||||
{
|
||||
const SFG_StrokeChar *schar;
|
||||
const SFG_StrokeStrip *strip;
|
||||
int i, j;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( character >= 0 );
|
||||
freeglut_return_if_fail( character < font->Quantity );
|
||||
freeglut_return_if_fail( font );
|
||||
|
||||
schar = font->Characters[ character ];
|
||||
freeglut_return_if_fail( schar );
|
||||
strip = schar->Strips;
|
||||
|
||||
for( i = 0; i < schar->Number; i++, strip++ )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
|
||||
glEnd( );
|
||||
glBegin( GL_POINTS );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
|
||||
glEnd( );
|
||||
}
|
||||
glTranslatef( schar->Right, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
|
||||
{
|
||||
unsigned char c;
|
||||
int i, j;
|
||||
float length = 0.0;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
|
||||
/*
|
||||
* Step through the string, drawing each character.
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++) )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' )
|
||||
{
|
||||
glTranslatef ( -length, -( float )( font->Height ), 0.0 );
|
||||
length = 0.0;
|
||||
}
|
||||
else /* Not an EOL, draw the bitmap character */
|
||||
{
|
||||
const SFG_StrokeChar *schar = font->Characters[ c ];
|
||||
if( schar )
|
||||
{
|
||||
const SFG_StrokeStrip *strip = schar->Strips;
|
||||
|
||||
for( i = 0; i < schar->Number; i++, strip++ )
|
||||
{
|
||||
glBegin( GL_LINE_STRIP );
|
||||
for( j = 0; j < strip->Number; j++ )
|
||||
glVertex2f( strip->Vertices[ j ].X,
|
||||
strip->Vertices[ j ].Y);
|
||||
|
||||
glEnd( );
|
||||
}
|
||||
|
||||
length += schar->Right;
|
||||
glTranslatef( schar->Right, 0.0, 0.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width in pixels of a stroke character
|
||||
*/
|
||||
int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
|
||||
{
|
||||
const SFG_StrokeChar *schar;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( ( character >= 0 ) &&
|
||||
( character < font->Quantity ),
|
||||
0
|
||||
);
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
schar = font->Characters[ character ];
|
||||
freeglut_return_val_if_fail( schar, 0 );
|
||||
|
||||
return ( int )( schar->Right + 0.5 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the width of a string drawn using a stroke font
|
||||
*/
|
||||
int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
|
||||
{
|
||||
unsigned char c;
|
||||
float length = 0.0;
|
||||
float this_line_length = 0.0;
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++) )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' ) /* EOL; reset the length of this line */
|
||||
{
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
this_line_length = 0.0;
|
||||
}
|
||||
else /* Not an EOL, increment the length of this line */
|
||||
{
|
||||
const SFG_StrokeChar *schar = font->Characters[ c ];
|
||||
if( schar )
|
||||
this_line_length += schar->Right;
|
||||
}
|
||||
}
|
||||
if( length < this_line_length )
|
||||
length = this_line_length;
|
||||
return( int )( length + 0.5 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the height of a stroke font
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutStrokeHeight( void* fontID )
|
||||
{
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0.0 );
|
||||
return font->Height;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,179 +1,179 @@
|
||||
/*
|
||||
* freeglut_gamemode.c
|
||||
*
|
||||
* The game mode handling code.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutGameModeString() -- missing
|
||||
* glutEnterGameMode() -- X11 version
|
||||
* glutLeaveGameMode() -- is that correct?
|
||||
* glutGameModeGet() -- is that correct?
|
||||
*/
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
extern void fgPlatformRememberState( void );
|
||||
extern void fgPlatformRestoreState( void );
|
||||
extern GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest );
|
||||
extern void fgPlatformEnterGameMode( void );
|
||||
extern void fgPlatformLeaveGameMode( void );
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Sets the game mode display string
|
||||
*/
|
||||
void FGAPIENTRY glutGameModeString( const char* string )
|
||||
{
|
||||
int width = -1, height = -1, depth = -1, refresh = -1;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );
|
||||
|
||||
/*
|
||||
* 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
|
||||
* that I assumed it is: "[width]x[height]:[depth]@[refresh rate]", which
|
||||
* appears in all GLUT game mode programs I have seen to date.
|
||||
*/
|
||||
if( sscanf( string, "%ix%i:%i@%i", &width, &height, &depth, &refresh ) !=
|
||||
4 )
|
||||
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", &width, &height ) != 2 )
|
||||
if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 )
|
||||
if( sscanf( string, ":%i", &depth ) != 1 )
|
||||
if( sscanf( string, "@%i", &refresh ) != 1 )
|
||||
fgWarning(
|
||||
"unable to parse game mode string `%s'",
|
||||
string
|
||||
);
|
||||
|
||||
/* All values not specified are now set to -1, which means those
|
||||
* aspects of the current display mode are not changed in
|
||||
* fgPlatformChangeDisplayMode() above.
|
||||
*/
|
||||
fgState.GameModeSize.X = width;
|
||||
fgState.GameModeSize.Y = height;
|
||||
fgState.GameModeDepth = depth;
|
||||
fgState.GameModeRefresh = refresh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Enters the game mode
|
||||
*/
|
||||
int FGAPIENTRY glutEnterGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );
|
||||
|
||||
if( fgStructure.GameModeWindow )
|
||||
fgAddToWindowDestroyList( fgStructure.GameModeWindow );
|
||||
else
|
||||
fgPlatformRememberState( );
|
||||
|
||||
if( ! fgPlatformChangeDisplayMode( GL_FALSE ) )
|
||||
{
|
||||
fgWarning( "failed to change screen settings" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
fgStructure.GameModeWindow = fgCreateWindow(
|
||||
NULL, "FREEGLUT", GL_TRUE, 0, 0,
|
||||
GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y,
|
||||
GL_TRUE, GL_FALSE
|
||||
);
|
||||
|
||||
fgStructure.GameModeWindow->State.Width = fgState.GameModeSize.X;
|
||||
fgStructure.GameModeWindow->State.Height = fgState.GameModeSize.Y;
|
||||
fgStructure.GameModeWindow->State.NeedToResize = GL_TRUE;
|
||||
|
||||
fgPlatformEnterGameMode();
|
||||
|
||||
return fgStructure.GameModeWindow->ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Leaves the game mode
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" );
|
||||
|
||||
freeglut_return_if_fail( fgStructure.GameModeWindow );
|
||||
|
||||
fgAddToWindowDestroyList( fgStructure.GameModeWindow );
|
||||
fgStructure.GameModeWindow = NULL;
|
||||
|
||||
fgPlatformLeaveGameMode();
|
||||
|
||||
fgPlatformRestoreState();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns information concerning the freeglut game mode
|
||||
*/
|
||||
int FGAPIENTRY glutGameModeGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" );
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_GAME_MODE_ACTIVE:
|
||||
return !!fgStructure.GameModeWindow;
|
||||
|
||||
case GLUT_GAME_MODE_POSSIBLE:
|
||||
return fgPlatformChangeDisplayMode( GL_TRUE );
|
||||
|
||||
case GLUT_GAME_MODE_WIDTH:
|
||||
return fgState.GameModeSize.X;
|
||||
|
||||
case GLUT_GAME_MODE_HEIGHT:
|
||||
return fgState.GameModeSize.Y;
|
||||
|
||||
case GLUT_GAME_MODE_PIXEL_DEPTH:
|
||||
return fgState.GameModeDepth;
|
||||
|
||||
case GLUT_GAME_MODE_REFRESH_RATE:
|
||||
return fgState.GameModeRefresh;
|
||||
|
||||
case GLUT_GAME_MODE_DISPLAY_CHANGED:
|
||||
/*
|
||||
* This is true if the game mode has been activated successfully..
|
||||
*/
|
||||
return !!fgStructure.GameModeWindow;
|
||||
}
|
||||
|
||||
fgWarning( "Unknown gamemode get: %d", eWhat );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_gamemode.c
|
||||
*
|
||||
* The game mode handling code.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutGameModeString() -- missing
|
||||
* glutEnterGameMode() -- X11 version
|
||||
* glutLeaveGameMode() -- is that correct?
|
||||
* glutGameModeGet() -- is that correct?
|
||||
*/
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
extern void fgPlatformRememberState( void );
|
||||
extern void fgPlatformRestoreState( void );
|
||||
extern GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest );
|
||||
extern void fgPlatformEnterGameMode( void );
|
||||
extern void fgPlatformLeaveGameMode( void );
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Sets the game mode display string
|
||||
*/
|
||||
void FGAPIENTRY glutGameModeString( const char* string )
|
||||
{
|
||||
int width = -1, height = -1, depth = -1, refresh = -1;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );
|
||||
|
||||
/*
|
||||
* 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
|
||||
* that I assumed it is: "[width]x[height]:[depth]@[refresh rate]", which
|
||||
* appears in all GLUT game mode programs I have seen to date.
|
||||
*/
|
||||
if( sscanf( string, "%ix%i:%i@%i", &width, &height, &depth, &refresh ) !=
|
||||
4 )
|
||||
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", &width, &height ) != 2 )
|
||||
if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 )
|
||||
if( sscanf( string, ":%i", &depth ) != 1 )
|
||||
if( sscanf( string, "@%i", &refresh ) != 1 )
|
||||
fgWarning(
|
||||
"unable to parse game mode string `%s'",
|
||||
string
|
||||
);
|
||||
|
||||
/* All values not specified are now set to -1, which means those
|
||||
* aspects of the current display mode are not changed in
|
||||
* fgPlatformChangeDisplayMode() above.
|
||||
*/
|
||||
fgState.GameModeSize.X = width;
|
||||
fgState.GameModeSize.Y = height;
|
||||
fgState.GameModeDepth = depth;
|
||||
fgState.GameModeRefresh = refresh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Enters the game mode
|
||||
*/
|
||||
int FGAPIENTRY glutEnterGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );
|
||||
|
||||
if( fgStructure.GameModeWindow )
|
||||
fgAddToWindowDestroyList( fgStructure.GameModeWindow );
|
||||
else
|
||||
fgPlatformRememberState( );
|
||||
|
||||
if( ! fgPlatformChangeDisplayMode( GL_FALSE ) )
|
||||
{
|
||||
fgWarning( "failed to change screen settings" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
fgStructure.GameModeWindow = fgCreateWindow(
|
||||
NULL, "FREEGLUT", GL_TRUE, 0, 0,
|
||||
GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y,
|
||||
GL_TRUE, GL_FALSE
|
||||
);
|
||||
|
||||
fgStructure.GameModeWindow->State.Width = fgState.GameModeSize.X;
|
||||
fgStructure.GameModeWindow->State.Height = fgState.GameModeSize.Y;
|
||||
fgStructure.GameModeWindow->State.NeedToResize = GL_TRUE;
|
||||
|
||||
fgPlatformEnterGameMode();
|
||||
|
||||
return fgStructure.GameModeWindow->ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Leaves the game mode
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" );
|
||||
|
||||
freeglut_return_if_fail( fgStructure.GameModeWindow );
|
||||
|
||||
fgAddToWindowDestroyList( fgStructure.GameModeWindow );
|
||||
fgStructure.GameModeWindow = NULL;
|
||||
|
||||
fgPlatformLeaveGameMode();
|
||||
|
||||
fgPlatformRestoreState();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns information concerning the freeglut game mode
|
||||
*/
|
||||
int FGAPIENTRY glutGameModeGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" );
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_GAME_MODE_ACTIVE:
|
||||
return !!fgStructure.GameModeWindow;
|
||||
|
||||
case GLUT_GAME_MODE_POSSIBLE:
|
||||
return fgPlatformChangeDisplayMode( GL_TRUE );
|
||||
|
||||
case GLUT_GAME_MODE_WIDTH:
|
||||
return fgState.GameModeSize.X;
|
||||
|
||||
case GLUT_GAME_MODE_HEIGHT:
|
||||
return fgState.GameModeSize.Y;
|
||||
|
||||
case GLUT_GAME_MODE_PIXEL_DEPTH:
|
||||
return fgState.GameModeDepth;
|
||||
|
||||
case GLUT_GAME_MODE_REFRESH_RATE:
|
||||
return fgState.GameModeRefresh;
|
||||
|
||||
case GLUT_GAME_MODE_DISPLAY_CHANGED:
|
||||
/*
|
||||
* This is true if the game mode has been activated successfully..
|
||||
*/
|
||||
return !!fgStructure.GameModeWindow;
|
||||
}
|
||||
|
||||
fgWarning( "Unknown gamemode get: %d", eWhat );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,213 +1,213 @@
|
||||
/*
|
||||
* freeglut_input_devices.c
|
||||
*
|
||||
* Handles miscellaneous input devices via direct serial-port access.
|
||||
* Proper X11 XInput device support is not yet supported.
|
||||
* Also lacks Mac support.
|
||||
*
|
||||
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005
|
||||
*
|
||||
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
typedef struct _serialport SERIALPORT;
|
||||
|
||||
|
||||
/********************* Dialbox definitions ***********************/
|
||||
|
||||
#define DIAL_NUM_VALUATORS 8
|
||||
|
||||
/* dial parser state machine states */
|
||||
#define DIAL_NEW (-1)
|
||||
#define DIAL_WHICH_DEVICE 0
|
||||
#define DIAL_VALUE_HIGH 1
|
||||
#define DIAL_VALUE_LOW 2
|
||||
|
||||
/* dial/button box commands */
|
||||
#define DIAL_INITIALIZE 0x20
|
||||
#define DIAL_SET_LEDS 0x75
|
||||
#define DIAL_SET_TEXT 0x61
|
||||
#define DIAL_SET_AUTO_DIALS 0x50
|
||||
#define DIAL_SET_AUTO_DELTA_DIALS 0x51
|
||||
#define DIAL_SET_FILTER 0x53
|
||||
#define DIAL_SET_BUTTONS_MOM_TYPE 0x71
|
||||
#define DIAL_SET_AUTO_MOM_BUTTONS 0x73
|
||||
#define DIAL_SET_ALL_LEDS 0x4b
|
||||
#define DIAL_CLEAR_ALL_LEDS 0x4c
|
||||
|
||||
/* dial/button box replies and events */
|
||||
#define DIAL_INITIALIZED 0x20
|
||||
#define DIAL_BASE 0x30
|
||||
#define DIAL_DELTA_BASE 0x40
|
||||
#define DIAL_PRESS_BASE 0xc0
|
||||
#define DIAL_RELEASE_BASE 0xe0
|
||||
|
||||
/* macros to determine reply type */
|
||||
#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_RELEASE(ch) (((ch)>=DIAL_RELEASE_BASE)&&((ch)<DIAL_RELEASE_BASE+DIAL_NUM_BUTTONS))
|
||||
#define IS_INIT_EVENT(ch) ((ch)==DIAL_INITIALIZED)
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
extern SERIALPORT *serial_open ( const char *device );
|
||||
extern void serial_close ( SERIALPORT *port );
|
||||
extern int serial_getchar ( SERIALPORT *port );
|
||||
extern int serial_putchar ( SERIALPORT *port, unsigned char ch );
|
||||
extern void serial_flush ( SERIALPORT *port );
|
||||
|
||||
extern void fgPlatformRegisterDialDevice ( const char *dial_device );
|
||||
static void send_dial_event(int dial, int value);
|
||||
static void poll_dials(int id);
|
||||
|
||||
/* local variables */
|
||||
static SERIALPORT *dialbox_port=NULL;
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Implementation for glutDeviceGet(GLUT_HAS_DIAL_AND_BUTTON_BOX)
|
||||
*/
|
||||
int fgInputDeviceDetect( void )
|
||||
{
|
||||
fgInitialiseInputDevices ();
|
||||
|
||||
if ( !dialbox_port )
|
||||
return 0;
|
||||
|
||||
if ( !fgState.InputDevsInitialised )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try initializing the input device(s)
|
||||
*/
|
||||
void fgInitialiseInputDevices ( void )
|
||||
{
|
||||
if( !fgState.InputDevsInitialised )
|
||||
{
|
||||
const char *dial_device=NULL;
|
||||
dial_device = getenv ( "GLUT_DIALS_SERIAL" );
|
||||
fgPlatformRegisterDialDevice ( dial_device );
|
||||
|
||||
if ( !dial_device ) return;
|
||||
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
|
||||
serial_putchar(dialbox_port,DIAL_INITIALIZE);
|
||||
glutTimerFunc ( 10, poll_dials, 0 );
|
||||
fgState.InputDevsInitialised = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void fgInputDeviceClose( void )
|
||||
{
|
||||
if ( fgState.InputDevsInitialised )
|
||||
{
|
||||
serial_close ( dialbox_port );
|
||||
dialbox_port = NULL;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
/* Check all windows for dialbox callbacks */
|
||||
static void fghcbEnumDialCallbacks ( SFG_Window *window, SFG_Enumerator *enumerator )
|
||||
{
|
||||
/* Built-in to INVOKE_WCB(): if window->Callbacks[CB_Dials] */
|
||||
INVOKE_WCB ( *window,Dials, ( ((int*)enumerator->data)[0], ((int*)enumerator->data)[1]) );
|
||||
fgEnumSubWindows ( window, fghcbEnumDialCallbacks, enumerator );
|
||||
}
|
||||
|
||||
static void send_dial_event ( int num, int value )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
int data[2];
|
||||
data[0] = num;
|
||||
data[1] = value;
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = data;
|
||||
fgEnumWindows ( fghcbEnumDialCallbacks, &enumerator );
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
static void poll_dials ( int id )
|
||||
{
|
||||
int data;
|
||||
static int dial_state = DIAL_NEW;
|
||||
static int dial_which;
|
||||
static int dial_value;
|
||||
static int dials[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
if ( !dialbox_port ) return;
|
||||
|
||||
while ( (data=serial_getchar(dialbox_port)) != EOF )
|
||||
{
|
||||
if ( ( dial_state > DIAL_WHICH_DEVICE ) || IS_DIAL_EVENT ( data ) )
|
||||
{
|
||||
switch ( dial_state )
|
||||
{
|
||||
case DIAL_WHICH_DEVICE:
|
||||
dial_which = data - DIAL_BASE;
|
||||
dial_state++;
|
||||
break;
|
||||
case DIAL_VALUE_HIGH:
|
||||
dial_value = ( data << 8 );
|
||||
dial_state++;
|
||||
break;
|
||||
case DIAL_VALUE_LOW:
|
||||
dial_value |= data;
|
||||
if ( dial_value & 0x8000 ) dial_value -= 0x10000;
|
||||
dials[dial_which] = dial_value;
|
||||
send_dial_event ( dial_which + 1, dial_value * 360 / 256 );
|
||||
dial_state = DIAL_WHICH_DEVICE;
|
||||
break;
|
||||
default:
|
||||
/* error: Impossible state value! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( data == DIAL_INITIALIZED )
|
||||
{
|
||||
fgState.InputDevsInitialised = GL_TRUE;
|
||||
dial_state = DIAL_WHICH_DEVICE;
|
||||
serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS);
|
||||
serial_putchar(dialbox_port,0xff);
|
||||
serial_putchar(dialbox_port,0xff);
|
||||
}
|
||||
else /* Unknown data; try flushing. */
|
||||
serial_flush(dialbox_port);
|
||||
}
|
||||
|
||||
glutTimerFunc ( 2, poll_dials, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_input_devices.c
|
||||
*
|
||||
* Handles miscellaneous input devices via direct serial-port access.
|
||||
* Proper X11 XInput device support is not yet supported.
|
||||
* Also lacks Mac support.
|
||||
*
|
||||
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005
|
||||
*
|
||||
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
typedef struct _serialport SERIALPORT;
|
||||
|
||||
|
||||
/********************* Dialbox definitions ***********************/
|
||||
|
||||
#define DIAL_NUM_VALUATORS 8
|
||||
|
||||
/* dial parser state machine states */
|
||||
#define DIAL_NEW (-1)
|
||||
#define DIAL_WHICH_DEVICE 0
|
||||
#define DIAL_VALUE_HIGH 1
|
||||
#define DIAL_VALUE_LOW 2
|
||||
|
||||
/* dial/button box commands */
|
||||
#define DIAL_INITIALIZE 0x20
|
||||
#define DIAL_SET_LEDS 0x75
|
||||
#define DIAL_SET_TEXT 0x61
|
||||
#define DIAL_SET_AUTO_DIALS 0x50
|
||||
#define DIAL_SET_AUTO_DELTA_DIALS 0x51
|
||||
#define DIAL_SET_FILTER 0x53
|
||||
#define DIAL_SET_BUTTONS_MOM_TYPE 0x71
|
||||
#define DIAL_SET_AUTO_MOM_BUTTONS 0x73
|
||||
#define DIAL_SET_ALL_LEDS 0x4b
|
||||
#define DIAL_CLEAR_ALL_LEDS 0x4c
|
||||
|
||||
/* dial/button box replies and events */
|
||||
#define DIAL_INITIALIZED 0x20
|
||||
#define DIAL_BASE 0x30
|
||||
#define DIAL_DELTA_BASE 0x40
|
||||
#define DIAL_PRESS_BASE 0xc0
|
||||
#define DIAL_RELEASE_BASE 0xe0
|
||||
|
||||
/* macros to determine reply type */
|
||||
#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_RELEASE(ch) (((ch)>=DIAL_RELEASE_BASE)&&((ch)<DIAL_RELEASE_BASE+DIAL_NUM_BUTTONS))
|
||||
#define IS_INIT_EVENT(ch) ((ch)==DIAL_INITIALIZED)
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
extern SERIALPORT *serial_open ( const char *device );
|
||||
extern void serial_close ( SERIALPORT *port );
|
||||
extern int serial_getchar ( SERIALPORT *port );
|
||||
extern int serial_putchar ( SERIALPORT *port, unsigned char ch );
|
||||
extern void serial_flush ( SERIALPORT *port );
|
||||
|
||||
extern void fgPlatformRegisterDialDevice ( const char *dial_device );
|
||||
static void send_dial_event(int dial, int value);
|
||||
static void poll_dials(int id);
|
||||
|
||||
/* local variables */
|
||||
static SERIALPORT *dialbox_port=NULL;
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Implementation for glutDeviceGet(GLUT_HAS_DIAL_AND_BUTTON_BOX)
|
||||
*/
|
||||
int fgInputDeviceDetect( void )
|
||||
{
|
||||
fgInitialiseInputDevices ();
|
||||
|
||||
if ( !dialbox_port )
|
||||
return 0;
|
||||
|
||||
if ( !fgState.InputDevsInitialised )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try initializing the input device(s)
|
||||
*/
|
||||
void fgInitialiseInputDevices ( void )
|
||||
{
|
||||
if( !fgState.InputDevsInitialised )
|
||||
{
|
||||
const char *dial_device=NULL;
|
||||
dial_device = getenv ( "GLUT_DIALS_SERIAL" );
|
||||
fgPlatformRegisterDialDevice ( dial_device );
|
||||
|
||||
if ( !dial_device ) return;
|
||||
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
|
||||
serial_putchar(dialbox_port,DIAL_INITIALIZE);
|
||||
glutTimerFunc ( 10, poll_dials, 0 );
|
||||
fgState.InputDevsInitialised = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void fgInputDeviceClose( void )
|
||||
{
|
||||
if ( fgState.InputDevsInitialised )
|
||||
{
|
||||
serial_close ( dialbox_port );
|
||||
dialbox_port = NULL;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
/* Check all windows for dialbox callbacks */
|
||||
static void fghcbEnumDialCallbacks ( SFG_Window *window, SFG_Enumerator *enumerator )
|
||||
{
|
||||
/* Built-in to INVOKE_WCB(): if window->Callbacks[CB_Dials] */
|
||||
INVOKE_WCB ( *window,Dials, ( ((int*)enumerator->data)[0], ((int*)enumerator->data)[1]) );
|
||||
fgEnumSubWindows ( window, fghcbEnumDialCallbacks, enumerator );
|
||||
}
|
||||
|
||||
static void send_dial_event ( int num, int value )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
int data[2];
|
||||
data[0] = num;
|
||||
data[1] = value;
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = data;
|
||||
fgEnumWindows ( fghcbEnumDialCallbacks, &enumerator );
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
static void poll_dials ( int id )
|
||||
{
|
||||
int data;
|
||||
static int dial_state = DIAL_NEW;
|
||||
static int dial_which;
|
||||
static int dial_value;
|
||||
static int dials[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
if ( !dialbox_port ) return;
|
||||
|
||||
while ( (data=serial_getchar(dialbox_port)) != EOF )
|
||||
{
|
||||
if ( ( dial_state > DIAL_WHICH_DEVICE ) || IS_DIAL_EVENT ( data ) )
|
||||
{
|
||||
switch ( dial_state )
|
||||
{
|
||||
case DIAL_WHICH_DEVICE:
|
||||
dial_which = data - DIAL_BASE;
|
||||
dial_state++;
|
||||
break;
|
||||
case DIAL_VALUE_HIGH:
|
||||
dial_value = ( data << 8 );
|
||||
dial_state++;
|
||||
break;
|
||||
case DIAL_VALUE_LOW:
|
||||
dial_value |= data;
|
||||
if ( dial_value & 0x8000 ) dial_value -= 0x10000;
|
||||
dials[dial_which] = dial_value;
|
||||
send_dial_event ( dial_which + 1, dial_value * 360 / 256 );
|
||||
dial_state = DIAL_WHICH_DEVICE;
|
||||
break;
|
||||
default:
|
||||
/* error: Impossible state value! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( data == DIAL_INITIALIZED )
|
||||
{
|
||||
fgState.InputDevsInitialised = GL_TRUE;
|
||||
dial_state = DIAL_WHICH_DEVICE;
|
||||
serial_putchar(dialbox_port,DIAL_SET_AUTO_DIALS);
|
||||
serial_putchar(dialbox_port,0xff);
|
||||
serial_putchar(dialbox_port,0xff);
|
||||
}
|
||||
else /* Unknown data; try flushing. */
|
||||
serial_flush(dialbox_port);
|
||||
}
|
||||
|
||||
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
@ -1,476 +1,476 @@
|
||||
/*
|
||||
* freeglut_main.c
|
||||
*
|
||||
* The windows message processing methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
#ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_VFPRINTF
|
||||
# define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
|
||||
#elif defined(HAVE__DOPRNT)
|
||||
# define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
|
||||
#else
|
||||
# define VFPRINTF(s,f,a)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
typedef struct GXDisplayProperties GXDisplayProperties;
|
||||
typedef struct GXKeyList GXKeyList;
|
||||
#include <gx.h>
|
||||
|
||||
typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
|
||||
typedef int (*GXOPENINPUT)();
|
||||
|
||||
GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
|
||||
GXOPENINPUT GXOpenInput_ = NULL;
|
||||
|
||||
struct GXKeyList gxKeyList;
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
/*
|
||||
* Try to get the maximum value allowed for ints, falling back to the minimum
|
||||
* guaranteed by ISO C99 if there is no suitable header.
|
||||
*/
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX 32767
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (((a)<(b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
|
||||
extern void fgPlatformDisplayWindow ( SFG_Window *window );
|
||||
extern unsigned long fgPlatformSystemTime ( void );
|
||||
extern void fgPlatformSleepForEvents( long msec );
|
||||
extern void fgPlatformProcessSingleEvent ( void );
|
||||
extern void fgPlatformMainLoopPreliminaryWork ( void );
|
||||
|
||||
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
static void fghReshapeWindow ( SFG_Window *window, int width, int height )
|
||||
{
|
||||
SFG_Window *current_window = fgStructure.CurrentWindow;
|
||||
|
||||
freeglut_return_if_fail( window != NULL );
|
||||
|
||||
fgPlatformReshapeWindow ( window, width, height );
|
||||
|
||||
if( FETCH_WCB( *window, Reshape ) )
|
||||
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
||||
else
|
||||
{
|
||||
fgSetWindow( window );
|
||||
glViewport( 0, 0, width, height );
|
||||
}
|
||||
|
||||
/*
|
||||
* Force a window redraw. In Windows at least this is only a partial
|
||||
* solution: if the window is increasing in size in either dimension,
|
||||
* 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
|
||||
* window.
|
||||
*/
|
||||
window->State.Redisplay = GL_TRUE;
|
||||
|
||||
if( window->IsMenu )
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
/*
|
||||
* Calls a window's redraw method. This is used when
|
||||
* a redraw is forced by the incoming window messages.
|
||||
*/
|
||||
void fghRedrawWindow ( SFG_Window *window )
|
||||
{
|
||||
SFG_Window *current_window = fgStructure.CurrentWindow;
|
||||
|
||||
freeglut_return_if_fail( window );
|
||||
freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
|
||||
|
||||
window->State.Redisplay = GL_FALSE;
|
||||
|
||||
freeglut_return_if_fail( window->State.Visible );
|
||||
|
||||
fgSetWindow( window );
|
||||
|
||||
if( window->State.NeedToResize )
|
||||
{
|
||||
fghReshapeWindow(
|
||||
window,
|
||||
window->State.Width,
|
||||
window->State.Height
|
||||
);
|
||||
|
||||
window->State.NeedToResize = GL_FALSE;
|
||||
}
|
||||
|
||||
INVOKE_WCB( *window, Display, ( ) );
|
||||
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
|
||||
static void fghcbDisplayWindow( SFG_Window *window,
|
||||
SFG_Enumerator *enumerator )
|
||||
{
|
||||
if( window->State.Redisplay &&
|
||||
window->State.Visible )
|
||||
{
|
||||
window->State.Redisplay = GL_FALSE;
|
||||
fgPlatformDisplayWindow ( window );
|
||||
}
|
||||
|
||||
fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Make all windows perform a display call
|
||||
*/
|
||||
static void fghDisplayAll( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
|
||||
fgEnumWindows( fghcbDisplayWindow, &enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window enumerator callback to check for the joystick polling code
|
||||
*/
|
||||
static void fghcbCheckJoystickPolls( SFG_Window *window,
|
||||
SFG_Enumerator *enumerator )
|
||||
{
|
||||
long int checkTime = fgElapsedTime( );
|
||||
|
||||
if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
|
||||
checkTime )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
fgJoystickPollWindow( window );
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
window->State.JoystickLastPoll = checkTime;
|
||||
}
|
||||
|
||||
fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all windows for joystick polling
|
||||
*/
|
||||
static void fghCheckJoystickPolls( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
|
||||
fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the global timers
|
||||
*/
|
||||
static void fghCheckTimers( void )
|
||||
{
|
||||
long checkTime = fgElapsedTime( );
|
||||
|
||||
while( fgState.Timers.First )
|
||||
{
|
||||
SFG_Timer *timer = fgState.Timers.First;
|
||||
|
||||
if( timer->TriggerTime > checkTime )
|
||||
break;
|
||||
|
||||
fgListRemove( &fgState.Timers, &timer->Node );
|
||||
fgListAppend( &fgState.FreeTimers, &timer->Node );
|
||||
|
||||
timer->Callback( timer->ID );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
|
||||
* This value wraps every 49.7 days, but integer overflows cancel
|
||||
* when subtracting an initial start time, unless the total time exceeds
|
||||
* 32-bit, where the GLUT API return value is also overflowed.
|
||||
*/
|
||||
unsigned long fgSystemTime(void)
|
||||
{
|
||||
return fgPlatformSystemTime ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Elapsed Time
|
||||
*/
|
||||
long fgElapsedTime( void )
|
||||
{
|
||||
return (long) (fgSystemTime() - fgState.Time);
|
||||
}
|
||||
|
||||
/*
|
||||
* Error Messages.
|
||||
*/
|
||||
void fgError( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (fgState.ErrorFunc) {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
/* call user set error handler here */
|
||||
fgState.ErrorFunc(fmt, ap);
|
||||
|
||||
va_end( ap );
|
||||
|
||||
} else {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
if( fgState.ProgramName )
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
VFPRINTF( stderr, fmt, ap );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
va_end( ap );
|
||||
|
||||
if ( fgState.Initialised )
|
||||
fgDeinitialize ();
|
||||
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void fgWarning( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (fgState.WarningFunc) {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
/* call user set warning handler here */
|
||||
fgState.WarningFunc(fmt, ap);
|
||||
|
||||
va_end( ap );
|
||||
|
||||
} else {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
if( fgState.ProgramName )
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
VFPRINTF( stderr, fmt, ap );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
va_end( ap );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Indicates whether Joystick events are being used by ANY window.
|
||||
*
|
||||
* The current mechanism is to walk all of the windows and ask if
|
||||
* there is a joystick callback. We have a short-circuit early
|
||||
* return if we find any joystick handler registered.
|
||||
*
|
||||
* 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
|
||||
* and all other "joystick timer" code can be yanked.
|
||||
*
|
||||
*/
|
||||
static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
{
|
||||
if( FETCH_WCB( *w, Joystick ) )
|
||||
{
|
||||
e->found = GL_TRUE;
|
||||
e->data = w;
|
||||
}
|
||||
fgEnumSubWindows( w, fghCheckJoystickCallback, e );
|
||||
}
|
||||
static int fghHaveJoystick( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghCheckJoystickCallback, &enumerator );
|
||||
return !!enumerator.data;
|
||||
}
|
||||
static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
{
|
||||
if( w->State.Redisplay && w->State.Visible )
|
||||
{
|
||||
e->found = GL_TRUE;
|
||||
e->data = w;
|
||||
}
|
||||
fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
|
||||
}
|
||||
static int fghHavePendingRedisplays (void)
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
|
||||
return !!enumerator.data;
|
||||
}
|
||||
/*
|
||||
* Returns the number of GLUT ticks (milliseconds) till the next timer event.
|
||||
*/
|
||||
static long fghNextTimer( void )
|
||||
{
|
||||
long ret = INT_MAX;
|
||||
SFG_Timer *timer = fgState.Timers.First;
|
||||
|
||||
if( timer )
|
||||
ret = timer->TriggerTime - fgElapsedTime();
|
||||
if( ret < 0 )
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fghSleepForEvents( void )
|
||||
{
|
||||
long msec;
|
||||
|
||||
if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
|
||||
return;
|
||||
|
||||
msec = fghNextTimer( );
|
||||
/* XXX Use GLUT timers for joysticks... */
|
||||
/* XXX Dumb; forces granularity to .01sec */
|
||||
if( fghHaveJoystick( ) && ( msec > 10 ) )
|
||||
msec = 10;
|
||||
|
||||
fgPlatformSleepForEvents ( msec );
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Executes a single iteration in the freeglut processing loop.
|
||||
*/
|
||||
void FGAPIENTRY glutMainLoopEvent( void )
|
||||
{
|
||||
fgPlatformProcessSingleEvent ();
|
||||
|
||||
if( fgState.Timers.First )
|
||||
fghCheckTimers( );
|
||||
fghCheckJoystickPolls( );
|
||||
fghDisplayAll( );
|
||||
|
||||
fgCloseWindows( );
|
||||
}
|
||||
|
||||
/*
|
||||
* Enters the freeglut processing loop.
|
||||
* Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
|
||||
*/
|
||||
void FGAPIENTRY glutMainLoop( void )
|
||||
{
|
||||
int action;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
|
||||
|
||||
fgPlatformMainLoopPreliminaryWork ();
|
||||
|
||||
fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
|
||||
while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
|
||||
{
|
||||
SFG_Window *window;
|
||||
|
||||
glutMainLoopEvent( );
|
||||
/*
|
||||
* Step through the list of windows, seeing if there are any
|
||||
* that are not menus
|
||||
*/
|
||||
for( window = ( SFG_Window * )fgStructure.Windows.First;
|
||||
window;
|
||||
window = ( SFG_Window * )window->Node.Next )
|
||||
if ( ! ( window->IsMenu ) )
|
||||
break;
|
||||
|
||||
if( ! window )
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP;
|
||||
else
|
||||
{
|
||||
if( fgState.IdleCallback )
|
||||
{
|
||||
if( fgStructure.CurrentWindow &&
|
||||
fgStructure.CurrentWindow->IsMenu )
|
||||
/* fail safe */
|
||||
fgSetWindow( window );
|
||||
fgState.IdleCallback( );
|
||||
}
|
||||
|
||||
fghSleepForEvents( );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When this loop terminates, destroy the display, state and structure
|
||||
* of a freeglut session, so that another glutInit() call can happen
|
||||
*
|
||||
* Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
|
||||
*/
|
||||
action = fgState.ActionOnWindowClose;
|
||||
fgDeinitialize( );
|
||||
if( action == GLUT_ACTION_EXIT )
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Leaves the freeglut processing loop.
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveMainLoop( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_main.c
|
||||
*
|
||||
* The windows message processing methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 3 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
#ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_VFPRINTF
|
||||
# define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
|
||||
#elif defined(HAVE__DOPRNT)
|
||||
# define VFPRINTF(s,f,a) _doprnt((f),(a),(s))
|
||||
#else
|
||||
# define VFPRINTF(s,f,a)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
||||
typedef struct GXDisplayProperties GXDisplayProperties;
|
||||
typedef struct GXKeyList GXKeyList;
|
||||
#include <gx.h>
|
||||
|
||||
typedef struct GXKeyList (*GXGETDEFAULTKEYS)(int);
|
||||
typedef int (*GXOPENINPUT)();
|
||||
|
||||
GXGETDEFAULTKEYS GXGetDefaultKeys_ = NULL;
|
||||
GXOPENINPUT GXOpenInput_ = NULL;
|
||||
|
||||
struct GXKeyList gxKeyList;
|
||||
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
/*
|
||||
* Try to get the maximum value allowed for ints, falling back to the minimum
|
||||
* guaranteed by ISO C99 if there is no suitable header.
|
||||
*/
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX 32767
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (((a)<(b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height );
|
||||
extern void fgPlatformDisplayWindow ( SFG_Window *window );
|
||||
extern unsigned long fgPlatformSystemTime ( void );
|
||||
extern void fgPlatformSleepForEvents( long msec );
|
||||
extern void fgPlatformProcessSingleEvent ( void );
|
||||
extern void fgPlatformMainLoopPreliminaryWork ( void );
|
||||
|
||||
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
static void fghReshapeWindow ( SFG_Window *window, int width, int height )
|
||||
{
|
||||
SFG_Window *current_window = fgStructure.CurrentWindow;
|
||||
|
||||
freeglut_return_if_fail( window != NULL );
|
||||
|
||||
fgPlatformReshapeWindow ( window, width, height );
|
||||
|
||||
if( FETCH_WCB( *window, Reshape ) )
|
||||
INVOKE_WCB( *window, Reshape, ( width, height ) );
|
||||
else
|
||||
{
|
||||
fgSetWindow( window );
|
||||
glViewport( 0, 0, width, height );
|
||||
}
|
||||
|
||||
/*
|
||||
* Force a window redraw. In Windows at least this is only a partial
|
||||
* solution: if the window is increasing in size in either dimension,
|
||||
* 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
|
||||
* window.
|
||||
*/
|
||||
window->State.Redisplay = GL_TRUE;
|
||||
|
||||
if( window->IsMenu )
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
/*
|
||||
* Calls a window's redraw method. This is used when
|
||||
* a redraw is forced by the incoming window messages.
|
||||
*/
|
||||
void fghRedrawWindow ( SFG_Window *window )
|
||||
{
|
||||
SFG_Window *current_window = fgStructure.CurrentWindow;
|
||||
|
||||
freeglut_return_if_fail( window );
|
||||
freeglut_return_if_fail( FETCH_WCB ( *window, Display ) );
|
||||
|
||||
window->State.Redisplay = GL_FALSE;
|
||||
|
||||
freeglut_return_if_fail( window->State.Visible );
|
||||
|
||||
fgSetWindow( window );
|
||||
|
||||
if( window->State.NeedToResize )
|
||||
{
|
||||
fghReshapeWindow(
|
||||
window,
|
||||
window->State.Width,
|
||||
window->State.Height
|
||||
);
|
||||
|
||||
window->State.NeedToResize = GL_FALSE;
|
||||
}
|
||||
|
||||
INVOKE_WCB( *window, Display, ( ) );
|
||||
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
|
||||
static void fghcbDisplayWindow( SFG_Window *window,
|
||||
SFG_Enumerator *enumerator )
|
||||
{
|
||||
if( window->State.Redisplay &&
|
||||
window->State.Visible )
|
||||
{
|
||||
window->State.Redisplay = GL_FALSE;
|
||||
fgPlatformDisplayWindow ( window );
|
||||
}
|
||||
|
||||
fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Make all windows perform a display call
|
||||
*/
|
||||
static void fghDisplayAll( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
|
||||
fgEnumWindows( fghcbDisplayWindow, &enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Window enumerator callback to check for the joystick polling code
|
||||
*/
|
||||
static void fghcbCheckJoystickPolls( SFG_Window *window,
|
||||
SFG_Enumerator *enumerator )
|
||||
{
|
||||
long int checkTime = fgElapsedTime( );
|
||||
|
||||
if( window->State.JoystickLastPoll + window->State.JoystickPollRate <=
|
||||
checkTime )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
fgJoystickPollWindow( window );
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
window->State.JoystickLastPoll = checkTime;
|
||||
}
|
||||
|
||||
fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all windows for joystick polling
|
||||
*/
|
||||
static void fghCheckJoystickPolls( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
|
||||
fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the global timers
|
||||
*/
|
||||
static void fghCheckTimers( void )
|
||||
{
|
||||
long checkTime = fgElapsedTime( );
|
||||
|
||||
while( fgState.Timers.First )
|
||||
{
|
||||
SFG_Timer *timer = fgState.Timers.First;
|
||||
|
||||
if( timer->TriggerTime > checkTime )
|
||||
break;
|
||||
|
||||
fgListRemove( &fgState.Timers, &timer->Node );
|
||||
fgListAppend( &fgState.FreeTimers, &timer->Node );
|
||||
|
||||
timer->Callback( timer->ID );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Platform-dependent time in milliseconds, as an unsigned 32-bit integer.
|
||||
* This value wraps every 49.7 days, but integer overflows cancel
|
||||
* when subtracting an initial start time, unless the total time exceeds
|
||||
* 32-bit, where the GLUT API return value is also overflowed.
|
||||
*/
|
||||
unsigned long fgSystemTime(void)
|
||||
{
|
||||
return fgPlatformSystemTime ();
|
||||
}
|
||||
|
||||
/*
|
||||
* Elapsed Time
|
||||
*/
|
||||
long fgElapsedTime( void )
|
||||
{
|
||||
return (long) (fgSystemTime() - fgState.Time);
|
||||
}
|
||||
|
||||
/*
|
||||
* Error Messages.
|
||||
*/
|
||||
void fgError( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (fgState.ErrorFunc) {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
/* call user set error handler here */
|
||||
fgState.ErrorFunc(fmt, ap);
|
||||
|
||||
va_end( ap );
|
||||
|
||||
} else {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
if( fgState.ProgramName )
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
VFPRINTF( stderr, fmt, ap );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
va_end( ap );
|
||||
|
||||
if ( fgState.Initialised )
|
||||
fgDeinitialize ();
|
||||
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void fgWarning( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (fgState.WarningFunc) {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
/* call user set warning handler here */
|
||||
fgState.WarningFunc(fmt, ap);
|
||||
|
||||
va_end( ap );
|
||||
|
||||
} else {
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
if( fgState.ProgramName )
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
VFPRINTF( stderr, fmt, ap );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
va_end( ap );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Indicates whether Joystick events are being used by ANY window.
|
||||
*
|
||||
* The current mechanism is to walk all of the windows and ask if
|
||||
* there is a joystick callback. We have a short-circuit early
|
||||
* return if we find any joystick handler registered.
|
||||
*
|
||||
* 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
|
||||
* and all other "joystick timer" code can be yanked.
|
||||
*
|
||||
*/
|
||||
static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
{
|
||||
if( FETCH_WCB( *w, Joystick ) )
|
||||
{
|
||||
e->found = GL_TRUE;
|
||||
e->data = w;
|
||||
}
|
||||
fgEnumSubWindows( w, fghCheckJoystickCallback, e );
|
||||
}
|
||||
static int fghHaveJoystick( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghCheckJoystickCallback, &enumerator );
|
||||
return !!enumerator.data;
|
||||
}
|
||||
static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
{
|
||||
if( w->State.Redisplay && w->State.Visible )
|
||||
{
|
||||
e->found = GL_TRUE;
|
||||
e->data = w;
|
||||
}
|
||||
fgEnumSubWindows( w, fghHavePendingRedisplaysCallback, e );
|
||||
}
|
||||
static int fghHavePendingRedisplays (void)
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
|
||||
return !!enumerator.data;
|
||||
}
|
||||
/*
|
||||
* Returns the number of GLUT ticks (milliseconds) till the next timer event.
|
||||
*/
|
||||
static long fghNextTimer( void )
|
||||
{
|
||||
long ret = INT_MAX;
|
||||
SFG_Timer *timer = fgState.Timers.First;
|
||||
|
||||
if( timer )
|
||||
ret = timer->TriggerTime - fgElapsedTime();
|
||||
if( ret < 0 )
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fghSleepForEvents( void )
|
||||
{
|
||||
long msec;
|
||||
|
||||
if( fgState.IdleCallback || fghHavePendingRedisplays( ) )
|
||||
return;
|
||||
|
||||
msec = fghNextTimer( );
|
||||
/* XXX Use GLUT timers for joysticks... */
|
||||
/* XXX Dumb; forces granularity to .01sec */
|
||||
if( fghHaveJoystick( ) && ( msec > 10 ) )
|
||||
msec = 10;
|
||||
|
||||
fgPlatformSleepForEvents ( msec );
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Executes a single iteration in the freeglut processing loop.
|
||||
*/
|
||||
void FGAPIENTRY glutMainLoopEvent( void )
|
||||
{
|
||||
fgPlatformProcessSingleEvent ();
|
||||
|
||||
if( fgState.Timers.First )
|
||||
fghCheckTimers( );
|
||||
fghCheckJoystickPolls( );
|
||||
fghDisplayAll( );
|
||||
|
||||
fgCloseWindows( );
|
||||
}
|
||||
|
||||
/*
|
||||
* Enters the freeglut processing loop.
|
||||
* Stays until the "ExecState" changes to "GLUT_EXEC_STATE_STOP".
|
||||
*/
|
||||
void FGAPIENTRY glutMainLoop( void )
|
||||
{
|
||||
int action;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
|
||||
|
||||
fgPlatformMainLoopPreliminaryWork ();
|
||||
|
||||
fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
|
||||
while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
|
||||
{
|
||||
SFG_Window *window;
|
||||
|
||||
glutMainLoopEvent( );
|
||||
/*
|
||||
* Step through the list of windows, seeing if there are any
|
||||
* that are not menus
|
||||
*/
|
||||
for( window = ( SFG_Window * )fgStructure.Windows.First;
|
||||
window;
|
||||
window = ( SFG_Window * )window->Node.Next )
|
||||
if ( ! ( window->IsMenu ) )
|
||||
break;
|
||||
|
||||
if( ! window )
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP;
|
||||
else
|
||||
{
|
||||
if( fgState.IdleCallback )
|
||||
{
|
||||
if( fgStructure.CurrentWindow &&
|
||||
fgStructure.CurrentWindow->IsMenu )
|
||||
/* fail safe */
|
||||
fgSetWindow( window );
|
||||
fgState.IdleCallback( );
|
||||
}
|
||||
|
||||
fghSleepForEvents( );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When this loop terminates, destroy the display, state and structure
|
||||
* of a freeglut session, so that another glutInit() call can happen
|
||||
*
|
||||
* Save the "ActionOnWindowClose" because "fgDeinitialize" resets it.
|
||||
*/
|
||||
action = fgState.ActionOnWindowClose;
|
||||
fgDeinitialize( );
|
||||
if( action == GLUT_ACTION_EXIT )
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Leaves the freeglut processing loop.
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveMainLoop( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,214 +1,214 @@
|
||||
/*
|
||||
* freeglut_misc.c
|
||||
*
|
||||
* Functions that didn't fit anywhere else...
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 9 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutSetColor() --
|
||||
* glutGetColor() --
|
||||
* glutCopyColormap() --
|
||||
* glutSetKeyRepeat() -- this is evil and should be removed from API
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This functions checks if an OpenGL extension is supported or not
|
||||
*
|
||||
* XXX Wouldn't this be simpler and clearer if we used strtok()?
|
||||
*/
|
||||
int FGAPIENTRY glutExtensionSupported( const char* extension )
|
||||
{
|
||||
const char *extensions, *start;
|
||||
const size_t len = strlen( extension );
|
||||
|
||||
/* Make sure there is a current window, and thus a current context available */
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" );
|
||||
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
|
||||
|
||||
if (strchr(extension, ' '))
|
||||
return 0;
|
||||
start = extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
/* XXX consider printing a warning to stderr that there's no current
|
||||
* rendering context.
|
||||
*/
|
||||
freeglut_return_val_if_fail( extensions != NULL, 0 );
|
||||
|
||||
while (1) {
|
||||
const char *p = strstr(extensions, extension);
|
||||
if (!p)
|
||||
return 0; /* not found */
|
||||
/* check that the match isn't a super string */
|
||||
if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
|
||||
return 1;
|
||||
/* skip the false match and continue */
|
||||
extensions = p + len;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#ifndef GL_INVALID_FRAMEBUFFER_OPERATION
|
||||
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#else
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_TABLE_TOO_LARGE
|
||||
#ifdef GL_TABLE_TOO_LARGE_EXT
|
||||
#define GL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE_EXT
|
||||
#else
|
||||
#define GL_TABLE_TOO_LARGE 0x8031
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_TEXTURE_TOO_LARGE
|
||||
#ifdef GL_TEXTURE_TOO_LARGE_EXT
|
||||
#define GL_TEXTURE_TOO_LARGE GL_TEXTURE_TOO_LARGE_EXT
|
||||
#else
|
||||
#define GL_TEXTURE_TOO_LARGE 0x8065
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A cut-down local version of gluErrorString to avoid depending on GLU.
|
||||
*/
|
||||
static const char* fghErrorString( GLenum error )
|
||||
{
|
||||
switch ( error ) {
|
||||
case GL_INVALID_ENUM: return "invalid enumerant";
|
||||
case GL_INVALID_VALUE: return "invalid value";
|
||||
case GL_INVALID_OPERATION: return "invalid operation";
|
||||
case GL_STACK_OVERFLOW: return "stack overflow";
|
||||
case GL_STACK_UNDERFLOW: return "stack underflow";
|
||||
case GL_OUT_OF_MEMORY: return "out of memory";
|
||||
case GL_TABLE_TOO_LARGE: return "table too large";
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION: return "invalid framebuffer operation";
|
||||
case GL_TEXTURE_TOO_LARGE: return "texture too large";
|
||||
default: return "unknown GL error";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function reports all the OpenGL errors that happened till now
|
||||
*/
|
||||
void FGAPIENTRY glutReportErrors( void )
|
||||
{
|
||||
GLenum error;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" );
|
||||
while( ( error = glGetError() ) != GL_NO_ERROR )
|
||||
fgWarning( "GL error: %s", fghErrorString( error ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Control the auto-repeat of keystrokes to the current window
|
||||
*/
|
||||
void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" );
|
||||
|
||||
fgStructure.CurrentWindow->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set global auto-repeat of keystrokes
|
||||
*
|
||||
* RepeatMode should be either:
|
||||
* GLUT_KEY_REPEAT_OFF
|
||||
* GLUT_KEY_REPEAT_ON
|
||||
* GLUT_KEY_REPEAT_DEFAULT
|
||||
*/
|
||||
void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" );
|
||||
|
||||
switch( repeatMode )
|
||||
{
|
||||
case GLUT_KEY_REPEAT_OFF:
|
||||
case GLUT_KEY_REPEAT_ON:
|
||||
fgState.KeyRepeat = repeatMode;
|
||||
break;
|
||||
|
||||
case GLUT_KEY_REPEAT_DEFAULT:
|
||||
fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgError ("Invalid glutSetKeyRepeat mode: %d", repeatMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Forces the joystick callback to be executed
|
||||
*/
|
||||
void FGAPIENTRY glutForceJoystickFunc( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutForceJoystickFunc" );
|
||||
#if !defined(_WIN32_WCE)
|
||||
freeglut_return_if_fail( fgStructure.CurrentWindow != NULL );
|
||||
freeglut_return_if_fail( FETCH_WCB( *( fgStructure.CurrentWindow ), Joystick ) );
|
||||
fgJoystickPollWindow( fgStructure.CurrentWindow );
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutGetColor( int color, int component )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" );
|
||||
/* We really need to do something here. */
|
||||
return( 0.0f );
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void FGAPIENTRY glutCopyColormap( int window )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_misc.c
|
||||
*
|
||||
* Functions that didn't fit anywhere else...
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 9 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutSetColor() --
|
||||
* glutGetColor() --
|
||||
* glutCopyColormap() --
|
||||
* glutSetKeyRepeat() -- this is evil and should be removed from API
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This functions checks if an OpenGL extension is supported or not
|
||||
*
|
||||
* XXX Wouldn't this be simpler and clearer if we used strtok()?
|
||||
*/
|
||||
int FGAPIENTRY glutExtensionSupported( const char* extension )
|
||||
{
|
||||
const char *extensions, *start;
|
||||
const size_t len = strlen( extension );
|
||||
|
||||
/* Make sure there is a current window, and thus a current context available */
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" );
|
||||
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
|
||||
|
||||
if (strchr(extension, ' '))
|
||||
return 0;
|
||||
start = extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
/* XXX consider printing a warning to stderr that there's no current
|
||||
* rendering context.
|
||||
*/
|
||||
freeglut_return_val_if_fail( extensions != NULL, 0 );
|
||||
|
||||
while (1) {
|
||||
const char *p = strstr(extensions, extension);
|
||||
if (!p)
|
||||
return 0; /* not found */
|
||||
/* check that the match isn't a super string */
|
||||
if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
|
||||
return 1;
|
||||
/* skip the false match and continue */
|
||||
extensions = p + len;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#ifndef GL_INVALID_FRAMEBUFFER_OPERATION
|
||||
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
#else
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_TABLE_TOO_LARGE
|
||||
#ifdef GL_TABLE_TOO_LARGE_EXT
|
||||
#define GL_TABLE_TOO_LARGE GL_TABLE_TOO_LARGE_EXT
|
||||
#else
|
||||
#define GL_TABLE_TOO_LARGE 0x8031
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GL_TEXTURE_TOO_LARGE
|
||||
#ifdef GL_TEXTURE_TOO_LARGE_EXT
|
||||
#define GL_TEXTURE_TOO_LARGE GL_TEXTURE_TOO_LARGE_EXT
|
||||
#else
|
||||
#define GL_TEXTURE_TOO_LARGE 0x8065
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A cut-down local version of gluErrorString to avoid depending on GLU.
|
||||
*/
|
||||
static const char* fghErrorString( GLenum error )
|
||||
{
|
||||
switch ( error ) {
|
||||
case GL_INVALID_ENUM: return "invalid enumerant";
|
||||
case GL_INVALID_VALUE: return "invalid value";
|
||||
case GL_INVALID_OPERATION: return "invalid operation";
|
||||
case GL_STACK_OVERFLOW: return "stack overflow";
|
||||
case GL_STACK_UNDERFLOW: return "stack underflow";
|
||||
case GL_OUT_OF_MEMORY: return "out of memory";
|
||||
case GL_TABLE_TOO_LARGE: return "table too large";
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION: return "invalid framebuffer operation";
|
||||
case GL_TEXTURE_TOO_LARGE: return "texture too large";
|
||||
default: return "unknown GL error";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function reports all the OpenGL errors that happened till now
|
||||
*/
|
||||
void FGAPIENTRY glutReportErrors( void )
|
||||
{
|
||||
GLenum error;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" );
|
||||
while( ( error = glGetError() ) != GL_NO_ERROR )
|
||||
fgWarning( "GL error: %s", fghErrorString( error ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Control the auto-repeat of keystrokes to the current window
|
||||
*/
|
||||
void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" );
|
||||
|
||||
fgStructure.CurrentWindow->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set global auto-repeat of keystrokes
|
||||
*
|
||||
* RepeatMode should be either:
|
||||
* GLUT_KEY_REPEAT_OFF
|
||||
* GLUT_KEY_REPEAT_ON
|
||||
* GLUT_KEY_REPEAT_DEFAULT
|
||||
*/
|
||||
void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" );
|
||||
|
||||
switch( repeatMode )
|
||||
{
|
||||
case GLUT_KEY_REPEAT_OFF:
|
||||
case GLUT_KEY_REPEAT_ON:
|
||||
fgState.KeyRepeat = repeatMode;
|
||||
break;
|
||||
|
||||
case GLUT_KEY_REPEAT_DEFAULT:
|
||||
fgState.KeyRepeat = GLUT_KEY_REPEAT_ON;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgError ("Invalid glutSetKeyRepeat mode: %d", repeatMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Forces the joystick callback to be executed
|
||||
*/
|
||||
void FGAPIENTRY glutForceJoystickFunc( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutForceJoystickFunc" );
|
||||
#if !defined(_WIN32_WCE)
|
||||
freeglut_return_if_fail( fgStructure.CurrentWindow != NULL );
|
||||
freeglut_return_if_fail( FETCH_WCB( *( fgStructure.CurrentWindow ), Joystick ) );
|
||||
fgJoystickPollWindow( fgStructure.CurrentWindow );
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutGetColor( int color, int component )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" );
|
||||
/* We really need to do something here. */
|
||||
return( 0.0f );
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void FGAPIENTRY glutCopyColormap( int window )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -1,45 +1,45 @@
|
||||
/*
|
||||
* freeglut_overlay.c
|
||||
*
|
||||
* Overlay management functions (as defined by GLUT API)
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* NOTE: functions declared in this file probably will not be implemented.
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
void FGAPIENTRY glutEstablishOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutRemoveOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutUseLayer( GLenum layer ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutPostOverlayRedisplay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutPostWindowOverlayRedisplay( int ID ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutShowOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutHideOverlay( void ) { /* Not implemented */ }
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_overlay.c
|
||||
*
|
||||
* Overlay management functions (as defined by GLUT API)
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* NOTE: functions declared in this file probably will not be implemented.
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
void FGAPIENTRY glutEstablishOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutRemoveOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutUseLayer( GLenum layer ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutPostOverlayRedisplay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutPostWindowOverlayRedisplay( int ID ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutShowOverlay( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutHideOverlay( void ) { /* Not implemented */ }
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
@ -1,76 +1,76 @@
|
||||
/* Spaceball support for Linux.
|
||||
* Written by John Tsiombikas <nuclear@member.fsf.org>
|
||||
*
|
||||
* This code supports 3Dconnexion's 6-dof space-whatever devices.
|
||||
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
|
||||
* free spacenavd (http://spacenav.sourceforge.net), through the "standard"
|
||||
* magellan X-based protocol.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */
|
||||
|
||||
extern void fgPlatformInitializeSpaceball(void);
|
||||
extern void fgPlatformSpaceballClose(void);
|
||||
extern int fgPlatformHasSpaceball(void);
|
||||
extern int fgPlatformSpaceballNumButtons(void);
|
||||
extern void fgPlatformSpaceballSetWindow(SFG_Window *window);
|
||||
|
||||
|
||||
int sball_initialized = 0;
|
||||
|
||||
void fgInitialiseSpaceball(void)
|
||||
{
|
||||
if(sball_initialized != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
fgPlatformInitializeSpaceball();
|
||||
|
||||
sball_initialized = 1;
|
||||
}
|
||||
|
||||
void fgSpaceballClose(void)
|
||||
{
|
||||
fgPlatformSpaceballClose();}
|
||||
|
||||
int fgHasSpaceball(void)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
fgWarning("fgInitialiseSpaceball failed\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fgPlatformHasSpaceball();
|
||||
}
|
||||
|
||||
int fgSpaceballNumButtons(void)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
fgWarning("fgInitialiseSpaceball failed\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fgPlatformSpaceballNumButtons();
|
||||
}
|
||||
|
||||
void fgSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fgPlatformSpaceballSetWindow(window);
|
||||
}
|
||||
|
||||
/* Spaceball support for Linux.
|
||||
* Written by John Tsiombikas <nuclear@member.fsf.org>
|
||||
*
|
||||
* This code supports 3Dconnexion's 6-dof space-whatever devices.
|
||||
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
|
||||
* free spacenavd (http://spacenav.sourceforge.net), through the "standard"
|
||||
* magellan X-based protocol.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/* -- PRIVATE FUNCTIONS --------------------------------------------------- */
|
||||
|
||||
extern void fgPlatformInitializeSpaceball(void);
|
||||
extern void fgPlatformSpaceballClose(void);
|
||||
extern int fgPlatformHasSpaceball(void);
|
||||
extern int fgPlatformSpaceballNumButtons(void);
|
||||
extern void fgPlatformSpaceballSetWindow(SFG_Window *window);
|
||||
|
||||
|
||||
int sball_initialized = 0;
|
||||
|
||||
void fgInitialiseSpaceball(void)
|
||||
{
|
||||
if(sball_initialized != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
fgPlatformInitializeSpaceball();
|
||||
|
||||
sball_initialized = 1;
|
||||
}
|
||||
|
||||
void fgSpaceballClose(void)
|
||||
{
|
||||
fgPlatformSpaceballClose();}
|
||||
|
||||
int fgHasSpaceball(void)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
fgWarning("fgInitialiseSpaceball failed\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fgPlatformHasSpaceball();
|
||||
}
|
||||
|
||||
int fgSpaceballNumButtons(void)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
fgWarning("fgInitialiseSpaceball failed\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fgPlatformSpaceballNumButtons();
|
||||
}
|
||||
|
||||
void fgSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fgPlatformSpaceballSetWindow(window);
|
||||
}
|
||||
|
||||
|
@ -1,322 +1,322 @@
|
||||
/*
|
||||
* freeglut_state.c
|
||||
*
|
||||
* Freeglut state query methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutGet() -- X11 tests passed, but check if all enums
|
||||
* handled (what about Win32?)
|
||||
* glutDeviceGet() -- X11 tests passed, but check if all enums
|
||||
* handled (what about Win32?)
|
||||
* glutGetModifiers() -- OK, but could also remove the limitation
|
||||
* glutLayerGet() -- what about GLUT_NORMAL_DAMAGED?
|
||||
*
|
||||
* The fail-on-call policy will help adding the most needed things imho.
|
||||
*/
|
||||
|
||||
extern int fgPlatformGlutGet ( GLenum eWhat );
|
||||
extern int fgPlatformGlutDeviceGet ( GLenum eWhat );
|
||||
extern int fgPlatformGlutLayerGet ( GLenum eWhat );
|
||||
extern int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size);
|
||||
|
||||
|
||||
/* -- LOCAL DEFINITIONS ---------------------------------------------------- */
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* General settings assignment method
|
||||
*/
|
||||
void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
|
||||
|
||||
/*
|
||||
* XXX In chronological code add order. (WHY in that order?)
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_INIT_WINDOW_X:
|
||||
fgState.Position.X = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_Y:
|
||||
fgState.Position.Y = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_WIDTH:
|
||||
fgState.Size.X = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_HEIGHT:
|
||||
fgState.Size.Y = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_DISPLAY_MODE:
|
||||
fgState.DisplayMode = (unsigned int)value;
|
||||
break;
|
||||
|
||||
case GLUT_ACTION_ON_WINDOW_CLOSE:
|
||||
fgState.ActionOnWindowClose = value;
|
||||
break;
|
||||
|
||||
case GLUT_RENDERING_CONTEXT:
|
||||
fgState.UseCurrentContext =
|
||||
( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
fgState.DirectContext = value;
|
||||
break;
|
||||
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
if( fgStructure.CurrentWindow != NULL )
|
||||
fgStructure.CurrentWindow->State.Cursor = value;
|
||||
break;
|
||||
|
||||
case GLUT_AUX:
|
||||
fgState.AuxiliaryBufferNumber = value;
|
||||
break;
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
fgState.SampleNumber = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* General settings query method
|
||||
*/
|
||||
int FGAPIENTRY glutGet( GLenum eWhat )
|
||||
{
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_INIT_STATE:
|
||||
return fgState.Initialised;
|
||||
|
||||
case GLUT_ELAPSED_TIME:
|
||||
return fgElapsedTime();
|
||||
}
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
|
||||
|
||||
/* XXX In chronological code add order. (WHY in that order?) */
|
||||
switch( eWhat )
|
||||
{
|
||||
/* Following values are stored in fgState and fgDisplay global structures */
|
||||
case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
|
||||
case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
|
||||
case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
|
||||
case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
|
||||
case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
|
||||
fgState.Position.X : -1 ;
|
||||
case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
|
||||
fgState.Position.Y : -1 ;
|
||||
case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
|
||||
fgState.Size.X : -1 ;
|
||||
case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
|
||||
fgState.Size.Y : -1 ;
|
||||
case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
|
||||
case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ;
|
||||
case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ;
|
||||
case GLUT_INIT_FLAGS: return fgState.ContextFlags ;
|
||||
case GLUT_INIT_PROFILE: return fgState.ContextProfile ;
|
||||
|
||||
/* The window structure queries */
|
||||
case GLUT_WINDOW_PARENT:
|
||||
if( fgStructure.CurrentWindow == NULL ) return 0;
|
||||
if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
|
||||
return fgStructure.CurrentWindow->Parent->ID;
|
||||
|
||||
case GLUT_WINDOW_NUM_CHILDREN:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
return fgListLength( &fgStructure.CurrentWindow->Children );
|
||||
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
return fgStructure.CurrentWindow->State.Cursor;
|
||||
|
||||
case GLUT_MENU_NUM_ITEMS:
|
||||
if( fgStructure.CurrentMenu == NULL )
|
||||
return 0;
|
||||
return fgListLength( &fgStructure.CurrentMenu->Entries );
|
||||
|
||||
case GLUT_ACTION_ON_WINDOW_CLOSE:
|
||||
return fgState.ActionOnWindowClose;
|
||||
|
||||
case GLUT_VERSION :
|
||||
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
|
||||
|
||||
case GLUT_RENDERING_CONTEXT:
|
||||
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
|
||||
: GLUT_CREATE_NEW_CONTEXT;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
return fgState.DirectContext;
|
||||
|
||||
case GLUT_FULL_SCREEN:
|
||||
return fgStructure.CurrentWindow->State.IsFullscreen;
|
||||
|
||||
case GLUT_AUX:
|
||||
return fgState.AuxiliaryBufferNumber;
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
return fgState.SampleNumber;
|
||||
|
||||
default:
|
||||
return fgPlatformGlutGet ( eWhat );
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns various device information.
|
||||
*/
|
||||
int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
|
||||
|
||||
/* XXX WARNING: we are mostly lying in this function. */
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_JOYSTICK:
|
||||
return fgJoystickDetect ();
|
||||
|
||||
case GLUT_OWNS_JOYSTICK:
|
||||
return fgState.JoysticksInitialised;
|
||||
|
||||
case GLUT_JOYSTICK_POLL_RATE:
|
||||
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
|
||||
|
||||
/* XXX The following two are only for Joystick 0 but this is an improvement */
|
||||
case GLUT_JOYSTICK_BUTTONS:
|
||||
return glutJoystickGetNumButtons ( 0 );
|
||||
|
||||
case GLUT_JOYSTICK_AXES:
|
||||
return glutJoystickGetNumAxes ( 0 );
|
||||
|
||||
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
|
||||
return fgInputDeviceDetect ();
|
||||
|
||||
case GLUT_NUM_DIALS:
|
||||
if ( fgState.InputDevsInitialised ) return 8;
|
||||
return 0;
|
||||
|
||||
case GLUT_NUM_BUTTON_BOX_BUTTONS:
|
||||
return 0;
|
||||
|
||||
case GLUT_HAS_SPACEBALL:
|
||||
return fgHasSpaceball();
|
||||
|
||||
case GLUT_HAS_TABLET:
|
||||
return 0;
|
||||
|
||||
case GLUT_NUM_SPACEBALL_BUTTONS:
|
||||
return fgSpaceballNumButtons();
|
||||
|
||||
case GLUT_NUM_TABLET_BUTTONS:
|
||||
return 0;
|
||||
|
||||
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
|
||||
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
|
||||
|
||||
case GLUT_DEVICE_KEY_REPEAT:
|
||||
return fgState.KeyRepeat;
|
||||
|
||||
default:
|
||||
return fgPlatformGlutDeviceGet ( eWhat );
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This should return the current state of ALT, SHIFT and CTRL keys.
|
||||
*/
|
||||
int FGAPIENTRY glutGetModifiers( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
|
||||
if( fgState.Modifiers == INVALID_MODIFIERS )
|
||||
{
|
||||
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fgState.Modifiers;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the state of the GLUT API overlay subsystem. A misery ;-)
|
||||
*/
|
||||
int FGAPIENTRY glutLayerGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
|
||||
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
|
||||
default:
|
||||
return fgPlatformGlutLayerGet( eWhat );
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
int *array;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
|
||||
|
||||
*size = 0;
|
||||
array = fgPlatformGlutGetModeValues ( eWhat, size );
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
/*
|
||||
* freeglut_state.c
|
||||
*
|
||||
* Freeglut state query methods.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* glutGet() -- X11 tests passed, but check if all enums
|
||||
* handled (what about Win32?)
|
||||
* glutDeviceGet() -- X11 tests passed, but check if all enums
|
||||
* handled (what about Win32?)
|
||||
* glutGetModifiers() -- OK, but could also remove the limitation
|
||||
* glutLayerGet() -- what about GLUT_NORMAL_DAMAGED?
|
||||
*
|
||||
* The fail-on-call policy will help adding the most needed things imho.
|
||||
*/
|
||||
|
||||
extern int fgPlatformGlutGet ( GLenum eWhat );
|
||||
extern int fgPlatformGlutDeviceGet ( GLenum eWhat );
|
||||
extern int fgPlatformGlutLayerGet ( GLenum eWhat );
|
||||
extern int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size);
|
||||
|
||||
|
||||
/* -- LOCAL DEFINITIONS ---------------------------------------------------- */
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* General settings assignment method
|
||||
*/
|
||||
void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
|
||||
|
||||
/*
|
||||
* XXX In chronological code add order. (WHY in that order?)
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_INIT_WINDOW_X:
|
||||
fgState.Position.X = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_Y:
|
||||
fgState.Position.Y = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_WIDTH:
|
||||
fgState.Size.X = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_WINDOW_HEIGHT:
|
||||
fgState.Size.Y = (GLint)value;
|
||||
break;
|
||||
|
||||
case GLUT_INIT_DISPLAY_MODE:
|
||||
fgState.DisplayMode = (unsigned int)value;
|
||||
break;
|
||||
|
||||
case GLUT_ACTION_ON_WINDOW_CLOSE:
|
||||
fgState.ActionOnWindowClose = value;
|
||||
break;
|
||||
|
||||
case GLUT_RENDERING_CONTEXT:
|
||||
fgState.UseCurrentContext =
|
||||
( value == GLUT_USE_CURRENT_CONTEXT ) ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
fgState.DirectContext = value;
|
||||
break;
|
||||
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
if( fgStructure.CurrentWindow != NULL )
|
||||
fgStructure.CurrentWindow->State.Cursor = value;
|
||||
break;
|
||||
|
||||
case GLUT_AUX:
|
||||
fgState.AuxiliaryBufferNumber = value;
|
||||
break;
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
fgState.SampleNumber = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning( "glutSetOption(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* General settings query method
|
||||
*/
|
||||
int FGAPIENTRY glutGet( GLenum eWhat )
|
||||
{
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_INIT_STATE:
|
||||
return fgState.Initialised;
|
||||
|
||||
case GLUT_ELAPSED_TIME:
|
||||
return fgElapsedTime();
|
||||
}
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
|
||||
|
||||
/* XXX In chronological code add order. (WHY in that order?) */
|
||||
switch( eWhat )
|
||||
{
|
||||
/* Following values are stored in fgState and fgDisplay global structures */
|
||||
case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
|
||||
case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
|
||||
case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
|
||||
case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
|
||||
case GLUT_INIT_WINDOW_X: return fgState.Position.Use ?
|
||||
fgState.Position.X : -1 ;
|
||||
case GLUT_INIT_WINDOW_Y: return fgState.Position.Use ?
|
||||
fgState.Position.Y : -1 ;
|
||||
case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.Use ?
|
||||
fgState.Size.X : -1 ;
|
||||
case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Use ?
|
||||
fgState.Size.Y : -1 ;
|
||||
case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
|
||||
case GLUT_INIT_MAJOR_VERSION: return fgState.MajorVersion ;
|
||||
case GLUT_INIT_MINOR_VERSION: return fgState.MinorVersion ;
|
||||
case GLUT_INIT_FLAGS: return fgState.ContextFlags ;
|
||||
case GLUT_INIT_PROFILE: return fgState.ContextProfile ;
|
||||
|
||||
/* The window structure queries */
|
||||
case GLUT_WINDOW_PARENT:
|
||||
if( fgStructure.CurrentWindow == NULL ) return 0;
|
||||
if( fgStructure.CurrentWindow->Parent == NULL ) return 0;
|
||||
return fgStructure.CurrentWindow->Parent->ID;
|
||||
|
||||
case GLUT_WINDOW_NUM_CHILDREN:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
return fgListLength( &fgStructure.CurrentWindow->Children );
|
||||
|
||||
case GLUT_WINDOW_CURSOR:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
return fgStructure.CurrentWindow->State.Cursor;
|
||||
|
||||
case GLUT_MENU_NUM_ITEMS:
|
||||
if( fgStructure.CurrentMenu == NULL )
|
||||
return 0;
|
||||
return fgListLength( &fgStructure.CurrentMenu->Entries );
|
||||
|
||||
case GLUT_ACTION_ON_WINDOW_CLOSE:
|
||||
return fgState.ActionOnWindowClose;
|
||||
|
||||
case GLUT_VERSION :
|
||||
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
|
||||
|
||||
case GLUT_RENDERING_CONTEXT:
|
||||
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
|
||||
: GLUT_CREATE_NEW_CONTEXT;
|
||||
|
||||
case GLUT_DIRECT_RENDERING:
|
||||
return fgState.DirectContext;
|
||||
|
||||
case GLUT_FULL_SCREEN:
|
||||
return fgStructure.CurrentWindow->State.IsFullscreen;
|
||||
|
||||
case GLUT_AUX:
|
||||
return fgState.AuxiliaryBufferNumber;
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
return fgState.SampleNumber;
|
||||
|
||||
default:
|
||||
return fgPlatformGlutGet ( eWhat );
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns various device information.
|
||||
*/
|
||||
int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
|
||||
|
||||
/* XXX WARNING: we are mostly lying in this function. */
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_JOYSTICK:
|
||||
return fgJoystickDetect ();
|
||||
|
||||
case GLUT_OWNS_JOYSTICK:
|
||||
return fgState.JoysticksInitialised;
|
||||
|
||||
case GLUT_JOYSTICK_POLL_RATE:
|
||||
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.JoystickPollRate : 0;
|
||||
|
||||
/* XXX The following two are only for Joystick 0 but this is an improvement */
|
||||
case GLUT_JOYSTICK_BUTTONS:
|
||||
return glutJoystickGetNumButtons ( 0 );
|
||||
|
||||
case GLUT_JOYSTICK_AXES:
|
||||
return glutJoystickGetNumAxes ( 0 );
|
||||
|
||||
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
|
||||
return fgInputDeviceDetect ();
|
||||
|
||||
case GLUT_NUM_DIALS:
|
||||
if ( fgState.InputDevsInitialised ) return 8;
|
||||
return 0;
|
||||
|
||||
case GLUT_NUM_BUTTON_BOX_BUTTONS:
|
||||
return 0;
|
||||
|
||||
case GLUT_HAS_SPACEBALL:
|
||||
return fgHasSpaceball();
|
||||
|
||||
case GLUT_HAS_TABLET:
|
||||
return 0;
|
||||
|
||||
case GLUT_NUM_SPACEBALL_BUTTONS:
|
||||
return fgSpaceballNumButtons();
|
||||
|
||||
case GLUT_NUM_TABLET_BUTTONS:
|
||||
return 0;
|
||||
|
||||
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
|
||||
return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.IgnoreKeyRepeat : 0;
|
||||
|
||||
case GLUT_DEVICE_KEY_REPEAT:
|
||||
return fgState.KeyRepeat;
|
||||
|
||||
default:
|
||||
return fgPlatformGlutDeviceGet ( eWhat );
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This should return the current state of ALT, SHIFT and CTRL keys.
|
||||
*/
|
||||
int FGAPIENTRY glutGetModifiers( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
|
||||
if( fgState.Modifiers == INVALID_MODIFIERS )
|
||||
{
|
||||
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fgState.Modifiers;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the state of the GLUT API overlay subsystem. A misery ;-)
|
||||
*/
|
||||
int FGAPIENTRY glutLayerGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
|
||||
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
|
||||
default:
|
||||
return fgPlatformGlutLayerGet( eWhat );
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
int *array;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");
|
||||
|
||||
*size = 0;
|
||||
array = fgPlatformGlutGetModeValues ( eWhat, size );
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/*** 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
@ -1,200 +1,200 @@
|
||||
/*
|
||||
* freeglut_teapot.c
|
||||
*
|
||||
* Teapot(tm) rendering code.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 24 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Original teapot code copyright follows:
|
||||
*/
|
||||
|
||||
/*
|
||||
* (c) Copyright 1993, Silicon Graphics, Inc.
|
||||
*
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies and that
|
||||
* both the copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Silicon
|
||||
* Graphics, Inc. not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
|
||||
* "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
|
||||
* OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
|
||||
* EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
|
||||
* ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
|
||||
* INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
|
||||
* SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
|
||||
* NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
*
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer
|
||||
* Software clause at DFARS 252.227-7013 and/or in similar or
|
||||
* successor clauses in the FAR or the DOD or NASA FAR
|
||||
* Supplement. Unpublished-- rights reserved under the copyright
|
||||
* laws of the United States. Contractor/manufacturer is Silicon
|
||||
* Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
|
||||
* 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
#include "freeglut_teapot_data.h"
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
|
||||
static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;
|
||||
#else
|
||||
double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
|
||||
long i, j, k, l;
|
||||
#endif
|
||||
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
|
||||
glEnable( GL_AUTO_NORMAL );
|
||||
glEnable( GL_NORMALIZE );
|
||||
glEnable( GL_MAP2_VERTEX_3 );
|
||||
glEnable( GL_MAP2_TEXTURE_COORD_2 );
|
||||
|
||||
glPushMatrix();
|
||||
glRotated( 270.0, 1.0, 0.0, 0.0 );
|
||||
glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );
|
||||
glTranslated( 0.0, 0.0, -1.5 );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
glRotated( 90.0, 1.0, 0.0, 0.0 );
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
|
||||
for( i = 0; i < numV-1; i++ )
|
||||
{
|
||||
int vidx = strip_vertices[i],
|
||||
nidx = strip_normals[i];
|
||||
|
||||
if( vidx != -1 )
|
||||
{
|
||||
glNormal3fv( normals[nidx] );
|
||||
glVertex3fv( vertices[vidx] );
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnd();
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
#else
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
for (k = 0; k < 4; k++) {
|
||||
for (l = 0; l < 3; l++) {
|
||||
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 1)
|
||||
q[j][k][l] *= -1.0;
|
||||
if (i < 6) {
|
||||
r[j][k][l] =
|
||||
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 0)
|
||||
r[j][k][l] *= -1.0;
|
||||
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
if (l == 0)
|
||||
s[j][k][l] *= -1.0;
|
||||
if (l == 1)
|
||||
s[j][k][l] *= -1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,
|
||||
&tex[0][0][0]);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&p[0][0][0]);
|
||||
glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&q[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
if (i < 6) {
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&r[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&s[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
}
|
||||
}
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Renders a beautiful wired teapot...
|
||||
*/
|
||||
void FGAPIENTRY glutWireTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 10, size, GL_LINE );
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders a beautiful filled teapot...
|
||||
*/
|
||||
void FGAPIENTRY glutSolidTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 7, size, GL_FILL );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* freeglut_teapot.c
|
||||
*
|
||||
* Teapot(tm) rendering code.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Fri Dec 24 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Original teapot code copyright follows:
|
||||
*/
|
||||
|
||||
/*
|
||||
* (c) Copyright 1993, Silicon Graphics, Inc.
|
||||
*
|
||||
* ALL RIGHTS RESERVED
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies and that
|
||||
* both the copyright notice and this permission notice appear in
|
||||
* supporting documentation, and that the name of Silicon
|
||||
* Graphics, Inc. not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU
|
||||
* "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR
|
||||
* OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
|
||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO
|
||||
* EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE
|
||||
* ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER,
|
||||
* INCLUDING WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE,
|
||||
* SAVINGS OR REVENUE, OR THE CLAIMS OF THIRD PARTIES, WHETHER OR
|
||||
* NOT SILICON GRAPHICS, INC. HAS BEEN ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH LOSS, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE POSSESSION, USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
*
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer
|
||||
* Software clause at DFARS 252.227-7013 and/or in similar or
|
||||
* successor clauses in the FAR or the DOD or NASA FAR
|
||||
* Supplement. Unpublished-- rights reserved under the copyright
|
||||
* laws of the United States. Contractor/manufacturer is Silicon
|
||||
* Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA
|
||||
* 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
#include "freeglut_teapot_data.h"
|
||||
|
||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
||||
|
||||
|
||||
static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
|
||||
{
|
||||
#if defined(_WIN32_WCE)
|
||||
int i, numV=sizeof(strip_vertices)/4, numI=sizeof(strip_normals)/4;
|
||||
#else
|
||||
double p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
|
||||
long i, j, k, l;
|
||||
#endif
|
||||
|
||||
glPushAttrib( GL_ENABLE_BIT | GL_EVAL_BIT );
|
||||
glEnable( GL_AUTO_NORMAL );
|
||||
glEnable( GL_NORMALIZE );
|
||||
glEnable( GL_MAP2_VERTEX_3 );
|
||||
glEnable( GL_MAP2_TEXTURE_COORD_2 );
|
||||
|
||||
glPushMatrix();
|
||||
glRotated( 270.0, 1.0, 0.0, 0.0 );
|
||||
glScaled( 0.5 * scale, 0.5 * scale, 0.5 * scale );
|
||||
glTranslated( 0.0, 0.0, -1.5 );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
glRotated( 90.0, 1.0, 0.0, 0.0 );
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
|
||||
for( i = 0; i < numV-1; i++ )
|
||||
{
|
||||
int vidx = strip_vertices[i],
|
||||
nidx = strip_normals[i];
|
||||
|
||||
if( vidx != -1 )
|
||||
{
|
||||
glNormal3fv( normals[nidx] );
|
||||
glVertex3fv( vertices[vidx] );
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnd();
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
#else
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
for (k = 0; k < 4; k++) {
|
||||
for (l = 0; l < 3; l++) {
|
||||
p[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
q[j][k][l] = cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 1)
|
||||
q[j][k][l] *= -1.0;
|
||||
if (i < 6) {
|
||||
r[j][k][l] =
|
||||
cpdata[patchdata[i][j * 4 + (3 - k)]][l];
|
||||
if (l == 0)
|
||||
r[j][k][l] *= -1.0;
|
||||
s[j][k][l] = cpdata[patchdata[i][j * 4 + k]][l];
|
||||
if (l == 0)
|
||||
s[j][k][l] *= -1.0;
|
||||
if (l == 1)
|
||||
s[j][k][l] *= -1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glMap2d(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2,
|
||||
&tex[0][0][0]);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&p[0][0][0]);
|
||||
glMapGrid2d(grid, 0.0, 1.0, grid, 0.0, 1.0);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&q[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
if (i < 6) {
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&r[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
glMap2d(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
|
||||
&s[0][0][0]);
|
||||
glEvalMesh2(type, 0, grid, 0, grid);
|
||||
}
|
||||
}
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Renders a beautiful wired teapot...
|
||||
*/
|
||||
void FGAPIENTRY glutWireTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 10, size, GL_LINE );
|
||||
}
|
||||
|
||||
/*
|
||||
* Renders a beautiful filled teapot...
|
||||
*/
|
||||
void FGAPIENTRY glutSolidTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 7, size, GL_FILL );
|
||||
}
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,50 @@
|
||||
/*
|
||||
* freeglut_videoresize.c
|
||||
*
|
||||
* Video resize functions (as defined by GLUT API)
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* NOTE: functions declared in this file probably will not be implemented.
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
int FGAPIENTRY glutVideoResizeGet( GLenum eWhat ) { return( 0x00 ); }
|
||||
void FGAPIENTRY glutSetupVideoResizing( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutStopVideoResizing( void ) { /* 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 */ }
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* freeglut_videoresize.c
|
||||
*
|
||||
* Video resize functions (as defined by GLUT API)
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Creation date: Thu Dec 16 1999
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* NOTE: functions declared in this file probably will not be implemented.
|
||||
*/
|
||||
|
||||
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||
|
||||
int FGAPIENTRY glutVideoResizeGet( GLenum eWhat ) { return( 0x00 ); }
|
||||
void FGAPIENTRY glutSetupVideoResizing( void ) { /* Not implemented */ }
|
||||
void FGAPIENTRY glutStopVideoResizing( void ) { /* 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 */ }
|
||||
|
||||
/*** END OF FILE ***/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,155 +1,155 @@
|
||||
LIBRARY freeglut
|
||||
VERSION 2.6
|
||||
EXPORTS
|
||||
glutInit
|
||||
glutInitWindowPosition
|
||||
glutInitWindowSize
|
||||
glutInitDisplayMode
|
||||
glutInitDisplayString
|
||||
glutMainLoop
|
||||
glutMainLoopEvent
|
||||
glutLeaveMainLoop
|
||||
glutCreateWindow
|
||||
glutCreateSubWindow
|
||||
glutDestroyWindow
|
||||
glutSetWindow
|
||||
glutGetWindow
|
||||
glutSetWindowData
|
||||
glutGetWindowData
|
||||
glutSetWindowTitle
|
||||
glutSetIconTitle
|
||||
glutReshapeWindow
|
||||
glutPositionWindow
|
||||
glutShowWindow
|
||||
glutHideWindow
|
||||
glutIconifyWindow
|
||||
glutPushWindow
|
||||
glutPopWindow
|
||||
glutFullScreen
|
||||
glutPostWindowRedisplay
|
||||
glutPostRedisplay
|
||||
glutSwapBuffers
|
||||
glutWarpPointer
|
||||
glutSetCursor
|
||||
glutEstablishOverlay
|
||||
glutRemoveOverlay
|
||||
glutUseLayer
|
||||
glutPostOverlayRedisplay
|
||||
glutPostWindowOverlayRedisplay
|
||||
glutShowOverlay
|
||||
glutHideOverlay
|
||||
glutCreateMenu
|
||||
glutDestroyMenu
|
||||
glutGetMenu
|
||||
glutSetMenu
|
||||
glutGetMenuData
|
||||
glutSetMenuData
|
||||
glutAddMenuEntry
|
||||
glutAddSubMenu
|
||||
glutChangeToMenuEntry
|
||||
glutChangeToSubMenu
|
||||
glutRemoveMenuItem
|
||||
glutAttachMenu
|
||||
glutDetachMenu
|
||||
glutTimerFunc
|
||||
glutIdleFunc
|
||||
glutKeyboardFunc
|
||||
glutSpecialFunc
|
||||
glutReshapeFunc
|
||||
glutVisibilityFunc
|
||||
glutDisplayFunc
|
||||
glutMouseFunc
|
||||
glutMouseWheelFunc
|
||||
glutMotionFunc
|
||||
glutPassiveMotionFunc
|
||||
glutEntryFunc
|
||||
glutCloseFunc
|
||||
glutWMCloseFunc
|
||||
glutKeyboardUpFunc
|
||||
glutSpecialUpFunc
|
||||
glutJoystickFunc
|
||||
glutMenuStateFunc
|
||||
glutMenuStatusFunc
|
||||
glutMenuDestroyFunc
|
||||
glutOverlayDisplayFunc
|
||||
glutWindowStatusFunc
|
||||
glutSpaceballMotionFunc
|
||||
glutSpaceballRotateFunc
|
||||
glutSpaceballButtonFunc
|
||||
glutButtonBoxFunc
|
||||
glutDialsFunc
|
||||
glutTabletMotionFunc
|
||||
glutTabletButtonFunc
|
||||
glutSetOption
|
||||
glutGet
|
||||
glutDeviceGet
|
||||
glutGetModifiers
|
||||
glutLayerGet
|
||||
glutBitmapCharacter
|
||||
glutBitmapWidth
|
||||
glutStrokeCharacter
|
||||
glutStrokeWidth
|
||||
glutBitmapLength
|
||||
glutStrokeLength
|
||||
glutBitmapHeight
|
||||
glutStrokeHeight
|
||||
glutBitmapString
|
||||
glutStrokeString
|
||||
glutWireCube
|
||||
glutSolidCube
|
||||
glutWireSphere
|
||||
glutSolidSphere
|
||||
glutWireCone
|
||||
glutSolidCone
|
||||
glutWireTorus
|
||||
glutSolidTorus
|
||||
glutWireDodecahedron
|
||||
glutSolidDodecahedron
|
||||
glutWireOctahedron
|
||||
glutSolidOctahedron
|
||||
glutWireTetrahedron
|
||||
glutSolidTetrahedron
|
||||
glutWireIcosahedron
|
||||
glutSolidIcosahedron
|
||||
glutWireRhombicDodecahedron
|
||||
glutSolidRhombicDodecahedron
|
||||
glutWireSierpinskiSponge
|
||||
glutSolidSierpinskiSponge
|
||||
glutWireTeapot
|
||||
glutSolidTeapot
|
||||
glutWireCylinder
|
||||
glutSolidCylinder
|
||||
glutGameModeString
|
||||
glutEnterGameMode
|
||||
glutLeaveGameMode
|
||||
glutGameModeGet
|
||||
glutVideoResizeGet
|
||||
glutSetupVideoResizing
|
||||
glutStopVideoResizing
|
||||
glutVideoResize
|
||||
glutVideoPan
|
||||
glutSetColor
|
||||
glutGetColor
|
||||
glutCopyColormap
|
||||
glutIgnoreKeyRepeat
|
||||
glutSetKeyRepeat
|
||||
glutForceJoystickFunc
|
||||
glutExtensionSupported
|
||||
glutReportErrors
|
||||
glutGetProcAddress
|
||||
glutExit
|
||||
glutFullScreenToggle
|
||||
glutLeaveFullScreen
|
||||
glutGetModeValues
|
||||
glutInitContextFlags
|
||||
glutInitContextVersion
|
||||
glutInitContextProfile
|
||||
glutInitErrorFunc
|
||||
glutInitWarningFunc
|
||||
__glutInitWithExit
|
||||
__glutCreateWindowWithExit
|
||||
__glutCreateMenuWithExit
|
||||
glutMultiButtonFunc
|
||||
glutMultiEntryFunc
|
||||
glutMultiMotionFunc
|
||||
glutMultiPassiveFunc
|
||||
LIBRARY freeglut
|
||||
VERSION 2.6
|
||||
EXPORTS
|
||||
glutInit
|
||||
glutInitWindowPosition
|
||||
glutInitWindowSize
|
||||
glutInitDisplayMode
|
||||
glutInitDisplayString
|
||||
glutMainLoop
|
||||
glutMainLoopEvent
|
||||
glutLeaveMainLoop
|
||||
glutCreateWindow
|
||||
glutCreateSubWindow
|
||||
glutDestroyWindow
|
||||
glutSetWindow
|
||||
glutGetWindow
|
||||
glutSetWindowData
|
||||
glutGetWindowData
|
||||
glutSetWindowTitle
|
||||
glutSetIconTitle
|
||||
glutReshapeWindow
|
||||
glutPositionWindow
|
||||
glutShowWindow
|
||||
glutHideWindow
|
||||
glutIconifyWindow
|
||||
glutPushWindow
|
||||
glutPopWindow
|
||||
glutFullScreen
|
||||
glutPostWindowRedisplay
|
||||
glutPostRedisplay
|
||||
glutSwapBuffers
|
||||
glutWarpPointer
|
||||
glutSetCursor
|
||||
glutEstablishOverlay
|
||||
glutRemoveOverlay
|
||||
glutUseLayer
|
||||
glutPostOverlayRedisplay
|
||||
glutPostWindowOverlayRedisplay
|
||||
glutShowOverlay
|
||||
glutHideOverlay
|
||||
glutCreateMenu
|
||||
glutDestroyMenu
|
||||
glutGetMenu
|
||||
glutSetMenu
|
||||
glutGetMenuData
|
||||
glutSetMenuData
|
||||
glutAddMenuEntry
|
||||
glutAddSubMenu
|
||||
glutChangeToMenuEntry
|
||||
glutChangeToSubMenu
|
||||
glutRemoveMenuItem
|
||||
glutAttachMenu
|
||||
glutDetachMenu
|
||||
glutTimerFunc
|
||||
glutIdleFunc
|
||||
glutKeyboardFunc
|
||||
glutSpecialFunc
|
||||
glutReshapeFunc
|
||||
glutVisibilityFunc
|
||||
glutDisplayFunc
|
||||
glutMouseFunc
|
||||
glutMouseWheelFunc
|
||||
glutMotionFunc
|
||||
glutPassiveMotionFunc
|
||||
glutEntryFunc
|
||||
glutCloseFunc
|
||||
glutWMCloseFunc
|
||||
glutKeyboardUpFunc
|
||||
glutSpecialUpFunc
|
||||
glutJoystickFunc
|
||||
glutMenuStateFunc
|
||||
glutMenuStatusFunc
|
||||
glutMenuDestroyFunc
|
||||
glutOverlayDisplayFunc
|
||||
glutWindowStatusFunc
|
||||
glutSpaceballMotionFunc
|
||||
glutSpaceballRotateFunc
|
||||
glutSpaceballButtonFunc
|
||||
glutButtonBoxFunc
|
||||
glutDialsFunc
|
||||
glutTabletMotionFunc
|
||||
glutTabletButtonFunc
|
||||
glutSetOption
|
||||
glutGet
|
||||
glutDeviceGet
|
||||
glutGetModifiers
|
||||
glutLayerGet
|
||||
glutBitmapCharacter
|
||||
glutBitmapWidth
|
||||
glutStrokeCharacter
|
||||
glutStrokeWidth
|
||||
glutBitmapLength
|
||||
glutStrokeLength
|
||||
glutBitmapHeight
|
||||
glutStrokeHeight
|
||||
glutBitmapString
|
||||
glutStrokeString
|
||||
glutWireCube
|
||||
glutSolidCube
|
||||
glutWireSphere
|
||||
glutSolidSphere
|
||||
glutWireCone
|
||||
glutSolidCone
|
||||
glutWireTorus
|
||||
glutSolidTorus
|
||||
glutWireDodecahedron
|
||||
glutSolidDodecahedron
|
||||
glutWireOctahedron
|
||||
glutSolidOctahedron
|
||||
glutWireTetrahedron
|
||||
glutSolidTetrahedron
|
||||
glutWireIcosahedron
|
||||
glutSolidIcosahedron
|
||||
glutWireRhombicDodecahedron
|
||||
glutSolidRhombicDodecahedron
|
||||
glutWireSierpinskiSponge
|
||||
glutSolidSierpinskiSponge
|
||||
glutWireTeapot
|
||||
glutSolidTeapot
|
||||
glutWireCylinder
|
||||
glutSolidCylinder
|
||||
glutGameModeString
|
||||
glutEnterGameMode
|
||||
glutLeaveGameMode
|
||||
glutGameModeGet
|
||||
glutVideoResizeGet
|
||||
glutSetupVideoResizing
|
||||
glutStopVideoResizing
|
||||
glutVideoResize
|
||||
glutVideoPan
|
||||
glutSetColor
|
||||
glutGetColor
|
||||
glutCopyColormap
|
||||
glutIgnoreKeyRepeat
|
||||
glutSetKeyRepeat
|
||||
glutForceJoystickFunc
|
||||
glutExtensionSupported
|
||||
glutReportErrors
|
||||
glutGetProcAddress
|
||||
glutExit
|
||||
glutFullScreenToggle
|
||||
glutLeaveFullScreen
|
||||
glutGetModeValues
|
||||
glutInitContextFlags
|
||||
glutInitContextVersion
|
||||
glutInitContextProfile
|
||||
glutInitErrorFunc
|
||||
glutInitWarningFunc
|
||||
__glutInitWithExit
|
||||
__glutCreateWindowWithExit
|
||||
__glutCreateMenuWithExit
|
||||
glutMultiButtonFunc
|
||||
glutMultiEntryFunc
|
||||
glutMultiMotionFunc
|
||||
glutMultiPassiveFunc
|
||||
|
@ -1,115 +1,115 @@
|
||||
/*
|
||||
* freeglut_cursor_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
/*
|
||||
* Joe Krahn is re-writing the following code.
|
||||
*/
|
||||
/* Set the cursor AND change it for this window class. */
|
||||
#if !defined(__MINGW64__) && _MSC_VER <= 1200
|
||||
# define MAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( LoadCursor( NULL, b ) ); \
|
||||
SetClassLong( window->Window.Handle, \
|
||||
GCL_HCURSOR, \
|
||||
( LONG )LoadCursor( NULL, b ) ); \
|
||||
break;
|
||||
/* Nuke the cursor AND change it for this window class. */
|
||||
# define ZAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( NULL ); \
|
||||
SetClassLong( window->Window.Handle, \
|
||||
GCL_HCURSOR, ( LONG )NULL ); \
|
||||
break;
|
||||
#else
|
||||
# define MAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( LoadCursor( NULL, b ) ); \
|
||||
SetClassLongPtr( window->Window.Handle, \
|
||||
GCLP_HCURSOR, \
|
||||
( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \
|
||||
break;
|
||||
/* Nuke the cursor AND change it for this window class. */
|
||||
# define ZAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( NULL ); \
|
||||
SetClassLongPtr( window->Window.Handle, \
|
||||
GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \
|
||||
break;
|
||||
#endif
|
||||
|
||||
switch( cursorID )
|
||||
{
|
||||
MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
|
||||
MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
|
||||
MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
|
||||
MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
|
||||
MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
|
||||
MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
|
||||
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM );
|
||||
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS );
|
||||
MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE );
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_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_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE );
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW );
|
||||
MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE );
|
||||
MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW );
|
||||
MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */
|
||||
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
|
||||
MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */
|
||||
|
||||
default:
|
||||
fgError( "Unknown cursor type: %d", cursorID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformWarpPointer ( int x, int y )
|
||||
{
|
||||
POINT coords;
|
||||
coords.x = x;
|
||||
coords.y = y;
|
||||
|
||||
/* ClientToScreen() translates {coords} for us. */
|
||||
ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords );
|
||||
SetCursorPos( coords.x, coords.y );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* freeglut_cursor_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
/*
|
||||
* Joe Krahn is re-writing the following code.
|
||||
*/
|
||||
/* Set the cursor AND change it for this window class. */
|
||||
#if !defined(__MINGW64__) && _MSC_VER <= 1200
|
||||
# define MAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( LoadCursor( NULL, b ) ); \
|
||||
SetClassLong( window->Window.Handle, \
|
||||
GCL_HCURSOR, \
|
||||
( LONG )LoadCursor( NULL, b ) ); \
|
||||
break;
|
||||
/* Nuke the cursor AND change it for this window class. */
|
||||
# define ZAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( NULL ); \
|
||||
SetClassLong( window->Window.Handle, \
|
||||
GCL_HCURSOR, ( LONG )NULL ); \
|
||||
break;
|
||||
#else
|
||||
# define MAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( LoadCursor( NULL, b ) ); \
|
||||
SetClassLongPtr( window->Window.Handle, \
|
||||
GCLP_HCURSOR, \
|
||||
( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \
|
||||
break;
|
||||
/* Nuke the cursor AND change it for this window class. */
|
||||
# define ZAP_CURSOR(a,b) \
|
||||
case a: \
|
||||
SetCursor( NULL ); \
|
||||
SetClassLongPtr( window->Window.Handle, \
|
||||
GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \
|
||||
break;
|
||||
#endif
|
||||
|
||||
switch( cursorID )
|
||||
{
|
||||
MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
|
||||
MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
|
||||
MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
|
||||
MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
|
||||
MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
|
||||
MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
|
||||
MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM );
|
||||
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
|
||||
MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS );
|
||||
MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE );
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_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_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE );
|
||||
MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW );
|
||||
MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE );
|
||||
MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW );
|
||||
MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */
|
||||
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
|
||||
MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */
|
||||
|
||||
default:
|
||||
fgError( "Unknown cursor type: %d", cursorID );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformWarpPointer ( int x, int y )
|
||||
{
|
||||
POINT coords;
|
||||
coords.x = x;
|
||||
coords.y = y;
|
||||
|
||||
/* ClientToScreen() translates {coords} for us. */
|
||||
ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords );
|
||||
SetCursorPos( coords.x, coords.y );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,37 +1,37 @@
|
||||
/*
|
||||
* freeglut_display_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 28, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
|
||||
{
|
||||
SwapBuffers( CurrentWindow->Window.pContext.Device );
|
||||
}
|
||||
/*
|
||||
* freeglut_display_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 28, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
|
||||
{
|
||||
SwapBuffers( CurrentWindow->Window.pContext.Device );
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
/*
|
||||
* freeglut_ext_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutJoystickFunc);
|
||||
CHECK_NAME(glutForceJoystickFunc);
|
||||
CHECK_NAME(glutGameModeString);
|
||||
CHECK_NAME(glutEnterGameMode);
|
||||
CHECK_NAME(glutLeaveGameMode);
|
||||
CHECK_NAME(glutGameModeGet);
|
||||
#undef CHECK_NAME
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SFG_Proc fgPlatformGetProcAddress( const char *procName )
|
||||
{
|
||||
return (SFG_Proc)wglGetProcAddress( ( LPCSTR )procName );
|
||||
}
|
||||
/*
|
||||
* freeglut_ext_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutJoystickFunc);
|
||||
CHECK_NAME(glutForceJoystickFunc);
|
||||
CHECK_NAME(glutGameModeString);
|
||||
CHECK_NAME(glutEnterGameMode);
|
||||
CHECK_NAME(glutLeaveGameMode);
|
||||
CHECK_NAME(glutGameModeGet);
|
||||
#undef CHECK_NAME
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SFG_Proc fgPlatformGetProcAddress( const char *procName )
|
||||
{
|
||||
return (SFG_Proc)wglGetProcAddress( ( LPCSTR )procName );
|
||||
}
|
||||
|
@ -1,157 +1,157 @@
|
||||
/*
|
||||
* freeglut_gamemode_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* Remembers the current visual settings, so that
|
||||
* we can change them and restore later...
|
||||
*/
|
||||
void fgPlatformRememberState( void )
|
||||
{
|
||||
/* DEVMODE devMode; */
|
||||
|
||||
/* Grab the current desktop settings... */
|
||||
|
||||
/* hack to get around my stupid cross-gcc headers */
|
||||
#define FREEGLUT_ENUM_CURRENT_SETTINGS -1
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
|
||||
&fgDisplay.pDisplay.DisplayMode );
|
||||
|
||||
/* Make sure we will be restoring all settings needed */
|
||||
fgDisplay.pDisplay.DisplayMode.dmFields |=
|
||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores the previously remembered visual settings
|
||||
*/
|
||||
void fgPlatformRestoreState( void )
|
||||
{
|
||||
/* Restore the previously remembered desktop display settings */
|
||||
ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Changes the current display mode to match user's settings
|
||||
*/
|
||||
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
{
|
||||
GLboolean success = GL_FALSE;
|
||||
DEVMODE devMode;
|
||||
char *fggmstr = NULL;
|
||||
char displayMode[300];
|
||||
|
||||
success = GL_FALSE;
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode );
|
||||
devMode.dmFields = 0;
|
||||
|
||||
if (fgState.GameModeSize.X!=-1)
|
||||
{
|
||||
devMode.dmPelsWidth = fgState.GameModeSize.X;
|
||||
devMode.dmFields |= DM_PELSWIDTH;
|
||||
}
|
||||
if (fgState.GameModeSize.Y!=-1)
|
||||
{
|
||||
devMode.dmPelsHeight = fgState.GameModeSize.Y;
|
||||
devMode.dmFields |= DM_PELSHEIGHT;
|
||||
}
|
||||
if (fgState.GameModeDepth!=-1)
|
||||
{
|
||||
devMode.dmBitsPerPel = fgState.GameModeDepth;
|
||||
devMode.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
if (fgState.GameModeRefresh!=-1)
|
||||
{
|
||||
devMode.dmDisplayFrequency = fgState.GameModeRefresh;
|
||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
|
||||
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
|
||||
{
|
||||
case DISP_CHANGE_SUCCESSFUL:
|
||||
success = GL_TRUE;
|
||||
|
||||
if (!haveToTest)
|
||||
{
|
||||
/* update vars in case if windows switched to proper mode */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
|
||||
fgState.GameModeSize.X = devMode.dmPelsWidth;
|
||||
fgState.GameModeSize.Y = devMode.dmPelsHeight;
|
||||
fgState.GameModeDepth = devMode.dmBitsPerPel;
|
||||
fgState.GameModeRefresh = devMode.dmDisplayFrequency;
|
||||
}
|
||||
break;
|
||||
case DISP_CHANGE_RESTART:
|
||||
fggmstr = "The computer must be restarted for the graphics mode to work.";
|
||||
break;
|
||||
case DISP_CHANGE_BADFLAGS:
|
||||
fggmstr = "An invalid set of flags was passed in.";
|
||||
break;
|
||||
case DISP_CHANGE_BADPARAM:
|
||||
fggmstr = "An invalid parameter was passed in. This can include an invalid flag or combination of flags.";
|
||||
break;
|
||||
case DISP_CHANGE_FAILED:
|
||||
fggmstr = "The display driver failed the specified graphics mode.";
|
||||
break;
|
||||
case DISP_CHANGE_BADMODE:
|
||||
fggmstr = "The graphics mode is not supported.";
|
||||
break;
|
||||
default:
|
||||
fggmstr = "Unknown error in graphics mode???"; /* dunno if it is possible,MSDN does not mention any other error */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !success )
|
||||
{
|
||||
/* 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 ;) */
|
||||
|
||||
/* 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);
|
||||
fgWarning(displayMode);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void fgPlatformEnterGameMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
void fgPlatformLeaveGameMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_gamemode_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* Remembers the current visual settings, so that
|
||||
* we can change them and restore later...
|
||||
*/
|
||||
void fgPlatformRememberState( void )
|
||||
{
|
||||
/* DEVMODE devMode; */
|
||||
|
||||
/* Grab the current desktop settings... */
|
||||
|
||||
/* hack to get around my stupid cross-gcc headers */
|
||||
#define FREEGLUT_ENUM_CURRENT_SETTINGS -1
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS,
|
||||
&fgDisplay.pDisplay.DisplayMode );
|
||||
|
||||
/* Make sure we will be restoring all settings needed */
|
||||
fgDisplay.pDisplay.DisplayMode.dmFields |=
|
||||
DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores the previously remembered visual settings
|
||||
*/
|
||||
void fgPlatformRestoreState( void )
|
||||
{
|
||||
/* Restore the previously remembered desktop display settings */
|
||||
ChangeDisplaySettingsEx( fgDisplay.pDisplay.DisplayName,&fgDisplay.pDisplay.DisplayMode, 0,0,0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Changes the current display mode to match user's settings
|
||||
*/
|
||||
GLboolean fgPlatformChangeDisplayMode( GLboolean haveToTest )
|
||||
{
|
||||
GLboolean success = GL_FALSE;
|
||||
DEVMODE devMode;
|
||||
char *fggmstr = NULL;
|
||||
char displayMode[300];
|
||||
|
||||
success = GL_FALSE;
|
||||
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, -1, &devMode );
|
||||
devMode.dmFields = 0;
|
||||
|
||||
if (fgState.GameModeSize.X!=-1)
|
||||
{
|
||||
devMode.dmPelsWidth = fgState.GameModeSize.X;
|
||||
devMode.dmFields |= DM_PELSWIDTH;
|
||||
}
|
||||
if (fgState.GameModeSize.Y!=-1)
|
||||
{
|
||||
devMode.dmPelsHeight = fgState.GameModeSize.Y;
|
||||
devMode.dmFields |= DM_PELSHEIGHT;
|
||||
}
|
||||
if (fgState.GameModeDepth!=-1)
|
||||
{
|
||||
devMode.dmBitsPerPel = fgState.GameModeDepth;
|
||||
devMode.dmFields |= DM_BITSPERPEL;
|
||||
}
|
||||
if (fgState.GameModeRefresh!=-1)
|
||||
{
|
||||
devMode.dmDisplayFrequency = fgState.GameModeRefresh;
|
||||
devMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
|
||||
switch ( ChangeDisplaySettingsEx(fgDisplay.pDisplay.DisplayName, &devMode, NULL, haveToTest ? CDS_TEST : CDS_FULLSCREEN , NULL) )
|
||||
{
|
||||
case DISP_CHANGE_SUCCESSFUL:
|
||||
success = GL_TRUE;
|
||||
|
||||
if (!haveToTest)
|
||||
{
|
||||
/* update vars in case if windows switched to proper mode */
|
||||
EnumDisplaySettings( fgDisplay.pDisplay.DisplayName, FREEGLUT_ENUM_CURRENT_SETTINGS, &devMode );
|
||||
fgState.GameModeSize.X = devMode.dmPelsWidth;
|
||||
fgState.GameModeSize.Y = devMode.dmPelsHeight;
|
||||
fgState.GameModeDepth = devMode.dmBitsPerPel;
|
||||
fgState.GameModeRefresh = devMode.dmDisplayFrequency;
|
||||
}
|
||||
break;
|
||||
case DISP_CHANGE_RESTART:
|
||||
fggmstr = "The computer must be restarted for the graphics mode to work.";
|
||||
break;
|
||||
case DISP_CHANGE_BADFLAGS:
|
||||
fggmstr = "An invalid set of flags was passed in.";
|
||||
break;
|
||||
case DISP_CHANGE_BADPARAM:
|
||||
fggmstr = "An invalid parameter was passed in. This can include an invalid flag or combination of flags.";
|
||||
break;
|
||||
case DISP_CHANGE_FAILED:
|
||||
fggmstr = "The display driver failed the specified graphics mode.";
|
||||
break;
|
||||
case DISP_CHANGE_BADMODE:
|
||||
fggmstr = "The graphics mode is not supported.";
|
||||
break;
|
||||
default:
|
||||
fggmstr = "Unknown error in graphics mode???"; /* dunno if it is possible,MSDN does not mention any other error */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !success )
|
||||
{
|
||||
/* 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 ;) */
|
||||
|
||||
/* 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);
|
||||
fgWarning(displayMode);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void fgPlatformEnterGameMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
void fgPlatformLeaveGameMode( void )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,345 +1,345 @@
|
||||
/*
|
||||
* freeglut_init_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
extern LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
||||
/*
|
||||
* A call to this function should initialize all the display stuff...
|
||||
*/
|
||||
void fgPlatformInitialize( const char* displayName )
|
||||
{
|
||||
WNDCLASS wc;
|
||||
ATOM atom;
|
||||
|
||||
/* What we need to do is to initialize the fgDisplay global structure here. */
|
||||
fgDisplay.pDisplay.Instance = GetModuleHandle( NULL );
|
||||
fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
|
||||
atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
|
||||
|
||||
if( atom == 0 )
|
||||
{
|
||||
ZeroMemory( &wc, sizeof(WNDCLASS) );
|
||||
|
||||
/*
|
||||
* Each of the windows should have its own device context, and we
|
||||
* want redraw events during Vertical and Horizontal Resizes by
|
||||
* the user.
|
||||
*
|
||||
* XXX Old code had "| CS_DBCLCKS" commented out. Plans for the
|
||||
* XXX future? Dead-end idea?
|
||||
*/
|
||||
wc.lpfnWndProc = fgPlatformWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = fgDisplay.pDisplay.Instance;
|
||||
wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
#else
|
||||
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||
if (!wc.hIcon)
|
||||
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO );
|
||||
#endif
|
||||
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = _T("FREEGLUT");
|
||||
|
||||
/* Register the window class */
|
||||
atom = RegisterClass( &wc );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fgPlatformInitialize" );
|
||||
}
|
||||
|
||||
/* The screen dimensions can be obtained via GetSystemMetrics() calls */
|
||||
fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN );
|
||||
fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
|
||||
|
||||
{
|
||||
HWND desktop = GetDesktopWindow( );
|
||||
HDC context = GetDC( desktop );
|
||||
|
||||
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
|
||||
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
|
||||
|
||||
ReleaseDC( desktop, context );
|
||||
}
|
||||
/* If we have a DisplayName try to use it for metrics */
|
||||
if( fgDisplay.pDisplay.DisplayName )
|
||||
{
|
||||
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
|
||||
if( context )
|
||||
{
|
||||
fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
|
||||
fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
|
||||
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
|
||||
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
|
||||
DeleteDC(context);
|
||||
}
|
||||
else
|
||||
fgWarning("fgPlatformInitialize: "
|
||||
"CreateDC failed, Screen size info may be incorrect\n"
|
||||
"This is quite likely caused by a bad '-display' parameter");
|
||||
|
||||
}
|
||||
/* Set the timer granularity to 1 ms */
|
||||
timeBeginPeriod ( 1 );
|
||||
|
||||
|
||||
fgState.Initialised = GL_TRUE;
|
||||
|
||||
/* Avoid registering atexit callback on Win32 as it results in an access
|
||||
* 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
|
||||
* see: http://blogs.msdn.com/b/oldnewthing/archive/2012/01/05/10253268.aspx
|
||||
*/
|
||||
/* atexit(fgDeinitialize); */
|
||||
|
||||
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
|
||||
fgInitialiseInputDevices();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Platform-Specific Deinitialization Functions: */
|
||||
extern void fghCloseInputDevices ( void );
|
||||
|
||||
void fgPlatformDeinitialiseInputDevices ( void )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
fghCloseInputDevices ();
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
fgState.JoysticksInitialised = GL_FALSE;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
|
||||
void fgPlatformCloseDisplay ( void )
|
||||
{
|
||||
if( fgDisplay.pDisplay.DisplayName )
|
||||
{
|
||||
free( fgDisplay.pDisplay.DisplayName );
|
||||
fgDisplay.pDisplay.DisplayName = NULL;
|
||||
}
|
||||
|
||||
/* Reset the timer granularity */
|
||||
timeEndPeriod ( 1 );
|
||||
}
|
||||
|
||||
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
|
||||
{
|
||||
/* Do nothing -- this is required for X11 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Everything down to the end of the next two functions is copied from the X sources.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1985, 1986, 1987,1998 The Open Group
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
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
|
||||
other dealings in this Software without prior written authorization
|
||||
from The Open Group.
|
||||
|
||||
*/
|
||||
|
||||
#define NoValue 0x0000
|
||||
#define XValue 0x0001
|
||||
#define YValue 0x0002
|
||||
#define WidthValue 0x0004
|
||||
#define HeightValue 0x0008
|
||||
#define AllValues 0x000F
|
||||
#define XNegative 0x0010
|
||||
#define YNegative 0x0020
|
||||
|
||||
/*
|
||||
* XParseGeometry parses strings of the form
|
||||
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
|
||||
* width, height, xoffset, and yoffset are unsigned integers.
|
||||
* Example: "=80x24+300-49"
|
||||
* The equal sign is optional.
|
||||
* It returns a bitmask that indicates which of the four values
|
||||
* were actually found in the string. For each value found,
|
||||
* the corresponding argument is updated; for each value
|
||||
* not found, the corresponding argument is left unchanged.
|
||||
*/
|
||||
|
||||
static int
|
||||
ReadInteger(char *string, char **NextString)
|
||||
{
|
||||
register int Result = 0;
|
||||
int Sign = 1;
|
||||
|
||||
if (*string == '+')
|
||||
string++;
|
||||
else if (*string == '-')
|
||||
{
|
||||
string++;
|
||||
Sign = -1;
|
||||
}
|
||||
for (; (*string >= '0') && (*string <= '9'); string++)
|
||||
{
|
||||
Result = (Result * 10) + (*string - '0');
|
||||
}
|
||||
*NextString = string;
|
||||
if (Sign >= 0)
|
||||
return Result;
|
||||
else
|
||||
return -Result;
|
||||
}
|
||||
|
||||
int XParseGeometry (
|
||||
const char *string,
|
||||
int *x,
|
||||
int *y,
|
||||
unsigned int *width, /* RETURN */
|
||||
unsigned int *height) /* RETURN */
|
||||
{
|
||||
int mask = NoValue;
|
||||
register char *strind;
|
||||
unsigned int tempWidth = 0, tempHeight = 0;
|
||||
int tempX = 0, tempY = 0;
|
||||
char *nextCharacter;
|
||||
|
||||
if ( (string == NULL) || (*string == '\0'))
|
||||
return mask;
|
||||
if (*string == '=')
|
||||
string++; /* ignore possible '=' at beg of geometry spec */
|
||||
|
||||
strind = (char *)string;
|
||||
if (*strind != '+' && *strind != '-' && *strind != 'x') {
|
||||
tempWidth = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= WidthValue;
|
||||
}
|
||||
|
||||
if (*strind == 'x' || *strind == 'X') {
|
||||
strind++;
|
||||
tempHeight = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= HeightValue;
|
||||
}
|
||||
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempX = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= XNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempX = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= XValue;
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempY = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= YNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempY = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= YValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* If strind isn't at the end of the string the it's an invalid
|
||||
geometry specification. */
|
||||
|
||||
if (*strind != '\0') return 0;
|
||||
|
||||
if (mask & XValue)
|
||||
*x = tempX;
|
||||
if (mask & YValue)
|
||||
*y = tempY;
|
||||
if (mask & WidthValue)
|
||||
*width = tempWidth;
|
||||
if (mask & HeightValue)
|
||||
*height = tempHeight;
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
|
||||
|
||||
void (__cdecl *__glutExitFunc)( int return_value ) = NULL;
|
||||
|
||||
void FGAPIENTRY __glutInitWithExit( int *pargc, char **argv, void (__cdecl *exit_function)(int) )
|
||||
{
|
||||
__glutExitFunc = exit_function;
|
||||
glutInit(pargc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_init_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
|
||||
extern LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
||||
/*
|
||||
* A call to this function should initialize all the display stuff...
|
||||
*/
|
||||
void fgPlatformInitialize( const char* displayName )
|
||||
{
|
||||
WNDCLASS wc;
|
||||
ATOM atom;
|
||||
|
||||
/* What we need to do is to initialize the fgDisplay global structure here. */
|
||||
fgDisplay.pDisplay.Instance = GetModuleHandle( NULL );
|
||||
fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ;
|
||||
atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
|
||||
|
||||
if( atom == 0 )
|
||||
{
|
||||
ZeroMemory( &wc, sizeof(WNDCLASS) );
|
||||
|
||||
/*
|
||||
* Each of the windows should have its own device context, and we
|
||||
* want redraw events during Vertical and Horizontal Resizes by
|
||||
* the user.
|
||||
*
|
||||
* XXX Old code had "| CS_DBCLCKS" commented out. Plans for the
|
||||
* XXX future? Dead-end idea?
|
||||
*/
|
||||
wc.lpfnWndProc = fgPlatformWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = fgDisplay.pDisplay.Instance;
|
||||
wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
#else
|
||||
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||
if (!wc.hIcon)
|
||||
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO );
|
||||
#endif
|
||||
|
||||
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = _T("FREEGLUT");
|
||||
|
||||
/* Register the window class */
|
||||
atom = RegisterClass( &wc );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fgPlatformInitialize" );
|
||||
}
|
||||
|
||||
/* The screen dimensions can be obtained via GetSystemMetrics() calls */
|
||||
fgDisplay.ScreenWidth = GetSystemMetrics( SM_CXSCREEN );
|
||||
fgDisplay.ScreenHeight = GetSystemMetrics( SM_CYSCREEN );
|
||||
|
||||
{
|
||||
HWND desktop = GetDesktopWindow( );
|
||||
HDC context = GetDC( desktop );
|
||||
|
||||
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
|
||||
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
|
||||
|
||||
ReleaseDC( desktop, context );
|
||||
}
|
||||
/* If we have a DisplayName try to use it for metrics */
|
||||
if( fgDisplay.pDisplay.DisplayName )
|
||||
{
|
||||
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
|
||||
if( context )
|
||||
{
|
||||
fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
|
||||
fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
|
||||
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
|
||||
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
|
||||
DeleteDC(context);
|
||||
}
|
||||
else
|
||||
fgWarning("fgPlatformInitialize: "
|
||||
"CreateDC failed, Screen size info may be incorrect\n"
|
||||
"This is quite likely caused by a bad '-display' parameter");
|
||||
|
||||
}
|
||||
/* Set the timer granularity to 1 ms */
|
||||
timeBeginPeriod ( 1 );
|
||||
|
||||
|
||||
fgState.Initialised = GL_TRUE;
|
||||
|
||||
/* Avoid registering atexit callback on Win32 as it results in an access
|
||||
* 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
|
||||
* see: http://blogs.msdn.com/b/oldnewthing/archive/2012/01/05/10253268.aspx
|
||||
*/
|
||||
/* atexit(fgDeinitialize); */
|
||||
|
||||
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
|
||||
fgInitialiseInputDevices();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Platform-Specific Deinitialization Functions: */
|
||||
extern void fghCloseInputDevices ( void );
|
||||
|
||||
void fgPlatformDeinitialiseInputDevices ( void )
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
fghCloseInputDevices ();
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
fgState.JoysticksInitialised = GL_FALSE;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
|
||||
void fgPlatformCloseDisplay ( void )
|
||||
{
|
||||
if( fgDisplay.pDisplay.DisplayName )
|
||||
{
|
||||
free( fgDisplay.pDisplay.DisplayName );
|
||||
fgDisplay.pDisplay.DisplayName = NULL;
|
||||
}
|
||||
|
||||
/* Reset the timer granularity */
|
||||
timeEndPeriod ( 1 );
|
||||
}
|
||||
|
||||
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
|
||||
{
|
||||
/* Do nothing -- this is required for X11 */
|
||||
}
|
||||
|
||||
/*
|
||||
* Everything down to the end of the next two functions is copied from the X sources.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Copyright 1985, 1986, 1987,1998 The Open Group
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and its
|
||||
documentation for any purpose is hereby granted without fee, provided that
|
||||
the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
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
|
||||
other dealings in this Software without prior written authorization
|
||||
from The Open Group.
|
||||
|
||||
*/
|
||||
|
||||
#define NoValue 0x0000
|
||||
#define XValue 0x0001
|
||||
#define YValue 0x0002
|
||||
#define WidthValue 0x0004
|
||||
#define HeightValue 0x0008
|
||||
#define AllValues 0x000F
|
||||
#define XNegative 0x0010
|
||||
#define YNegative 0x0020
|
||||
|
||||
/*
|
||||
* XParseGeometry parses strings of the form
|
||||
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
|
||||
* width, height, xoffset, and yoffset are unsigned integers.
|
||||
* Example: "=80x24+300-49"
|
||||
* The equal sign is optional.
|
||||
* It returns a bitmask that indicates which of the four values
|
||||
* were actually found in the string. For each value found,
|
||||
* the corresponding argument is updated; for each value
|
||||
* not found, the corresponding argument is left unchanged.
|
||||
*/
|
||||
|
||||
static int
|
||||
ReadInteger(char *string, char **NextString)
|
||||
{
|
||||
register int Result = 0;
|
||||
int Sign = 1;
|
||||
|
||||
if (*string == '+')
|
||||
string++;
|
||||
else if (*string == '-')
|
||||
{
|
||||
string++;
|
||||
Sign = -1;
|
||||
}
|
||||
for (; (*string >= '0') && (*string <= '9'); string++)
|
||||
{
|
||||
Result = (Result * 10) + (*string - '0');
|
||||
}
|
||||
*NextString = string;
|
||||
if (Sign >= 0)
|
||||
return Result;
|
||||
else
|
||||
return -Result;
|
||||
}
|
||||
|
||||
int XParseGeometry (
|
||||
const char *string,
|
||||
int *x,
|
||||
int *y,
|
||||
unsigned int *width, /* RETURN */
|
||||
unsigned int *height) /* RETURN */
|
||||
{
|
||||
int mask = NoValue;
|
||||
register char *strind;
|
||||
unsigned int tempWidth = 0, tempHeight = 0;
|
||||
int tempX = 0, tempY = 0;
|
||||
char *nextCharacter;
|
||||
|
||||
if ( (string == NULL) || (*string == '\0'))
|
||||
return mask;
|
||||
if (*string == '=')
|
||||
string++; /* ignore possible '=' at beg of geometry spec */
|
||||
|
||||
strind = (char *)string;
|
||||
if (*strind != '+' && *strind != '-' && *strind != 'x') {
|
||||
tempWidth = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= WidthValue;
|
||||
}
|
||||
|
||||
if (*strind == 'x' || *strind == 'X') {
|
||||
strind++;
|
||||
tempHeight = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= HeightValue;
|
||||
}
|
||||
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempX = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= XNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempX = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= XValue;
|
||||
if ((*strind == '+') || (*strind == '-')) {
|
||||
if (*strind == '-') {
|
||||
strind++;
|
||||
tempY = -ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
mask |= YNegative;
|
||||
}
|
||||
else
|
||||
{
|
||||
strind++;
|
||||
tempY = ReadInteger(strind, &nextCharacter);
|
||||
if (strind == nextCharacter)
|
||||
return 0;
|
||||
strind = nextCharacter;
|
||||
}
|
||||
mask |= YValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* If strind isn't at the end of the string the it's an invalid
|
||||
geometry specification. */
|
||||
|
||||
if (*strind != '\0') return 0;
|
||||
|
||||
if (mask & XValue)
|
||||
*x = tempX;
|
||||
if (mask & YValue)
|
||||
*y = tempY;
|
||||
if (mask & WidthValue)
|
||||
*width = tempWidth;
|
||||
if (mask & HeightValue)
|
||||
*height = tempHeight;
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
|
||||
|
||||
void (__cdecl *__glutExitFunc)( int return_value ) = NULL;
|
||||
|
||||
void FGAPIENTRY __glutInitWithExit( int *pargc, char **argv, void (__cdecl *exit_function)(int) )
|
||||
{
|
||||
__glutExitFunc = exit_function;
|
||||
glutInit(pargc, argv);
|
||||
}
|
||||
|
||||
|
@ -1,127 +1,127 @@
|
||||
/*
|
||||
* freeglut_input_devices_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 21, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <winbase.h>
|
||||
|
||||
typedef struct {
|
||||
HANDLE fh;
|
||||
COMMTIMEOUTS timeouts_save;
|
||||
DCB dcb_save;
|
||||
} SERIALPORT;
|
||||
|
||||
/* Serial Port Prototypes */
|
||||
SERIALPORT *serial_open ( const char *device );
|
||||
void serial_close ( SERIALPORT *port );
|
||||
int serial_getchar ( SERIALPORT *port );
|
||||
int serial_putchar ( SERIALPORT *port, unsigned char ch );
|
||||
void serial_flush ( SERIALPORT *port );
|
||||
|
||||
|
||||
void fgPlatformRegisterDialDevice ( const char *dial_device )
|
||||
{
|
||||
if (!dial_device){
|
||||
static char devname[256];
|
||||
DWORD size=sizeof(devname);
|
||||
DWORD type = REG_SZ;
|
||||
HKEY key;
|
||||
if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) {
|
||||
if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){
|
||||
dial_device=devname;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Serial Port Functions */
|
||||
SERIALPORT *serial_open(const char *device){
|
||||
HANDLE fh;
|
||||
DCB dcb={sizeof(DCB)};
|
||||
COMMTIMEOUTS timeouts;
|
||||
SERIALPORT *port;
|
||||
|
||||
fh = CreateFile(device,GENERIC_READ|GENERIC_WRITE,0,NULL,
|
||||
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (!fh) return NULL;
|
||||
|
||||
port = malloc(sizeof(SERIALPORT));
|
||||
ZeroMemory(port, sizeof(SERIALPORT));
|
||||
port->fh = fh;
|
||||
|
||||
/* save current port settings */
|
||||
GetCommState(fh,&port->dcb_save);
|
||||
GetCommTimeouts(fh,&port->timeouts_save);
|
||||
|
||||
dcb.DCBlength=sizeof(DCB);
|
||||
BuildCommDCB("96,n,8,1",&dcb);
|
||||
SetCommState(fh,&dcb);
|
||||
|
||||
ZeroMemory(&timeouts,sizeof(timeouts));
|
||||
timeouts.ReadTotalTimeoutConstant=1;
|
||||
timeouts.WriteTotalTimeoutConstant=1;
|
||||
SetCommTimeouts(fh,&timeouts);
|
||||
|
||||
serial_flush(port);
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
void serial_close(SERIALPORT *port){
|
||||
if (port){
|
||||
/* restore old port settings */
|
||||
SetCommState(port->fh,&port->dcb_save);
|
||||
SetCommTimeouts(port->fh,&port->timeouts_save);
|
||||
CloseHandle(port->fh);
|
||||
free(port);
|
||||
}
|
||||
}
|
||||
|
||||
int serial_getchar(SERIALPORT *port){
|
||||
DWORD n;
|
||||
unsigned char ch;
|
||||
if (!port) return EOF;
|
||||
if (!ReadFile(port->fh,&ch,1,&n,NULL)) return EOF;
|
||||
if (n==1) return ch;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int serial_putchar(SERIALPORT *port, unsigned char ch){
|
||||
DWORD n;
|
||||
if (!port) return 0;
|
||||
return WriteFile(port->fh,&ch,1,&n,NULL);
|
||||
}
|
||||
|
||||
void serial_flush ( SERIALPORT *port )
|
||||
{
|
||||
FlushFileBuffers(port->fh);
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_input_devices_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 21, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <winbase.h>
|
||||
|
||||
typedef struct {
|
||||
HANDLE fh;
|
||||
COMMTIMEOUTS timeouts_save;
|
||||
DCB dcb_save;
|
||||
} SERIALPORT;
|
||||
|
||||
/* Serial Port Prototypes */
|
||||
SERIALPORT *serial_open ( const char *device );
|
||||
void serial_close ( SERIALPORT *port );
|
||||
int serial_getchar ( SERIALPORT *port );
|
||||
int serial_putchar ( SERIALPORT *port, unsigned char ch );
|
||||
void serial_flush ( SERIALPORT *port );
|
||||
|
||||
|
||||
void fgPlatformRegisterDialDevice ( const char *dial_device )
|
||||
{
|
||||
if (!dial_device){
|
||||
static char devname[256];
|
||||
DWORD size=sizeof(devname);
|
||||
DWORD type = REG_SZ;
|
||||
HKEY key;
|
||||
if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) {
|
||||
if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){
|
||||
dial_device=devname;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Serial Port Functions */
|
||||
SERIALPORT *serial_open(const char *device){
|
||||
HANDLE fh;
|
||||
DCB dcb={sizeof(DCB)};
|
||||
COMMTIMEOUTS timeouts;
|
||||
SERIALPORT *port;
|
||||
|
||||
fh = CreateFile(device,GENERIC_READ|GENERIC_WRITE,0,NULL,
|
||||
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (!fh) return NULL;
|
||||
|
||||
port = malloc(sizeof(SERIALPORT));
|
||||
ZeroMemory(port, sizeof(SERIALPORT));
|
||||
port->fh = fh;
|
||||
|
||||
/* save current port settings */
|
||||
GetCommState(fh,&port->dcb_save);
|
||||
GetCommTimeouts(fh,&port->timeouts_save);
|
||||
|
||||
dcb.DCBlength=sizeof(DCB);
|
||||
BuildCommDCB("96,n,8,1",&dcb);
|
||||
SetCommState(fh,&dcb);
|
||||
|
||||
ZeroMemory(&timeouts,sizeof(timeouts));
|
||||
timeouts.ReadTotalTimeoutConstant=1;
|
||||
timeouts.WriteTotalTimeoutConstant=1;
|
||||
SetCommTimeouts(fh,&timeouts);
|
||||
|
||||
serial_flush(port);
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
void serial_close(SERIALPORT *port){
|
||||
if (port){
|
||||
/* restore old port settings */
|
||||
SetCommState(port->fh,&port->dcb_save);
|
||||
SetCommTimeouts(port->fh,&port->timeouts_save);
|
||||
CloseHandle(port->fh);
|
||||
free(port);
|
||||
}
|
||||
}
|
||||
|
||||
int serial_getchar(SERIALPORT *port){
|
||||
DWORD n;
|
||||
unsigned char ch;
|
||||
if (!port) return EOF;
|
||||
if (!ReadFile(port->fh,&ch,1,&n,NULL)) return EOF;
|
||||
if (n==1) return ch;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int serial_putchar(SERIALPORT *port, unsigned char ch){
|
||||
DWORD n;
|
||||
if (!port) return 0;
|
||||
return WriteFile(port->fh,&ch,1,&n,NULL);
|
||||
}
|
||||
|
||||
void serial_flush ( SERIALPORT *port )
|
||||
{
|
||||
FlushFileBuffers(port->fh);
|
||||
}
|
||||
|
||||
|
@ -1,124 +1,124 @@
|
||||
/*
|
||||
* freeglut_internal_mswin.h
|
||||
*
|
||||
* The freeglut library private include file.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef FREEGLUT_INTERNAL_MSWIN_H
|
||||
#define FREEGLUT_INTERNAL_MSWIN_H
|
||||
|
||||
|
||||
/* All Win32 headers depend on the huge windows.h recursive include.
|
||||
* Note: Lower-case header names are used, for best cross-platform
|
||||
* compatibility.
|
||||
*/
|
||||
#if !defined(_WIN32_WCE)
|
||||
# include <windows.h>
|
||||
# include <windowsx.h>
|
||||
# include <mmsystem.h>
|
||||
/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */
|
||||
# ifndef __CYGWIN__
|
||||
# include <tchar.h>
|
||||
# else
|
||||
# define _TEXT(x) TEXT(x)
|
||||
# define _T(x) TEXT(x)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define HAVE_VFPRINTF 1
|
||||
|
||||
/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */
|
||||
#if !defined(ChangeDisplaySettingsEx)
|
||||
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);
|
||||
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
|
||||
# ifdef UNICODE
|
||||
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExW
|
||||
# else
|
||||
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Structure Definitions */
|
||||
|
||||
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
||||
struct tagSFG_PlatformDisplay
|
||||
{
|
||||
HINSTANCE Instance; /* The application's instance */
|
||||
DEVMODE DisplayMode; /* Desktop's display settings */
|
||||
char *DisplayName; /* Display name for multi display support*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Make "freeglut" window handle and context types so that we don't need so
|
||||
* much conditionally-compiled code later in the library.
|
||||
*/
|
||||
typedef HWND SFG_WindowHandleType ;
|
||||
typedef HGLRC SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
HDC Device; /* The window's device context */
|
||||
};
|
||||
|
||||
|
||||
/* Window's state description. This structure should be kept portable. */
|
||||
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
|
||||
struct tagSFG_PlatformWindowState
|
||||
{
|
||||
RECT OldRect; /* window rect - stored before the window is made fullscreen */
|
||||
DWORD OldStyle; /* window style - stored before the window is made fullscreen */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Joystick-Specific Definitions */
|
||||
#if !defined(_WIN32_WCE)
|
||||
# define _JS_MAX_AXES 8
|
||||
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
||||
struct tagSFG_PlatformJoystick
|
||||
{
|
||||
JOYCAPS jsCaps;
|
||||
JOYINFOEX js;
|
||||
UINT js_id;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* Menu font and color definitions */
|
||||
#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_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_HBACK_COLORS {0.15f, 0.15f, 0.45f, 1.0f}
|
||||
|
||||
|
||||
/* Function to be called on exit */
|
||||
extern void (__cdecl *__glutExitFunc)( int return_value );
|
||||
|
||||
|
||||
/*
|
||||
* freeglut_internal_mswin.h
|
||||
*
|
||||
* The freeglut library private include file.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Thu Jan 19, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef FREEGLUT_INTERNAL_MSWIN_H
|
||||
#define FREEGLUT_INTERNAL_MSWIN_H
|
||||
|
||||
|
||||
/* All Win32 headers depend on the huge windows.h recursive include.
|
||||
* Note: Lower-case header names are used, for best cross-platform
|
||||
* compatibility.
|
||||
*/
|
||||
#if !defined(_WIN32_WCE)
|
||||
# include <windows.h>
|
||||
# include <windowsx.h>
|
||||
# include <mmsystem.h>
|
||||
/* CYGWIN does not have tchar.h, but has TEXT(x), defined in winnt.h. */
|
||||
# ifndef __CYGWIN__
|
||||
# include <tchar.h>
|
||||
# else
|
||||
# define _TEXT(x) TEXT(x)
|
||||
# define _T(x) TEXT(x)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define HAVE_VFPRINTF 1
|
||||
|
||||
/* MinGW may lack a prototype for ChangeDisplaySettingsEx() (depending on the version?) */
|
||||
#if !defined(ChangeDisplaySettingsEx)
|
||||
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR,LPDEVMODEA,HWND,DWORD,LPVOID);
|
||||
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
|
||||
# ifdef UNICODE
|
||||
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExW
|
||||
# else
|
||||
# define ChangeDisplaySettingsEx ChangeDisplaySettingsExA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Structure Definitions */
|
||||
|
||||
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
||||
struct tagSFG_PlatformDisplay
|
||||
{
|
||||
HINSTANCE Instance; /* The application's instance */
|
||||
DEVMODE DisplayMode; /* Desktop's display settings */
|
||||
char *DisplayName; /* Display name for multi display support*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Make "freeglut" window handle and context types so that we don't need so
|
||||
* much conditionally-compiled code later in the library.
|
||||
*/
|
||||
typedef HWND SFG_WindowHandleType ;
|
||||
typedef HGLRC SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
HDC Device; /* The window's device context */
|
||||
};
|
||||
|
||||
|
||||
/* Window's state description. This structure should be kept portable. */
|
||||
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
|
||||
struct tagSFG_PlatformWindowState
|
||||
{
|
||||
RECT OldRect; /* window rect - stored before the window is made fullscreen */
|
||||
DWORD OldStyle; /* window style - stored before the window is made fullscreen */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Joystick-Specific Definitions */
|
||||
#if !defined(_WIN32_WCE)
|
||||
# define _JS_MAX_AXES 8
|
||||
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
||||
struct tagSFG_PlatformJoystick
|
||||
{
|
||||
JOYCAPS jsCaps;
|
||||
JOYINFOEX js;
|
||||
UINT js_id;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* Menu font and color definitions */
|
||||
#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_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_HBACK_COLORS {0.15f, 0.15f, 0.45f, 1.0f}
|
||||
|
||||
|
||||
/* Function to be called on exit */
|
||||
extern void (__cdecl *__glutExitFunc)( int return_value );
|
||||
|
||||
|
||||
#endif /* FREEGLUT_INTERNAL_MSWIN_H */
|
@ -1,264 +1,264 @@
|
||||
/*
|
||||
* freeglut_joystick_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 28, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
#if !defined(_WIN32_WCE)
|
||||
# include <windows.h>
|
||||
# include <mmsystem.h>
|
||||
# include <regstr.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
||||
{
|
||||
MMRESULT status;
|
||||
|
||||
status = joyGetPosEx( joy->pJoystick.js_id, &joy->pJoystick.js );
|
||||
|
||||
if ( status != JOYERR_NOERROR )
|
||||
{
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
*buttons = joy->pJoystick.js.dwButtons;
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
/*
|
||||
* WARNING - Fall through case clauses!!
|
||||
*/
|
||||
switch ( joy->num_axes )
|
||||
{
|
||||
case 8:
|
||||
/* Generate two POV axes from the POV hat angle.
|
||||
* Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in
|
||||
* hundredths of a degree, or 0xFFFF when idle.
|
||||
*/
|
||||
if ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) == 0xFFFF )
|
||||
{
|
||||
axes [ 6 ] = 0.0;
|
||||
axes [ 7 ] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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:
|
||||
* SG_PI would pull in sg, M_PI is undefined for MSVC
|
||||
* But the accuracy of the value of PI is very unimportant at
|
||||
* this point.
|
||||
*/
|
||||
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 ) );
|
||||
|
||||
/* Convert to coordinates on a square so that North-East
|
||||
* is (1,1) not (.7,.7), etc.
|
||||
* s and c cannot both be zero so we won't divide by zero.
|
||||
*/
|
||||
if ( fabs ( s ) < fabs ( c ) )
|
||||
{
|
||||
axes [ 6 ] = ( c < 0.0 ) ? -s/c : s/c ;
|
||||
axes [ 7 ] = ( c < 0.0 ) ? -1.0f : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
axes [ 6 ] = ( s < 0.0 ) ? -1.0f : 1.0f;
|
||||
axes [ 7 ] = ( s < 0.0 ) ? -c/s : c/s ;
|
||||
}
|
||||
}
|
||||
|
||||
case 6: axes[5] = (float) joy->pJoystick.js.dwVpos;
|
||||
case 5: axes[4] = (float) joy->pJoystick.js.dwUpos;
|
||||
case 4: axes[3] = (float) joy->pJoystick.js.dwRpos;
|
||||
case 3: axes[2] = (float) joy->pJoystick.js.dwZpos;
|
||||
case 2: axes[1] = (float) joy->pJoystick.js.dwYpos;
|
||||
case 1: axes[0] = (float) joy->pJoystick.js.dwXpos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Inspired by
|
||||
http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp
|
||||
*/
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib, "advapi32.lib")
|
||||
# endif
|
||||
|
||||
static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz )
|
||||
{
|
||||
char buffer [ 256 ];
|
||||
|
||||
char OEMKey [ 256 ];
|
||||
|
||||
HKEY hKey;
|
||||
DWORD dwcb;
|
||||
LONG lr;
|
||||
|
||||
if ( joy->error )
|
||||
return 0;
|
||||
|
||||
/* Open .. MediaResources\CurrentJoystickSettings */
|
||||
_snprintf ( buffer, sizeof(buffer), "%s\\%s\\%s",
|
||||
REGSTR_PATH_JOYCONFIG, joy->pJoystick.jsCaps.szRegKey,
|
||||
REGSTR_KEY_JOYCURR );
|
||||
|
||||
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Get OEM Key name */
|
||||
dwcb = sizeof(OEMKey);
|
||||
|
||||
/* 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 );
|
||||
|
||||
lr = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEMKey, &dwcb);
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Open OEM Key from ...MediaProperties */
|
||||
_snprintf ( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEMKey );
|
||||
|
||||
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Get OEM Name */
|
||||
dwcb = buf_sz;
|
||||
|
||||
lr = RegQueryValueEx ( hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buf,
|
||||
&dwcb );
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickOpen( SFG_Joystick* joy )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
joy->pJoystick.js.dwFlags = JOY_RETURNALL;
|
||||
joy->pJoystick.js.dwSize = sizeof( joy->pJoystick.js );
|
||||
|
||||
memset( &joy->pJoystick.jsCaps, 0, sizeof( joy->pJoystick.jsCaps ) );
|
||||
|
||||
joy->error =
|
||||
( joyGetDevCaps( joy->pJoystick.js_id, &joy->pJoystick.jsCaps, sizeof( joy->pJoystick.jsCaps ) ) !=
|
||||
JOYERR_NOERROR );
|
||||
|
||||
if( joy->pJoystick.jsCaps.wNumAxes == 0 )
|
||||
{
|
||||
joy->num_axes = 0;
|
||||
joy->error = GL_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Device name from jsCaps is often "Microsoft PC-joystick driver",
|
||||
* at least for USB. Try to get the real name from the registry.
|
||||
*/
|
||||
if ( ! fghJoystickGetOEMProductName( joy, joy->name,
|
||||
sizeof( joy->name ) ) )
|
||||
{
|
||||
fgWarning( "JS: Failed to read joystick name from registry" );
|
||||
strncpy( joy->name, joy->pJoystick.jsCaps.szPname, sizeof( joy->name ) );
|
||||
}
|
||||
|
||||
/* Windows joystick drivers may provide any combination of
|
||||
* X,Y,Z,R,U,V,POV - not necessarily the first n of these.
|
||||
*/
|
||||
if( joy->pJoystick.jsCaps.wCaps & JOYCAPS_HASPOV )
|
||||
{
|
||||
joy->num_axes = _JS_MAX_AXES;
|
||||
joy->min[ 7 ] = -1.0; joy->max[ 7 ] = 1.0; /* POV Y */
|
||||
joy->min[ 6 ] = -1.0; joy->max[ 6 ] = 1.0; /* POV X */
|
||||
}
|
||||
else
|
||||
joy->num_axes = 6;
|
||||
|
||||
joy->min[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmin;
|
||||
joy->max[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmax;
|
||||
joy->min[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmin;
|
||||
joy->max[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmax;
|
||||
joy->min[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmin;
|
||||
joy->max[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmax;
|
||||
joy->min[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmin;
|
||||
joy->max[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmax;
|
||||
joy->min[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmin;
|
||||
joy->max[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmax;
|
||||
joy->min[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmin;
|
||||
joy->max[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmax;
|
||||
}
|
||||
|
||||
/* Guess all the rest judging on the axes extremals */
|
||||
for( i = 0; i < joy->num_axes; i++ )
|
||||
{
|
||||
joy->center [ i ] = ( joy->max[ i ] + joy->min[ i ] ) * 0.5f;
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
|
||||
{
|
||||
switch( ident )
|
||||
{
|
||||
case 0:
|
||||
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID1;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
break;
|
||||
case 1:
|
||||
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID2;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
break;
|
||||
default:
|
||||
fgJoystick[ ident ]->num_axes = 0;
|
||||
fgJoystick[ ident ]->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickClose ( int ident )
|
||||
{
|
||||
/* Do nothing special */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* freeglut_joystick_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Jan 28, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
#if !defined(_WIN32_WCE)
|
||||
# include <windows.h>
|
||||
# include <mmsystem.h>
|
||||
# include <regstr.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
||||
{
|
||||
MMRESULT status;
|
||||
|
||||
status = joyGetPosEx( joy->pJoystick.js_id, &joy->pJoystick.js );
|
||||
|
||||
if ( status != JOYERR_NOERROR )
|
||||
{
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
*buttons = joy->pJoystick.js.dwButtons;
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
/*
|
||||
* WARNING - Fall through case clauses!!
|
||||
*/
|
||||
switch ( joy->num_axes )
|
||||
{
|
||||
case 8:
|
||||
/* Generate two POV axes from the POV hat angle.
|
||||
* Low 16 bits of js.dwPOV gives heading (clockwise from ahead) in
|
||||
* hundredths of a degree, or 0xFFFF when idle.
|
||||
*/
|
||||
if ( ( joy->pJoystick.js.dwPOV & 0xFFFF ) == 0xFFFF )
|
||||
{
|
||||
axes [ 6 ] = 0.0;
|
||||
axes [ 7 ] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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:
|
||||
* SG_PI would pull in sg, M_PI is undefined for MSVC
|
||||
* But the accuracy of the value of PI is very unimportant at
|
||||
* this point.
|
||||
*/
|
||||
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 ) );
|
||||
|
||||
/* Convert to coordinates on a square so that North-East
|
||||
* is (1,1) not (.7,.7), etc.
|
||||
* s and c cannot both be zero so we won't divide by zero.
|
||||
*/
|
||||
if ( fabs ( s ) < fabs ( c ) )
|
||||
{
|
||||
axes [ 6 ] = ( c < 0.0 ) ? -s/c : s/c ;
|
||||
axes [ 7 ] = ( c < 0.0 ) ? -1.0f : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
axes [ 6 ] = ( s < 0.0 ) ? -1.0f : 1.0f;
|
||||
axes [ 7 ] = ( s < 0.0 ) ? -c/s : c/s ;
|
||||
}
|
||||
}
|
||||
|
||||
case 6: axes[5] = (float) joy->pJoystick.js.dwVpos;
|
||||
case 5: axes[4] = (float) joy->pJoystick.js.dwUpos;
|
||||
case 4: axes[3] = (float) joy->pJoystick.js.dwRpos;
|
||||
case 3: axes[2] = (float) joy->pJoystick.js.dwZpos;
|
||||
case 2: axes[1] = (float) joy->pJoystick.js.dwYpos;
|
||||
case 1: axes[0] = (float) joy->pJoystick.js.dwXpos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Inspired by
|
||||
http://msdn.microsoft.com/archive/en-us/dnargame/html/msdn_sidewind3d.asp
|
||||
*/
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib, "advapi32.lib")
|
||||
# endif
|
||||
|
||||
static int fghJoystickGetOEMProductName ( SFG_Joystick* joy, char *buf, int buf_sz )
|
||||
{
|
||||
char buffer [ 256 ];
|
||||
|
||||
char OEMKey [ 256 ];
|
||||
|
||||
HKEY hKey;
|
||||
DWORD dwcb;
|
||||
LONG lr;
|
||||
|
||||
if ( joy->error )
|
||||
return 0;
|
||||
|
||||
/* Open .. MediaResources\CurrentJoystickSettings */
|
||||
_snprintf ( buffer, sizeof(buffer), "%s\\%s\\%s",
|
||||
REGSTR_PATH_JOYCONFIG, joy->pJoystick.jsCaps.szRegKey,
|
||||
REGSTR_KEY_JOYCURR );
|
||||
|
||||
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Get OEM Key name */
|
||||
dwcb = sizeof(OEMKey);
|
||||
|
||||
/* 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 );
|
||||
|
||||
lr = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEMKey, &dwcb);
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Open OEM Key from ...MediaProperties */
|
||||
_snprintf ( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEMKey );
|
||||
|
||||
lr = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
/* Get OEM Name */
|
||||
dwcb = buf_sz;
|
||||
|
||||
lr = RegQueryValueEx ( hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buf,
|
||||
&dwcb );
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( lr != ERROR_SUCCESS ) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickOpen( SFG_Joystick* joy )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
joy->pJoystick.js.dwFlags = JOY_RETURNALL;
|
||||
joy->pJoystick.js.dwSize = sizeof( joy->pJoystick.js );
|
||||
|
||||
memset( &joy->pJoystick.jsCaps, 0, sizeof( joy->pJoystick.jsCaps ) );
|
||||
|
||||
joy->error =
|
||||
( joyGetDevCaps( joy->pJoystick.js_id, &joy->pJoystick.jsCaps, sizeof( joy->pJoystick.jsCaps ) ) !=
|
||||
JOYERR_NOERROR );
|
||||
|
||||
if( joy->pJoystick.jsCaps.wNumAxes == 0 )
|
||||
{
|
||||
joy->num_axes = 0;
|
||||
joy->error = GL_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Device name from jsCaps is often "Microsoft PC-joystick driver",
|
||||
* at least for USB. Try to get the real name from the registry.
|
||||
*/
|
||||
if ( ! fghJoystickGetOEMProductName( joy, joy->name,
|
||||
sizeof( joy->name ) ) )
|
||||
{
|
||||
fgWarning( "JS: Failed to read joystick name from registry" );
|
||||
strncpy( joy->name, joy->pJoystick.jsCaps.szPname, sizeof( joy->name ) );
|
||||
}
|
||||
|
||||
/* Windows joystick drivers may provide any combination of
|
||||
* X,Y,Z,R,U,V,POV - not necessarily the first n of these.
|
||||
*/
|
||||
if( joy->pJoystick.jsCaps.wCaps & JOYCAPS_HASPOV )
|
||||
{
|
||||
joy->num_axes = _JS_MAX_AXES;
|
||||
joy->min[ 7 ] = -1.0; joy->max[ 7 ] = 1.0; /* POV Y */
|
||||
joy->min[ 6 ] = -1.0; joy->max[ 6 ] = 1.0; /* POV X */
|
||||
}
|
||||
else
|
||||
joy->num_axes = 6;
|
||||
|
||||
joy->min[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmin;
|
||||
joy->max[ 5 ] = ( float )joy->pJoystick.jsCaps.wVmax;
|
||||
joy->min[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmin;
|
||||
joy->max[ 4 ] = ( float )joy->pJoystick.jsCaps.wUmax;
|
||||
joy->min[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmin;
|
||||
joy->max[ 3 ] = ( float )joy->pJoystick.jsCaps.wRmax;
|
||||
joy->min[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmin;
|
||||
joy->max[ 2 ] = ( float )joy->pJoystick.jsCaps.wZmax;
|
||||
joy->min[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmin;
|
||||
joy->max[ 1 ] = ( float )joy->pJoystick.jsCaps.wYmax;
|
||||
joy->min[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmin;
|
||||
joy->max[ 0 ] = ( float )joy->pJoystick.jsCaps.wXmax;
|
||||
}
|
||||
|
||||
/* Guess all the rest judging on the axes extremals */
|
||||
for( i = 0; i < joy->num_axes; i++ )
|
||||
{
|
||||
joy->center [ i ] = ( joy->max[ i ] + joy->min[ i ] ) * 0.5f;
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
|
||||
{
|
||||
switch( ident )
|
||||
{
|
||||
case 0:
|
||||
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID1;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
break;
|
||||
case 1:
|
||||
fgJoystick[ ident ]->pJoystick.js_id = JOYSTICKID2;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
break;
|
||||
default:
|
||||
fgJoystick[ ident ]->num_axes = 0;
|
||||
fgJoystick[ ident ]->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fgPlatformJoystickClose ( int ident )
|
||||
{
|
||||
/* Do nothing special */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,48 +1,48 @@
|
||||
/*
|
||||
* freeglut_menu_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
|
||||
{
|
||||
*x = glutGet ( GLUT_SCREEN_WIDTH );
|
||||
*y = glutGet ( GLUT_SCREEN_HEIGHT );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
|
||||
|
||||
int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl *exit_function)(int) )
|
||||
{
|
||||
__glutExitFunc = exit_function;
|
||||
return glutCreateMenu( callback );
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_menu_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
|
||||
{
|
||||
*x = glutGet ( GLUT_SCREEN_WIDTH );
|
||||
*y = glutGet ( GLUT_SCREEN_HEIGHT );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
|
||||
|
||||
int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl *exit_function)(int) )
|
||||
{
|
||||
__glutExitFunc = exit_function;
|
||||
return glutCreateMenu( callback );
|
||||
}
|
||||
|
||||
|
@ -1,58 +1,58 @@
|
||||
/*
|
||||
* freeglut_spaceball_mswin.c
|
||||
*
|
||||
* Spaceball support for Windows
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Sat Feb 4, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
* This code is a very complicated way of doing nothing.
|
||||
* But is needed for mswindows platform builds.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
void fgPlatformInitializeSpaceball(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballClose(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int fgPlatformHasSpaceball(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fgPlatformSpaceballNumButtons(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* freeglut_spaceball_mswin.c
|
||||
*
|
||||
* Spaceball support for Windows
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Sat Feb 4, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
* This code is a very complicated way of doing nothing.
|
||||
* But is needed for mswindows platform builds.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
void fgPlatformInitializeSpaceball(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballClose(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int fgPlatformHasSpaceball(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fgPlatformSpaceballNumButtons(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1,343 +1,343 @@
|
||||
/*
|
||||
* freeglut_state_mswin.c
|
||||
*
|
||||
* The Windows-specific state query methods.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
|
||||
unsigned char layer_type );
|
||||
|
||||
/*
|
||||
* Helper functions for getting client area from the window rect
|
||||
* 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).
|
||||
*/
|
||||
extern RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside );
|
||||
extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth);
|
||||
|
||||
|
||||
/* The following include file is available from SGI but is not standard:
|
||||
* #include <GL/wglext.h>
|
||||
* So we copy the necessary parts out of it to support the multisampling query
|
||||
*/
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
|
||||
|
||||
|
||||
int fgPlatformGlutGet ( GLenum eWhat )
|
||||
{
|
||||
int returnValue ;
|
||||
GLboolean boolValue ;
|
||||
|
||||
int nsamples = 0;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_NUM_SAMPLES:
|
||||
glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
|
||||
return nsamples;
|
||||
|
||||
/* Handle the OpenGL inquiries */
|
||||
case GLUT_WINDOW_RGBA:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_RGBA_MODE, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_DOUBLEBUFFER:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_STEREO:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_STEREO, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_RED_SIZE:
|
||||
glGetIntegerv ( GL_RED_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_GREEN_SIZE:
|
||||
glGetIntegerv ( GL_GREEN_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_BLUE_SIZE:
|
||||
glGetIntegerv ( GL_BLUE_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ALPHA_SIZE:
|
||||
glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_RED_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_DEPTH_SIZE:
|
||||
glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_BUFFER_SIZE:
|
||||
returnValue = 1 ; /* ????? */
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_STENCIL_SIZE:
|
||||
returnValue = 0 ; /* ????? */
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_X:
|
||||
case GLUT_WINDOW_Y:
|
||||
case GLUT_WINDOW_WIDTH:
|
||||
case GLUT_WINDOW_HEIGHT:
|
||||
{
|
||||
/*
|
||||
* There is considerable confusion about the "right thing to
|
||||
* do" concerning window size and position. GLUT itself is
|
||||
* not consistent between Windows and UNIX/X11; since
|
||||
* platform independence is a virtue for "freeglut", we
|
||||
* decided to break with GLUT's behaviour.
|
||||
*
|
||||
* Under UNIX/X11, it is apparently not possible to get the
|
||||
* window border sizes in order to subtract them off the
|
||||
* window's initial position until some time after the window
|
||||
* has been created. Therefore we decided on the following
|
||||
* behaviour, both under Windows and under UNIX/X11:
|
||||
* - When you create a window with position (x,y) and size
|
||||
* (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
|
||||
* (w,h).
|
||||
* - When you query the size and position of the window--as
|
||||
* is happening here for Windows--"freeglut" will return
|
||||
* the size of the drawable area--the (w,h) that you
|
||||
* specified when you created the window--and the coordinates
|
||||
* of the upper left hand corner of the drawable
|
||||
* area--which is NOT the (x,y) you specified.
|
||||
*/
|
||||
|
||||
RECT winRect;
|
||||
|
||||
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
|
||||
#else
|
||||
winRect = fghGetClientArea(fgStructure.CurrentWindow, FALSE);
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_X: return winRect.left ;
|
||||
case GLUT_WINDOW_Y: return winRect.top ;
|
||||
case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
|
||||
case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_WINDOW_BORDER_WIDTH :
|
||||
case GLUT_WINDOW_HEADER_HEIGHT :
|
||||
#if defined(_WIN32_WCE)
|
||||
return 0;
|
||||
#else
|
||||
{
|
||||
DWORD windowStyle;
|
||||
|
||||
if (fgStructure.CurrentWindow && fgStructure.CurrentWindow->Window.Handle)
|
||||
windowStyle = GetWindowLong(fgStructure.CurrentWindow->Window.Handle, GWL_STYLE);
|
||||
else
|
||||
/* If no window, return sizes for a default window with title bar and border */
|
||||
windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_BORDER_WIDTH:
|
||||
{
|
||||
int xBorderWidth, yBorderWidth;
|
||||
fghGetBorderWidth(windowStyle, &xBorderWidth, &yBorderWidth);
|
||||
return xBorderWidth;
|
||||
}
|
||||
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... */
|
||||
return (windowStyle & WS_MAXIMIZEBOX)? GetSystemMetrics( SM_CYCAPTION ) : 0;
|
||||
}
|
||||
}
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||
#if defined(_WIN32_WCE)
|
||||
return 0;
|
||||
#else
|
||||
return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
|
||||
PFD_MAIN_PLANE );
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
#if !defined(_WIN32_WCE)
|
||||
if( fgStructure.CurrentWindow != NULL )
|
||||
return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device );
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
return 0;
|
||||
|
||||
default:
|
||||
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
||||
{
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_KEYBOARD:
|
||||
/*
|
||||
* Win32 is assumed a keyboard, and this cannot be queried,
|
||||
* except for WindowsCE.
|
||||
*
|
||||
* X11 has a core keyboard by definition, although it can
|
||||
* be present as a virtual/dummy keyboard. For now, there
|
||||
* is no reliable way to tell if a real keyboard is present.
|
||||
*/
|
||||
#if defined(_WIN32_CE)
|
||||
return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib,"Kbdui.lib")
|
||||
# endif
|
||||
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
case GLUT_HAS_MOUSE:
|
||||
/*
|
||||
* MS Windows can be booted without a mouse.
|
||||
*/
|
||||
return GetSystemMetrics( SM_MOUSEPRESENT );
|
||||
|
||||
case GLUT_NUM_MOUSE_BUTTONS:
|
||||
# if defined(_WIN32_WCE)
|
||||
return 1;
|
||||
# else
|
||||
return GetSystemMetrics( SM_CMOUSEBUTTONS );
|
||||
# endif
|
||||
|
||||
default:
|
||||
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutLayerGet( GLenum eWhat )
|
||||
{
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
|
||||
case GLUT_OVERLAY_POSSIBLE:
|
||||
/* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
|
||||
PFD_OVERLAY_PLANE ); */
|
||||
return 0 ;
|
||||
|
||||
case GLUT_LAYER_IN_USE:
|
||||
return GLUT_NORMAL;
|
||||
|
||||
case GLUT_HAS_OVERLAY:
|
||||
return 0;
|
||||
|
||||
case GLUT_TRANSPARENT_INDEX:
|
||||
/*
|
||||
* Return just anything, which is always defined as zero
|
||||
*
|
||||
* XXX HUH?
|
||||
*/
|
||||
return 0;
|
||||
|
||||
case GLUT_NORMAL_DAMAGED:
|
||||
/* XXX Actually I do not know. Maybe. */
|
||||
return 0;
|
||||
|
||||
case GLUT_OVERLAY_DAMAGED:
|
||||
return -1;
|
||||
|
||||
default:
|
||||
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* MSwin does not currently have any Mode values? */
|
||||
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
*size = 0;
|
||||
return NULL;
|
||||
/*
|
||||
* freeglut_state_mswin.c
|
||||
*
|
||||
* The Windows-specific state query methods.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,
|
||||
unsigned char layer_type );
|
||||
|
||||
/*
|
||||
* Helper functions for getting client area from the window rect
|
||||
* 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).
|
||||
*/
|
||||
extern RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside );
|
||||
extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth);
|
||||
|
||||
|
||||
/* The following include file is available from SGI but is not standard:
|
||||
* #include <GL/wglext.h>
|
||||
* So we copy the necessary parts out of it to support the multisampling query
|
||||
*/
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
|
||||
|
||||
|
||||
int fgPlatformGlutGet ( GLenum eWhat )
|
||||
{
|
||||
int returnValue ;
|
||||
GLboolean boolValue ;
|
||||
|
||||
int nsamples = 0;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_NUM_SAMPLES:
|
||||
glGetIntegerv(WGL_SAMPLES_ARB, &nsamples);
|
||||
return nsamples;
|
||||
|
||||
/* Handle the OpenGL inquiries */
|
||||
case GLUT_WINDOW_RGBA:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_RGBA_MODE, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_DOUBLEBUFFER:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_STEREO:
|
||||
#if defined(_WIN32_WCE)
|
||||
boolValue = (GLboolean)0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetBooleanv ( GL_STEREO, &boolValue );
|
||||
returnValue = boolValue ? 1 : 0;
|
||||
#endif
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_RED_SIZE:
|
||||
glGetIntegerv ( GL_RED_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_GREEN_SIZE:
|
||||
glGetIntegerv ( GL_GREEN_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_BLUE_SIZE:
|
||||
glGetIntegerv ( GL_BLUE_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ALPHA_SIZE:
|
||||
glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_RED_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
|
||||
#if defined(_WIN32_WCE)
|
||||
returnValue = 0; /* WinCE doesn't support this feature */
|
||||
#else
|
||||
glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
|
||||
#endif
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_DEPTH_SIZE:
|
||||
glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_BUFFER_SIZE:
|
||||
returnValue = 1 ; /* ????? */
|
||||
return returnValue;
|
||||
case GLUT_WINDOW_STENCIL_SIZE:
|
||||
returnValue = 0 ; /* ????? */
|
||||
return returnValue;
|
||||
|
||||
case GLUT_WINDOW_X:
|
||||
case GLUT_WINDOW_Y:
|
||||
case GLUT_WINDOW_WIDTH:
|
||||
case GLUT_WINDOW_HEIGHT:
|
||||
{
|
||||
/*
|
||||
* There is considerable confusion about the "right thing to
|
||||
* do" concerning window size and position. GLUT itself is
|
||||
* not consistent between Windows and UNIX/X11; since
|
||||
* platform independence is a virtue for "freeglut", we
|
||||
* decided to break with GLUT's behaviour.
|
||||
*
|
||||
* Under UNIX/X11, it is apparently not possible to get the
|
||||
* window border sizes in order to subtract them off the
|
||||
* window's initial position until some time after the window
|
||||
* has been created. Therefore we decided on the following
|
||||
* behaviour, both under Windows and under UNIX/X11:
|
||||
* - When you create a window with position (x,y) and size
|
||||
* (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
|
||||
* (w,h).
|
||||
* - When you query the size and position of the window--as
|
||||
* is happening here for Windows--"freeglut" will return
|
||||
* the size of the drawable area--the (w,h) that you
|
||||
* specified when you created the window--and the coordinates
|
||||
* of the upper left hand corner of the drawable
|
||||
* area--which is NOT the (x,y) you specified.
|
||||
*/
|
||||
|
||||
RECT winRect;
|
||||
|
||||
freeglut_return_val_if_fail( fgStructure.CurrentWindow != NULL, 0 );
|
||||
|
||||
#if defined(_WIN32_WCE)
|
||||
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect );
|
||||
#else
|
||||
winRect = fghGetClientArea(fgStructure.CurrentWindow, FALSE);
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_X: return winRect.left ;
|
||||
case GLUT_WINDOW_Y: return winRect.top ;
|
||||
case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
|
||||
case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GLUT_WINDOW_BORDER_WIDTH :
|
||||
case GLUT_WINDOW_HEADER_HEIGHT :
|
||||
#if defined(_WIN32_WCE)
|
||||
return 0;
|
||||
#else
|
||||
{
|
||||
DWORD windowStyle;
|
||||
|
||||
if (fgStructure.CurrentWindow && fgStructure.CurrentWindow->Window.Handle)
|
||||
windowStyle = GetWindowLong(fgStructure.CurrentWindow->Window.Handle, GWL_STYLE);
|
||||
else
|
||||
/* If no window, return sizes for a default window with title bar and border */
|
||||
windowStyle = WS_OVERLAPPEDWINDOW;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_BORDER_WIDTH:
|
||||
{
|
||||
int xBorderWidth, yBorderWidth;
|
||||
fghGetBorderWidth(windowStyle, &xBorderWidth, &yBorderWidth);
|
||||
return xBorderWidth;
|
||||
}
|
||||
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... */
|
||||
return (windowStyle & WS_MAXIMIZEBOX)? GetSystemMetrics( SM_CYCAPTION ) : 0;
|
||||
}
|
||||
}
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||
#if defined(_WIN32_WCE)
|
||||
return 0;
|
||||
#else
|
||||
return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
|
||||
PFD_MAIN_PLANE );
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
|
||||
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
#if !defined(_WIN32_WCE)
|
||||
if( fgStructure.CurrentWindow != NULL )
|
||||
return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device );
|
||||
#endif /* defined(_WIN32_WCE) */
|
||||
return 0;
|
||||
|
||||
default:
|
||||
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
||||
{
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_KEYBOARD:
|
||||
/*
|
||||
* Win32 is assumed a keyboard, and this cannot be queried,
|
||||
* except for WindowsCE.
|
||||
*
|
||||
* X11 has a core keyboard by definition, although it can
|
||||
* be present as a virtual/dummy keyboard. For now, there
|
||||
* is no reliable way to tell if a real keyboard is present.
|
||||
*/
|
||||
#if defined(_WIN32_CE)
|
||||
return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0;
|
||||
# if FREEGLUT_LIB_PRAGMAS
|
||||
# pragma comment (lib,"Kbdui.lib")
|
||||
# endif
|
||||
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
case GLUT_HAS_MOUSE:
|
||||
/*
|
||||
* MS Windows can be booted without a mouse.
|
||||
*/
|
||||
return GetSystemMetrics( SM_MOUSEPRESENT );
|
||||
|
||||
case GLUT_NUM_MOUSE_BUTTONS:
|
||||
# if defined(_WIN32_WCE)
|
||||
return 1;
|
||||
# else
|
||||
return GetSystemMetrics( SM_CMOUSEBUTTONS );
|
||||
# endif
|
||||
|
||||
default:
|
||||
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutLayerGet( GLenum eWhat )
|
||||
{
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
|
||||
case GLUT_OVERLAY_POSSIBLE:
|
||||
/* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE,
|
||||
PFD_OVERLAY_PLANE ); */
|
||||
return 0 ;
|
||||
|
||||
case GLUT_LAYER_IN_USE:
|
||||
return GLUT_NORMAL;
|
||||
|
||||
case GLUT_HAS_OVERLAY:
|
||||
return 0;
|
||||
|
||||
case GLUT_TRANSPARENT_INDEX:
|
||||
/*
|
||||
* Return just anything, which is always defined as zero
|
||||
*
|
||||
* XXX HUH?
|
||||
*/
|
||||
return 0;
|
||||
|
||||
case GLUT_NORMAL_DAMAGED:
|
||||
/* XXX Actually I do not know. Maybe. */
|
||||
return 0;
|
||||
|
||||
case GLUT_OVERLAY_DAMAGED:
|
||||
return -1;
|
||||
|
||||
default:
|
||||
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* MSwin does not currently have any Mode values? */
|
||||
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
*size = 0;
|
||||
return NULL;
|
||||
}
|
@ -1,34 +1,34 @@
|
||||
/*
|
||||
* freeglut_structure_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
void fgPlatformCreateWindow ( SFG_Window *window )
|
||||
{
|
||||
}
|
||||
/*
|
||||
* freeglut_structure_mswin.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Jan 22, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
|
||||
void fgPlatformCreateWindow ( SFG_Window *window )
|
||||
{
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,151 +1,151 @@
|
||||
/*
|
||||
* freeglut_cursor_x11.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Feb 5, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/* This code is for Posix/X11, Solaris, and OSX */
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
/*
|
||||
* A factory method for an empty cursor
|
||||
*/
|
||||
static Cursor getEmptyCursor( void )
|
||||
{
|
||||
static Cursor cursorNone = None;
|
||||
if( cursorNone == None ) {
|
||||
char cursorNoneBits[ 32 ];
|
||||
XColor dontCare;
|
||||
Pixmap cursorNonePixmap;
|
||||
memset( cursorNoneBits, 0, sizeof( cursorNoneBits ) );
|
||||
memset( &dontCare, 0, sizeof( dontCare ) );
|
||||
cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
cursorNoneBits, 16, 16 );
|
||||
if( cursorNonePixmap != None ) {
|
||||
cursorNone = XCreatePixmapCursor( fgDisplay.pDisplay.Display,
|
||||
cursorNonePixmap, cursorNonePixmap,
|
||||
&dontCare, &dontCare, 0, 0 );
|
||||
XFreePixmap( fgDisplay.pDisplay.Display, cursorNonePixmap );
|
||||
}
|
||||
}
|
||||
return cursorNone;
|
||||
}
|
||||
|
||||
typedef struct tag_cursorCacheEntry cursorCacheEntry;
|
||||
struct tag_cursorCacheEntry {
|
||||
unsigned int cursorShape; /* an XC_foo value */
|
||||
Cursor cachedCursor; /* None if the corresponding cursor has
|
||||
not been created yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: The arrangement of the table below depends on the fact that
|
||||
* the "normal" GLUT_CURSOR_* values start a 0 and are consecutive.
|
||||
*/
|
||||
static cursorCacheEntry cursorCache[] = {
|
||||
{ XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */
|
||||
{ XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */
|
||||
{ XC_hand1, None }, /* GLUT_CURSOR_INFO */
|
||||
{ XC_pirate, None }, /* GLUT_CURSOR_DESTROY */
|
||||
{ XC_question_arrow, None }, /* GLUT_CURSOR_HELP */
|
||||
{ XC_exchange, None }, /* GLUT_CURSOR_CYCLE */
|
||||
{ XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */
|
||||
{ XC_watch, None }, /* GLUT_CURSOR_WAIT */
|
||||
{ XC_xterm, None }, /* GLUT_CURSOR_TEXT */
|
||||
{ XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */
|
||||
{ XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */
|
||||
{ XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */
|
||||
{ XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */
|
||||
{ XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */
|
||||
{ XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */
|
||||
{ XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */
|
||||
{ XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */
|
||||
{ XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
|
||||
{ XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
|
||||
{ XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
|
||||
};
|
||||
|
||||
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
Cursor cursor;
|
||||
/*
|
||||
* XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows
|
||||
* for this, but if there is a system that easily supports a full-
|
||||
* window (or full-screen) crosshair, we might consider it.
|
||||
*/
|
||||
int cursorIDToUse =
|
||||
( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID;
|
||||
|
||||
if( ( cursorIDToUse >= 0 ) &&
|
||||
( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) {
|
||||
cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ];
|
||||
if( entry->cachedCursor == None ) {
|
||||
entry->cachedCursor =
|
||||
XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape );
|
||||
}
|
||||
cursor = entry->cachedCursor;
|
||||
} else {
|
||||
switch( cursorIDToUse )
|
||||
{
|
||||
case GLUT_CURSOR_NONE:
|
||||
cursor = getEmptyCursor( );
|
||||
break;
|
||||
|
||||
case GLUT_CURSOR_INHERIT:
|
||||
cursor = None;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgError( "Unknown cursor type: %d", cursorIDToUse );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) {
|
||||
XUndefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle );
|
||||
} else if ( cursor != None ) {
|
||||
XDefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle, cursor );
|
||||
} else if ( cursorIDToUse != GLUT_CURSOR_NONE ) {
|
||||
fgError( "Failed to create cursor" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformWarpPointer ( int x, int y )
|
||||
{
|
||||
XWarpPointer(
|
||||
fgDisplay.pDisplay.Display,
|
||||
None,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
0, 0, 0, 0,
|
||||
x, y
|
||||
);
|
||||
/* Make the warp visible immediately. */
|
||||
XFlush( fgDisplay.pDisplay.Display );
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_cursor_x11.c
|
||||
*
|
||||
* The Windows-specific mouse cursor related stuff.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sun Feb 5, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/* This code is for Posix/X11, Solaris, and OSX */
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
/*
|
||||
* A factory method for an empty cursor
|
||||
*/
|
||||
static Cursor getEmptyCursor( void )
|
||||
{
|
||||
static Cursor cursorNone = None;
|
||||
if( cursorNone == None ) {
|
||||
char cursorNoneBits[ 32 ];
|
||||
XColor dontCare;
|
||||
Pixmap cursorNonePixmap;
|
||||
memset( cursorNoneBits, 0, sizeof( cursorNoneBits ) );
|
||||
memset( &dontCare, 0, sizeof( dontCare ) );
|
||||
cursorNonePixmap = XCreateBitmapFromData ( fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
cursorNoneBits, 16, 16 );
|
||||
if( cursorNonePixmap != None ) {
|
||||
cursorNone = XCreatePixmapCursor( fgDisplay.pDisplay.Display,
|
||||
cursorNonePixmap, cursorNonePixmap,
|
||||
&dontCare, &dontCare, 0, 0 );
|
||||
XFreePixmap( fgDisplay.pDisplay.Display, cursorNonePixmap );
|
||||
}
|
||||
}
|
||||
return cursorNone;
|
||||
}
|
||||
|
||||
typedef struct tag_cursorCacheEntry cursorCacheEntry;
|
||||
struct tag_cursorCacheEntry {
|
||||
unsigned int cursorShape; /* an XC_foo value */
|
||||
Cursor cachedCursor; /* None if the corresponding cursor has
|
||||
not been created yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: The arrangement of the table below depends on the fact that
|
||||
* the "normal" GLUT_CURSOR_* values start a 0 and are consecutive.
|
||||
*/
|
||||
static cursorCacheEntry cursorCache[] = {
|
||||
{ XC_arrow, None }, /* GLUT_CURSOR_RIGHT_ARROW */
|
||||
{ XC_top_left_arrow, None }, /* GLUT_CURSOR_LEFT_ARROW */
|
||||
{ XC_hand1, None }, /* GLUT_CURSOR_INFO */
|
||||
{ XC_pirate, None }, /* GLUT_CURSOR_DESTROY */
|
||||
{ XC_question_arrow, None }, /* GLUT_CURSOR_HELP */
|
||||
{ XC_exchange, None }, /* GLUT_CURSOR_CYCLE */
|
||||
{ XC_spraycan, None }, /* GLUT_CURSOR_SPRAY */
|
||||
{ XC_watch, None }, /* GLUT_CURSOR_WAIT */
|
||||
{ XC_xterm, None }, /* GLUT_CURSOR_TEXT */
|
||||
{ XC_crosshair, None }, /* GLUT_CURSOR_CROSSHAIR */
|
||||
{ XC_sb_v_double_arrow, None }, /* GLUT_CURSOR_UP_DOWN */
|
||||
{ XC_sb_h_double_arrow, None }, /* GLUT_CURSOR_LEFT_RIGHT */
|
||||
{ XC_top_side, None }, /* GLUT_CURSOR_TOP_SIDE */
|
||||
{ XC_bottom_side, None }, /* GLUT_CURSOR_BOTTOM_SIDE */
|
||||
{ XC_left_side, None }, /* GLUT_CURSOR_LEFT_SIDE */
|
||||
{ XC_right_side, None }, /* GLUT_CURSOR_RIGHT_SIDE */
|
||||
{ XC_top_left_corner, None }, /* GLUT_CURSOR_TOP_LEFT_CORNER */
|
||||
{ XC_top_right_corner, None }, /* GLUT_CURSOR_TOP_RIGHT_CORNER */
|
||||
{ XC_bottom_right_corner, None }, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */
|
||||
{ XC_bottom_left_corner, None } /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */
|
||||
};
|
||||
|
||||
void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
|
||||
{
|
||||
Cursor cursor;
|
||||
/*
|
||||
* XXX FULL_CROSSHAIR demotes to plain CROSSHAIR. Old GLUT allows
|
||||
* for this, but if there is a system that easily supports a full-
|
||||
* window (or full-screen) crosshair, we might consider it.
|
||||
*/
|
||||
int cursorIDToUse =
|
||||
( cursorID == GLUT_CURSOR_FULL_CROSSHAIR ) ? GLUT_CURSOR_CROSSHAIR : cursorID;
|
||||
|
||||
if( ( cursorIDToUse >= 0 ) &&
|
||||
( cursorIDToUse < sizeof( cursorCache ) / sizeof( cursorCache[0] ) ) ) {
|
||||
cursorCacheEntry *entry = &cursorCache[ cursorIDToUse ];
|
||||
if( entry->cachedCursor == None ) {
|
||||
entry->cachedCursor =
|
||||
XCreateFontCursor( fgDisplay.pDisplay.Display, entry->cursorShape );
|
||||
}
|
||||
cursor = entry->cachedCursor;
|
||||
} else {
|
||||
switch( cursorIDToUse )
|
||||
{
|
||||
case GLUT_CURSOR_NONE:
|
||||
cursor = getEmptyCursor( );
|
||||
break;
|
||||
|
||||
case GLUT_CURSOR_INHERIT:
|
||||
cursor = None;
|
||||
break;
|
||||
|
||||
default:
|
||||
fgError( "Unknown cursor type: %d", cursorIDToUse );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( cursorIDToUse == GLUT_CURSOR_INHERIT ) {
|
||||
XUndefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle );
|
||||
} else if ( cursor != None ) {
|
||||
XDefineCursor( fgDisplay.pDisplay.Display, window->Window.Handle, cursor );
|
||||
} else if ( cursorIDToUse != GLUT_CURSOR_NONE ) {
|
||||
fgError( "Failed to create cursor" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformWarpPointer ( int x, int y )
|
||||
{
|
||||
XWarpPointer(
|
||||
fgDisplay.pDisplay.Display,
|
||||
None,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
0, 0, 0, 0,
|
||||
x, y
|
||||
);
|
||||
/* Make the warp visible immediately. */
|
||||
XFlush( fgDisplay.pDisplay.Display );
|
||||
}
|
||||
|
||||
|
@ -1,36 +1,36 @@
|
||||
/*
|
||||
* freeglut_display_x11.c
|
||||
*
|
||||
* Display message posting, context buffer swapping.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
|
||||
{
|
||||
glXSwapBuffers( pDisplayPtr->Display, CurrentWindow->Window.Handle );
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_display_x11.c
|
||||
*
|
||||
* Display message posting, context buffer swapping.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
|
||||
{
|
||||
glXSwapBuffers( pDisplayPtr->Display, CurrentWindow->Window.Handle );
|
||||
}
|
||||
|
||||
|
@ -1,60 +1,60 @@
|
||||
/*
|
||||
* freeglut_ext.c
|
||||
*
|
||||
* Functions related to OpenGL extensions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutJoystickFunc);
|
||||
CHECK_NAME(glutForceJoystickFunc);
|
||||
CHECK_NAME(glutGameModeString);
|
||||
CHECK_NAME(glutEnterGameMode);
|
||||
CHECK_NAME(glutLeaveGameMode);
|
||||
CHECK_NAME(glutGameModeGet);
|
||||
#undef CHECK_NAME
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SFG_Proc fgPlatformGetProcAddress( const char *procName )
|
||||
{
|
||||
#if defined( GLX_ARB_get_proc_address )
|
||||
return (SFG_Proc)glXGetProcAddressARB( ( const GLubyte * )procName );
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_ext.c
|
||||
*
|
||||
* Functions related to OpenGL extensions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define GLX_GLXEXT_PROTOTYPES
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
GLUTproc fgPlatformGetGLUTProcAddress( const char* procName )
|
||||
{
|
||||
/* optimization: quick initial check */
|
||||
if( strncmp( procName, "glut", 4 ) != 0 )
|
||||
return NULL;
|
||||
|
||||
#define CHECK_NAME(x) if( strcmp( procName, #x ) == 0) return (GLUTproc)x;
|
||||
CHECK_NAME(glutJoystickFunc);
|
||||
CHECK_NAME(glutForceJoystickFunc);
|
||||
CHECK_NAME(glutGameModeString);
|
||||
CHECK_NAME(glutEnterGameMode);
|
||||
CHECK_NAME(glutLeaveGameMode);
|
||||
CHECK_NAME(glutGameModeGet);
|
||||
#undef CHECK_NAME
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SFG_Proc fgPlatformGetProcAddress( const char *procName )
|
||||
{
|
||||
#if defined( GLX_ARB_get_proc_address )
|
||||
return (SFG_Proc)glXGetProcAddressARB( ( const GLubyte * )procName );
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,104 +1,104 @@
|
||||
/*
|
||||
* freeglut_glutfont_definitions_x11.c
|
||||
*
|
||||
* Bitmap and stroke fonts displaying.
|
||||
*
|
||||
* Copyright (c) 2003 Stephen J. Baker (whether he wants it or not).
|
||||
* All Rights Reserved.
|
||||
* Written by John F. Fay <fayjf@sourceforge.net>, who releases the
|
||||
* copyright over to the "freeglut" project lead.
|
||||
* Creation date: Mon July 21 2003
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* 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
|
||||
* original GLUT defined its font variables in rather an unusual way.
|
||||
* Publicly, in "glut.h", they were defined as "void *". Privately,
|
||||
* in one of the source code files, they were defined as pointers to a
|
||||
* structure. Most compilers and linkers are satisfied with the "void *"
|
||||
* 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
|
||||
* ".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
|
||||
* structure to match GLUT.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* necessary machinery. But this poses another problem, caused by the ugly
|
||||
* 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
|
||||
* CPP HACK.
|
||||
*/
|
||||
|
||||
#define glutStrokeRoman glutStrokeRomanIGNOREME
|
||||
#define glutStrokeMonoRoman glutStrokeMonoRomanIGNOREME
|
||||
#define glutBitmap9By15 glutBitmap9By15IGNOREME
|
||||
#define glutBitmap8By13 glutBitmap8By13IGNOREME
|
||||
#define glutBitmapTimesRoman10 glutBitmapTimesRoman10IGNOREME
|
||||
#define glutBitmapTimesRoman24 glutBitmapTimesRoman24IGNOREME
|
||||
#define glutBitmapHelvetica10 glutBitmapHelvetica10IGNOREME
|
||||
#define glutBitmapHelvetica12 glutBitmapHelvetica12IGNOREME
|
||||
#define glutBitmapHelvetica18 glutBitmapHelvetica18IGNOREME
|
||||
|
||||
#include <GL/freeglut_std.h>
|
||||
|
||||
#undef glutStrokeRoman
|
||||
#undef glutStrokeMonoRoman
|
||||
#undef glutBitmap9By15
|
||||
#undef glutBitmap8By13
|
||||
#undef glutBitmapTimesRoman10
|
||||
#undef glutBitmapTimesRoman24
|
||||
#undef glutBitmapHelvetica10
|
||||
#undef glutBitmapHelvetica12
|
||||
#undef glutBitmapHelvetica18
|
||||
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
struct freeglutStrokeFont
|
||||
{
|
||||
const char *name ;
|
||||
int num_chars ;
|
||||
void *ch ;
|
||||
float top ;
|
||||
float bottom ;
|
||||
};
|
||||
|
||||
struct freeglutBitmapFont
|
||||
{
|
||||
const char *name ;
|
||||
const int num_chars ;
|
||||
const int first ;
|
||||
const void *ch ;
|
||||
};
|
||||
|
||||
|
||||
struct freeglutStrokeFont glutStrokeRoman ;
|
||||
struct freeglutStrokeFont glutStrokeMonoRoman ;
|
||||
|
||||
struct freeglutBitmapFont glutBitmap9By15 ;
|
||||
struct freeglutBitmapFont glutBitmap8By13 ;
|
||||
struct freeglutBitmapFont glutBitmapTimesRoman10 ;
|
||||
struct freeglutBitmapFont glutBitmapTimesRoman24 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica10 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica12 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica18 ;
|
||||
|
||||
/*
|
||||
* freeglut_glutfont_definitions_x11.c
|
||||
*
|
||||
* Bitmap and stroke fonts displaying.
|
||||
*
|
||||
* Copyright (c) 2003 Stephen J. Baker (whether he wants it or not).
|
||||
* All Rights Reserved.
|
||||
* Written by John F. Fay <fayjf@sourceforge.net>, who releases the
|
||||
* copyright over to the "freeglut" project lead.
|
||||
* Creation date: Mon July 21 2003
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* 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
|
||||
* original GLUT defined its font variables in rather an unusual way.
|
||||
* Publicly, in "glut.h", they were defined as "void *". Privately,
|
||||
* in one of the source code files, they were defined as pointers to a
|
||||
* structure. Most compilers and linkers are satisfied with the "void *"
|
||||
* 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
|
||||
* ".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
|
||||
* structure to match GLUT.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* necessary machinery. But this poses another problem, caused by the ugly
|
||||
* 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
|
||||
* CPP HACK.
|
||||
*/
|
||||
|
||||
#define glutStrokeRoman glutStrokeRomanIGNOREME
|
||||
#define glutStrokeMonoRoman glutStrokeMonoRomanIGNOREME
|
||||
#define glutBitmap9By15 glutBitmap9By15IGNOREME
|
||||
#define glutBitmap8By13 glutBitmap8By13IGNOREME
|
||||
#define glutBitmapTimesRoman10 glutBitmapTimesRoman10IGNOREME
|
||||
#define glutBitmapTimesRoman24 glutBitmapTimesRoman24IGNOREME
|
||||
#define glutBitmapHelvetica10 glutBitmapHelvetica10IGNOREME
|
||||
#define glutBitmapHelvetica12 glutBitmapHelvetica12IGNOREME
|
||||
#define glutBitmapHelvetica18 glutBitmapHelvetica18IGNOREME
|
||||
|
||||
#include <GL/freeglut_std.h>
|
||||
|
||||
#undef glutStrokeRoman
|
||||
#undef glutStrokeMonoRoman
|
||||
#undef glutBitmap9By15
|
||||
#undef glutBitmap8By13
|
||||
#undef glutBitmapTimesRoman10
|
||||
#undef glutBitmapTimesRoman24
|
||||
#undef glutBitmapHelvetica10
|
||||
#undef glutBitmapHelvetica12
|
||||
#undef glutBitmapHelvetica18
|
||||
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
struct freeglutStrokeFont
|
||||
{
|
||||
const char *name ;
|
||||
int num_chars ;
|
||||
void *ch ;
|
||||
float top ;
|
||||
float bottom ;
|
||||
};
|
||||
|
||||
struct freeglutBitmapFont
|
||||
{
|
||||
const char *name ;
|
||||
const int num_chars ;
|
||||
const int first ;
|
||||
const void *ch ;
|
||||
};
|
||||
|
||||
|
||||
struct freeglutStrokeFont glutStrokeRoman ;
|
||||
struct freeglutStrokeFont glutStrokeMonoRoman ;
|
||||
|
||||
struct freeglutBitmapFont glutBitmap9By15 ;
|
||||
struct freeglutBitmapFont glutBitmap8By13 ;
|
||||
struct freeglutBitmapFont glutBitmapTimesRoman10 ;
|
||||
struct freeglutBitmapFont glutBitmapTimesRoman24 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica10 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica12 ;
|
||||
struct freeglutBitmapFont glutBitmapHelvetica18 ;
|
||||
|
||||
|
@ -1,273 +1,273 @@
|
||||
/*
|
||||
* freeglut_init_x11.c
|
||||
*
|
||||
* Various freeglut initialization functions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <limits.h> /* LONG_MAX */
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/* Return the atom associated with "name". */
|
||||
static Atom fghGetAtom(const char * name)
|
||||
{
|
||||
return XInternAtom(fgDisplay.pDisplay.Display, name, False);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
* number of elements in "data". Return zero otherwise. In both cases, use
|
||||
* "Xfree()" to free "data".
|
||||
*/
|
||||
static int fghGetWindowProperty(Window window,
|
||||
Atom property,
|
||||
Atom type,
|
||||
unsigned char ** data)
|
||||
{
|
||||
/*
|
||||
* Caller always has to use "Xfree()" to free "data", since
|
||||
* "XGetWindowProperty() always allocates one extra byte in prop_return
|
||||
* [i.e. "data"] (even if the property is zero length) [..]".
|
||||
*/
|
||||
|
||||
int status; /* Returned by "XGetWindowProperty". */
|
||||
|
||||
Atom type_returned;
|
||||
int temp_format; /* Not used. */
|
||||
unsigned long number_of_elements;
|
||||
unsigned long temp_bytes_after; /* Not used. */
|
||||
|
||||
|
||||
status = XGetWindowProperty(fgDisplay.pDisplay.Display,
|
||||
window,
|
||||
property,
|
||||
0,
|
||||
LONG_MAX,
|
||||
False,
|
||||
type,
|
||||
&type_returned,
|
||||
&temp_format,
|
||||
&number_of_elements,
|
||||
&temp_bytes_after,
|
||||
data);
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT(status == Success,
|
||||
"XGetWindowProperty failled",
|
||||
"fghGetWindowProperty");
|
||||
|
||||
if (type_returned != type)
|
||||
{
|
||||
number_of_elements = 0;
|
||||
}
|
||||
|
||||
return number_of_elements;
|
||||
}
|
||||
|
||||
/* Check if the window manager is NET WM compliant. */
|
||||
static int fghNetWMSupported(void)
|
||||
{
|
||||
Atom wm_check;
|
||||
Window ** window_ptr_1;
|
||||
|
||||
int number_of_windows;
|
||||
int net_wm_supported;
|
||||
|
||||
|
||||
net_wm_supported = 0;
|
||||
|
||||
wm_check = fghGetAtom("_NET_SUPPORTING_WM_CHECK");
|
||||
window_ptr_1 = malloc(sizeof(Window *));
|
||||
|
||||
/*
|
||||
* Check that the window manager has set this property on the root window.
|
||||
* The property must be the ID of a child window.
|
||||
*/
|
||||
number_of_windows = fghGetWindowProperty(fgDisplay.pDisplay.RootWindow,
|
||||
wm_check,
|
||||
XA_WINDOW,
|
||||
(unsigned char **) window_ptr_1);
|
||||
if (number_of_windows == 1)
|
||||
{
|
||||
Window ** window_ptr_2;
|
||||
|
||||
window_ptr_2 = malloc(sizeof(Window *));
|
||||
|
||||
/* Check that the window has the same property set to the same value. */
|
||||
number_of_windows = fghGetWindowProperty(**window_ptr_1,
|
||||
wm_check,
|
||||
XA_WINDOW,
|
||||
(unsigned char **) window_ptr_2);
|
||||
if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2))
|
||||
{
|
||||
/* NET WM compliant */
|
||||
net_wm_supported = 1;
|
||||
}
|
||||
|
||||
XFree(*window_ptr_2);
|
||||
free(window_ptr_2);
|
||||
}
|
||||
|
||||
XFree(*window_ptr_1);
|
||||
free(window_ptr_1);
|
||||
|
||||
return net_wm_supported;
|
||||
}
|
||||
|
||||
/* Check if "hint" is present in "property" for "window". */
|
||||
int fgHintPresent(Window window, Atom property, Atom hint)
|
||||
{
|
||||
Atom *atoms;
|
||||
int number_of_atoms;
|
||||
int supported;
|
||||
int i;
|
||||
|
||||
supported = 0;
|
||||
|
||||
number_of_atoms = fghGetWindowProperty(window,
|
||||
property,
|
||||
XA_ATOM,
|
||||
(unsigned char **) &atoms);
|
||||
for (i = 0; i < number_of_atoms; i++)
|
||||
{
|
||||
if (atoms[i] == hint)
|
||||
{
|
||||
supported = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(atoms);
|
||||
return supported;
|
||||
}
|
||||
|
||||
/*
|
||||
* A call to this function should initialize all the display stuff...
|
||||
*/
|
||||
void fgPlatformInitialize( const char* displayName )
|
||||
{
|
||||
fgDisplay.pDisplay.Display = XOpenDisplay( displayName );
|
||||
|
||||
if( fgDisplay.pDisplay.Display == NULL )
|
||||
fgError( "failed to open display '%s'", XDisplayName( displayName ) );
|
||||
|
||||
if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
|
||||
fgError( "OpenGL GLX extension not supported by display '%s'",
|
||||
XDisplayName( displayName ) );
|
||||
|
||||
fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
|
||||
fgDisplay.pDisplay.RootWindow = RootWindow(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.ScreenWidth = DisplayWidth(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
fgDisplay.ScreenHeight = DisplayHeight(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.ScreenWidthMM = DisplayWidthMM(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
fgDisplay.ScreenHeightMM = DisplayHeightMM(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );
|
||||
|
||||
/* Create the window deletion atom */
|
||||
fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");
|
||||
|
||||
/* Create the state and full screen atoms */
|
||||
fgDisplay.pDisplay.State = None;
|
||||
fgDisplay.pDisplay.StateFullScreen = None;
|
||||
|
||||
if (fghNetWMSupported())
|
||||
{
|
||||
const Atom supported = fghGetAtom("_NET_SUPPORTED");
|
||||
const Atom state = fghGetAtom("_NET_WM_STATE");
|
||||
|
||||
/* Check if the state hint is supported. */
|
||||
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
|
||||
{
|
||||
const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
|
||||
|
||||
fgDisplay.pDisplay.State = state;
|
||||
|
||||
/* Check if the window manager supports full screen. */
|
||||
/** Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
|
||||
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
|
||||
{
|
||||
fgDisplay.pDisplay.StateFullScreen = full_screen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fgState.Initialised = GL_TRUE;
|
||||
|
||||
atexit(fgDeinitialize);
|
||||
|
||||
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
|
||||
fgInitialiseInputDevices();
|
||||
}
|
||||
|
||||
void fgPlatformDeinitialiseInputDevices ( void )
|
||||
{
|
||||
fghCloseInputDevices ();
|
||||
|
||||
fgState.JoysticksInitialised = GL_FALSE;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformCloseDisplay ( void )
|
||||
{
|
||||
/*
|
||||
* Make sure all X-client data we have created will be destroyed on
|
||||
* display closing
|
||||
*/
|
||||
XSetCloseDownMode( fgDisplay.pDisplay.Display, DestroyAll );
|
||||
|
||||
/*
|
||||
* Close the display connection, destroying all windows we have
|
||||
* created so far
|
||||
*/
|
||||
XCloseDisplay( fgDisplay.pDisplay.Display );
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
|
||||
{
|
||||
/* Note that the MVisualInfo is not owned by the MenuContext! */
|
||||
glXDestroyContext( pDisplay.Display, MContext );
|
||||
/*
|
||||
* freeglut_init_x11.c
|
||||
*
|
||||
* Various freeglut initialization functions.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define FREEGLUT_BUILDING_LIB
|
||||
#include <limits.h> /* LONG_MAX */
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/* Return the atom associated with "name". */
|
||||
static Atom fghGetAtom(const char * name)
|
||||
{
|
||||
return XInternAtom(fgDisplay.pDisplay.Display, name, False);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
* number of elements in "data". Return zero otherwise. In both cases, use
|
||||
* "Xfree()" to free "data".
|
||||
*/
|
||||
static int fghGetWindowProperty(Window window,
|
||||
Atom property,
|
||||
Atom type,
|
||||
unsigned char ** data)
|
||||
{
|
||||
/*
|
||||
* Caller always has to use "Xfree()" to free "data", since
|
||||
* "XGetWindowProperty() always allocates one extra byte in prop_return
|
||||
* [i.e. "data"] (even if the property is zero length) [..]".
|
||||
*/
|
||||
|
||||
int status; /* Returned by "XGetWindowProperty". */
|
||||
|
||||
Atom type_returned;
|
||||
int temp_format; /* Not used. */
|
||||
unsigned long number_of_elements;
|
||||
unsigned long temp_bytes_after; /* Not used. */
|
||||
|
||||
|
||||
status = XGetWindowProperty(fgDisplay.pDisplay.Display,
|
||||
window,
|
||||
property,
|
||||
0,
|
||||
LONG_MAX,
|
||||
False,
|
||||
type,
|
||||
&type_returned,
|
||||
&temp_format,
|
||||
&number_of_elements,
|
||||
&temp_bytes_after,
|
||||
data);
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT(status == Success,
|
||||
"XGetWindowProperty failled",
|
||||
"fghGetWindowProperty");
|
||||
|
||||
if (type_returned != type)
|
||||
{
|
||||
number_of_elements = 0;
|
||||
}
|
||||
|
||||
return number_of_elements;
|
||||
}
|
||||
|
||||
/* Check if the window manager is NET WM compliant. */
|
||||
static int fghNetWMSupported(void)
|
||||
{
|
||||
Atom wm_check;
|
||||
Window ** window_ptr_1;
|
||||
|
||||
int number_of_windows;
|
||||
int net_wm_supported;
|
||||
|
||||
|
||||
net_wm_supported = 0;
|
||||
|
||||
wm_check = fghGetAtom("_NET_SUPPORTING_WM_CHECK");
|
||||
window_ptr_1 = malloc(sizeof(Window *));
|
||||
|
||||
/*
|
||||
* Check that the window manager has set this property on the root window.
|
||||
* The property must be the ID of a child window.
|
||||
*/
|
||||
number_of_windows = fghGetWindowProperty(fgDisplay.pDisplay.RootWindow,
|
||||
wm_check,
|
||||
XA_WINDOW,
|
||||
(unsigned char **) window_ptr_1);
|
||||
if (number_of_windows == 1)
|
||||
{
|
||||
Window ** window_ptr_2;
|
||||
|
||||
window_ptr_2 = malloc(sizeof(Window *));
|
||||
|
||||
/* Check that the window has the same property set to the same value. */
|
||||
number_of_windows = fghGetWindowProperty(**window_ptr_1,
|
||||
wm_check,
|
||||
XA_WINDOW,
|
||||
(unsigned char **) window_ptr_2);
|
||||
if ((number_of_windows == 1) && (**window_ptr_1 == **window_ptr_2))
|
||||
{
|
||||
/* NET WM compliant */
|
||||
net_wm_supported = 1;
|
||||
}
|
||||
|
||||
XFree(*window_ptr_2);
|
||||
free(window_ptr_2);
|
||||
}
|
||||
|
||||
XFree(*window_ptr_1);
|
||||
free(window_ptr_1);
|
||||
|
||||
return net_wm_supported;
|
||||
}
|
||||
|
||||
/* Check if "hint" is present in "property" for "window". */
|
||||
int fgHintPresent(Window window, Atom property, Atom hint)
|
||||
{
|
||||
Atom *atoms;
|
||||
int number_of_atoms;
|
||||
int supported;
|
||||
int i;
|
||||
|
||||
supported = 0;
|
||||
|
||||
number_of_atoms = fghGetWindowProperty(window,
|
||||
property,
|
||||
XA_ATOM,
|
||||
(unsigned char **) &atoms);
|
||||
for (i = 0; i < number_of_atoms; i++)
|
||||
{
|
||||
if (atoms[i] == hint)
|
||||
{
|
||||
supported = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(atoms);
|
||||
return supported;
|
||||
}
|
||||
|
||||
/*
|
||||
* A call to this function should initialize all the display stuff...
|
||||
*/
|
||||
void fgPlatformInitialize( const char* displayName )
|
||||
{
|
||||
fgDisplay.pDisplay.Display = XOpenDisplay( displayName );
|
||||
|
||||
if( fgDisplay.pDisplay.Display == NULL )
|
||||
fgError( "failed to open display '%s'", XDisplayName( displayName ) );
|
||||
|
||||
if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
|
||||
fgError( "OpenGL GLX extension not supported by display '%s'",
|
||||
XDisplayName( displayName ) );
|
||||
|
||||
fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
|
||||
fgDisplay.pDisplay.RootWindow = RootWindow(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.ScreenWidth = DisplayWidth(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
fgDisplay.ScreenHeight = DisplayHeight(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.ScreenWidthMM = DisplayWidthMM(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
fgDisplay.ScreenHeightMM = DisplayHeightMM(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen
|
||||
);
|
||||
|
||||
fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );
|
||||
|
||||
/* Create the window deletion atom */
|
||||
fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");
|
||||
|
||||
/* Create the state and full screen atoms */
|
||||
fgDisplay.pDisplay.State = None;
|
||||
fgDisplay.pDisplay.StateFullScreen = None;
|
||||
|
||||
if (fghNetWMSupported())
|
||||
{
|
||||
const Atom supported = fghGetAtom("_NET_SUPPORTED");
|
||||
const Atom state = fghGetAtom("_NET_WM_STATE");
|
||||
|
||||
/* Check if the state hint is supported. */
|
||||
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
|
||||
{
|
||||
const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
|
||||
|
||||
fgDisplay.pDisplay.State = state;
|
||||
|
||||
/* Check if the window manager supports full screen. */
|
||||
/** Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
|
||||
if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
|
||||
{
|
||||
fgDisplay.pDisplay.StateFullScreen = full_screen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fgState.Initialised = GL_TRUE;
|
||||
|
||||
atexit(fgDeinitialize);
|
||||
|
||||
/* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
|
||||
fgInitialiseInputDevices();
|
||||
}
|
||||
|
||||
void fgPlatformDeinitialiseInputDevices ( void )
|
||||
{
|
||||
fghCloseInputDevices ();
|
||||
|
||||
fgState.JoysticksInitialised = GL_FALSE;
|
||||
fgState.InputDevsInitialised = GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformCloseDisplay ( void )
|
||||
{
|
||||
/*
|
||||
* Make sure all X-client data we have created will be destroyed on
|
||||
* display closing
|
||||
*/
|
||||
XSetCloseDownMode( fgDisplay.pDisplay.Display, DestroyAll );
|
||||
|
||||
/*
|
||||
* Close the display connection, destroying all windows we have
|
||||
* created so far
|
||||
*/
|
||||
XCloseDisplay( fgDisplay.pDisplay.Display );
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
|
||||
{
|
||||
/* Note that the MVisualInfo is not owned by the MenuContext! */
|
||||
glXDestroyContext( pDisplay.Display, MContext );
|
||||
}
|
@ -1,132 +1,132 @@
|
||||
/*
|
||||
* freeglut_input_devices_x11.c
|
||||
*
|
||||
* Handles miscellaneous input devices via direct serial-port access.
|
||||
* Proper X11 XInput device support is not yet supported.
|
||||
* Also lacks Mac support.
|
||||
*
|
||||
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005
|
||||
*
|
||||
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct _serialport {
|
||||
int fd;
|
||||
struct termios termio, termio_save;
|
||||
};
|
||||
|
||||
typedef struct _serialport SERIALPORT;
|
||||
|
||||
void serial_flush ( SERIALPORT *port );
|
||||
|
||||
/* local variables */
|
||||
static SERIALPORT *dialbox_port=NULL;
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Try initializing the input device(s)
|
||||
*/
|
||||
void fgPlatformRegisterDialDevice ( const char *dial_device )
|
||||
{
|
||||
}
|
||||
|
||||
SERIALPORT *serial_open ( const char *device )
|
||||
{
|
||||
int fd;
|
||||
struct termios termio;
|
||||
SERIALPORT *port;
|
||||
|
||||
fd = open(device, O_RDWR | O_NONBLOCK );
|
||||
if (fd <0) {
|
||||
perror(device);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
port = malloc(sizeof(SERIALPORT));
|
||||
memset(port, 0, sizeof(SERIALPORT));
|
||||
port->fd = fd;
|
||||
|
||||
/* save current port settings */
|
||||
tcgetattr(fd,&port->termio_save);
|
||||
|
||||
memset(&termio, 0, sizeof(termio));
|
||||
termio.c_cflag = CS8 | CREAD | HUPCL ;
|
||||
termio.c_iflag = IGNPAR | IGNBRK ;
|
||||
termio.c_cc[VTIME] = 0; /* inter-character timer */
|
||||
termio.c_cc[VMIN] = 1; /* block read until 1 chars received, when blocking I/O */
|
||||
|
||||
cfsetispeed(&termio, B9600);
|
||||
cfsetospeed(&termio, B9600);
|
||||
tcsetattr(fd,TCSANOW,&termio);
|
||||
|
||||
serial_flush(port);
|
||||
return port;
|
||||
}
|
||||
|
||||
void serial_close(SERIALPORT *port)
|
||||
{
|
||||
if (port)
|
||||
{
|
||||
/* restore old port settings */
|
||||
tcsetattr(port->fd,TCSANOW,&port->termio_save);
|
||||
close(port->fd);
|
||||
free(port);
|
||||
}
|
||||
}
|
||||
|
||||
int serial_getchar(SERIALPORT *port)
|
||||
{
|
||||
unsigned char ch;
|
||||
if (!port) return EOF;
|
||||
if (read(port->fd,&ch,1)) return ch;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int serial_putchar(SERIALPORT *port, unsigned char ch)
|
||||
{
|
||||
if (!port) return 0;
|
||||
return write(port->fd,&ch,1);
|
||||
}
|
||||
|
||||
void serial_flush ( SERIALPORT *port )
|
||||
{
|
||||
tcflush ( port->fd, TCIOFLUSH );
|
||||
}
|
||||
/*
|
||||
* freeglut_input_devices_x11.c
|
||||
*
|
||||
* Handles miscellaneous input devices via direct serial-port access.
|
||||
* Proper X11 XInput device support is not yet supported.
|
||||
* Also lacks Mac support.
|
||||
*
|
||||
* Written by Joe Krahn <krahn@niehs.nih.gov> 2005
|
||||
*
|
||||
* Copyright (c) 2005 Stephen J. Baker. All Rights Reserved.
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct _serialport {
|
||||
int fd;
|
||||
struct termios termio, termio_save;
|
||||
};
|
||||
|
||||
typedef struct _serialport SERIALPORT;
|
||||
|
||||
void serial_flush ( SERIALPORT *port );
|
||||
|
||||
/* local variables */
|
||||
static SERIALPORT *dialbox_port=NULL;
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/*
|
||||
* Try initializing the input device(s)
|
||||
*/
|
||||
void fgPlatformRegisterDialDevice ( const char *dial_device )
|
||||
{
|
||||
}
|
||||
|
||||
SERIALPORT *serial_open ( const char *device )
|
||||
{
|
||||
int fd;
|
||||
struct termios termio;
|
||||
SERIALPORT *port;
|
||||
|
||||
fd = open(device, O_RDWR | O_NONBLOCK );
|
||||
if (fd <0) {
|
||||
perror(device);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
port = malloc(sizeof(SERIALPORT));
|
||||
memset(port, 0, sizeof(SERIALPORT));
|
||||
port->fd = fd;
|
||||
|
||||
/* save current port settings */
|
||||
tcgetattr(fd,&port->termio_save);
|
||||
|
||||
memset(&termio, 0, sizeof(termio));
|
||||
termio.c_cflag = CS8 | CREAD | HUPCL ;
|
||||
termio.c_iflag = IGNPAR | IGNBRK ;
|
||||
termio.c_cc[VTIME] = 0; /* inter-character timer */
|
||||
termio.c_cc[VMIN] = 1; /* block read until 1 chars received, when blocking I/O */
|
||||
|
||||
cfsetispeed(&termio, B9600);
|
||||
cfsetospeed(&termio, B9600);
|
||||
tcsetattr(fd,TCSANOW,&termio);
|
||||
|
||||
serial_flush(port);
|
||||
return port;
|
||||
}
|
||||
|
||||
void serial_close(SERIALPORT *port)
|
||||
{
|
||||
if (port)
|
||||
{
|
||||
/* restore old port settings */
|
||||
tcsetattr(port->fd,TCSANOW,&port->termio_save);
|
||||
close(port->fd);
|
||||
free(port);
|
||||
}
|
||||
}
|
||||
|
||||
int serial_getchar(SERIALPORT *port)
|
||||
{
|
||||
unsigned char ch;
|
||||
if (!port) return EOF;
|
||||
if (read(port->fd,&ch,1)) return ch;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
int serial_putchar(SERIALPORT *port, unsigned char ch)
|
||||
{
|
||||
if (!port) return 0;
|
||||
return write(port->fd,&ch,1);
|
||||
}
|
||||
|
||||
void serial_flush ( SERIALPORT *port )
|
||||
{
|
||||
tcflush ( port->fd, TCIOFLUSH );
|
||||
}
|
||||
|
@ -1,229 +1,229 @@
|
||||
/*
|
||||
* freeglut_internal_x11.h
|
||||
*
|
||||
* The freeglut library private include file.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by Diederick C. Niehorster, <dcnieho@gmail.com>
|
||||
* Creation date: Fri Jan 20, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef FREEGLUT_INTERNAL_X11_H
|
||||
#define FREEGLUT_INTERNAL_X11_H
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
# include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
/* If GLX is too old, we will fail during runtime when multisampling
|
||||
is requested, but at least freeglut compiles. */
|
||||
#ifndef GLX_SAMPLE_BUFFERS
|
||||
# define GLX_SAMPLE_BUFFERS 0x80A8
|
||||
#endif
|
||||
#ifndef GLX_SAMPLES
|
||||
# define GLX_SAMPLES 0x80A9
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
||||
/* The structure used by display initialization in freeglut_init.c */
|
||||
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
||||
struct tagSFG_PlatformDisplay
|
||||
{
|
||||
Display* Display; /* The display we are being run in. */
|
||||
int Screen; /* The screen we are about to use. */
|
||||
Window RootWindow; /* The screen's root window. */
|
||||
int Connection; /* The display's connection number */
|
||||
Atom DeleteWindow; /* The window deletion atom */
|
||||
Atom State; /* The state atom */
|
||||
Atom StateFullScreen; /* The full screen atom */
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
int prev_xsz, prev_ysz;
|
||||
int prev_refresh;
|
||||
int prev_size_valid;
|
||||
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
/*
|
||||
* XF86VidMode may be compilable even if it fails at runtime. Therefore,
|
||||
* the validity of the VidMode has to be tracked
|
||||
*/
|
||||
int DisplayModeValid; /* Flag that indicates runtime status*/
|
||||
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
|
||||
int DisplayModeClock; /* The display mode's refresh rate */
|
||||
int DisplayViewPortX; /* saved X location of the viewport */
|
||||
int DisplayViewPortY; /* saved Y location of the viewport */
|
||||
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
|
||||
|
||||
int DisplayPointerX; /* saved X 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
|
||||
* much conditionally-compiled code later in the library.
|
||||
*/
|
||||
typedef Window SFG_WindowHandleType ;
|
||||
typedef GLXContext SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
GLXFBConfig* FBConfig; /* The window's FBConfig */
|
||||
};
|
||||
|
||||
|
||||
/* Window's state description. This structure should be kept portable. */
|
||||
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
|
||||
struct tagSFG_PlatformWindowState
|
||||
{
|
||||
int OldWidth; /* Window width from before a resize */
|
||||
int OldHeight; /* " height " " " " */
|
||||
};
|
||||
|
||||
|
||||
/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
|
||||
/*
|
||||
* Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
|
||||
* interspersed
|
||||
*/
|
||||
# ifdef HAVE_SYS_IOCTL_H
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
# ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
# include <string.h>
|
||||
# endif
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
/* XXX The below hack is done until freeglut's autoconf is updated. */
|
||||
# define HAVE_USB_JS 1
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
# include <sys/joystick.h>
|
||||
# else
|
||||
/*
|
||||
* XXX NetBSD/amd64 systems may find that they have to steal the
|
||||
* XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
|
||||
* XXX I cannot comment whether that works for the interface, but
|
||||
* XXX it lets you compile...(^& I do not think that we can do away
|
||||
* XXX with this header.
|
||||
*/
|
||||
# include <machine/joystick.h> /* For analog joysticks */
|
||||
# endif
|
||||
# define JS_DATA_TYPE joystick
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
|
||||
# if defined(__linux__)
|
||||
# include <linux/joystick.h>
|
||||
|
||||
/* check the joystick driver version */
|
||||
# if defined(JS_VERSION) && JS_VERSION >= 0x010000
|
||||
# define JS_NEW
|
||||
# endif
|
||||
# else /* Not BSD or Linux */
|
||||
# ifndef JS_RETURN
|
||||
|
||||
/*
|
||||
* We'll put these values in and that should
|
||||
* allow the code to at least compile when there is
|
||||
* no support. The JS open routine should error out
|
||||
* and shut off all the code downstream anyway and if
|
||||
* the application doesn't use a joystick we'll be fine.
|
||||
*/
|
||||
|
||||
struct JS_DATA_TYPE
|
||||
{
|
||||
int buttons;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* XXX It might be better to poll the operating system for the numbers of buttons and
|
||||
* XXX axes and then dynamically allocate the arrays.
|
||||
*/
|
||||
# define _JS_MAX_AXES 16
|
||||
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
||||
struct tagSFG_PlatformJoystick
|
||||
{
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
struct os_specific_s *os;
|
||||
# endif
|
||||
|
||||
# ifdef JS_NEW
|
||||
struct js_event js;
|
||||
int tmp_buttons;
|
||||
float tmp_axes [ _JS_MAX_AXES ];
|
||||
# else
|
||||
struct JS_DATA_TYPE js;
|
||||
# endif
|
||||
|
||||
char fname [ 128 ];
|
||||
int fd;
|
||||
};
|
||||
|
||||
|
||||
/* Menu font and color definitions */
|
||||
#define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18
|
||||
|
||||
#define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_BACK_COLORS {0.70f, 0.70f, 0.70f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
|
||||
|
||||
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
|
||||
/* spaceball device functions, defined in freeglut_spaceball.c */
|
||||
int fgIsSpaceballXEvent( const XEvent *ev );
|
||||
void fgSpaceballHandleXEvent( const XEvent *ev );
|
||||
|
||||
/*
|
||||
* Check if "hint" is present in "property" for "window". See freeglut_init.c
|
||||
*/
|
||||
int fgHintPresent(Window window, Atom property, Atom hint);
|
||||
|
||||
/* Handler for X extension Events */
|
||||
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
||||
void fgHandleExtensionEvents( XEvent * ev );
|
||||
void fgRegisterDevices( Display* dpy, Window* win );
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FREEGLUT_INTERNAL_X11_H */
|
||||
/*
|
||||
* freeglut_internal_x11.h
|
||||
*
|
||||
* The freeglut library private include file.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by Diederick C. Niehorster, <dcnieho@gmail.com>
|
||||
* Creation date: Fri Jan 20, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef FREEGLUT_INTERNAL_X11_H
|
||||
#define FREEGLUT_INTERNAL_X11_H
|
||||
|
||||
|
||||
/* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
# include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
/* If GLX is too old, we will fail during runtime when multisampling
|
||||
is requested, but at least freeglut compiles. */
|
||||
#ifndef GLX_SAMPLE_BUFFERS
|
||||
# define GLX_SAMPLE_BUFFERS 0x80A8
|
||||
#endif
|
||||
#ifndef GLX_SAMPLES
|
||||
# define GLX_SAMPLES 0x80A9
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
||||
/* The structure used by display initialization in freeglut_init.c */
|
||||
typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
||||
struct tagSFG_PlatformDisplay
|
||||
{
|
||||
Display* Display; /* The display we are being run in. */
|
||||
int Screen; /* The screen we are about to use. */
|
||||
Window RootWindow; /* The screen's root window. */
|
||||
int Connection; /* The display's connection number */
|
||||
Atom DeleteWindow; /* The window deletion atom */
|
||||
Atom State; /* The state atom */
|
||||
Atom StateFullScreen; /* The full screen atom */
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
|
||||
int prev_xsz, prev_ysz;
|
||||
int prev_refresh;
|
||||
int prev_size_valid;
|
||||
#endif /* HAVE_X11_EXTENSIONS_XRANDR_H */
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H
|
||||
/*
|
||||
* XF86VidMode may be compilable even if it fails at runtime. Therefore,
|
||||
* the validity of the VidMode has to be tracked
|
||||
*/
|
||||
int DisplayModeValid; /* Flag that indicates runtime status*/
|
||||
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
|
||||
int DisplayModeClock; /* The display mode's refresh rate */
|
||||
int DisplayViewPortX; /* saved X location of the viewport */
|
||||
int DisplayViewPortY; /* saved Y location of the viewport */
|
||||
#endif /* HAVE_X11_EXTENSIONS_XF86VMODE_H */
|
||||
|
||||
int DisplayPointerX; /* saved X 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
|
||||
* much conditionally-compiled code later in the library.
|
||||
*/
|
||||
typedef Window SFG_WindowHandleType ;
|
||||
typedef GLXContext SFG_WindowContextType ;
|
||||
typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
||||
struct tagSFG_PlatformContext
|
||||
{
|
||||
GLXFBConfig* FBConfig; /* The window's FBConfig */
|
||||
};
|
||||
|
||||
|
||||
/* Window's state description. This structure should be kept portable. */
|
||||
typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState;
|
||||
struct tagSFG_PlatformWindowState
|
||||
{
|
||||
int OldWidth; /* Window width from before a resize */
|
||||
int OldHeight; /* " height " " " " */
|
||||
};
|
||||
|
||||
|
||||
/* -- JOYSTICK-SPECIFIC STRUCTURES AND TYPES ------------------------------- */
|
||||
/*
|
||||
* Initial defines from "js.h" starting around line 33 with the existing "freeglut_joystick.c"
|
||||
* interspersed
|
||||
*/
|
||||
# ifdef HAVE_SYS_IOCTL_H
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
# ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# ifdef HAVE_ERRNO_H
|
||||
# include <errno.h>
|
||||
# include <string.h>
|
||||
# endif
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
/* XXX The below hack is done until freeglut's autoconf is updated. */
|
||||
# define HAVE_USB_JS 1
|
||||
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
# include <sys/joystick.h>
|
||||
# else
|
||||
/*
|
||||
* XXX NetBSD/amd64 systems may find that they have to steal the
|
||||
* XXX /usr/include/machine/joystick.h from a NetBSD/i386 system.
|
||||
* XXX I cannot comment whether that works for the interface, but
|
||||
* XXX it lets you compile...(^& I do not think that we can do away
|
||||
* XXX with this header.
|
||||
*/
|
||||
# include <machine/joystick.h> /* For analog joysticks */
|
||||
# endif
|
||||
# define JS_DATA_TYPE joystick
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
|
||||
# if defined(__linux__)
|
||||
# include <linux/joystick.h>
|
||||
|
||||
/* check the joystick driver version */
|
||||
# if defined(JS_VERSION) && JS_VERSION >= 0x010000
|
||||
# define JS_NEW
|
||||
# endif
|
||||
# else /* Not BSD or Linux */
|
||||
# ifndef JS_RETURN
|
||||
|
||||
/*
|
||||
* We'll put these values in and that should
|
||||
* allow the code to at least compile when there is
|
||||
* no support. The JS open routine should error out
|
||||
* and shut off all the code downstream anyway and if
|
||||
* the application doesn't use a joystick we'll be fine.
|
||||
*/
|
||||
|
||||
struct JS_DATA_TYPE
|
||||
{
|
||||
int buttons;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
# define JS_RETURN (sizeof(struct JS_DATA_TYPE))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* XXX It might be better to poll the operating system for the numbers of buttons and
|
||||
* XXX axes and then dynamically allocate the arrays.
|
||||
*/
|
||||
# define _JS_MAX_AXES 16
|
||||
typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick;
|
||||
struct tagSFG_PlatformJoystick
|
||||
{
|
||||
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
struct os_specific_s *os;
|
||||
# endif
|
||||
|
||||
# ifdef JS_NEW
|
||||
struct js_event js;
|
||||
int tmp_buttons;
|
||||
float tmp_axes [ _JS_MAX_AXES ];
|
||||
# else
|
||||
struct JS_DATA_TYPE js;
|
||||
# endif
|
||||
|
||||
char fname [ 128 ];
|
||||
int fd;
|
||||
};
|
||||
|
||||
|
||||
/* Menu font and color definitions */
|
||||
#define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18
|
||||
|
||||
#define FREEGLUT_MENU_PEN_FORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_BACK_COLORS {0.70f, 0.70f, 0.70f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_HFORE_COLORS {0.0f, 0.0f, 0.0f, 1.0f}
|
||||
#define FREEGLUT_MENU_PEN_HBACK_COLORS {1.0f, 1.0f, 1.0f, 1.0f}
|
||||
|
||||
|
||||
|
||||
|
||||
/* -- PRIVATE FUNCTION DECLARATIONS ---------------------------------------- */
|
||||
/* spaceball device functions, defined in freeglut_spaceball.c */
|
||||
int fgIsSpaceballXEvent( const XEvent *ev );
|
||||
void fgSpaceballHandleXEvent( const XEvent *ev );
|
||||
|
||||
/*
|
||||
* Check if "hint" is present in "property" for "window". See freeglut_init.c
|
||||
*/
|
||||
int fgHintPresent(Window window, Atom property, Atom hint);
|
||||
|
||||
/* Handler for X extension Events */
|
||||
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
||||
void fgHandleExtensionEvents( XEvent * ev );
|
||||
void fgRegisterDevices( Display* dpy, Window* win );
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* FREEGLUT_INTERNAL_X11_H */
|
||||
|
@ -1,465 +1,465 @@
|
||||
/*
|
||||
* freeglut_joystick_x11.c
|
||||
*
|
||||
* Joystick handling code
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Steve Baker, <sjbaker1@airmail.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Many thanks for Steve Baker for permission to pull from that library.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*this should be defined in a header file */
|
||||
#define MAX_NUM_JOYSTICKS 2
|
||||
extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
|
||||
|
||||
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
||||
{
|
||||
int status;
|
||||
|
||||
int i;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
int len;
|
||||
|
||||
if ( joy->pJoystick.os->is_analog )
|
||||
{
|
||||
int status = read ( joy->pJoystick.os->fd, &joy->pJoystick.os->ajs, sizeof(joy->pJoystick.os->ajs) );
|
||||
if ( status != sizeof(joy->pJoystick.os->ajs) ) {
|
||||
perror ( joy->pJoystick.os->fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
if ( buttons != NULL )
|
||||
*buttons = ( joy->pJoystick.os->ajs.b1 ? 1 : 0 ) | ( joy->pJoystick.os->ajs.b2 ? 2 : 0 );
|
||||
|
||||
if ( axes != NULL )
|
||||
{
|
||||
axes[0] = (float) joy->pJoystick.os->ajs.x;
|
||||
axes[1] = (float) joy->pJoystick.os->ajs.y;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# 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 )
|
||||
{
|
||||
struct hid_item *h;
|
||||
|
||||
for ( h = joy->pJoystick.os->hids; h; h = h->next )
|
||||
{
|
||||
int d = hid_get_data ( joy->pJoystick.os->hid_data_buf, h );
|
||||
|
||||
int page = HID_PAGE ( h->usage );
|
||||
int usage = HID_USAGE ( h->usage );
|
||||
|
||||
if ( page == HUP_GENERIC_DESKTOP )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < joy->num_axes; i++ )
|
||||
if (joy->pJoystick.os->axes_usage[i] == usage)
|
||||
{
|
||||
if (usage == HUG_HAT_SWITCH)
|
||||
{
|
||||
if (d < 0 || d > 8)
|
||||
d = 0; /* safety */
|
||||
joy->pJoystick.os->cache_axes[i] = (float)hatmap_x[d];
|
||||
joy->pJoystick.os->cache_axes[i + 1] = (float)hatmap_y[d];
|
||||
}
|
||||
else
|
||||
{
|
||||
joy->pJoystick.os->cache_axes[i] = (float)d;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (page == HUP_BUTTON)
|
||||
{
|
||||
if (usage > 0 && usage < _JS_MAX_BUTTONS + 1)
|
||||
{
|
||||
if (d)
|
||||
joy->pJoystick.os->cache_buttons |= (1 << ( usage - 1 ));
|
||||
else
|
||||
joy->pJoystick.os->cache_buttons &= ~(1 << ( usage - 1 ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# ifdef HAVE_ERRNO_H
|
||||
if ( len < 0 && errno != EAGAIN )
|
||||
# else
|
||||
if ( len < 0 )
|
||||
# endif
|
||||
{
|
||||
perror( joy->pJoystick.os->fname );
|
||||
joy->error = 1;
|
||||
}
|
||||
if ( buttons != NULL ) *buttons = joy->pJoystick.os->cache_buttons;
|
||||
if ( axes != NULL )
|
||||
memcpy ( axes, joy->pJoystick.os->cache_axes, sizeof(float) * joy->num_axes );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef JS_NEW
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
status = read ( joy->pJoystick.fd, &joy->pJoystick.js, sizeof(struct js_event) );
|
||||
|
||||
if ( status != sizeof( struct js_event ) )
|
||||
{
|
||||
# ifdef HAVE_ERRNO_H
|
||||
if ( errno == EAGAIN )
|
||||
{
|
||||
/* Use the old values */
|
||||
if ( buttons )
|
||||
*buttons = joy->pJoystick.tmp_buttons;
|
||||
if ( axes )
|
||||
memcpy( axes, joy->pJoystick.tmp_axes,
|
||||
sizeof( float ) * joy->num_axes );
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
fgWarning ( "%s", joy->pJoystick.fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( joy->pJoystick.js.type & ~JS_EVENT_INIT )
|
||||
{
|
||||
case JS_EVENT_BUTTON:
|
||||
if( joy->pJoystick.js.value == 0 ) /* clear the flag */
|
||||
joy->pJoystick.tmp_buttons &= ~( 1 << joy->pJoystick.js.number );
|
||||
else
|
||||
joy->pJoystick.tmp_buttons |= ( 1 << joy->pJoystick.js.number );
|
||||
break;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
if ( joy->pJoystick.js.number < joy->num_axes )
|
||||
{
|
||||
joy->pJoystick.tmp_axes[ joy->pJoystick.js.number ] = ( float )joy->pJoystick.js.value;
|
||||
|
||||
if( axes )
|
||||
memcpy( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning ( "PLIB_JS: Unrecognised /dev/js return!?!" );
|
||||
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons != NULL ) *buttons = joy->pJoystick.tmp_buttons;
|
||||
if ( axes != NULL )
|
||||
memcpy ( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( buttons )
|
||||
*buttons = joy->pJoystick.tmp_buttons;
|
||||
}
|
||||
#else
|
||||
|
||||
status = read( joy->pJoystick.fd, &joy->pJoystick.js, JS_RETURN );
|
||||
|
||||
if ( status != JS_RETURN )
|
||||
{
|
||||
fgWarning( "%s", joy->pJoystick.fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
# 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 */
|
||||
# else
|
||||
*buttons = joy->pJoystick.js.buttons;
|
||||
# endif
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
axes[ 0 ] = (float) joy->pJoystick.js.x;
|
||||
axes[ 1 ] = (float) joy->pJoystick.js.y;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickOpen( SFG_Joystick* joy )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
int i = 0;
|
||||
char *cp;
|
||||
#endif
|
||||
#ifdef JS_NEW
|
||||
unsigned char u;
|
||||
int i=0;
|
||||
#else
|
||||
# if defined( __linux__ ) || TARGET_HOST_SOLARIS
|
||||
int i = 0;
|
||||
int counter = 0;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
joy->pJoystick.os->cache_axes[ i ] = 0.0f;
|
||||
|
||||
joy->pJoystick.os->cache_buttons = 0;
|
||||
|
||||
joy->pJoystick.os->fd = open( joy->pJoystick.os->fname, O_RDONLY | O_NONBLOCK);
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
if( joy->pJoystick.os->fd < 0 && errno == EACCES )
|
||||
fgWarning ( "%s exists but is not readable by you", joy->pJoystick.os->fname );
|
||||
#endif
|
||||
|
||||
joy->error =( joy->pJoystick.os->fd < 0 );
|
||||
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
joy->num_axes = 0;
|
||||
joy->num_buttons = 0;
|
||||
if( joy->pJoystick.os->is_analog )
|
||||
{
|
||||
FILE *joyfile;
|
||||
char joyfname[ 1024 ];
|
||||
int noargs, in_no_axes;
|
||||
|
||||
float axes [ _JS_MAX_AXES ];
|
||||
int buttons[ _JS_MAX_AXES ];
|
||||
|
||||
joy->num_axes = 2;
|
||||
joy->num_buttons = 32;
|
||||
|
||||
fghJoystickRawRead( joy, buttons, axes );
|
||||
joy->error = axes[ 0 ] < -1000000000.0f;
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id );
|
||||
|
||||
joyfile = fopen( joyfname, "r" );
|
||||
joy->error =( joyfile == NULL );
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
noargs = fscanf( joyfile, "%d%f%f%f%f%f%f", &in_no_axes,
|
||||
&joy->min[ 0 ], &joy->center[ 0 ], &joy->max[ 0 ],
|
||||
&joy->min[ 1 ], &joy->center[ 1 ], &joy->max[ 1 ] );
|
||||
joy->error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
|
||||
fclose( joyfile );
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
|
||||
return; /* End of analog code */
|
||||
}
|
||||
|
||||
# ifdef HAVE_USB_JS
|
||||
if( ! fghJoystickInitializeHID( joy->pJoystick.os, &joy->num_axes,
|
||||
&joy->num_buttons ) )
|
||||
{
|
||||
close( joy->pJoystick.os->fd );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
cp = strrchr( joy->pJoystick.os->fname, '/' );
|
||||
if( cp )
|
||||
{
|
||||
if( fghJoystickFindUSBdev( &cp[1], joy->name, sizeof( joy->name ) ) ==
|
||||
0 )
|
||||
strcpy( joy->name, &cp[1] );
|
||||
}
|
||||
|
||||
if( joy->num_axes > _JS_MAX_AXES )
|
||||
joy->num_axes = _JS_MAX_AXES;
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
/* We really should get this from the HID, but that data seems
|
||||
* to be quite unreliable for analog-to-USB converters. Punt for
|
||||
* now.
|
||||
*/
|
||||
if( joy->pJoystick.os->axes_usage[ i ] == HUG_HAT_SWITCH )
|
||||
{
|
||||
joy->max [ i ] = 1.0f;
|
||||
joy->center[ i ] = 0.0f;
|
||||
joy->min [ i ] = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
joy->max [ i ] = 255.0f;
|
||||
joy->center[ i ] = 127.0f;
|
||||
joy->min [ i ] = 0.0f;
|
||||
}
|
||||
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate[ i ] = 1.0f;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __linux__ ) || TARGET_HOST_SOLARIS
|
||||
/* Default for older Linux systems. */
|
||||
joy->num_axes = 2;
|
||||
joy->num_buttons = 32;
|
||||
|
||||
# ifdef JS_NEW
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
joy->pJoystick.tmp_axes[ i ] = 0.0f;
|
||||
|
||||
joy->pJoystick.tmp_buttons = 0;
|
||||
# endif
|
||||
|
||||
joy->pJoystick.fd = open( joy->pJoystick.fname, O_RDONLY );
|
||||
|
||||
joy->error =( joy->pJoystick.fd < 0 );
|
||||
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
/* Set the correct number of axes for the linux driver */
|
||||
# ifdef JS_NEW
|
||||
/* Melchior Franz's fixes for big-endian Linuxes since writing
|
||||
* to the upper byte of an uninitialized word doesn't work.
|
||||
* 9 April 2003
|
||||
*/
|
||||
ioctl( joy->pJoystick.fd, JSIOCGAXES, &u );
|
||||
joy->num_axes = u;
|
||||
ioctl( joy->pJoystick.fd, JSIOCGBUTTONS, &u );
|
||||
joy->num_buttons = u;
|
||||
ioctl( joy->pJoystick.fd, JSIOCGNAME( sizeof( joy->name ) ), joy->name );
|
||||
fcntl( joy->pJoystick.fd, F_SETFL, O_NONBLOCK );
|
||||
# endif
|
||||
|
||||
/*
|
||||
* The Linux driver seems to return 512 for all axes
|
||||
* when no stick is present - but there is a chance
|
||||
* that could happen by accident - so it's gotta happen
|
||||
* on both axes for at least 100 attempts.
|
||||
*
|
||||
* PWO: shouldn't be that done somehow wiser on the kernel level?
|
||||
*/
|
||||
# ifndef JS_NEW
|
||||
counter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
fghJoystickRawRead( joy, NULL, joy->center );
|
||||
counter++;
|
||||
} while( !joy->error &&
|
||||
counter < 100 &&
|
||||
joy->center[ 0 ] == 512.0f &&
|
||||
joy->center[ 1 ] == 512.0f );
|
||||
|
||||
if ( counter >= 100 )
|
||||
joy->error = GL_TRUE;
|
||||
# endif
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
# ifdef JS_NEW
|
||||
joy->max [ i ] = 32767.0f;
|
||||
joy->center[ i ] = 0.0f;
|
||||
joy->min [ i ] = -32767.0f;
|
||||
# else
|
||||
joy->max[ i ] = joy->center[ i ] * 2.0f;
|
||||
joy->min[ i ] = 0.0f;
|
||||
# endif
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
fgJoystick[ ident ]->id = ident;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
|
||||
fgJoystick[ ident ]->pJoystick.os = calloc( 1, sizeof( struct os_specific_s ) );
|
||||
memset( fgJoystick[ ident ]->pJoystick.os, 0, sizeof( struct os_specific_s ) );
|
||||
if( ident < USB_IDENT_OFFSET )
|
||||
fgJoystick[ ident ]->pJoystick.os->is_analog = 1;
|
||||
if( fgJoystick[ ident ]->pJoystick.os->is_analog )
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", AJSDEV, ident );
|
||||
else
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", UHIDDEV,
|
||||
ident - USB_IDENT_OFFSET );
|
||||
#elif defined( __linux__ )
|
||||
fgJoystick[ ident ]->id = ident;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
|
||||
snprintf( fgJoystick[ident]->pJoystick.fname, sizeof(fgJoystick[ident]->pJoystick.fname), "/dev/input/js%d", ident );
|
||||
|
||||
if( access( fgJoystick[ ident ]->pJoystick.fname, F_OK ) != 0 )
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.fname, sizeof(fgJoystick[ ident ]->pJoystick.fname), "/dev/js%d", ident );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickClose ( int ident )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
if( fgJoystick[ident]->pJoystick.os )
|
||||
{
|
||||
if( ! fgJoystick[ ident ]->error )
|
||||
close( fgJoystick[ ident ]->pJoystick.os->fd );
|
||||
#ifdef HAVE_USB_JS
|
||||
if( fgJoystick[ ident ]->pJoystick.os->hids )
|
||||
free (fgJoystick[ ident ]->pJoystick.os->hids);
|
||||
if( fgJoystick[ ident ]->pJoystick.os->hid_data_buf )
|
||||
free( fgJoystick[ ident ]->pJoystick.os->hid_data_buf );
|
||||
#endif
|
||||
free( fgJoystick[ident]->pJoystick.os );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ! fgJoystick[ident]->error )
|
||||
close( fgJoystick[ ident ]->pJoystick.fd );
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_joystick_x11.c
|
||||
*
|
||||
* Joystick handling code
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Steve Baker, <sjbaker1@airmail.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Many thanks for Steve Baker for permission to pull from that library.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*this should be defined in a header file */
|
||||
#define MAX_NUM_JOYSTICKS 2
|
||||
extern SFG_Joystick *fgJoystick [ MAX_NUM_JOYSTICKS ];
|
||||
|
||||
void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
||||
{
|
||||
int status;
|
||||
|
||||
int i;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
int len;
|
||||
|
||||
if ( joy->pJoystick.os->is_analog )
|
||||
{
|
||||
int status = read ( joy->pJoystick.os->fd, &joy->pJoystick.os->ajs, sizeof(joy->pJoystick.os->ajs) );
|
||||
if ( status != sizeof(joy->pJoystick.os->ajs) ) {
|
||||
perror ( joy->pJoystick.os->fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
if ( buttons != NULL )
|
||||
*buttons = ( joy->pJoystick.os->ajs.b1 ? 1 : 0 ) | ( joy->pJoystick.os->ajs.b2 ? 2 : 0 );
|
||||
|
||||
if ( axes != NULL )
|
||||
{
|
||||
axes[0] = (float) joy->pJoystick.os->ajs.x;
|
||||
axes[1] = (float) joy->pJoystick.os->ajs.y;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# 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 )
|
||||
{
|
||||
struct hid_item *h;
|
||||
|
||||
for ( h = joy->pJoystick.os->hids; h; h = h->next )
|
||||
{
|
||||
int d = hid_get_data ( joy->pJoystick.os->hid_data_buf, h );
|
||||
|
||||
int page = HID_PAGE ( h->usage );
|
||||
int usage = HID_USAGE ( h->usage );
|
||||
|
||||
if ( page == HUP_GENERIC_DESKTOP )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < joy->num_axes; i++ )
|
||||
if (joy->pJoystick.os->axes_usage[i] == usage)
|
||||
{
|
||||
if (usage == HUG_HAT_SWITCH)
|
||||
{
|
||||
if (d < 0 || d > 8)
|
||||
d = 0; /* safety */
|
||||
joy->pJoystick.os->cache_axes[i] = (float)hatmap_x[d];
|
||||
joy->pJoystick.os->cache_axes[i + 1] = (float)hatmap_y[d];
|
||||
}
|
||||
else
|
||||
{
|
||||
joy->pJoystick.os->cache_axes[i] = (float)d;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (page == HUP_BUTTON)
|
||||
{
|
||||
if (usage > 0 && usage < _JS_MAX_BUTTONS + 1)
|
||||
{
|
||||
if (d)
|
||||
joy->pJoystick.os->cache_buttons |= (1 << ( usage - 1 ));
|
||||
else
|
||||
joy->pJoystick.os->cache_buttons &= ~(1 << ( usage - 1 ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# ifdef HAVE_ERRNO_H
|
||||
if ( len < 0 && errno != EAGAIN )
|
||||
# else
|
||||
if ( len < 0 )
|
||||
# endif
|
||||
{
|
||||
perror( joy->pJoystick.os->fname );
|
||||
joy->error = 1;
|
||||
}
|
||||
if ( buttons != NULL ) *buttons = joy->pJoystick.os->cache_buttons;
|
||||
if ( axes != NULL )
|
||||
memcpy ( axes, joy->pJoystick.os->cache_axes, sizeof(float) * joy->num_axes );
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef JS_NEW
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
status = read ( joy->pJoystick.fd, &joy->pJoystick.js, sizeof(struct js_event) );
|
||||
|
||||
if ( status != sizeof( struct js_event ) )
|
||||
{
|
||||
# ifdef HAVE_ERRNO_H
|
||||
if ( errno == EAGAIN )
|
||||
{
|
||||
/* Use the old values */
|
||||
if ( buttons )
|
||||
*buttons = joy->pJoystick.tmp_buttons;
|
||||
if ( axes )
|
||||
memcpy( axes, joy->pJoystick.tmp_axes,
|
||||
sizeof( float ) * joy->num_axes );
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
||||
fgWarning ( "%s", joy->pJoystick.fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( joy->pJoystick.js.type & ~JS_EVENT_INIT )
|
||||
{
|
||||
case JS_EVENT_BUTTON:
|
||||
if( joy->pJoystick.js.value == 0 ) /* clear the flag */
|
||||
joy->pJoystick.tmp_buttons &= ~( 1 << joy->pJoystick.js.number );
|
||||
else
|
||||
joy->pJoystick.tmp_buttons |= ( 1 << joy->pJoystick.js.number );
|
||||
break;
|
||||
|
||||
case JS_EVENT_AXIS:
|
||||
if ( joy->pJoystick.js.number < joy->num_axes )
|
||||
{
|
||||
joy->pJoystick.tmp_axes[ joy->pJoystick.js.number ] = ( float )joy->pJoystick.js.value;
|
||||
|
||||
if( axes )
|
||||
memcpy( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fgWarning ( "PLIB_JS: Unrecognised /dev/js return!?!" );
|
||||
|
||||
/* use the old values */
|
||||
|
||||
if ( buttons != NULL ) *buttons = joy->pJoystick.tmp_buttons;
|
||||
if ( axes != NULL )
|
||||
memcpy ( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( buttons )
|
||||
*buttons = joy->pJoystick.tmp_buttons;
|
||||
}
|
||||
#else
|
||||
|
||||
status = read( joy->pJoystick.fd, &joy->pJoystick.js, JS_RETURN );
|
||||
|
||||
if ( status != JS_RETURN )
|
||||
{
|
||||
fgWarning( "%s", joy->pJoystick.fname );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( buttons )
|
||||
# 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 */
|
||||
# else
|
||||
*buttons = joy->pJoystick.js.buttons;
|
||||
# endif
|
||||
|
||||
if ( axes )
|
||||
{
|
||||
axes[ 0 ] = (float) joy->pJoystick.js.x;
|
||||
axes[ 1 ] = (float) joy->pJoystick.js.y;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickOpen( SFG_Joystick* joy )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
int i = 0;
|
||||
char *cp;
|
||||
#endif
|
||||
#ifdef JS_NEW
|
||||
unsigned char u;
|
||||
int i=0;
|
||||
#else
|
||||
# if defined( __linux__ ) || TARGET_HOST_SOLARIS
|
||||
int i = 0;
|
||||
int counter = 0;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
joy->pJoystick.os->cache_axes[ i ] = 0.0f;
|
||||
|
||||
joy->pJoystick.os->cache_buttons = 0;
|
||||
|
||||
joy->pJoystick.os->fd = open( joy->pJoystick.os->fname, O_RDONLY | O_NONBLOCK);
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
if( joy->pJoystick.os->fd < 0 && errno == EACCES )
|
||||
fgWarning ( "%s exists but is not readable by you", joy->pJoystick.os->fname );
|
||||
#endif
|
||||
|
||||
joy->error =( joy->pJoystick.os->fd < 0 );
|
||||
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
joy->num_axes = 0;
|
||||
joy->num_buttons = 0;
|
||||
if( joy->pJoystick.os->is_analog )
|
||||
{
|
||||
FILE *joyfile;
|
||||
char joyfname[ 1024 ];
|
||||
int noargs, in_no_axes;
|
||||
|
||||
float axes [ _JS_MAX_AXES ];
|
||||
int buttons[ _JS_MAX_AXES ];
|
||||
|
||||
joy->num_axes = 2;
|
||||
joy->num_buttons = 32;
|
||||
|
||||
fghJoystickRawRead( joy, buttons, axes );
|
||||
joy->error = axes[ 0 ] < -1000000000.0f;
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id );
|
||||
|
||||
joyfile = fopen( joyfname, "r" );
|
||||
joy->error =( joyfile == NULL );
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
noargs = fscanf( joyfile, "%d%f%f%f%f%f%f", &in_no_axes,
|
||||
&joy->min[ 0 ], &joy->center[ 0 ], &joy->max[ 0 ],
|
||||
&joy->min[ 1 ], &joy->center[ 1 ], &joy->max[ 1 ] );
|
||||
joy->error = noargs != 7 || in_no_axes != _JS_MAX_AXES;
|
||||
fclose( joyfile );
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
|
||||
return; /* End of analog code */
|
||||
}
|
||||
|
||||
# ifdef HAVE_USB_JS
|
||||
if( ! fghJoystickInitializeHID( joy->pJoystick.os, &joy->num_axes,
|
||||
&joy->num_buttons ) )
|
||||
{
|
||||
close( joy->pJoystick.os->fd );
|
||||
joy->error = GL_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
cp = strrchr( joy->pJoystick.os->fname, '/' );
|
||||
if( cp )
|
||||
{
|
||||
if( fghJoystickFindUSBdev( &cp[1], joy->name, sizeof( joy->name ) ) ==
|
||||
0 )
|
||||
strcpy( joy->name, &cp[1] );
|
||||
}
|
||||
|
||||
if( joy->num_axes > _JS_MAX_AXES )
|
||||
joy->num_axes = _JS_MAX_AXES;
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
/* We really should get this from the HID, but that data seems
|
||||
* to be quite unreliable for analog-to-USB converters. Punt for
|
||||
* now.
|
||||
*/
|
||||
if( joy->pJoystick.os->axes_usage[ i ] == HUG_HAT_SWITCH )
|
||||
{
|
||||
joy->max [ i ] = 1.0f;
|
||||
joy->center[ i ] = 0.0f;
|
||||
joy->min [ i ] = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
joy->max [ i ] = 255.0f;
|
||||
joy->center[ i ] = 127.0f;
|
||||
joy->min [ i ] = 0.0f;
|
||||
}
|
||||
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate[ i ] = 1.0f;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __linux__ ) || TARGET_HOST_SOLARIS
|
||||
/* Default for older Linux systems. */
|
||||
joy->num_axes = 2;
|
||||
joy->num_buttons = 32;
|
||||
|
||||
# ifdef JS_NEW
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
joy->pJoystick.tmp_axes[ i ] = 0.0f;
|
||||
|
||||
joy->pJoystick.tmp_buttons = 0;
|
||||
# endif
|
||||
|
||||
joy->pJoystick.fd = open( joy->pJoystick.fname, O_RDONLY );
|
||||
|
||||
joy->error =( joy->pJoystick.fd < 0 );
|
||||
|
||||
if( joy->error )
|
||||
return;
|
||||
|
||||
/* Set the correct number of axes for the linux driver */
|
||||
# ifdef JS_NEW
|
||||
/* Melchior Franz's fixes for big-endian Linuxes since writing
|
||||
* to the upper byte of an uninitialized word doesn't work.
|
||||
* 9 April 2003
|
||||
*/
|
||||
ioctl( joy->pJoystick.fd, JSIOCGAXES, &u );
|
||||
joy->num_axes = u;
|
||||
ioctl( joy->pJoystick.fd, JSIOCGBUTTONS, &u );
|
||||
joy->num_buttons = u;
|
||||
ioctl( joy->pJoystick.fd, JSIOCGNAME( sizeof( joy->name ) ), joy->name );
|
||||
fcntl( joy->pJoystick.fd, F_SETFL, O_NONBLOCK );
|
||||
# endif
|
||||
|
||||
/*
|
||||
* The Linux driver seems to return 512 for all axes
|
||||
* when no stick is present - but there is a chance
|
||||
* that could happen by accident - so it's gotta happen
|
||||
* on both axes for at least 100 attempts.
|
||||
*
|
||||
* PWO: shouldn't be that done somehow wiser on the kernel level?
|
||||
*/
|
||||
# ifndef JS_NEW
|
||||
counter = 0;
|
||||
|
||||
do
|
||||
{
|
||||
fghJoystickRawRead( joy, NULL, joy->center );
|
||||
counter++;
|
||||
} while( !joy->error &&
|
||||
counter < 100 &&
|
||||
joy->center[ 0 ] == 512.0f &&
|
||||
joy->center[ 1 ] == 512.0f );
|
||||
|
||||
if ( counter >= 100 )
|
||||
joy->error = GL_TRUE;
|
||||
# endif
|
||||
|
||||
for( i = 0; i < _JS_MAX_AXES; i++ )
|
||||
{
|
||||
# ifdef JS_NEW
|
||||
joy->max [ i ] = 32767.0f;
|
||||
joy->center[ i ] = 0.0f;
|
||||
joy->min [ i ] = -32767.0f;
|
||||
# else
|
||||
joy->max[ i ] = joy->center[ i ] * 2.0f;
|
||||
joy->min[ i ] = 0.0f;
|
||||
# endif
|
||||
joy->dead_band[ i ] = 0.0f;
|
||||
joy->saturate [ i ] = 1.0f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickInit( SFG_Joystick *fgJoystick[], int ident )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
fgJoystick[ ident ]->id = ident;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
|
||||
fgJoystick[ ident ]->pJoystick.os = calloc( 1, sizeof( struct os_specific_s ) );
|
||||
memset( fgJoystick[ ident ]->pJoystick.os, 0, sizeof( struct os_specific_s ) );
|
||||
if( ident < USB_IDENT_OFFSET )
|
||||
fgJoystick[ ident ]->pJoystick.os->is_analog = 1;
|
||||
if( fgJoystick[ ident ]->pJoystick.os->is_analog )
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", AJSDEV, ident );
|
||||
else
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.os->fname, sizeof(fgJoystick[ ident ]->pJoystick.os->fname), "%s%d", UHIDDEV,
|
||||
ident - USB_IDENT_OFFSET );
|
||||
#elif defined( __linux__ )
|
||||
fgJoystick[ ident ]->id = ident;
|
||||
fgJoystick[ ident ]->error = GL_FALSE;
|
||||
|
||||
snprintf( fgJoystick[ident]->pJoystick.fname, sizeof(fgJoystick[ident]->pJoystick.fname), "/dev/input/js%d", ident );
|
||||
|
||||
if( access( fgJoystick[ ident ]->pJoystick.fname, F_OK ) != 0 )
|
||||
snprintf( fgJoystick[ ident ]->pJoystick.fname, sizeof(fgJoystick[ ident ]->pJoystick.fname), "/dev/js%d", ident );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void fgPlatformJoystickClose ( int ident )
|
||||
{
|
||||
#if defined( __FreeBSD__ ) || defined(__FreeBSD_kernel__) || defined( __NetBSD__ )
|
||||
if( fgJoystick[ident]->pJoystick.os )
|
||||
{
|
||||
if( ! fgJoystick[ ident ]->error )
|
||||
close( fgJoystick[ ident ]->pJoystick.os->fd );
|
||||
#ifdef HAVE_USB_JS
|
||||
if( fgJoystick[ ident ]->pJoystick.os->hids )
|
||||
free (fgJoystick[ ident ]->pJoystick.os->hids);
|
||||
if( fgJoystick[ ident ]->pJoystick.os->hid_data_buf )
|
||||
free( fgJoystick[ ident ]->pJoystick.os->hid_data_buf );
|
||||
#endif
|
||||
free( fgJoystick[ident]->pJoystick.os );
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ! fgJoystick[ident]->error )
|
||||
close( fgJoystick[ ident ]->pJoystick.fd );
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,49 +1,49 @@
|
||||
/*
|
||||
* freeglut_menu_x11.c
|
||||
*
|
||||
* Pull-down menu creation and handling.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Wed Feb 1, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* * Private function to get the virtual maximum screen extent
|
||||
* */
|
||||
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
|
||||
{
|
||||
int wx, wy;
|
||||
Window w;
|
||||
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
window->Window.Handle,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
0, 0, &wx, &wy, &w);
|
||||
|
||||
*x = fgState.GameModeSize.X + wx;
|
||||
*y = fgState.GameModeSize.Y + wy;
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_menu_x11.c
|
||||
*
|
||||
* Pull-down menu creation and handling.
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Wed Feb 1, 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* * Private function to get the virtual maximum screen extent
|
||||
* */
|
||||
GLvoid fgPlatformGetGameModeVMaxExtent( SFG_Window* window, int* x, int* y )
|
||||
{
|
||||
int wx, wy;
|
||||
Window w;
|
||||
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
window->Window.Handle,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
0, 0, &wx, &wy, &w);
|
||||
|
||||
*x = fgState.GameModeSize.X + wx;
|
||||
*y = fgState.GameModeSize.Y + wy;
|
||||
}
|
||||
|
||||
|
@ -1,415 +1,415 @@
|
||||
/* Spaceball support for Linux.
|
||||
* Written by John Tsiombikas <nuclear@member.fsf.org>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* This code supports 3Dconnexion's 6-dof space-whatever devices.
|
||||
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
|
||||
* free spacenavd (http://spacenav.sourceforge.net), through the "standard"
|
||||
* magellan X-based protocol.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
extern int sball_initialized;
|
||||
|
||||
enum {
|
||||
SPNAV_EVENT_ANY, /* used by spnav_remove_events() */
|
||||
SPNAV_EVENT_MOTION,
|
||||
SPNAV_EVENT_BUTTON /* includes both press and release */
|
||||
};
|
||||
|
||||
struct spnav_event_motion {
|
||||
int type;
|
||||
int x, y, z;
|
||||
int rx, ry, rz;
|
||||
unsigned int period;
|
||||
int *data;
|
||||
};
|
||||
|
||||
struct spnav_event_button {
|
||||
int type;
|
||||
int press;
|
||||
int bnum;
|
||||
};
|
||||
|
||||
typedef union spnav_event {
|
||||
int type;
|
||||
struct spnav_event_motion motion;
|
||||
struct spnav_event_button button;
|
||||
} spnav_event;
|
||||
|
||||
|
||||
static int spnav_x11_open(Display *dpy, Window win);
|
||||
static int spnav_x11_window(Window win);
|
||||
static int spnav_x11_event(const XEvent *xev, spnav_event *event);
|
||||
static int spnav_close(void);
|
||||
static int spnav_fd(void);
|
||||
static int spnav_remove_events(int type);
|
||||
|
||||
static SFG_Window *spnav_win;
|
||||
|
||||
void fgPlatformInitializeSpaceball(void)
|
||||
{
|
||||
Window w;
|
||||
|
||||
sball_initialized = 1;
|
||||
if(!fgStructure.CurrentWindow)
|
||||
{
|
||||
sball_initialized = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
w = fgStructure.CurrentWindow->Window.Handle;
|
||||
if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1)
|
||||
{
|
||||
sball_initialized = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballClose(void)
|
||||
{
|
||||
spnav_close();
|
||||
}
|
||||
|
||||
int fgPlatformHasSpaceball(void)
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
return spnav_fd() == -1 ? 0 : 1;
|
||||
}
|
||||
|
||||
int fgPlatformSpaceballNumButtons(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
if(spnav_win != window) {
|
||||
spnav_x11_window(window->Window.Handle);
|
||||
spnav_win = window;
|
||||
}
|
||||
}
|
||||
|
||||
int fgIsSpaceballXEvent(const XEvent *xev)
|
||||
{
|
||||
spnav_event sev;
|
||||
|
||||
if(spnav_win != fgStructure.CurrentWindow) {
|
||||
/* this will also initialize spaceball if needed (first call) */
|
||||
fgSpaceballSetWindow(fgStructure.CurrentWindow);
|
||||
}
|
||||
|
||||
if(sball_initialized != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return spnav_x11_event(xev, &sev);
|
||||
}
|
||||
|
||||
void fgSpaceballHandleXEvent(const XEvent *xev)
|
||||
{
|
||||
spnav_event sev;
|
||||
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(spnav_x11_event(xev, &sev)) {
|
||||
switch(sev.type) {
|
||||
case SPNAV_EVENT_MOTION:
|
||||
if(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) {
|
||||
INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz));
|
||||
}
|
||||
spnav_remove_events(SPNAV_EVENT_MOTION);
|
||||
break;
|
||||
|
||||
case SPNAV_EVENT_BUTTON:
|
||||
INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum, sev.button.press ? GLUT_DOWN : GLUT_UP));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
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
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
static Window get_daemon_window(Display *dpy);
|
||||
static int catch_badwin(Display *dpy, XErrorEvent *err);
|
||||
|
||||
static Display *dpy;
|
||||
static Window app_win;
|
||||
static Atom motion_event, button_press_event, button_release_event, command_event;
|
||||
|
||||
enum {
|
||||
CMD_APP_WINDOW = 27695,
|
||||
CMD_APP_SENS
|
||||
};
|
||||
|
||||
#define IS_OPEN dpy
|
||||
|
||||
struct event_node {
|
||||
spnav_event event;
|
||||
struct event_node *next;
|
||||
};
|
||||
|
||||
static int spnav_x11_open(Display *display, Window win)
|
||||
{
|
||||
if(IS_OPEN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
dpy = display;
|
||||
|
||||
motion_event = XInternAtom(dpy, "MotionEvent", True);
|
||||
button_press_event = XInternAtom(dpy, "ButtonPressEvent", True);
|
||||
button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True);
|
||||
command_event = XInternAtom(dpy, "CommandEvent", True);
|
||||
|
||||
if(!motion_event || !button_press_event || !button_release_event || !command_event) {
|
||||
dpy = 0;
|
||||
return -1; /* daemon not started */
|
||||
}
|
||||
|
||||
if(spnav_x11_window(win) == -1) {
|
||||
dpy = 0;
|
||||
return -1; /* daemon not started */
|
||||
}
|
||||
|
||||
app_win = win;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_close(void)
|
||||
{
|
||||
if(dpy) {
|
||||
spnav_x11_window(DefaultRootWindow(dpy));
|
||||
app_win = 0;
|
||||
dpy = 0;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int spnav_x11_window(Window win)
|
||||
{
|
||||
int (*prev_xerr_handler)(Display*, XErrorEvent*);
|
||||
XEvent xev;
|
||||
Window daemon_win;
|
||||
|
||||
if(!IS_OPEN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(daemon_win = get_daemon_window(dpy))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
prev_xerr_handler = XSetErrorHandler(catch_badwin);
|
||||
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.send_event = False;
|
||||
xev.xclient.display = dpy;
|
||||
xev.xclient.window = win;
|
||||
xev.xclient.message_type = command_event;
|
||||
xev.xclient.format = 16;
|
||||
xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16;
|
||||
xev.xclient.data.s[1] = (unsigned int)win & 0xffff;
|
||||
xev.xclient.data.s[2] = CMD_APP_WINDOW;
|
||||
|
||||
XSendEvent(dpy, daemon_win, False, 0, &xev);
|
||||
XSync(dpy, False);
|
||||
|
||||
XSetErrorHandler(prev_xerr_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_fd(void)
|
||||
{
|
||||
if(dpy) {
|
||||
return ConnectionNumber(dpy);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*static int spnav_wait_event(spnav_event *event)
|
||||
{
|
||||
if(dpy) {
|
||||
for(;;) {
|
||||
XEvent xev;
|
||||
XNextEvent(dpy, &xev);
|
||||
|
||||
if(spnav_x11_event(&xev, event) > 0) {
|
||||
return event->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_poll_event(spnav_event *event)
|
||||
{
|
||||
if(dpy) {
|
||||
if(XPending(dpy)) {
|
||||
XEvent xev;
|
||||
XNextEvent(dpy, &xev);
|
||||
|
||||
return spnav_x11_event(&xev, event);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
static Bool match_events(Display *dpy, XEvent *xev, char *arg)
|
||||
{
|
||||
int evtype = *(int*)arg;
|
||||
|
||||
if(xev->type != ClientMessage) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if(xev->xclient.message_type == motion_event) {
|
||||
return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False;
|
||||
}
|
||||
if(xev->xclient.message_type == button_press_event ||
|
||||
xev->xclient.message_type == button_release_event) {
|
||||
return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
static int spnav_remove_events(int type)
|
||||
{
|
||||
int rm_count = 0;
|
||||
|
||||
if(dpy) {
|
||||
XEvent xev;
|
||||
|
||||
while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) {
|
||||
rm_count++;
|
||||
}
|
||||
return rm_count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_x11_event(const XEvent *xev, spnav_event *event)
|
||||
{
|
||||
int i;
|
||||
int xmsg_type;
|
||||
|
||||
if(xev->type != ClientMessage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmsg_type = xev->xclient.message_type;
|
||||
|
||||
if(xmsg_type != motion_event && xmsg_type != button_press_event &&
|
||||
xmsg_type != button_release_event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(xmsg_type == motion_event) {
|
||||
event->type = SPNAV_EVENT_MOTION;
|
||||
event->motion.data = &event->motion.x;
|
||||
|
||||
for(i=0; i<6; i++) {
|
||||
event->motion.data[i] = xev->xclient.data.s[i + 2];
|
||||
}
|
||||
event->motion.period = xev->xclient.data.s[8];
|
||||
} else {
|
||||
event->type = SPNAV_EVENT_BUTTON;
|
||||
event->button.press = xmsg_type == button_press_event ? 1 : 0;
|
||||
event->button.bnum = xev->xclient.data.s[2];
|
||||
}
|
||||
return event->type;
|
||||
}
|
||||
|
||||
|
||||
static Window get_daemon_window(Display *dpy)
|
||||
{
|
||||
Window win, root_win;
|
||||
XTextProperty wname;
|
||||
Atom type;
|
||||
int fmt;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *prop;
|
||||
|
||||
root_win = DefaultRootWindow(dpy);
|
||||
|
||||
XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop);
|
||||
if(!prop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
win = *(Window*)prop;
|
||||
XFree(prop);
|
||||
|
||||
if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
static int catch_badwin(Display *dpy, XErrorEvent *err)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
if(err->error_code == BadWindow) {
|
||||
/* do nothing? */
|
||||
} else {
|
||||
XGetErrorText(dpy, err->error_code, buf, sizeof buf);
|
||||
fprintf(stderr, "Caught unexpected X error: %s\n", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Spaceball support for Linux.
|
||||
* Written by John Tsiombikas <nuclear@member.fsf.org>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* This code supports 3Dconnexion's 6-dof space-whatever devices.
|
||||
* It can communicate with either the proprietary 3Dconnexion daemon (3dxsrv)
|
||||
* free spacenavd (http://spacenav.sourceforge.net), through the "standard"
|
||||
* magellan X-based protocol.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
extern int sball_initialized;
|
||||
|
||||
enum {
|
||||
SPNAV_EVENT_ANY, /* used by spnav_remove_events() */
|
||||
SPNAV_EVENT_MOTION,
|
||||
SPNAV_EVENT_BUTTON /* includes both press and release */
|
||||
};
|
||||
|
||||
struct spnav_event_motion {
|
||||
int type;
|
||||
int x, y, z;
|
||||
int rx, ry, rz;
|
||||
unsigned int period;
|
||||
int *data;
|
||||
};
|
||||
|
||||
struct spnav_event_button {
|
||||
int type;
|
||||
int press;
|
||||
int bnum;
|
||||
};
|
||||
|
||||
typedef union spnav_event {
|
||||
int type;
|
||||
struct spnav_event_motion motion;
|
||||
struct spnav_event_button button;
|
||||
} spnav_event;
|
||||
|
||||
|
||||
static int spnav_x11_open(Display *dpy, Window win);
|
||||
static int spnav_x11_window(Window win);
|
||||
static int spnav_x11_event(const XEvent *xev, spnav_event *event);
|
||||
static int spnav_close(void);
|
||||
static int spnav_fd(void);
|
||||
static int spnav_remove_events(int type);
|
||||
|
||||
static SFG_Window *spnav_win;
|
||||
|
||||
void fgPlatformInitializeSpaceball(void)
|
||||
{
|
||||
Window w;
|
||||
|
||||
sball_initialized = 1;
|
||||
if(!fgStructure.CurrentWindow)
|
||||
{
|
||||
sball_initialized = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
w = fgStructure.CurrentWindow->Window.Handle;
|
||||
if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1)
|
||||
{
|
||||
sball_initialized = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballClose(void)
|
||||
{
|
||||
spnav_close();
|
||||
}
|
||||
|
||||
int fgPlatformHasSpaceball(void)
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
return spnav_fd() == -1 ? 0 : 1;
|
||||
}
|
||||
|
||||
int fgPlatformSpaceballNumButtons(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
void fgPlatformSpaceballSetWindow(SFG_Window *window)
|
||||
{
|
||||
if(spnav_win != window) {
|
||||
spnav_x11_window(window->Window.Handle);
|
||||
spnav_win = window;
|
||||
}
|
||||
}
|
||||
|
||||
int fgIsSpaceballXEvent(const XEvent *xev)
|
||||
{
|
||||
spnav_event sev;
|
||||
|
||||
if(spnav_win != fgStructure.CurrentWindow) {
|
||||
/* this will also initialize spaceball if needed (first call) */
|
||||
fgSpaceballSetWindow(fgStructure.CurrentWindow);
|
||||
}
|
||||
|
||||
if(sball_initialized != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return spnav_x11_event(xev, &sev);
|
||||
}
|
||||
|
||||
void fgSpaceballHandleXEvent(const XEvent *xev)
|
||||
{
|
||||
spnav_event sev;
|
||||
|
||||
if(sball_initialized == 0) {
|
||||
fgInitialiseSpaceball();
|
||||
if(sball_initialized != 1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(spnav_x11_event(xev, &sev)) {
|
||||
switch(sev.type) {
|
||||
case SPNAV_EVENT_MOTION:
|
||||
if(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) {
|
||||
INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz));
|
||||
}
|
||||
spnav_remove_events(SPNAV_EVENT_MOTION);
|
||||
break;
|
||||
|
||||
case SPNAV_EVENT_BUTTON:
|
||||
INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum, sev.button.press ? GLUT_DOWN : GLUT_UP));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
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
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
static Window get_daemon_window(Display *dpy);
|
||||
static int catch_badwin(Display *dpy, XErrorEvent *err);
|
||||
|
||||
static Display *dpy;
|
||||
static Window app_win;
|
||||
static Atom motion_event, button_press_event, button_release_event, command_event;
|
||||
|
||||
enum {
|
||||
CMD_APP_WINDOW = 27695,
|
||||
CMD_APP_SENS
|
||||
};
|
||||
|
||||
#define IS_OPEN dpy
|
||||
|
||||
struct event_node {
|
||||
spnav_event event;
|
||||
struct event_node *next;
|
||||
};
|
||||
|
||||
static int spnav_x11_open(Display *display, Window win)
|
||||
{
|
||||
if(IS_OPEN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
dpy = display;
|
||||
|
||||
motion_event = XInternAtom(dpy, "MotionEvent", True);
|
||||
button_press_event = XInternAtom(dpy, "ButtonPressEvent", True);
|
||||
button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True);
|
||||
command_event = XInternAtom(dpy, "CommandEvent", True);
|
||||
|
||||
if(!motion_event || !button_press_event || !button_release_event || !command_event) {
|
||||
dpy = 0;
|
||||
return -1; /* daemon not started */
|
||||
}
|
||||
|
||||
if(spnav_x11_window(win) == -1) {
|
||||
dpy = 0;
|
||||
return -1; /* daemon not started */
|
||||
}
|
||||
|
||||
app_win = win;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_close(void)
|
||||
{
|
||||
if(dpy) {
|
||||
spnav_x11_window(DefaultRootWindow(dpy));
|
||||
app_win = 0;
|
||||
dpy = 0;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int spnav_x11_window(Window win)
|
||||
{
|
||||
int (*prev_xerr_handler)(Display*, XErrorEvent*);
|
||||
XEvent xev;
|
||||
Window daemon_win;
|
||||
|
||||
if(!IS_OPEN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(daemon_win = get_daemon_window(dpy))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
prev_xerr_handler = XSetErrorHandler(catch_badwin);
|
||||
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.send_event = False;
|
||||
xev.xclient.display = dpy;
|
||||
xev.xclient.window = win;
|
||||
xev.xclient.message_type = command_event;
|
||||
xev.xclient.format = 16;
|
||||
xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16;
|
||||
xev.xclient.data.s[1] = (unsigned int)win & 0xffff;
|
||||
xev.xclient.data.s[2] = CMD_APP_WINDOW;
|
||||
|
||||
XSendEvent(dpy, daemon_win, False, 0, &xev);
|
||||
XSync(dpy, False);
|
||||
|
||||
XSetErrorHandler(prev_xerr_handler);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_fd(void)
|
||||
{
|
||||
if(dpy) {
|
||||
return ConnectionNumber(dpy);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*static int spnav_wait_event(spnav_event *event)
|
||||
{
|
||||
if(dpy) {
|
||||
for(;;) {
|
||||
XEvent xev;
|
||||
XNextEvent(dpy, &xev);
|
||||
|
||||
if(spnav_x11_event(&xev, event) > 0) {
|
||||
return event->type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_poll_event(spnav_event *event)
|
||||
{
|
||||
if(dpy) {
|
||||
if(XPending(dpy)) {
|
||||
XEvent xev;
|
||||
XNextEvent(dpy, &xev);
|
||||
|
||||
return spnav_x11_event(&xev, event);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
static Bool match_events(Display *dpy, XEvent *xev, char *arg)
|
||||
{
|
||||
int evtype = *(int*)arg;
|
||||
|
||||
if(xev->type != ClientMessage) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if(xev->xclient.message_type == motion_event) {
|
||||
return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False;
|
||||
}
|
||||
if(xev->xclient.message_type == button_press_event ||
|
||||
xev->xclient.message_type == button_release_event) {
|
||||
return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
static int spnav_remove_events(int type)
|
||||
{
|
||||
int rm_count = 0;
|
||||
|
||||
if(dpy) {
|
||||
XEvent xev;
|
||||
|
||||
while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) {
|
||||
rm_count++;
|
||||
}
|
||||
return rm_count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spnav_x11_event(const XEvent *xev, spnav_event *event)
|
||||
{
|
||||
int i;
|
||||
int xmsg_type;
|
||||
|
||||
if(xev->type != ClientMessage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmsg_type = xev->xclient.message_type;
|
||||
|
||||
if(xmsg_type != motion_event && xmsg_type != button_press_event &&
|
||||
xmsg_type != button_release_event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(xmsg_type == motion_event) {
|
||||
event->type = SPNAV_EVENT_MOTION;
|
||||
event->motion.data = &event->motion.x;
|
||||
|
||||
for(i=0; i<6; i++) {
|
||||
event->motion.data[i] = xev->xclient.data.s[i + 2];
|
||||
}
|
||||
event->motion.period = xev->xclient.data.s[8];
|
||||
} else {
|
||||
event->type = SPNAV_EVENT_BUTTON;
|
||||
event->button.press = xmsg_type == button_press_event ? 1 : 0;
|
||||
event->button.bnum = xev->xclient.data.s[2];
|
||||
}
|
||||
return event->type;
|
||||
}
|
||||
|
||||
|
||||
static Window get_daemon_window(Display *dpy)
|
||||
{
|
||||
Window win, root_win;
|
||||
XTextProperty wname;
|
||||
Atom type;
|
||||
int fmt;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *prop;
|
||||
|
||||
root_win = DefaultRootWindow(dpy);
|
||||
|
||||
XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop);
|
||||
if(!prop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
win = *(Window*)prop;
|
||||
XFree(prop);
|
||||
|
||||
if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
static int catch_badwin(Display *dpy, XErrorEvent *err)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
if(err->error_code == BadWindow) {
|
||||
/* do nothing? */
|
||||
} else {
|
||||
XGetErrorText(dpy, err->error_code, buf, sizeof buf);
|
||||
fprintf(stderr, "Caught unexpected X error: %s\n", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,406 +1,406 @@
|
||||
/*
|
||||
* freeglut_state_x11.c
|
||||
*
|
||||
* X11-specific freeglut state query methods.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Feb 4 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* fgPlatformChooseFBConfig() -- OK, but what about glutInitDisplayString()?
|
||||
*/
|
||||
|
||||
/* A helper function to check if a display mode is possible to use */
|
||||
GLXFBConfig* fgPlatformChooseFBConfig( int* numcfgs );
|
||||
|
||||
/*
|
||||
* Queries the GL context about some attributes
|
||||
*/
|
||||
int fgPlatformGetConfig( int attribute )
|
||||
{
|
||||
int returnValue = 0;
|
||||
int result; /* Not checked */
|
||||
|
||||
if( fgStructure.CurrentWindow )
|
||||
result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
|
||||
*(fgStructure.CurrentWindow->Window.pContext.FBConfig),
|
||||
attribute,
|
||||
&returnValue );
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
int fgPlatformGlutGet ( GLenum eWhat )
|
||||
{
|
||||
int nsamples = 0;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
/*
|
||||
* The window/context specific queries are handled mostly by
|
||||
* fgPlatformGetConfig().
|
||||
*/
|
||||
case GLUT_WINDOW_NUM_SAMPLES:
|
||||
#ifdef GLX_VERSION_1_3
|
||||
glGetIntegerv(GL_SAMPLES, &nsamples);
|
||||
#endif
|
||||
return nsamples;
|
||||
|
||||
/*
|
||||
* The rest of GLX queries under X are general enough to use a macro to
|
||||
* check them
|
||||
*/
|
||||
# define GLX_QUERY(a,b) case a: return fgPlatformGetConfig( b );
|
||||
|
||||
GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
|
||||
GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
|
||||
GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_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_GREEN_SIZE, GLX_ACCUM_GREEN_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_STEREO, GLX_STEREO );
|
||||
|
||||
# undef GLX_QUERY
|
||||
|
||||
/* Colormap size is handled in a bit different way than all the rest */
|
||||
case GLUT_WINDOW_COLORMAP_SIZE:
|
||||
if( (fgPlatformGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
|
||||
{
|
||||
/*
|
||||
* We've got a RGBA visual, so there is no colormap at all.
|
||||
* The other possibility is that we have no current window set.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLXFBConfig * fbconfig =
|
||||
fgStructure.CurrentWindow->Window.pContext.FBConfig;
|
||||
|
||||
XVisualInfo * visualInfo =
|
||||
glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, *fbconfig );
|
||||
|
||||
const int result = visualInfo->visual->map_entries;
|
||||
|
||||
XFree(visualInfo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Those calls are somewhat similiar, as they use XGetWindowAttributes()
|
||||
* function
|
||||
*/
|
||||
case GLUT_WINDOW_X:
|
||||
case GLUT_WINDOW_Y:
|
||||
case GLUT_WINDOW_BORDER_WIDTH:
|
||||
case GLUT_WINDOW_HEADER_HEIGHT:
|
||||
{
|
||||
int x, y;
|
||||
Window w;
|
||||
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
0, 0, &x, &y, &w);
|
||||
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_X: return x;
|
||||
case GLUT_WINDOW_Y: return y;
|
||||
}
|
||||
|
||||
if ( w == 0 )
|
||||
return 0;
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
w, 0, 0, &x, &y, &w);
|
||||
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_BORDER_WIDTH: return x;
|
||||
case GLUT_WINDOW_HEADER_HEIGHT: return y;
|
||||
}
|
||||
}
|
||||
|
||||
case GLUT_WINDOW_WIDTH:
|
||||
case GLUT_WINDOW_HEIGHT:
|
||||
{
|
||||
XWindowAttributes winAttributes;
|
||||
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
XGetWindowAttributes(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&winAttributes
|
||||
);
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_WIDTH: return winAttributes.width ;
|
||||
case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
|
||||
}
|
||||
}
|
||||
|
||||
/* I do not know yet if there will be a fgChooseVisual() function for Win32 */
|
||||
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||
{
|
||||
/* We should not have to call fgPlatformChooseFBConfig again here. */
|
||||
GLXFBConfig * fbconfig;
|
||||
int isPossible;
|
||||
|
||||
fbconfig = fgPlatformChooseFBConfig(NULL);
|
||||
|
||||
if (fbconfig == NULL)
|
||||
{
|
||||
isPossible = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
isPossible = 1;
|
||||
XFree(fbconfig);
|
||||
}
|
||||
|
||||
return isPossible;
|
||||
}
|
||||
|
||||
/* This is system-dependant */
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
|
||||
return fgPlatformGetConfig( GLX_VISUAL_ID );
|
||||
|
||||
default:
|
||||
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
||||
{
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_KEYBOARD:
|
||||
/*
|
||||
* X11 has a core keyboard by definition, although it can
|
||||
* be present as a virtual/dummy keyboard. For now, there
|
||||
* is no reliable way to tell if a real keyboard is present.
|
||||
*/
|
||||
return 1;
|
||||
|
||||
/* X11 has a mouse by definition */
|
||||
case GLUT_HAS_MOUSE:
|
||||
return 1 ;
|
||||
|
||||
case GLUT_NUM_MOUSE_BUTTONS:
|
||||
/* 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.
|
||||
*
|
||||
* In XFree86/Xorg servers, a mouse wheel is seen as two buttons
|
||||
* rather than an Axis; "freeglut_main.c" expects this when
|
||||
* checking for a wheel event.
|
||||
*/
|
||||
{
|
||||
unsigned char map;
|
||||
int nbuttons = XGetPointerMapping(fgDisplay.pDisplay.Display, &map,0);
|
||||
return nbuttons;
|
||||
}
|
||||
|
||||
default:
|
||||
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fgPlatformGlutLayerGet( GLenum eWhat )
|
||||
{
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_OVERLAY_POSSIBLE:
|
||||
return 0;
|
||||
|
||||
case GLUT_LAYER_IN_USE:
|
||||
return GLUT_NORMAL;
|
||||
|
||||
case GLUT_HAS_OVERLAY:
|
||||
return 0;
|
||||
|
||||
case GLUT_TRANSPARENT_INDEX:
|
||||
/*
|
||||
* Return just anything, which is always defined as zero
|
||||
*
|
||||
* XXX HUH?
|
||||
*/
|
||||
return 0;
|
||||
|
||||
case GLUT_NORMAL_DAMAGED:
|
||||
/* XXX Actually I do not know. Maybe. */
|
||||
return 0;
|
||||
|
||||
case GLUT_OVERLAY_DAMAGED:
|
||||
return -1;
|
||||
|
||||
default:
|
||||
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
int *array;
|
||||
|
||||
int attributes[9];
|
||||
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
|
||||
int fbconfigArraySize; /* Number of FBConfigs in the array */
|
||||
int attribute_name = 0;
|
||||
|
||||
array = NULL;
|
||||
*size = 0;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_AUX:
|
||||
case GLUT_MULTISAMPLE:
|
||||
|
||||
attributes[0] = GLX_BUFFER_SIZE;
|
||||
attributes[1] = GLX_DONT_CARE;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_AUX:
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of auxiliary
|
||||
buffers. We want at least one buffer.
|
||||
*/
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = 1;
|
||||
attributes[4] = None;
|
||||
|
||||
attribute_name = GLX_AUX_BUFFERS;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = GLX_DONT_CARE;
|
||||
attributes[4] = GLX_SAMPLE_BUFFERS;
|
||||
attributes[5] = 1;
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of samples per
|
||||
pixel. We want at least one sample.
|
||||
*/
|
||||
attributes[6] = GLX_SAMPLES;
|
||||
attributes[7] = 1;
|
||||
attributes[8] = None;
|
||||
|
||||
attribute_name = GLX_SAMPLES;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
fbconfigArray = glXChooseFBConfig(fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen,
|
||||
attributes,
|
||||
&fbconfigArraySize);
|
||||
|
||||
if (fbconfigArray != NULL)
|
||||
{
|
||||
int * temp_array;
|
||||
int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
|
||||
int previous_value;
|
||||
int i;
|
||||
|
||||
temp_array = malloc(sizeof(int) * fbconfigArraySize);
|
||||
previous_value = 0;
|
||||
|
||||
for (i = 0; i < fbconfigArraySize; i++)
|
||||
{
|
||||
int value;
|
||||
|
||||
result = glXGetFBConfigAttrib(fgDisplay.pDisplay.Display,
|
||||
fbconfigArray[i],
|
||||
attribute_name,
|
||||
&value);
|
||||
if (value > previous_value)
|
||||
{
|
||||
temp_array[*size] = value;
|
||||
previous_value = value;
|
||||
(*size)++;
|
||||
}
|
||||
}
|
||||
|
||||
array = malloc(sizeof(int) * (*size));
|
||||
for (i = 0; i < *size; i++)
|
||||
{
|
||||
array[i] = temp_array[i];
|
||||
}
|
||||
|
||||
free(temp_array);
|
||||
XFree(fbconfigArray);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* freeglut_state_x11.c
|
||||
*
|
||||
* X11-specific freeglut state query methods.
|
||||
*
|
||||
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
|
||||
* Written by John F. Fay, <fayjf@sourceforge.net>
|
||||
* Creation date: Sat Feb 4 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
/*
|
||||
* TODO BEFORE THE STABLE RELEASE:
|
||||
*
|
||||
* fgPlatformChooseFBConfig() -- OK, but what about glutInitDisplayString()?
|
||||
*/
|
||||
|
||||
/* A helper function to check if a display mode is possible to use */
|
||||
GLXFBConfig* fgPlatformChooseFBConfig( int* numcfgs );
|
||||
|
||||
/*
|
||||
* Queries the GL context about some attributes
|
||||
*/
|
||||
int fgPlatformGetConfig( int attribute )
|
||||
{
|
||||
int returnValue = 0;
|
||||
int result; /* Not checked */
|
||||
|
||||
if( fgStructure.CurrentWindow )
|
||||
result = glXGetFBConfigAttrib( fgDisplay.pDisplay.Display,
|
||||
*(fgStructure.CurrentWindow->Window.pContext.FBConfig),
|
||||
attribute,
|
||||
&returnValue );
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
int fgPlatformGlutGet ( GLenum eWhat )
|
||||
{
|
||||
int nsamples = 0;
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
/*
|
||||
* The window/context specific queries are handled mostly by
|
||||
* fgPlatformGetConfig().
|
||||
*/
|
||||
case GLUT_WINDOW_NUM_SAMPLES:
|
||||
#ifdef GLX_VERSION_1_3
|
||||
glGetIntegerv(GL_SAMPLES, &nsamples);
|
||||
#endif
|
||||
return nsamples;
|
||||
|
||||
/*
|
||||
* The rest of GLX queries under X are general enough to use a macro to
|
||||
* check them
|
||||
*/
|
||||
# define GLX_QUERY(a,b) case a: return fgPlatformGetConfig( b );
|
||||
|
||||
GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
|
||||
GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
|
||||
GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE, GLX_BUFFER_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE, GLX_STENCIL_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE, GLX_DEPTH_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_RED_SIZE, GLX_RED_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_GREEN_SIZE, GLX_GREEN_SIZE );
|
||||
GLX_QUERY( GLUT_WINDOW_BLUE_SIZE, GLX_BLUE_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_GREEN_SIZE, GLX_ACCUM_GREEN_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_STEREO, GLX_STEREO );
|
||||
|
||||
# undef GLX_QUERY
|
||||
|
||||
/* Colormap size is handled in a bit different way than all the rest */
|
||||
case GLUT_WINDOW_COLORMAP_SIZE:
|
||||
if( (fgPlatformGetConfig( GLX_RGBA )) || (fgStructure.CurrentWindow == NULL) )
|
||||
{
|
||||
/*
|
||||
* We've got a RGBA visual, so there is no colormap at all.
|
||||
* The other possibility is that we have no current window set.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLXFBConfig * fbconfig =
|
||||
fgStructure.CurrentWindow->Window.pContext.FBConfig;
|
||||
|
||||
XVisualInfo * visualInfo =
|
||||
glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, *fbconfig );
|
||||
|
||||
const int result = visualInfo->visual->map_entries;
|
||||
|
||||
XFree(visualInfo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Those calls are somewhat similiar, as they use XGetWindowAttributes()
|
||||
* function
|
||||
*/
|
||||
case GLUT_WINDOW_X:
|
||||
case GLUT_WINDOW_Y:
|
||||
case GLUT_WINDOW_BORDER_WIDTH:
|
||||
case GLUT_WINDOW_HEADER_HEIGHT:
|
||||
{
|
||||
int x, y;
|
||||
Window w;
|
||||
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
fgDisplay.pDisplay.RootWindow,
|
||||
0, 0, &x, &y, &w);
|
||||
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_X: return x;
|
||||
case GLUT_WINDOW_Y: return y;
|
||||
}
|
||||
|
||||
if ( w == 0 )
|
||||
return 0;
|
||||
XTranslateCoordinates(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
w, 0, 0, &x, &y, &w);
|
||||
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_BORDER_WIDTH: return x;
|
||||
case GLUT_WINDOW_HEADER_HEIGHT: return y;
|
||||
}
|
||||
}
|
||||
|
||||
case GLUT_WINDOW_WIDTH:
|
||||
case GLUT_WINDOW_HEIGHT:
|
||||
{
|
||||
XWindowAttributes winAttributes;
|
||||
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
XGetWindowAttributes(
|
||||
fgDisplay.pDisplay.Display,
|
||||
fgStructure.CurrentWindow->Window.Handle,
|
||||
&winAttributes
|
||||
);
|
||||
switch ( eWhat )
|
||||
{
|
||||
case GLUT_WINDOW_WIDTH: return winAttributes.width ;
|
||||
case GLUT_WINDOW_HEIGHT: return winAttributes.height ;
|
||||
}
|
||||
}
|
||||
|
||||
/* I do not know yet if there will be a fgChooseVisual() function for Win32 */
|
||||
case GLUT_DISPLAY_MODE_POSSIBLE:
|
||||
{
|
||||
/* We should not have to call fgPlatformChooseFBConfig again here. */
|
||||
GLXFBConfig * fbconfig;
|
||||
int isPossible;
|
||||
|
||||
fbconfig = fgPlatformChooseFBConfig(NULL);
|
||||
|
||||
if (fbconfig == NULL)
|
||||
{
|
||||
isPossible = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
isPossible = 1;
|
||||
XFree(fbconfig);
|
||||
}
|
||||
|
||||
return isPossible;
|
||||
}
|
||||
|
||||
/* This is system-dependant */
|
||||
case GLUT_WINDOW_FORMAT_ID:
|
||||
if( fgStructure.CurrentWindow == NULL )
|
||||
return 0;
|
||||
|
||||
return fgPlatformGetConfig( GLX_VISUAL_ID );
|
||||
|
||||
default:
|
||||
fgWarning( "glutGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int fgPlatformGlutDeviceGet ( GLenum eWhat )
|
||||
{
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_HAS_KEYBOARD:
|
||||
/*
|
||||
* X11 has a core keyboard by definition, although it can
|
||||
* be present as a virtual/dummy keyboard. For now, there
|
||||
* is no reliable way to tell if a real keyboard is present.
|
||||
*/
|
||||
return 1;
|
||||
|
||||
/* X11 has a mouse by definition */
|
||||
case GLUT_HAS_MOUSE:
|
||||
return 1 ;
|
||||
|
||||
case GLUT_NUM_MOUSE_BUTTONS:
|
||||
/* 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.
|
||||
*
|
||||
* In XFree86/Xorg servers, a mouse wheel is seen as two buttons
|
||||
* rather than an Axis; "freeglut_main.c" expects this when
|
||||
* checking for a wheel event.
|
||||
*/
|
||||
{
|
||||
unsigned char map;
|
||||
int nbuttons = XGetPointerMapping(fgDisplay.pDisplay.Display, &map,0);
|
||||
return nbuttons;
|
||||
}
|
||||
|
||||
default:
|
||||
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And now -- the failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fgPlatformGlutLayerGet( GLenum eWhat )
|
||||
{
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
*
|
||||
* XXX Can we merge the UNIX/X11 and WIN32 sections? Or
|
||||
* XXX is overlay support planned?
|
||||
*/
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_OVERLAY_POSSIBLE:
|
||||
return 0;
|
||||
|
||||
case GLUT_LAYER_IN_USE:
|
||||
return GLUT_NORMAL;
|
||||
|
||||
case GLUT_HAS_OVERLAY:
|
||||
return 0;
|
||||
|
||||
case GLUT_TRANSPARENT_INDEX:
|
||||
/*
|
||||
* Return just anything, which is always defined as zero
|
||||
*
|
||||
* XXX HUH?
|
||||
*/
|
||||
return 0;
|
||||
|
||||
case GLUT_NORMAL_DAMAGED:
|
||||
/* XXX Actually I do not know. Maybe. */
|
||||
return 0;
|
||||
|
||||
case GLUT_OVERLAY_DAMAGED:
|
||||
return -1;
|
||||
|
||||
default:
|
||||
fgWarning( "glutLayerGet(): missing enum handle %d", eWhat );
|
||||
break;
|
||||
}
|
||||
|
||||
/* And fail. That's good. Programs do love failing. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size)
|
||||
{
|
||||
int *array;
|
||||
|
||||
int attributes[9];
|
||||
GLXFBConfig * fbconfigArray; /* Array of FBConfigs */
|
||||
int fbconfigArraySize; /* Number of FBConfigs in the array */
|
||||
int attribute_name = 0;
|
||||
|
||||
array = NULL;
|
||||
*size = 0;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_AUX:
|
||||
case GLUT_MULTISAMPLE:
|
||||
|
||||
attributes[0] = GLX_BUFFER_SIZE;
|
||||
attributes[1] = GLX_DONT_CARE;
|
||||
|
||||
switch (eWhat)
|
||||
{
|
||||
case GLUT_AUX:
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of auxiliary
|
||||
buffers. We want at least one buffer.
|
||||
*/
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = 1;
|
||||
attributes[4] = None;
|
||||
|
||||
attribute_name = GLX_AUX_BUFFERS;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case GLUT_MULTISAMPLE:
|
||||
attributes[2] = GLX_AUX_BUFFERS;
|
||||
attributes[3] = GLX_DONT_CARE;
|
||||
attributes[4] = GLX_SAMPLE_BUFFERS;
|
||||
attributes[5] = 1;
|
||||
/*
|
||||
FBConfigs are now sorted by increasing number of samples per
|
||||
pixel. We want at least one sample.
|
||||
*/
|
||||
attributes[6] = GLX_SAMPLES;
|
||||
attributes[7] = 1;
|
||||
attributes[8] = None;
|
||||
|
||||
attribute_name = GLX_SAMPLES;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
fbconfigArray = glXChooseFBConfig(fgDisplay.pDisplay.Display,
|
||||
fgDisplay.pDisplay.Screen,
|
||||
attributes,
|
||||
&fbconfigArraySize);
|
||||
|
||||
if (fbconfigArray != NULL)
|
||||
{
|
||||
int * temp_array;
|
||||
int result; /* Returned by glXGetFBConfigAttrib. Not checked. */
|
||||
int previous_value;
|
||||
int i;
|
||||
|
||||
temp_array = malloc(sizeof(int) * fbconfigArraySize);
|
||||
previous_value = 0;
|
||||
|
||||
for (i = 0; i < fbconfigArraySize; i++)
|
||||
{
|
||||
int value;
|
||||
|
||||
result = glXGetFBConfigAttrib(fgDisplay.pDisplay.Display,
|
||||
fbconfigArray[i],
|
||||
attribute_name,
|
||||
&value);
|
||||
if (value > previous_value)
|
||||
{
|
||||
temp_array[*size] = value;
|
||||
previous_value = value;
|
||||
(*size)++;
|
||||
}
|
||||
}
|
||||
|
||||
array = malloc(sizeof(int) * (*size));
|
||||
for (i = 0; i < *size; i++)
|
||||
{
|
||||
array[i] = temp_array[i];
|
||||
}
|
||||
|
||||
free(temp_array);
|
||||
XFree(fbconfigArray);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,40 +1,40 @@
|
||||
/*
|
||||
* freeglut_structure.c
|
||||
*
|
||||
* Windows and menus need tree structure
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
extern SFG_Structure fgStructure;
|
||||
|
||||
void fgPlatformCreateWindow ( SFG_Window *window )
|
||||
{
|
||||
window->Window.pContext.FBConfig = NULL;
|
||||
|
||||
window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* freeglut_structure.c
|
||||
*
|
||||
* Windows and menus need tree structure
|
||||
*
|
||||
* Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
|
||||
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
|
||||
* Copied for Platform code by Evan Felix <karcaw at gmail.com>
|
||||
* Creation date: Thur Feb 2 2012
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* 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
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <GL/freeglut.h>
|
||||
#include "../Common/freeglut_internal.h"
|
||||
|
||||
extern SFG_Structure fgStructure;
|
||||
|
||||
void fgPlatformCreateWindow ( SFG_Window *window )
|
||||
{
|
||||
window->Window.pContext.FBConfig = NULL;
|
||||
|
||||
window->State.pWState.OldHeight = window->State.pWState.OldWidth = -1;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user